@routevn/creator-model 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/model.js +1272 -536
package/src/model.js CHANGED
@@ -312,13 +312,19 @@ const validateExactKeys = ({ value, expectedKeys, path, errorFactory }) => {
312
312
 
313
313
  for (const key of Object.keys(value)) {
314
314
  if (!expectedKeys.includes(key)) {
315
- return invalidFromErrorFactory(errorFactory, `${path}.${key} is not allowed`);
315
+ return invalidFromErrorFactory(
316
+ errorFactory,
317
+ `${path}.${key} is not allowed`,
318
+ );
316
319
  }
317
320
  }
318
321
 
319
322
  for (const key of expectedKeys) {
320
323
  if (!Object.hasOwn(value, key)) {
321
- return invalidFromErrorFactory(errorFactory, `${path}.${key} is required`);
324
+ return invalidFromErrorFactory(
325
+ errorFactory,
326
+ `${path}.${key} is required`,
327
+ );
322
328
  }
323
329
  }
324
330
  };
@@ -330,7 +336,10 @@ const validateAllowedKeys = ({ value, allowedKeys, path, errorFactory }) => {
330
336
 
331
337
  for (const key of Object.keys(value)) {
332
338
  if (!allowedKeys.includes(key)) {
333
- return invalidFromErrorFactory(errorFactory, `${path}.${key} is not allowed`);
339
+ return invalidFromErrorFactory(
340
+ errorFactory,
341
+ `${path}.${key} is not allowed`,
342
+ );
334
343
  }
335
344
  }
336
345
  };
@@ -356,15 +365,24 @@ const validateOptionalPosition = ({ value, path, errorFactory }) => {
356
365
  const hasY = value.y !== undefined;
357
366
 
358
367
  if (!hasX && !hasY) {
359
- return invalidFromErrorFactory(errorFactory, `${path} must contain at least one of 'x' or 'y'`);
368
+ return invalidFromErrorFactory(
369
+ errorFactory,
370
+ `${path} must contain at least one of 'x' or 'y'`,
371
+ );
360
372
  }
361
373
 
362
374
  if (hasX && !isFiniteNumber(value.x)) {
363
- return invalidFromErrorFactory(errorFactory, `${path}.x must be a finite number`);
375
+ return invalidFromErrorFactory(
376
+ errorFactory,
377
+ `${path}.x must be a finite number`,
378
+ );
364
379
  }
365
380
 
366
381
  if (hasY && !isFiniteNumber(value.y)) {
367
- return invalidFromErrorFactory(errorFactory, `${path}.y must be a finite number`);
382
+ return invalidFromErrorFactory(
383
+ errorFactory,
384
+ `${path}.y must be a finite number`,
385
+ );
368
386
  }
369
387
  };
370
388
 
@@ -388,19 +406,31 @@ const validateSceneItems = ({ items, path, errorFactory }) => {
388
406
  }
389
407
 
390
408
  if (!isNonEmptyString(item.id)) {
391
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
409
+ return invalidFromErrorFactory(
410
+ errorFactory,
411
+ `${itemPath}.id must be a non-empty string`,
412
+ );
392
413
  }
393
414
 
394
415
  if (item.id !== itemId) {
395
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
416
+ return invalidFromErrorFactory(
417
+ errorFactory,
418
+ `${itemPath}.id must match item key '${itemId}'`,
419
+ );
396
420
  }
397
421
 
398
422
  if (item.type !== "scene" && item.type !== "folder") {
399
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'scene' or 'folder'`);
423
+ return invalidFromErrorFactory(
424
+ errorFactory,
425
+ `${itemPath}.type must be 'scene' or 'folder'`,
426
+ );
400
427
  }
401
428
 
402
429
  if (!isNonEmptyString(item.name)) {
403
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
430
+ return invalidFromErrorFactory(
431
+ errorFactory,
432
+ `${itemPath}.name must be a non-empty string`,
433
+ );
404
434
  }
405
435
 
406
436
  {
@@ -449,15 +479,24 @@ const validateSectionItems = ({ items, path, errorFactory }) => {
449
479
  }
450
480
 
451
481
  if (!isNonEmptyString(item.id)) {
452
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
482
+ return invalidFromErrorFactory(
483
+ errorFactory,
484
+ `${itemPath}.id must be a non-empty string`,
485
+ );
453
486
  }
454
487
 
455
488
  if (item.id !== itemId) {
456
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
489
+ return invalidFromErrorFactory(
490
+ errorFactory,
491
+ `${itemPath}.id must match item key '${itemId}'`,
492
+ );
457
493
  }
458
494
 
459
495
  if (!isNonEmptyString(item.name)) {
460
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
496
+ return invalidFromErrorFactory(
497
+ errorFactory,
498
+ `${itemPath}.name must be a non-empty string`,
499
+ );
461
500
  }
462
501
 
463
502
  if (item.lines !== undefined) {
@@ -497,15 +536,24 @@ const validateLineItems = ({ items, path, errorFactory }) => {
497
536
  }
498
537
 
499
538
  if (!isNonEmptyString(item.id)) {
500
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
539
+ return invalidFromErrorFactory(
540
+ errorFactory,
541
+ `${itemPath}.id must be a non-empty string`,
542
+ );
501
543
  }
502
544
 
503
545
  if (item.id !== itemId) {
504
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
546
+ return invalidFromErrorFactory(
547
+ errorFactory,
548
+ `${itemPath}.id must match item key '${itemId}'`,
549
+ );
505
550
  }
506
551
 
507
552
  if (!isPlainObject(item.actions)) {
508
- return invalidFromErrorFactory(errorFactory, `${itemPath}.actions must be an object`);
553
+ return invalidFromErrorFactory(
554
+ errorFactory,
555
+ `${itemPath}.actions must be an object`,
556
+ );
509
557
  }
510
558
  }
511
559
  };
@@ -588,7 +636,10 @@ const validateImageItems = ({ items, path, errorFactory }) => {
588
636
  const itemPath = `${path}.${itemId}`;
589
637
 
590
638
  if (item?.type !== "folder" && item?.type !== "image") {
591
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'image'`);
639
+ return invalidFromErrorFactory(
640
+ errorFactory,
641
+ `${itemPath}.type must be 'folder' or 'image'`,
642
+ );
592
643
  }
593
644
 
594
645
  {
@@ -618,19 +669,29 @@ const validateImageItems = ({ items, path, errorFactory }) => {
618
669
  }
619
670
 
620
671
  if (!isNonEmptyString(item.id)) {
621
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
672
+ return invalidFromErrorFactory(
673
+ errorFactory,
674
+ `${itemPath}.id must be a non-empty string`,
675
+ );
622
676
  }
623
677
 
624
678
  if (item.id !== itemId) {
625
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
679
+ return invalidFromErrorFactory(
680
+ errorFactory,
681
+ `${itemPath}.id must match item key '${itemId}'`,
682
+ );
626
683
  }
627
684
 
628
685
  if (!isNonEmptyString(item.name)) {
629
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
686
+ return invalidFromErrorFactory(
687
+ errorFactory,
688
+ `${itemPath}.name must be a non-empty string`,
689
+ );
630
690
  }
631
691
 
632
692
  if (item.description !== undefined && !isString(item.description)) {
633
- return invalidFromErrorFactory(errorFactory,
693
+ return invalidFromErrorFactory(
694
+ errorFactory,
634
695
  `${itemPath}.description must be a string when provided`,
635
696
  );
636
697
  }
@@ -647,25 +708,38 @@ const validateImageItems = ({ items, path, errorFactory }) => {
647
708
  }
648
709
 
649
710
  if (!isNonEmptyString(item.fileId)) {
650
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileId must be a non-empty string`);
711
+ return invalidFromErrorFactory(
712
+ errorFactory,
713
+ `${itemPath}.fileId must be a non-empty string`,
714
+ );
651
715
  }
652
716
 
653
717
  if (item.fileType !== undefined && !isString(item.fileType)) {
654
- return invalidFromErrorFactory(errorFactory,
718
+ return invalidFromErrorFactory(
719
+ errorFactory,
655
720
  `${itemPath}.fileType must be a string when provided`,
656
721
  );
657
722
  }
658
723
 
659
724
  if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
660
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileSize must be a finite number`);
725
+ return invalidFromErrorFactory(
726
+ errorFactory,
727
+ `${itemPath}.fileSize must be a finite number`,
728
+ );
661
729
  }
662
730
 
663
731
  if (item.width !== undefined && !isFiniteNumber(item.width)) {
664
- return invalidFromErrorFactory(errorFactory, `${itemPath}.width must be a finite number`);
732
+ return invalidFromErrorFactory(
733
+ errorFactory,
734
+ `${itemPath}.width must be a finite number`,
735
+ );
665
736
  }
666
737
 
667
738
  if (item.height !== undefined && !isFiniteNumber(item.height)) {
668
- return invalidFromErrorFactory(errorFactory, `${itemPath}.height must be a finite number`);
739
+ return invalidFromErrorFactory(
740
+ errorFactory,
741
+ `${itemPath}.height must be a finite number`,
742
+ );
669
743
  }
670
744
  }
671
745
  }
@@ -676,7 +750,10 @@ const validateSoundItems = ({ items, path, errorFactory }) => {
676
750
  const itemPath = `${path}.${itemId}`;
677
751
 
678
752
  if (item?.type !== "folder" && item?.type !== "sound") {
679
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'sound'`);
753
+ return invalidFromErrorFactory(
754
+ errorFactory,
755
+ `${itemPath}.type must be 'folder' or 'sound'`,
756
+ );
680
757
  }
681
758
 
682
759
  {
@@ -705,36 +782,53 @@ const validateSoundItems = ({ items, path, errorFactory }) => {
705
782
  }
706
783
 
707
784
  if (!isNonEmptyString(item.id)) {
708
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
785
+ return invalidFromErrorFactory(
786
+ errorFactory,
787
+ `${itemPath}.id must be a non-empty string`,
788
+ );
709
789
  }
710
790
 
711
791
  if (item.id !== itemId) {
712
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
792
+ return invalidFromErrorFactory(
793
+ errorFactory,
794
+ `${itemPath}.id must match item key '${itemId}'`,
795
+ );
713
796
  }
714
797
 
715
798
  if (!isNonEmptyString(item.name)) {
716
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
799
+ return invalidFromErrorFactory(
800
+ errorFactory,
801
+ `${itemPath}.name must be a non-empty string`,
802
+ );
717
803
  }
718
804
 
719
805
  if (item.description !== undefined && !isString(item.description)) {
720
- return invalidFromErrorFactory(errorFactory,
806
+ return invalidFromErrorFactory(
807
+ errorFactory,
721
808
  `${itemPath}.description must be a string when provided`,
722
809
  );
723
810
  }
724
811
 
725
812
  if (item.type === "sound") {
726
813
  if (!isNonEmptyString(item.fileId)) {
727
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileId must be a non-empty string`);
814
+ return invalidFromErrorFactory(
815
+ errorFactory,
816
+ `${itemPath}.fileId must be a non-empty string`,
817
+ );
728
818
  }
729
819
 
730
820
  if (item.fileType !== undefined && !isString(item.fileType)) {
731
- return invalidFromErrorFactory(errorFactory,
821
+ return invalidFromErrorFactory(
822
+ errorFactory,
732
823
  `${itemPath}.fileType must be a string when provided`,
733
824
  );
734
825
  }
735
826
 
736
827
  if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
737
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileSize must be a finite number`);
828
+ return invalidFromErrorFactory(
829
+ errorFactory,
830
+ `${itemPath}.fileSize must be a finite number`,
831
+ );
738
832
  }
739
833
 
740
834
  if (
@@ -742,13 +836,17 @@ const validateSoundItems = ({ items, path, errorFactory }) => {
742
836
  item.waveformDataFileId !== null &&
743
837
  !isNonEmptyString(item.waveformDataFileId)
744
838
  ) {
745
- return invalidFromErrorFactory(errorFactory,
839
+ return invalidFromErrorFactory(
840
+ errorFactory,
746
841
  `${itemPath}.waveformDataFileId must be a non-empty string or null when provided`,
747
842
  );
748
843
  }
749
844
 
750
845
  if (item.duration !== undefined && !isFiniteNumber(item.duration)) {
751
- return invalidFromErrorFactory(errorFactory, `${itemPath}.duration must be a finite number`);
846
+ return invalidFromErrorFactory(
847
+ errorFactory,
848
+ `${itemPath}.duration must be a finite number`,
849
+ );
752
850
  }
753
851
  }
754
852
  }
@@ -759,7 +857,10 @@ const validateVideoItems = ({ items, path, errorFactory }) => {
759
857
  const itemPath = `${path}.${itemId}`;
760
858
 
761
859
  if (item?.type !== "folder" && item?.type !== "video") {
762
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'video'`);
860
+ return invalidFromErrorFactory(
861
+ errorFactory,
862
+ `${itemPath}.type must be 'folder' or 'video'`,
863
+ );
763
864
  }
764
865
 
765
866
  {
@@ -789,50 +890,74 @@ const validateVideoItems = ({ items, path, errorFactory }) => {
789
890
  }
790
891
 
791
892
  if (!isNonEmptyString(item.id)) {
792
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
893
+ return invalidFromErrorFactory(
894
+ errorFactory,
895
+ `${itemPath}.id must be a non-empty string`,
896
+ );
793
897
  }
794
898
 
795
899
  if (item.id !== itemId) {
796
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
900
+ return invalidFromErrorFactory(
901
+ errorFactory,
902
+ `${itemPath}.id must match item key '${itemId}'`,
903
+ );
797
904
  }
798
905
 
799
906
  if (!isNonEmptyString(item.name)) {
800
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
907
+ return invalidFromErrorFactory(
908
+ errorFactory,
909
+ `${itemPath}.name must be a non-empty string`,
910
+ );
801
911
  }
802
912
 
803
913
  if (item.description !== undefined && !isString(item.description)) {
804
- return invalidFromErrorFactory(errorFactory,
914
+ return invalidFromErrorFactory(
915
+ errorFactory,
805
916
  `${itemPath}.description must be a string when provided`,
806
917
  );
807
918
  }
808
919
 
809
920
  if (item.type === "video") {
810
921
  if (!isNonEmptyString(item.fileId)) {
811
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileId must be a non-empty string`);
922
+ return invalidFromErrorFactory(
923
+ errorFactory,
924
+ `${itemPath}.fileId must be a non-empty string`,
925
+ );
812
926
  }
813
927
 
814
928
  if (!isNonEmptyString(item.thumbnailFileId)) {
815
- return invalidFromErrorFactory(errorFactory,
929
+ return invalidFromErrorFactory(
930
+ errorFactory,
816
931
  `${itemPath}.thumbnailFileId must be a non-empty string`,
817
932
  );
818
933
  }
819
934
 
820
935
  if (item.fileType !== undefined && !isString(item.fileType)) {
821
- return invalidFromErrorFactory(errorFactory,
936
+ return invalidFromErrorFactory(
937
+ errorFactory,
822
938
  `${itemPath}.fileType must be a string when provided`,
823
939
  );
824
940
  }
825
941
 
826
942
  if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
827
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileSize must be a finite number`);
943
+ return invalidFromErrorFactory(
944
+ errorFactory,
945
+ `${itemPath}.fileSize must be a finite number`,
946
+ );
828
947
  }
829
948
 
830
949
  if (item.width !== undefined && !isFiniteNumber(item.width)) {
831
- return invalidFromErrorFactory(errorFactory, `${itemPath}.width must be a finite number`);
950
+ return invalidFromErrorFactory(
951
+ errorFactory,
952
+ `${itemPath}.width must be a finite number`,
953
+ );
832
954
  }
833
955
 
834
956
  if (item.height !== undefined && !isFiniteNumber(item.height)) {
835
- return invalidFromErrorFactory(errorFactory, `${itemPath}.height must be a finite number`);
957
+ return invalidFromErrorFactory(
958
+ errorFactory,
959
+ `${itemPath}.height must be a finite number`,
960
+ );
836
961
  }
837
962
  }
838
963
  }
@@ -840,7 +965,10 @@ const validateVideoItems = ({ items, path, errorFactory }) => {
840
965
 
841
966
  const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
842
967
  if (!Array.isArray(keyframes) || keyframes.length === 0) {
843
- return invalidFromErrorFactory(errorFactory, `${path} must be a non-empty array`);
968
+ return invalidFromErrorFactory(
969
+ errorFactory,
970
+ `${path} must be a non-empty array`,
971
+ );
844
972
  }
845
973
 
846
974
  for (const [index, keyframe] of keyframes.entries()) {
@@ -859,19 +987,29 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
859
987
  }
860
988
 
861
989
  if (!("value" in keyframe)) {
862
- return invalidFromErrorFactory(errorFactory, `${keyframePath}.value is required`);
990
+ return invalidFromErrorFactory(
991
+ errorFactory,
992
+ `${keyframePath}.value is required`,
993
+ );
863
994
  }
864
995
 
865
996
  if (!("duration" in keyframe)) {
866
- return invalidFromErrorFactory(errorFactory, `${keyframePath}.duration is required`);
997
+ return invalidFromErrorFactory(
998
+ errorFactory,
999
+ `${keyframePath}.duration is required`,
1000
+ );
867
1001
  }
868
1002
 
869
1003
  if (!isFiniteNumber(keyframe.value)) {
870
- return invalidFromErrorFactory(errorFactory, `${keyframePath}.value must be a finite number`);
1004
+ return invalidFromErrorFactory(
1005
+ errorFactory,
1006
+ `${keyframePath}.value must be a finite number`,
1007
+ );
871
1008
  }
872
1009
 
873
1010
  if (!isFiniteNumber(keyframe.duration) || keyframe.duration < 1) {
874
- return invalidFromErrorFactory(errorFactory,
1011
+ return invalidFromErrorFactory(
1012
+ errorFactory,
875
1013
  `${keyframePath}.duration must be a finite number >= 1`,
876
1014
  );
877
1015
  }
@@ -880,7 +1018,8 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
880
1018
  keyframe.easing !== undefined &&
881
1019
  !ANIMATION_EASING_KEYS.includes(keyframe.easing)
882
1020
  ) {
883
- return invalidFromErrorFactory(errorFactory,
1021
+ return invalidFromErrorFactory(
1022
+ errorFactory,
884
1023
  `${keyframePath}.easing must be a supported Route Graphics easing`,
885
1024
  );
886
1025
  }
@@ -889,7 +1028,8 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
889
1028
  keyframe.relative !== undefined &&
890
1029
  typeof keyframe.relative !== "boolean"
891
1030
  ) {
892
- return invalidFromErrorFactory(errorFactory,
1031
+ return invalidFromErrorFactory(
1032
+ errorFactory,
893
1033
  `${keyframePath}.relative must be a boolean when provided`,
894
1034
  );
895
1035
  }
@@ -910,14 +1050,20 @@ const validateTweenProperty = ({ config, path, errorFactory }) => {
910
1050
  }
911
1051
 
912
1052
  if (!("keyframes" in config)) {
913
- return invalidFromErrorFactory(errorFactory, `${path}.keyframes is required`);
1053
+ return invalidFromErrorFactory(
1054
+ errorFactory,
1055
+ `${path}.keyframes is required`,
1056
+ );
914
1057
  }
915
1058
 
916
1059
  if (
917
1060
  config.initialValue !== undefined &&
918
1061
  !isFiniteNumber(config.initialValue)
919
1062
  ) {
920
- return invalidFromErrorFactory(errorFactory, `${path}.initialValue must be a finite number`);
1063
+ return invalidFromErrorFactory(
1064
+ errorFactory,
1065
+ `${path}.initialValue must be a finite number`,
1066
+ );
921
1067
  }
922
1068
 
923
1069
  {
@@ -944,14 +1090,20 @@ const validateTweenDefinition = ({
944
1090
  }
945
1091
 
946
1092
  if (Object.keys(tween).length === 0) {
947
- return invalidFromErrorFactory(errorFactory, `${path} must include at least one tween property`);
1093
+ return invalidFromErrorFactory(
1094
+ errorFactory,
1095
+ `${path} must include at least one tween property`,
1096
+ );
948
1097
  }
949
1098
 
950
1099
  for (const [propertyName, config] of Object.entries(tween)) {
951
1100
  const propertyPath = `${path}.${propertyName}`;
952
1101
 
953
1102
  if (!allowedProperties.includes(propertyName)) {
954
- return invalidFromErrorFactory(errorFactory, `${propertyPath} ${unsupportedMessage}`);
1103
+ return invalidFromErrorFactory(
1104
+ errorFactory,
1105
+ `${propertyPath} ${unsupportedMessage}`,
1106
+ );
955
1107
  }
956
1108
 
957
1109
  {
@@ -992,7 +1144,10 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
992
1144
  }
993
1145
 
994
1146
  if (!isNonEmptyString(mask.kind)) {
995
- return invalidFromErrorFactory(errorFactory, `${path}.kind must be a non-empty string`);
1147
+ return invalidFromErrorFactory(
1148
+ errorFactory,
1149
+ `${path}.kind must be a non-empty string`,
1150
+ );
996
1151
  }
997
1152
 
998
1153
  if (
@@ -1000,27 +1155,31 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
1000
1155
  mask.kind !== "sequence" &&
1001
1156
  mask.kind !== "composite"
1002
1157
  ) {
1003
- return invalidFromErrorFactory(errorFactory,
1158
+ return invalidFromErrorFactory(
1159
+ errorFactory,
1004
1160
  `${path}.kind must be 'single', 'sequence', or 'composite'`,
1005
1161
  );
1006
1162
  }
1007
1163
 
1008
1164
  if (mask.texture !== undefined && !isNonEmptyString(mask.texture)) {
1009
- return invalidFromErrorFactory(errorFactory,
1165
+ return invalidFromErrorFactory(
1166
+ errorFactory,
1010
1167
  `${path}.texture must be a non-empty string when provided`,
1011
1168
  );
1012
1169
  }
1013
1170
 
1014
1171
  if (mask.textures !== undefined) {
1015
1172
  if (!Array.isArray(mask.textures) || mask.textures.length === 0) {
1016
- return invalidFromErrorFactory(errorFactory,
1173
+ return invalidFromErrorFactory(
1174
+ errorFactory,
1017
1175
  `${path}.textures must be a non-empty array when provided`,
1018
1176
  );
1019
1177
  }
1020
1178
 
1021
1179
  for (const [index, texture] of mask.textures.entries()) {
1022
1180
  if (!isNonEmptyString(texture)) {
1023
- return invalidFromErrorFactory(errorFactory,
1181
+ return invalidFromErrorFactory(
1182
+ errorFactory,
1024
1183
  `${path}.textures[${index}] must be a non-empty string`,
1025
1184
  );
1026
1185
  }
@@ -1029,7 +1188,8 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
1029
1188
 
1030
1189
  if (mask.items !== undefined) {
1031
1190
  if (!Array.isArray(mask.items) || mask.items.length === 0) {
1032
- return invalidFromErrorFactory(errorFactory,
1191
+ return invalidFromErrorFactory(
1192
+ errorFactory,
1033
1193
  `${path}.items must be a non-empty array when provided`,
1034
1194
  );
1035
1195
  }
@@ -1050,20 +1210,25 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
1050
1210
  }
1051
1211
 
1052
1212
  if (!isNonEmptyString(item.texture)) {
1053
- return invalidFromErrorFactory(errorFactory, `${itemPath}.texture must be a non-empty string`);
1213
+ return invalidFromErrorFactory(
1214
+ errorFactory,
1215
+ `${itemPath}.texture must be a non-empty string`,
1216
+ );
1054
1217
  }
1055
1218
 
1056
1219
  if (
1057
1220
  item.channel !== undefined &&
1058
1221
  !MASK_CHANNEL_KEYS.includes(item.channel)
1059
1222
  ) {
1060
- return invalidFromErrorFactory(errorFactory,
1223
+ return invalidFromErrorFactory(
1224
+ errorFactory,
1061
1225
  `${itemPath}.channel must be a supported mask channel`,
1062
1226
  );
1063
1227
  }
1064
1228
 
1065
1229
  if (item.invert !== undefined && typeof item.invert !== "boolean") {
1066
- return invalidFromErrorFactory(errorFactory,
1230
+ return invalidFromErrorFactory(
1231
+ errorFactory,
1067
1232
  `${itemPath}.invert must be a boolean when provided`,
1068
1233
  );
1069
1234
  }
@@ -1071,25 +1236,38 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
1071
1236
  }
1072
1237
 
1073
1238
  if (mask.combine !== undefined && !MASK_COMBINE_KEYS.includes(mask.combine)) {
1074
- return invalidFromErrorFactory(errorFactory, `${path}.combine must be a supported mask combine mode`);
1239
+ return invalidFromErrorFactory(
1240
+ errorFactory,
1241
+ `${path}.combine must be a supported mask combine mode`,
1242
+ );
1075
1243
  }
1076
1244
 
1077
1245
  if (mask.channel !== undefined && !MASK_CHANNEL_KEYS.includes(mask.channel)) {
1078
- return invalidFromErrorFactory(errorFactory, `${path}.channel must be a supported mask channel`);
1246
+ return invalidFromErrorFactory(
1247
+ errorFactory,
1248
+ `${path}.channel must be a supported mask channel`,
1249
+ );
1079
1250
  }
1080
1251
 
1081
1252
  if (mask.softness !== undefined && !isFiniteNumber(mask.softness)) {
1082
- return invalidFromErrorFactory(errorFactory,
1253
+ return invalidFromErrorFactory(
1254
+ errorFactory,
1083
1255
  `${path}.softness must be a finite number when provided`,
1084
1256
  );
1085
1257
  }
1086
1258
 
1087
1259
  if (mask.invert !== undefined && typeof mask.invert !== "boolean") {
1088
- return invalidFromErrorFactory(errorFactory, `${path}.invert must be a boolean when provided`);
1260
+ return invalidFromErrorFactory(
1261
+ errorFactory,
1262
+ `${path}.invert must be a boolean when provided`,
1263
+ );
1089
1264
  }
1090
1265
 
1091
1266
  if (mask.sample !== undefined && !isString(mask.sample)) {
1092
- return invalidFromErrorFactory(errorFactory, `${path}.sample must be a string when provided`);
1267
+ return invalidFromErrorFactory(
1268
+ errorFactory,
1269
+ `${path}.sample must be a string when provided`,
1270
+ );
1093
1271
  }
1094
1272
 
1095
1273
  if (mask.progress !== undefined) {
@@ -1106,19 +1284,22 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
1106
1284
  }
1107
1285
 
1108
1286
  if (mask.kind === "single" && !isNonEmptyString(mask.texture)) {
1109
- return invalidFromErrorFactory(errorFactory,
1287
+ return invalidFromErrorFactory(
1288
+ errorFactory,
1110
1289
  `${path}.texture is required when ${path}.kind is 'single'`,
1111
1290
  );
1112
1291
  }
1113
1292
 
1114
1293
  if (mask.kind === "sequence" && mask.textures === undefined) {
1115
- return invalidFromErrorFactory(errorFactory,
1294
+ return invalidFromErrorFactory(
1295
+ errorFactory,
1116
1296
  `${path}.textures is required when ${path}.kind is 'sequence'`,
1117
1297
  );
1118
1298
  }
1119
1299
 
1120
1300
  if (mask.kind === "composite" && mask.items === undefined) {
1121
- return invalidFromErrorFactory(errorFactory,
1301
+ return invalidFromErrorFactory(
1302
+ errorFactory,
1122
1303
  `${path}.items is required when ${path}.kind is 'composite'`,
1123
1304
  );
1124
1305
  }
@@ -1138,11 +1319,17 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1138
1319
  }
1139
1320
 
1140
1321
  if (!isNonEmptyString(animation.type)) {
1141
- return invalidFromErrorFactory(errorFactory, `${path}.type must be a non-empty string`);
1322
+ return invalidFromErrorFactory(
1323
+ errorFactory,
1324
+ `${path}.type must be a non-empty string`,
1325
+ );
1142
1326
  }
1143
1327
 
1144
1328
  if (animation.type !== "live" && animation.type !== "replace") {
1145
- return invalidFromErrorFactory(errorFactory, `${path}.type must be 'live' or 'replace'`);
1329
+ return invalidFromErrorFactory(
1330
+ errorFactory,
1331
+ `${path}.type must be 'live' or 'replace'`,
1332
+ );
1146
1333
  }
1147
1334
 
1148
1335
  if (animation.type === "live") {
@@ -1151,13 +1338,15 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1151
1338
  animation.next !== undefined ||
1152
1339
  animation.mask !== undefined
1153
1340
  ) {
1154
- return invalidFromErrorFactory(errorFactory,
1341
+ return invalidFromErrorFactory(
1342
+ errorFactory,
1155
1343
  `${path}.live animations cannot define prev, next, or mask`,
1156
1344
  );
1157
1345
  }
1158
1346
 
1159
1347
  if (animation.tween === undefined) {
1160
- return invalidFromErrorFactory(errorFactory,
1348
+ return invalidFromErrorFactory(
1349
+ errorFactory,
1161
1350
  `${path}.tween is required when ${path}.type is 'live'`,
1162
1351
  );
1163
1352
  }
@@ -1179,7 +1368,10 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1179
1368
  }
1180
1369
 
1181
1370
  if (animation.tween !== undefined) {
1182
- return invalidFromErrorFactory(errorFactory, `${path}.replace animations cannot define tween`);
1371
+ return invalidFromErrorFactory(
1372
+ errorFactory,
1373
+ `${path}.replace animations cannot define tween`,
1374
+ );
1183
1375
  }
1184
1376
 
1185
1377
  if (
@@ -1187,7 +1379,8 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
1187
1379
  animation.next === undefined &&
1188
1380
  animation.mask === undefined
1189
1381
  ) {
1190
- return invalidFromErrorFactory(errorFactory,
1382
+ return invalidFromErrorFactory(
1383
+ errorFactory,
1191
1384
  `${path} must define at least one of prev, next, or mask when ${path}.type is 'replace'`,
1192
1385
  );
1193
1386
  }
@@ -1242,7 +1435,10 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
1242
1435
  const itemPath = `${path}.${itemId}`;
1243
1436
 
1244
1437
  if (item?.type !== "folder" && item?.type !== "animation") {
1245
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'animation'`);
1438
+ return invalidFromErrorFactory(
1439
+ errorFactory,
1440
+ `${itemPath}.type must be 'folder' or 'animation'`,
1441
+ );
1246
1442
  }
1247
1443
 
1248
1444
  {
@@ -1261,15 +1457,24 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
1261
1457
  }
1262
1458
 
1263
1459
  if (!isNonEmptyString(item.id)) {
1264
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
1460
+ return invalidFromErrorFactory(
1461
+ errorFactory,
1462
+ `${itemPath}.id must be a non-empty string`,
1463
+ );
1265
1464
  }
1266
1465
 
1267
1466
  if (item.id !== itemId) {
1268
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
1467
+ return invalidFromErrorFactory(
1468
+ errorFactory,
1469
+ `${itemPath}.id must match item key '${itemId}'`,
1470
+ );
1269
1471
  }
1270
1472
 
1271
1473
  if (!isNonEmptyString(item.name)) {
1272
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
1474
+ return invalidFromErrorFactory(
1475
+ errorFactory,
1476
+ `${itemPath}.name must be a non-empty string`,
1477
+ );
1273
1478
  }
1274
1479
 
1275
1480
  if (item.type === "animation") {
@@ -1292,7 +1497,10 @@ const validateFontItems = ({ items, path, errorFactory }) => {
1292
1497
  const itemPath = `${path}.${itemId}`;
1293
1498
 
1294
1499
  if (item?.type !== "folder" && item?.type !== "font") {
1295
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'font'`);
1500
+ return invalidFromErrorFactory(
1501
+ errorFactory,
1502
+ `${itemPath}.type must be 'folder' or 'font'`,
1503
+ );
1296
1504
  }
1297
1505
 
1298
1506
  {
@@ -1319,34 +1527,53 @@ const validateFontItems = ({ items, path, errorFactory }) => {
1319
1527
  }
1320
1528
 
1321
1529
  if (!isNonEmptyString(item.id)) {
1322
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
1530
+ return invalidFromErrorFactory(
1531
+ errorFactory,
1532
+ `${itemPath}.id must be a non-empty string`,
1533
+ );
1323
1534
  }
1324
1535
 
1325
1536
  if (item.id !== itemId) {
1326
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
1537
+ return invalidFromErrorFactory(
1538
+ errorFactory,
1539
+ `${itemPath}.id must match item key '${itemId}'`,
1540
+ );
1327
1541
  }
1328
1542
 
1329
1543
  if (!isNonEmptyString(item.name)) {
1330
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
1544
+ return invalidFromErrorFactory(
1545
+ errorFactory,
1546
+ `${itemPath}.name must be a non-empty string`,
1547
+ );
1331
1548
  }
1332
1549
 
1333
1550
  if (item.type === "font") {
1334
1551
  if (!isNonEmptyString(item.fileId)) {
1335
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileId must be a non-empty string`);
1552
+ return invalidFromErrorFactory(
1553
+ errorFactory,
1554
+ `${itemPath}.fileId must be a non-empty string`,
1555
+ );
1336
1556
  }
1337
1557
 
1338
1558
  if (!isNonEmptyString(item.fontFamily)) {
1339
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fontFamily must be a non-empty string`);
1559
+ return invalidFromErrorFactory(
1560
+ errorFactory,
1561
+ `${itemPath}.fontFamily must be a non-empty string`,
1562
+ );
1340
1563
  }
1341
1564
 
1342
1565
  if (item.fileType !== undefined && !isString(item.fileType)) {
1343
- return invalidFromErrorFactory(errorFactory,
1566
+ return invalidFromErrorFactory(
1567
+ errorFactory,
1344
1568
  `${itemPath}.fileType must be a string when provided`,
1345
1569
  );
1346
1570
  }
1347
1571
 
1348
1572
  if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
1349
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileSize must be a finite number`);
1573
+ return invalidFromErrorFactory(
1574
+ errorFactory,
1575
+ `${itemPath}.fileSize must be a finite number`,
1576
+ );
1350
1577
  }
1351
1578
  }
1352
1579
  }
@@ -1357,7 +1584,10 @@ const validateColorItems = ({ items, path, errorFactory }) => {
1357
1584
  const itemPath = `${path}.${itemId}`;
1358
1585
 
1359
1586
  if (item?.type !== "folder" && item?.type !== "color") {
1360
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'color'`);
1587
+ return invalidFromErrorFactory(
1588
+ errorFactory,
1589
+ `${itemPath}.type must be 'folder' or 'color'`,
1590
+ );
1361
1591
  }
1362
1592
 
1363
1593
  {
@@ -1376,19 +1606,31 @@ const validateColorItems = ({ items, path, errorFactory }) => {
1376
1606
  }
1377
1607
 
1378
1608
  if (!isNonEmptyString(item.id)) {
1379
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
1609
+ return invalidFromErrorFactory(
1610
+ errorFactory,
1611
+ `${itemPath}.id must be a non-empty string`,
1612
+ );
1380
1613
  }
1381
1614
 
1382
1615
  if (item.id !== itemId) {
1383
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
1616
+ return invalidFromErrorFactory(
1617
+ errorFactory,
1618
+ `${itemPath}.id must match item key '${itemId}'`,
1619
+ );
1384
1620
  }
1385
1621
 
1386
1622
  if (!isNonEmptyString(item.name)) {
1387
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
1623
+ return invalidFromErrorFactory(
1624
+ errorFactory,
1625
+ `${itemPath}.name must be a non-empty string`,
1626
+ );
1388
1627
  }
1389
1628
 
1390
1629
  if (item.type === "color" && !isHexColor(item.hex)) {
1391
- return invalidFromErrorFactory(errorFactory, `${itemPath}.hex must be a #RRGGBB string`);
1630
+ return invalidFromErrorFactory(
1631
+ errorFactory,
1632
+ `${itemPath}.hex must be a #RRGGBB string`,
1633
+ );
1392
1634
  }
1393
1635
  }
1394
1636
  };
@@ -1398,7 +1640,10 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
1398
1640
  const itemPath = `${path}.${itemId}`;
1399
1641
 
1400
1642
  if (item?.type !== "folder" && item?.type !== "transform") {
1401
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'transform'`);
1643
+ return invalidFromErrorFactory(
1644
+ errorFactory,
1645
+ `${itemPath}.type must be 'folder' or 'transform'`,
1646
+ );
1402
1647
  }
1403
1648
 
1404
1649
  {
@@ -1428,15 +1673,24 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
1428
1673
  }
1429
1674
 
1430
1675
  if (!isNonEmptyString(item.id)) {
1431
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
1676
+ return invalidFromErrorFactory(
1677
+ errorFactory,
1678
+ `${itemPath}.id must be a non-empty string`,
1679
+ );
1432
1680
  }
1433
1681
 
1434
1682
  if (item.id !== itemId) {
1435
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
1683
+ return invalidFromErrorFactory(
1684
+ errorFactory,
1685
+ `${itemPath}.id must match item key '${itemId}'`,
1686
+ );
1436
1687
  }
1437
1688
 
1438
1689
  if (!isNonEmptyString(item.name)) {
1439
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
1690
+ return invalidFromErrorFactory(
1691
+ errorFactory,
1692
+ `${itemPath}.name must be a non-empty string`,
1693
+ );
1440
1694
  }
1441
1695
 
1442
1696
  if (item.type === "transform") {
@@ -1450,7 +1704,10 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
1450
1704
  "rotation",
1451
1705
  ]) {
1452
1706
  if (!isFiniteNumber(item[key])) {
1453
- return invalidFromErrorFactory(errorFactory, `${itemPath}.${key} must be a finite number`);
1707
+ return invalidFromErrorFactory(
1708
+ errorFactory,
1709
+ `${itemPath}.${key} must be a finite number`,
1710
+ );
1454
1711
  }
1455
1712
  }
1456
1713
  }
@@ -1468,7 +1725,10 @@ const validateVariableTypedValue = ({
1468
1725
  }
1469
1726
 
1470
1727
  if (variableType === "number" && !isFiniteNumber(value)) {
1471
- return invalidFromErrorFactory(errorFactory, `${path} must be a finite number`);
1728
+ return invalidFromErrorFactory(
1729
+ errorFactory,
1730
+ `${path} must be a finite number`,
1731
+ );
1472
1732
  }
1473
1733
 
1474
1734
  if (variableType === "boolean" && typeof value !== "boolean") {
@@ -1485,7 +1745,8 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
1485
1745
  variableType !== "folder" &&
1486
1746
  !VARIABLE_TYPE_KEYS.includes(variableType)
1487
1747
  ) {
1488
- return invalidFromErrorFactory(errorFactory,
1748
+ return invalidFromErrorFactory(
1749
+ errorFactory,
1489
1750
  `${itemPath}.type must be 'folder', 'string', 'number', or 'boolean'`,
1490
1751
  );
1491
1752
  }
@@ -1506,20 +1767,30 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
1506
1767
  }
1507
1768
 
1508
1769
  if (!isNonEmptyString(item.id)) {
1509
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
1770
+ return invalidFromErrorFactory(
1771
+ errorFactory,
1772
+ `${itemPath}.id must be a non-empty string`,
1773
+ );
1510
1774
  }
1511
1775
 
1512
1776
  if (item.id !== itemId) {
1513
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
1777
+ return invalidFromErrorFactory(
1778
+ errorFactory,
1779
+ `${itemPath}.id must match item key '${itemId}'`,
1780
+ );
1514
1781
  }
1515
1782
 
1516
1783
  if (!isNonEmptyString(item.name)) {
1517
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
1784
+ return invalidFromErrorFactory(
1785
+ errorFactory,
1786
+ `${itemPath}.name must be a non-empty string`,
1787
+ );
1518
1788
  }
1519
1789
 
1520
1790
  if (variableType !== "folder") {
1521
1791
  if (!VARIABLE_SCOPE_KEYS.includes(item.scope)) {
1522
- return invalidFromErrorFactory(errorFactory,
1792
+ return invalidFromErrorFactory(
1793
+ errorFactory,
1523
1794
  `${itemPath}.scope must be 'context', 'global-device', or 'global-account'`,
1524
1795
  );
1525
1796
  }
@@ -1555,7 +1826,10 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
1555
1826
  const itemPath = `${path}.${itemId}`;
1556
1827
 
1557
1828
  if (item?.type !== "folder" && item?.type !== "textStyle") {
1558
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'textStyle'`);
1829
+ return invalidFromErrorFactory(
1830
+ errorFactory,
1831
+ `${itemPath}.type must be 'folder' or 'textStyle'`,
1832
+ );
1559
1833
  }
1560
1834
 
1561
1835
  {
@@ -1592,46 +1866,72 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
1592
1866
  }
1593
1867
 
1594
1868
  if (!isNonEmptyString(item.id)) {
1595
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
1869
+ return invalidFromErrorFactory(
1870
+ errorFactory,
1871
+ `${itemPath}.id must be a non-empty string`,
1872
+ );
1596
1873
  }
1597
1874
 
1598
1875
  if (item.id !== itemId) {
1599
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
1876
+ return invalidFromErrorFactory(
1877
+ errorFactory,
1878
+ `${itemPath}.id must match item key '${itemId}'`,
1879
+ );
1600
1880
  }
1601
1881
 
1602
1882
  if (!isNonEmptyString(item.name)) {
1603
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
1883
+ return invalidFromErrorFactory(
1884
+ errorFactory,
1885
+ `${itemPath}.name must be a non-empty string`,
1886
+ );
1604
1887
  }
1605
1888
 
1606
1889
  if (item.type === "textStyle") {
1607
1890
  if (!isNonEmptyString(item.fontId)) {
1608
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fontId must be a non-empty string`);
1891
+ return invalidFromErrorFactory(
1892
+ errorFactory,
1893
+ `${itemPath}.fontId must be a non-empty string`,
1894
+ );
1609
1895
  }
1610
1896
 
1611
1897
  if (!isNonEmptyString(item.colorId)) {
1612
- return invalidFromErrorFactory(errorFactory, `${itemPath}.colorId must be a non-empty string`);
1898
+ return invalidFromErrorFactory(
1899
+ errorFactory,
1900
+ `${itemPath}.colorId must be a non-empty string`,
1901
+ );
1613
1902
  }
1614
1903
 
1615
1904
  if (!isFiniteNumber(item.fontSize)) {
1616
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fontSize must be a finite number`);
1905
+ return invalidFromErrorFactory(
1906
+ errorFactory,
1907
+ `${itemPath}.fontSize must be a finite number`,
1908
+ );
1617
1909
  }
1618
1910
 
1619
1911
  if (!isFiniteNumber(item.lineHeight)) {
1620
- return invalidFromErrorFactory(errorFactory, `${itemPath}.lineHeight must be a finite number`);
1912
+ return invalidFromErrorFactory(
1913
+ errorFactory,
1914
+ `${itemPath}.lineHeight must be a finite number`,
1915
+ );
1621
1916
  }
1622
1917
 
1623
1918
  if (!isNonEmptyString(item.fontWeight)) {
1624
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fontWeight must be a non-empty string`);
1919
+ return invalidFromErrorFactory(
1920
+ errorFactory,
1921
+ `${itemPath}.fontWeight must be a non-empty string`,
1922
+ );
1625
1923
  }
1626
1924
 
1627
1925
  if (item.previewText !== undefined && !isString(item.previewText)) {
1628
- return invalidFromErrorFactory(errorFactory,
1926
+ return invalidFromErrorFactory(
1927
+ errorFactory,
1629
1928
  `${itemPath}.previewText must be a string when provided`,
1630
1929
  );
1631
1930
  }
1632
1931
 
1633
1932
  if (item.fontStyle !== undefined && !isString(item.fontStyle)) {
1634
- return invalidFromErrorFactory(errorFactory,
1933
+ return invalidFromErrorFactory(
1934
+ errorFactory,
1635
1935
  `${itemPath}.fontStyle must be a string when provided`,
1636
1936
  );
1637
1937
  }
@@ -1640,7 +1940,8 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
1640
1940
  item.breakWords !== undefined &&
1641
1941
  typeof item.breakWords !== "boolean"
1642
1942
  ) {
1643
- return invalidFromErrorFactory(errorFactory,
1943
+ return invalidFromErrorFactory(
1944
+ errorFactory,
1644
1945
  `${itemPath}.breakWords must be a boolean when provided`,
1645
1946
  );
1646
1947
  }
@@ -1649,13 +1950,15 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
1649
1950
  item.align !== undefined &&
1650
1951
  !LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS.includes(item.align)
1651
1952
  ) {
1652
- return invalidFromErrorFactory(errorFactory,
1953
+ return invalidFromErrorFactory(
1954
+ errorFactory,
1653
1955
  `${itemPath}.align must be 'left', 'center', or 'right' when provided`,
1654
1956
  );
1655
1957
  }
1656
1958
 
1657
1959
  if (item.wordWrap !== undefined && typeof item.wordWrap !== "boolean") {
1658
- return invalidFromErrorFactory(errorFactory,
1960
+ return invalidFromErrorFactory(
1961
+ errorFactory,
1659
1962
  `${itemPath}.wordWrap must be a boolean when provided`,
1660
1963
  );
1661
1964
  }
@@ -1664,7 +1967,8 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
1664
1967
  item.wordWrapWidth !== undefined &&
1665
1968
  !isFiniteNumber(item.wordWrapWidth)
1666
1969
  ) {
1667
- return invalidFromErrorFactory(errorFactory,
1970
+ return invalidFromErrorFactory(
1971
+ errorFactory,
1668
1972
  `${itemPath}.wordWrapWidth must be a finite number when provided`,
1669
1973
  );
1670
1974
  }
@@ -1673,19 +1977,22 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
1673
1977
  item.strokeColorId !== undefined &&
1674
1978
  !isNonEmptyString(item.strokeColorId)
1675
1979
  ) {
1676
- return invalidFromErrorFactory(errorFactory,
1980
+ return invalidFromErrorFactory(
1981
+ errorFactory,
1677
1982
  `${itemPath}.strokeColorId must be a non-empty string when provided`,
1678
1983
  );
1679
1984
  }
1680
1985
 
1681
1986
  if (item.strokeAlpha !== undefined && !isFiniteNumber(item.strokeAlpha)) {
1682
- return invalidFromErrorFactory(errorFactory,
1987
+ return invalidFromErrorFactory(
1988
+ errorFactory,
1683
1989
  `${itemPath}.strokeAlpha must be a finite number when provided`,
1684
1990
  );
1685
1991
  }
1686
1992
 
1687
1993
  if (item.strokeWidth !== undefined && !isFiniteNumber(item.strokeWidth)) {
1688
- return invalidFromErrorFactory(errorFactory,
1994
+ return invalidFromErrorFactory(
1995
+ errorFactory,
1689
1996
  `${itemPath}.strokeWidth must be a finite number when provided`,
1690
1997
  );
1691
1998
  }
@@ -1698,7 +2005,10 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
1698
2005
  const itemPath = `${path}.${itemId}`;
1699
2006
 
1700
2007
  if (item?.type !== "folder" && item?.type !== "image") {
1701
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'image'`);
2008
+ return invalidFromErrorFactory(
2009
+ errorFactory,
2010
+ `${itemPath}.type must be 'folder' or 'image'`,
2011
+ );
1702
2012
  }
1703
2013
 
1704
2014
  {
@@ -1726,42 +2036,58 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
1726
2036
  }
1727
2037
 
1728
2038
  if (!isNonEmptyString(item.id)) {
1729
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
2039
+ return invalidFromErrorFactory(
2040
+ errorFactory,
2041
+ `${itemPath}.id must be a non-empty string`,
2042
+ );
1730
2043
  }
1731
2044
 
1732
2045
  if (item.id !== itemId) {
1733
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
2046
+ return invalidFromErrorFactory(
2047
+ errorFactory,
2048
+ `${itemPath}.id must match item key '${itemId}'`,
2049
+ );
1734
2050
  }
1735
2051
 
1736
2052
  if (!isNonEmptyString(item.name)) {
1737
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
2053
+ return invalidFromErrorFactory(
2054
+ errorFactory,
2055
+ `${itemPath}.name must be a non-empty string`,
2056
+ );
1738
2057
  }
1739
2058
 
1740
2059
  if (item.type === "image") {
1741
2060
  if (!isNonEmptyString(item.fileId)) {
1742
- return invalidFromErrorFactory(errorFactory, `${itemPath}.fileId must be a non-empty string`);
2061
+ return invalidFromErrorFactory(
2062
+ errorFactory,
2063
+ `${itemPath}.fileId must be a non-empty string`,
2064
+ );
1743
2065
  }
1744
2066
 
1745
2067
  if (item.fileType !== undefined && !isString(item.fileType)) {
1746
- return invalidFromErrorFactory(errorFactory,
2068
+ return invalidFromErrorFactory(
2069
+ errorFactory,
1747
2070
  `${itemPath}.fileType must be a string when provided`,
1748
2071
  );
1749
2072
  }
1750
2073
 
1751
2074
  if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
1752
- return invalidFromErrorFactory(errorFactory,
2075
+ return invalidFromErrorFactory(
2076
+ errorFactory,
1753
2077
  `${itemPath}.fileSize must be a finite number when provided`,
1754
2078
  );
1755
2079
  }
1756
2080
 
1757
2081
  if (item.width !== undefined && !isFiniteNumber(item.width)) {
1758
- return invalidFromErrorFactory(errorFactory,
2082
+ return invalidFromErrorFactory(
2083
+ errorFactory,
1759
2084
  `${itemPath}.width must be a finite number when provided`,
1760
2085
  );
1761
2086
  }
1762
2087
 
1763
2088
  if (item.height !== undefined && !isFiniteNumber(item.height)) {
1764
- return invalidFromErrorFactory(errorFactory,
2089
+ return invalidFromErrorFactory(
2090
+ errorFactory,
1765
2091
  `${itemPath}.height must be a finite number when provided`,
1766
2092
  );
1767
2093
  }
@@ -1786,7 +2112,8 @@ const validateLayoutElementStyle = ({ style, path, errorFactory }) => {
1786
2112
  style.align !== undefined &&
1787
2113
  !LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS.includes(style.align)
1788
2114
  ) {
1789
- return invalidFromErrorFactory(errorFactory,
2115
+ return invalidFromErrorFactory(
2116
+ errorFactory,
1790
2117
  `${path}.align must be 'left', 'center', or 'right' when provided`,
1791
2118
  );
1792
2119
  }
@@ -1795,7 +2122,8 @@ const validateLayoutElementStyle = ({ style, path, errorFactory }) => {
1795
2122
  style.wordWrapWidth !== undefined &&
1796
2123
  !isFiniteNumber(style.wordWrapWidth)
1797
2124
  ) {
1798
- return invalidFromErrorFactory(errorFactory,
2125
+ return invalidFromErrorFactory(
2126
+ errorFactory,
1799
2127
  `${path}.wordWrapWidth must be a finite number when provided`,
1800
2128
  );
1801
2129
  }
@@ -1867,7 +2195,8 @@ const validateLayoutElementData = ({
1867
2195
 
1868
2196
  if (!allowPartial || data.type !== undefined) {
1869
2197
  if (!LAYOUT_ELEMENT_BASE_TYPES.includes(data.type)) {
1870
- return invalidFromErrorFactory(errorFactory,
2198
+ return invalidFromErrorFactory(
2199
+ errorFactory,
1871
2200
  `${path}.type must be a supported layout element type`,
1872
2201
  );
1873
2202
  }
@@ -1875,7 +2204,10 @@ const validateLayoutElementData = ({
1875
2204
 
1876
2205
  if (!allowPartial || data.name !== undefined) {
1877
2206
  if (!isNonEmptyString(data.name)) {
1878
- return invalidFromErrorFactory(errorFactory, `${path}.name must be a non-empty string`);
2207
+ return invalidFromErrorFactory(
2208
+ errorFactory,
2209
+ `${path}.name must be a non-empty string`,
2210
+ );
1879
2211
  }
1880
2212
  }
1881
2213
 
@@ -1897,7 +2229,8 @@ const validateLayoutElementData = ({
1897
2229
  "opacity",
1898
2230
  ]) {
1899
2231
  if (data[key] !== undefined && !isFiniteNumber(data[key])) {
1900
- return invalidFromErrorFactory(errorFactory,
2232
+ return invalidFromErrorFactory(
2233
+ errorFactory,
1901
2234
  `${path}.${key} must be a finite number when provided`,
1902
2235
  );
1903
2236
  }
@@ -1908,7 +2241,8 @@ const validateLayoutElementData = ({
1908
2241
  !isFiniteNumber(data.initialValue) &&
1909
2242
  !isString(data.initialValue)
1910
2243
  ) {
1911
- return invalidFromErrorFactory(errorFactory,
2244
+ return invalidFromErrorFactory(
2245
+ errorFactory,
1912
2246
  `${path}.initialValue must be a finite number or string when provided`,
1913
2247
  );
1914
2248
  }
@@ -1917,7 +2251,8 @@ const validateLayoutElementData = ({
1917
2251
  data.opacity !== undefined &&
1918
2252
  (!isFiniteNumber(data.opacity) || data.opacity < 0 || data.opacity > 1)
1919
2253
  ) {
1920
- return invalidFromErrorFactory(errorFactory,
2254
+ return invalidFromErrorFactory(
2255
+ errorFactory,
1921
2256
  `${path}.opacity must be a finite number between 0 and 1 when provided`,
1922
2257
  );
1923
2258
  }
@@ -1939,7 +2274,10 @@ const validateLayoutElementData = ({
1939
2274
  "$when",
1940
2275
  ]) {
1941
2276
  if (data[key] !== undefined && !isString(data[key])) {
1942
- return invalidFromErrorFactory(errorFactory, `${path}.${key} must be a string when provided`);
2277
+ return invalidFromErrorFactory(
2278
+ errorFactory,
2279
+ `${path}.${key} must be a string when provided`,
2280
+ );
1943
2281
  }
1944
2282
  }
1945
2283
 
@@ -1948,20 +2286,25 @@ const validateLayoutElementData = ({
1948
2286
  data.direction !== "horizontal" &&
1949
2287
  data.direction !== "vertical"
1950
2288
  ) {
1951
- return invalidFromErrorFactory(errorFactory,
2289
+ return invalidFromErrorFactory(
2290
+ errorFactory,
1952
2291
  `${path}.direction must be 'horizontal' or 'vertical' when provided`,
1953
2292
  );
1954
2293
  }
1955
2294
 
1956
2295
  if (data.scroll !== undefined && typeof data.scroll !== "boolean") {
1957
- return invalidFromErrorFactory(errorFactory, `${path}.scroll must be a boolean when provided`);
2296
+ return invalidFromErrorFactory(
2297
+ errorFactory,
2298
+ `${path}.scroll must be a boolean when provided`,
2299
+ );
1958
2300
  }
1959
2301
 
1960
2302
  if (
1961
2303
  data.anchorToBottom !== undefined &&
1962
2304
  typeof data.anchorToBottom !== "boolean"
1963
2305
  ) {
1964
- return invalidFromErrorFactory(errorFactory,
2306
+ return invalidFromErrorFactory(
2307
+ errorFactory,
1965
2308
  `${path}.anchorToBottom must be a boolean when provided`,
1966
2309
  );
1967
2310
  }
@@ -1980,15 +2323,24 @@ const validateLayoutElementData = ({
1980
2323
  }
1981
2324
 
1982
2325
  if (data.click !== undefined && !isPlainObject(data.click)) {
1983
- return invalidFromErrorFactory(errorFactory, `${path}.click must be an object when provided`);
2326
+ return invalidFromErrorFactory(
2327
+ errorFactory,
2328
+ `${path}.click must be an object when provided`,
2329
+ );
1984
2330
  }
1985
2331
 
1986
2332
  if (data.rightClick !== undefined && !isPlainObject(data.rightClick)) {
1987
- return invalidFromErrorFactory(errorFactory, `${path}.rightClick must be an object when provided`);
2333
+ return invalidFromErrorFactory(
2334
+ errorFactory,
2335
+ `${path}.rightClick must be an object when provided`,
2336
+ );
1988
2337
  }
1989
2338
 
1990
2339
  if (data.change !== undefined && !isPlainObject(data.change)) {
1991
- return invalidFromErrorFactory(errorFactory, `${path}.change must be an object when provided`);
2340
+ return invalidFromErrorFactory(
2341
+ errorFactory,
2342
+ `${path}.change must be an object when provided`,
2343
+ );
1992
2344
  }
1993
2345
  };
1994
2346
 
@@ -2050,11 +2402,17 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
2050
2402
  }
2051
2403
 
2052
2404
  if (!isNonEmptyString(item.id)) {
2053
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
2405
+ return invalidFromErrorFactory(
2406
+ errorFactory,
2407
+ `${itemPath}.id must be a non-empty string`,
2408
+ );
2054
2409
  }
2055
2410
 
2056
2411
  if (item.id !== itemId) {
2057
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
2412
+ return invalidFromErrorFactory(
2413
+ errorFactory,
2414
+ `${itemPath}.id must match item key '${itemId}'`,
2415
+ );
2058
2416
  }
2059
2417
 
2060
2418
  {
@@ -2077,7 +2435,10 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
2077
2435
  const itemPath = `${path}.${itemId}`;
2078
2436
 
2079
2437
  if (item?.type !== "folder" && item?.type !== "character") {
2080
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'character'`);
2438
+ return invalidFromErrorFactory(
2439
+ errorFactory,
2440
+ `${itemPath}.type must be 'folder' or 'character'`,
2441
+ );
2081
2442
  }
2082
2443
 
2083
2444
  {
@@ -2106,44 +2467,58 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
2106
2467
  }
2107
2468
 
2108
2469
  if (!isNonEmptyString(item.id)) {
2109
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
2470
+ return invalidFromErrorFactory(
2471
+ errorFactory,
2472
+ `${itemPath}.id must be a non-empty string`,
2473
+ );
2110
2474
  }
2111
2475
 
2112
2476
  if (item.id !== itemId) {
2113
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
2477
+ return invalidFromErrorFactory(
2478
+ errorFactory,
2479
+ `${itemPath}.id must match item key '${itemId}'`,
2480
+ );
2114
2481
  }
2115
2482
 
2116
2483
  if (!isNonEmptyString(item.name)) {
2117
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
2484
+ return invalidFromErrorFactory(
2485
+ errorFactory,
2486
+ `${itemPath}.name must be a non-empty string`,
2487
+ );
2118
2488
  }
2119
2489
 
2120
2490
  if (item.type === "character") {
2121
2491
  if (item.description !== undefined && !isString(item.description)) {
2122
- return invalidFromErrorFactory(errorFactory,
2492
+ return invalidFromErrorFactory(
2493
+ errorFactory,
2123
2494
  `${itemPath}.description must be a string when provided`,
2124
2495
  );
2125
2496
  }
2126
2497
 
2127
2498
  if (item.shortcut !== undefined && !isString(item.shortcut)) {
2128
- return invalidFromErrorFactory(errorFactory,
2499
+ return invalidFromErrorFactory(
2500
+ errorFactory,
2129
2501
  `${itemPath}.shortcut must be a string when provided`,
2130
2502
  );
2131
2503
  }
2132
2504
 
2133
2505
  if (item.fileId !== undefined && !isNonEmptyString(item.fileId)) {
2134
- return invalidFromErrorFactory(errorFactory,
2506
+ return invalidFromErrorFactory(
2507
+ errorFactory,
2135
2508
  `${itemPath}.fileId must be a non-empty string when provided`,
2136
2509
  );
2137
2510
  }
2138
2511
 
2139
2512
  if (item.fileType !== undefined && !isString(item.fileType)) {
2140
- return invalidFromErrorFactory(errorFactory,
2513
+ return invalidFromErrorFactory(
2514
+ errorFactory,
2141
2515
  `${itemPath}.fileType must be a string when provided`,
2142
2516
  );
2143
2517
  }
2144
2518
 
2145
2519
  if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
2146
- return invalidFromErrorFactory(errorFactory,
2520
+ return invalidFromErrorFactory(
2521
+ errorFactory,
2147
2522
  `${itemPath}.fileSize must be a finite number when provided`,
2148
2523
  );
2149
2524
  }
@@ -2165,12 +2540,46 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
2165
2540
  }
2166
2541
  };
2167
2542
 
2543
+ const validateKeyboardMap = ({ value, path, errorFactory }) => {
2544
+ if (value === undefined) {
2545
+ return VALID_RESULT;
2546
+ }
2547
+
2548
+ if (!isPlainObject(value)) {
2549
+ return invalidFromErrorFactory(
2550
+ errorFactory,
2551
+ `${path} must be an object when provided`,
2552
+ );
2553
+ }
2554
+
2555
+ for (const [key, interaction] of Object.entries(value)) {
2556
+ if (!isNonEmptyString(key)) {
2557
+ return invalidFromErrorFactory(
2558
+ errorFactory,
2559
+ `${path} keys must be non-empty strings`,
2560
+ );
2561
+ }
2562
+
2563
+ if (!isPlainObject(interaction)) {
2564
+ return invalidFromErrorFactory(
2565
+ errorFactory,
2566
+ `${path}.${key} must be an object`,
2567
+ );
2568
+ }
2569
+ }
2570
+
2571
+ return VALID_RESULT;
2572
+ };
2573
+
2168
2574
  const validateLayoutItems = ({ items, path, errorFactory }) => {
2169
2575
  for (const [itemId, item] of Object.entries(items)) {
2170
2576
  const itemPath = `${path}.${itemId}`;
2171
2577
 
2172
2578
  if (item?.type !== "folder" && item?.type !== "layout") {
2173
- return invalidFromErrorFactory(errorFactory, `${itemPath}.type must be 'folder' or 'layout'`);
2579
+ return invalidFromErrorFactory(
2580
+ errorFactory,
2581
+ `${itemPath}.type must be 'folder' or 'layout'`,
2582
+ );
2174
2583
  }
2175
2584
 
2176
2585
  {
@@ -2179,7 +2588,7 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
2179
2588
  allowedKeys:
2180
2589
  item.type === "folder"
2181
2590
  ? ["id", "type", "name"]
2182
- : ["id", "type", "name", "layoutType", "elements"],
2591
+ : ["id", "type", "name", "layoutType", "elements", "keyboard"],
2183
2592
  path: itemPath,
2184
2593
  errorFactory,
2185
2594
  });
@@ -2189,20 +2598,30 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
2189
2598
  }
2190
2599
 
2191
2600
  if (!isNonEmptyString(item.id)) {
2192
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must be a non-empty string`);
2601
+ return invalidFromErrorFactory(
2602
+ errorFactory,
2603
+ `${itemPath}.id must be a non-empty string`,
2604
+ );
2193
2605
  }
2194
2606
 
2195
2607
  if (item.id !== itemId) {
2196
- return invalidFromErrorFactory(errorFactory, `${itemPath}.id must match item key '${itemId}'`);
2608
+ return invalidFromErrorFactory(
2609
+ errorFactory,
2610
+ `${itemPath}.id must match item key '${itemId}'`,
2611
+ );
2197
2612
  }
2198
2613
 
2199
2614
  if (!isNonEmptyString(item.name)) {
2200
- return invalidFromErrorFactory(errorFactory, `${itemPath}.name must be a non-empty string`);
2615
+ return invalidFromErrorFactory(
2616
+ errorFactory,
2617
+ `${itemPath}.name must be a non-empty string`,
2618
+ );
2201
2619
  }
2202
2620
 
2203
2621
  if (item.type === "layout") {
2204
2622
  if (!LAYOUT_TYPE_KEYS.includes(item.layoutType)) {
2205
- return invalidFromErrorFactory(errorFactory,
2623
+ return invalidFromErrorFactory(
2624
+ errorFactory,
2206
2625
  `${itemPath}.layoutType must be 'normal', 'dialogue', 'nvl', 'choice', or 'base'`,
2207
2626
  );
2208
2627
  }
@@ -2219,6 +2638,17 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
2219
2638
  return result;
2220
2639
  }
2221
2640
  }
2641
+
2642
+ {
2643
+ const result = validateKeyboardMap({
2644
+ value: item.keyboard,
2645
+ path: `${itemPath}.keyboard`,
2646
+ errorFactory,
2647
+ });
2648
+ if (result?.valid === false) {
2649
+ return result;
2650
+ }
2651
+ }
2222
2652
  }
2223
2653
  }
2224
2654
  };
@@ -2282,7 +2712,10 @@ const validateSectionTreeShape = ({ nodes, items, path, errorFactory }) => {
2282
2712
  const children = Array.isArray(node.children) ? node.children : [];
2283
2713
 
2284
2714
  if (!Object.hasOwn(items, node.id)) {
2285
- return invalidFromErrorFactory(errorFactory, `${nodePath}.id must reference an existing section`);
2715
+ return invalidFromErrorFactory(
2716
+ errorFactory,
2717
+ `${nodePath}.id must reference an existing section`,
2718
+ );
2286
2719
  }
2287
2720
 
2288
2721
  {
@@ -2306,9 +2739,7 @@ const validateLineTreeFlatShape = ({ nodes, path }) => {
2306
2739
  const children = Array.isArray(node.children) ? node.children : [];
2307
2740
 
2308
2741
  if (children.length > 0) {
2309
- return invalidState(
2310
- `${nodePath}.children is not supported for lines`,
2311
- );
2742
+ return invalidState(`${nodePath}.children is not supported for lines`);
2312
2743
  }
2313
2744
  }
2314
2745
  };
@@ -2476,7 +2907,8 @@ const validateGenericFolderOwnership = ({
2476
2907
  const children = Array.isArray(node.children) ? node.children : [];
2477
2908
 
2478
2909
  if (children.length > 0 && items[node.id]?.type !== "folder") {
2479
- return invalidFromErrorFactory(errorFactory,
2910
+ return invalidFromErrorFactory(
2911
+ errorFactory,
2480
2912
  `${nodePath}.children requires '${node.id}' to be a ${folderLabel}`,
2481
2913
  );
2482
2914
  }
@@ -2511,7 +2943,8 @@ const validateLayoutElementTreeOwnership = ({
2511
2943
  children.length > 0 &&
2512
2944
  !LAYOUT_CONTAINER_ELEMENT_TYPES.includes(items[node.id]?.type)
2513
2945
  ) {
2514
- return invalidFromErrorFactory(errorFactory,
2946
+ return invalidFromErrorFactory(
2947
+ errorFactory,
2515
2948
  `${nodePath}.children requires '${node.id}' to be a folder or container layout element`,
2516
2949
  );
2517
2950
  }
@@ -2558,15 +2991,24 @@ const validateTreeNodes = ({
2558
2991
  }
2559
2992
 
2560
2993
  if (!isNonEmptyString(node.id)) {
2561
- return invalidFromErrorFactory(errorFactory, `${nodePath}.id must be a non-empty string`);
2994
+ return invalidFromErrorFactory(
2995
+ errorFactory,
2996
+ `${nodePath}.id must be a non-empty string`,
2997
+ );
2562
2998
  }
2563
2999
 
2564
3000
  if (!Object.hasOwn(items, node.id)) {
2565
- return invalidFromErrorFactory(errorFactory, `${nodePath}.id must reference an existing item`);
3001
+ return invalidFromErrorFactory(
3002
+ errorFactory,
3003
+ `${nodePath}.id must reference an existing item`,
3004
+ );
2566
3005
  }
2567
3006
 
2568
3007
  if (seenIds.has(node.id)) {
2569
- return invalidFromErrorFactory(errorFactory, `${nodePath}.id is duplicated in tree`);
3008
+ return invalidFromErrorFactory(
3009
+ errorFactory,
3010
+ `${nodePath}.id is duplicated in tree`,
3011
+ );
2570
3012
  }
2571
3013
  seenIds.add(node.id);
2572
3014
 
@@ -2608,7 +3050,10 @@ const validateNestedCollection = ({
2608
3050
  }
2609
3051
 
2610
3052
  if (!isPlainObject(collection.items)) {
2611
- return invalidFromErrorFactory(errorFactory, `${path}.items must be an object`);
3053
+ return invalidFromErrorFactory(
3054
+ errorFactory,
3055
+ `${path}.items must be an object`,
3056
+ );
2612
3057
  }
2613
3058
 
2614
3059
  {
@@ -2651,7 +3096,10 @@ const validateNestedCollection = ({
2651
3096
 
2652
3097
  for (const itemId of Object.keys(collection.items)) {
2653
3098
  if (!seenIds.has(itemId)) {
2654
- return invalidFromErrorFactory(errorFactory, `${path}.tree is missing item '${itemId}'`);
3099
+ return invalidFromErrorFactory(
3100
+ errorFactory,
3101
+ `${path}.tree is missing item '${itemId}'`,
3102
+ );
2655
3103
  }
2656
3104
  }
2657
3105
  };
@@ -2936,9 +3384,7 @@ const validateCollection = ({ collection, path }) => {
2936
3384
 
2937
3385
  for (const itemId of Object.keys(collection.items)) {
2938
3386
  if (!seenIds.has(itemId)) {
2939
- return invalidState(
2940
- `${path}.tree is missing item '${itemId}'`,
2941
- );
3387
+ return invalidState(`${path}.tree is missing item '${itemId}'`);
2942
3388
  }
2943
3389
  }
2944
3390
  };
@@ -2975,16 +3421,16 @@ const validateFileReference = ({
2975
3421
  );
2976
3422
  }
2977
3423
 
2978
- if (Array.isArray(allowedTypes) && allowedTypes.length > 0 && !allowedTypes.includes(file.type)) {
2979
- return invalidFromErrorFactory(
2980
- errorFactory,
2981
- expectedTypeMessage,
2982
- {
2983
- ...details,
2984
- expectedFileTypes: [...allowedTypes],
2985
- actualFileType: file.type,
2986
- },
2987
- );
3424
+ if (
3425
+ Array.isArray(allowedTypes) &&
3426
+ allowedTypes.length > 0 &&
3427
+ !allowedTypes.includes(file.type)
3428
+ ) {
3429
+ return invalidFromErrorFactory(errorFactory, expectedTypeMessage, {
3430
+ ...details,
3431
+ expectedFileTypes: [...allowedTypes],
3432
+ actualFileType: file.type,
3433
+ });
2988
3434
  }
2989
3435
 
2990
3436
  return VALID_RESULT;
@@ -3032,27 +3478,29 @@ export const assertInvariants = ({ state }) => {
3032
3478
 
3033
3479
  for (const [sectionId, section] of Object.entries(sections.items)) {
3034
3480
  if (!isNonEmptyString(section.id) || section.id !== sectionId) {
3035
- return invalidInvariant(
3036
- "section.id must match the section key",
3037
- { sceneId, sectionId },
3038
- );
3481
+ return invalidInvariant("section.id must match the section key", {
3482
+ sceneId,
3483
+ sectionId,
3484
+ });
3039
3485
  }
3040
3486
 
3041
3487
  const lines = section.lines ?? createEmptyNestedCollection();
3042
3488
 
3043
3489
  for (const [lineId, line] of Object.entries(lines.items)) {
3044
3490
  if (!isNonEmptyString(line.id) || line.id !== lineId) {
3045
- return invalidInvariant(
3046
- "line.id must match the line key",
3047
- { sceneId, sectionId, lineId },
3048
- );
3491
+ return invalidInvariant("line.id must match the line key", {
3492
+ sceneId,
3493
+ sectionId,
3494
+ lineId,
3495
+ });
3049
3496
  }
3050
3497
 
3051
3498
  if (!isPlainObject(line.actions)) {
3052
- return invalidInvariant(
3053
- "line.actions must be an object",
3054
- { sceneId, sectionId, lineId },
3055
- );
3499
+ return invalidInvariant("line.actions must be an object", {
3500
+ sceneId,
3501
+ sectionId,
3502
+ lineId,
3503
+ });
3056
3504
  }
3057
3505
  }
3058
3506
  }
@@ -3154,7 +3602,10 @@ export const assertInvariants = ({ state }) => {
3154
3602
  }
3155
3603
  }
3156
3604
 
3157
- if (sound.waveformDataFileId !== undefined && sound.waveformDataFileId !== null) {
3605
+ if (
3606
+ sound.waveformDataFileId !== undefined &&
3607
+ sound.waveformDataFileId !== null
3608
+ ) {
3158
3609
  const result = validateFileReference({
3159
3610
  state,
3160
3611
  fileId: sound.waveformDataFileId,
@@ -3221,7 +3672,9 @@ export const assertInvariants = ({ state }) => {
3221
3672
  }
3222
3673
  }
3223
3674
 
3224
- for (const [characterId, character] of Object.entries(state.characters.items)) {
3675
+ for (const [characterId, character] of Object.entries(
3676
+ state.characters.items,
3677
+ )) {
3225
3678
  if (character.type !== "character") {
3226
3679
  continue;
3227
3680
  }
@@ -3479,7 +3932,8 @@ const validatePlacementFields = ({ payload, errorFactory }) => {
3479
3932
  payload.index !== undefined &&
3480
3933
  (!Number.isInteger(payload.index) || payload.index < 0)
3481
3934
  ) {
3482
- return invalidFromErrorFactory(errorFactory,
3935
+ return invalidFromErrorFactory(
3936
+ errorFactory,
3483
3937
  "payload.index must be an integer greater than or equal to 0",
3484
3938
  );
3485
3939
  }
@@ -3488,14 +3942,18 @@ const validatePlacementFields = ({ payload, errorFactory }) => {
3488
3942
  const hasPositionTargetId = payload.positionTargetId !== undefined;
3489
3943
 
3490
3944
  if (payload.index !== undefined && hasPosition) {
3491
- return invalidFromErrorFactory(errorFactory,
3945
+ return invalidFromErrorFactory(
3946
+ errorFactory,
3492
3947
  "payload.index cannot be combined with payload.position",
3493
3948
  );
3494
3949
  }
3495
3950
 
3496
3951
  if (!hasPosition) {
3497
3952
  if (hasPositionTargetId) {
3498
- return invalidFromErrorFactory(errorFactory, "payload.positionTargetId requires payload.position");
3953
+ return invalidFromErrorFactory(
3954
+ errorFactory,
3955
+ "payload.positionTargetId requires payload.position",
3956
+ );
3499
3957
  }
3500
3958
  return;
3501
3959
  }
@@ -3506,14 +3964,16 @@ const validatePlacementFields = ({ payload, errorFactory }) => {
3506
3964
  payload.position !== "before" &&
3507
3965
  payload.position !== "after"
3508
3966
  ) {
3509
- return invalidFromErrorFactory(errorFactory,
3967
+ return invalidFromErrorFactory(
3968
+ errorFactory,
3510
3969
  "payload.position must be 'first', 'last', 'before', or 'after'",
3511
3970
  );
3512
3971
  }
3513
3972
 
3514
3973
  if (payload.position === "before" || payload.position === "after") {
3515
3974
  if (!isNonEmptyString(payload.positionTargetId)) {
3516
- return invalidFromErrorFactory(errorFactory,
3975
+ return invalidFromErrorFactory(
3976
+ errorFactory,
3517
3977
  "payload.positionTargetId must be a non-empty string when payload.position is 'before' or 'after'",
3518
3978
  );
3519
3979
  }
@@ -3521,7 +3981,8 @@ const validatePlacementFields = ({ payload, errorFactory }) => {
3521
3981
  }
3522
3982
 
3523
3983
  if (hasPositionTargetId) {
3524
- return invalidFromErrorFactory(errorFactory,
3984
+ return invalidFromErrorFactory(
3985
+ errorFactory,
3525
3986
  "payload.positionTargetId is allowed only when payload.position is 'before' or 'after'",
3526
3987
  );
3527
3988
  }
@@ -3541,7 +4002,10 @@ const validateSceneCreateData = ({ data, errorFactory }) => {
3541
4002
  }
3542
4003
 
3543
4004
  if (!isNonEmptyString(data.name)) {
3544
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4005
+ return invalidFromErrorFactory(
4006
+ errorFactory,
4007
+ "payload.data.name must be a non-empty string",
4008
+ );
3545
4009
  }
3546
4010
 
3547
4011
  if (
@@ -3549,7 +4013,10 @@ const validateSceneCreateData = ({ data, errorFactory }) => {
3549
4013
  data.type !== "scene" &&
3550
4014
  data.type !== "folder"
3551
4015
  ) {
3552
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'scene' or 'folder'");
4016
+ return invalidFromErrorFactory(
4017
+ errorFactory,
4018
+ "payload.data.type must be 'scene' or 'folder'",
4019
+ );
3553
4020
  }
3554
4021
 
3555
4022
  {
@@ -3581,13 +4048,17 @@ const validateSceneUpdateData = ({ data, errorFactory }) => {
3581
4048
  const hasPosition = data.position !== undefined;
3582
4049
 
3583
4050
  if (!hasName && !hasPosition) {
3584
- return invalidFromErrorFactory(errorFactory,
4051
+ return invalidFromErrorFactory(
4052
+ errorFactory,
3585
4053
  "payload.data must include at least one updatable field",
3586
4054
  );
3587
4055
  }
3588
4056
 
3589
4057
  if (hasName && !isNonEmptyString(data.name)) {
3590
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4058
+ return invalidFromErrorFactory(
4059
+ errorFactory,
4060
+ "payload.data.name must be a non-empty string",
4061
+ );
3591
4062
  }
3592
4063
 
3593
4064
  if (hasPosition) {
@@ -3606,18 +4077,27 @@ const validateSceneUpdateData = ({ data, errorFactory }) => {
3606
4077
 
3607
4078
  const validateRequiredUniqueIdArray = ({ value, path, errorFactory }) => {
3608
4079
  if (!Array.isArray(value) || value.length === 0) {
3609
- return invalidFromErrorFactory(errorFactory, `${path} must be a non-empty array`);
4080
+ return invalidFromErrorFactory(
4081
+ errorFactory,
4082
+ `${path} must be a non-empty array`,
4083
+ );
3610
4084
  }
3611
4085
 
3612
4086
  const seen = new Set();
3613
4087
 
3614
4088
  for (const [index, entry] of value.entries()) {
3615
4089
  if (!isNonEmptyString(entry)) {
3616
- return invalidFromErrorFactory(errorFactory, `${path}[${index}] must be a non-empty string`);
4090
+ return invalidFromErrorFactory(
4091
+ errorFactory,
4092
+ `${path}[${index}] must be a non-empty string`,
4093
+ );
3617
4094
  }
3618
4095
 
3619
4096
  if (seen.has(entry)) {
3620
- return invalidFromErrorFactory(errorFactory, `${path}[${index}] must be unique`);
4097
+ return invalidFromErrorFactory(
4098
+ errorFactory,
4099
+ `${path}[${index}] must be unique`,
4100
+ );
3621
4101
  }
3622
4102
 
3623
4103
  seen.add(entry);
@@ -3638,7 +4118,10 @@ const validateSectionCreateData = ({ data, errorFactory }) => {
3638
4118
  }
3639
4119
 
3640
4120
  if (!isNonEmptyString(data.name)) {
3641
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4121
+ return invalidFromErrorFactory(
4122
+ errorFactory,
4123
+ "payload.data.name must be a non-empty string",
4124
+ );
3642
4125
  }
3643
4126
  };
3644
4127
 
@@ -3656,13 +4139,19 @@ const validateSectionUpdateData = ({ data, errorFactory }) => {
3656
4139
  }
3657
4140
 
3658
4141
  if (!isNonEmptyString(data.name)) {
3659
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4142
+ return invalidFromErrorFactory(
4143
+ errorFactory,
4144
+ "payload.data.name must be a non-empty string",
4145
+ );
3660
4146
  }
3661
4147
  };
3662
4148
 
3663
4149
  const validateLineCreatePayload = ({ payload, errorFactory }) => {
3664
4150
  if (!Array.isArray(payload.lines) || payload.lines.length === 0) {
3665
- return invalidFromErrorFactory(errorFactory, "payload.lines must be a non-empty array");
4151
+ return invalidFromErrorFactory(
4152
+ errorFactory,
4153
+ "payload.lines must be a non-empty array",
4154
+ );
3666
4155
  }
3667
4156
 
3668
4157
  const seenLineIds = new Set();
@@ -3683,11 +4172,17 @@ const validateLineCreatePayload = ({ payload, errorFactory }) => {
3683
4172
  }
3684
4173
 
3685
4174
  if (!isNonEmptyString(item.lineId)) {
3686
- return invalidFromErrorFactory(errorFactory, `${itemPath}.lineId must be a non-empty string`);
4175
+ return invalidFromErrorFactory(
4176
+ errorFactory,
4177
+ `${itemPath}.lineId must be a non-empty string`,
4178
+ );
3687
4179
  }
3688
4180
 
3689
4181
  if (seenLineIds.has(item.lineId)) {
3690
- return invalidFromErrorFactory(errorFactory, `${itemPath}.lineId must be unique`);
4182
+ return invalidFromErrorFactory(
4183
+ errorFactory,
4184
+ `${itemPath}.lineId must be unique`,
4185
+ );
3691
4186
  }
3692
4187
  seenLineIds.add(item.lineId);
3693
4188
 
@@ -3704,24 +4199,36 @@ const validateLineCreatePayload = ({ payload, errorFactory }) => {
3704
4199
  }
3705
4200
 
3706
4201
  if (item.data.actions !== undefined && !isPlainObject(item.data.actions)) {
3707
- return invalidFromErrorFactory(errorFactory, `${itemPath}.data.actions must be an object`);
4202
+ return invalidFromErrorFactory(
4203
+ errorFactory,
4204
+ `${itemPath}.data.actions must be an object`,
4205
+ );
3708
4206
  }
3709
4207
  }
3710
4208
  };
3711
4209
 
3712
4210
  const validateLineUpdateActionsData = ({ data, errorFactory }) => {
3713
4211
  if (!isPlainObject(data)) {
3714
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
4212
+ return invalidFromErrorFactory(
4213
+ errorFactory,
4214
+ "payload.data must be an object",
4215
+ );
3715
4216
  }
3716
4217
  };
3717
4218
 
3718
4219
  const validateImageCreateData = ({ data, errorFactory }) => {
3719
4220
  if (!isPlainObject(data)) {
3720
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
4221
+ return invalidFromErrorFactory(
4222
+ errorFactory,
4223
+ "payload.data must be an object",
4224
+ );
3721
4225
  }
3722
4226
 
3723
4227
  if (data.type !== "folder" && data.type !== "image") {
3724
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'image'");
4228
+ return invalidFromErrorFactory(
4229
+ errorFactory,
4230
+ "payload.data.type must be 'folder' or 'image'",
4231
+ );
3725
4232
  }
3726
4233
 
3727
4234
  {
@@ -3750,11 +4257,15 @@ const validateImageCreateData = ({ data, errorFactory }) => {
3750
4257
  }
3751
4258
 
3752
4259
  if (!isNonEmptyString(data.name)) {
3753
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4260
+ return invalidFromErrorFactory(
4261
+ errorFactory,
4262
+ "payload.data.name must be a non-empty string",
4263
+ );
3754
4264
  }
3755
4265
 
3756
4266
  if (data.description !== undefined && !isString(data.description)) {
3757
- return invalidFromErrorFactory(errorFactory,
4267
+ return invalidFromErrorFactory(
4268
+ errorFactory,
3758
4269
  "payload.data.description must be a string when provided",
3759
4270
  );
3760
4271
  }
@@ -3771,25 +4282,38 @@ const validateImageCreateData = ({ data, errorFactory }) => {
3771
4282
  }
3772
4283
 
3773
4284
  if (!isNonEmptyString(data.fileId)) {
3774
- return invalidFromErrorFactory(errorFactory, "payload.data.fileId must be a non-empty string");
4285
+ return invalidFromErrorFactory(
4286
+ errorFactory,
4287
+ "payload.data.fileId must be a non-empty string",
4288
+ );
3775
4289
  }
3776
4290
 
3777
4291
  if (data.fileType !== undefined && !isString(data.fileType)) {
3778
- return invalidFromErrorFactory(errorFactory,
4292
+ return invalidFromErrorFactory(
4293
+ errorFactory,
3779
4294
  "payload.data.fileType must be a string when provided",
3780
4295
  );
3781
4296
  }
3782
4297
 
3783
4298
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
3784
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4299
+ return invalidFromErrorFactory(
4300
+ errorFactory,
4301
+ "payload.data.fileSize must be a finite number",
4302
+ );
3785
4303
  }
3786
4304
 
3787
4305
  if (data.width !== undefined && !isFiniteNumber(data.width)) {
3788
- return invalidFromErrorFactory(errorFactory, "payload.data.width must be a finite number");
4306
+ return invalidFromErrorFactory(
4307
+ errorFactory,
4308
+ "payload.data.width must be a finite number",
4309
+ );
3789
4310
  }
3790
4311
 
3791
4312
  if (data.height !== undefined && !isFiniteNumber(data.height)) {
3792
- return invalidFromErrorFactory(errorFactory, "payload.data.height must be a finite number");
4313
+ return invalidFromErrorFactory(
4314
+ errorFactory,
4315
+ "payload.data.height must be a finite number",
4316
+ );
3793
4317
  }
3794
4318
  }
3795
4319
  };
@@ -3817,19 +4341,22 @@ const validateImageUpdateData = ({ data, errorFactory }) => {
3817
4341
  }
3818
4342
 
3819
4343
  if (Object.keys(data).length === 0) {
3820
- return invalidFromErrorFactory(errorFactory,
4344
+ return invalidFromErrorFactory(
4345
+ errorFactory,
3821
4346
  "payload.data must include at least one updatable field",
3822
4347
  );
3823
4348
  }
3824
4349
 
3825
4350
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
3826
- return invalidFromErrorFactory(errorFactory,
4351
+ return invalidFromErrorFactory(
4352
+ errorFactory,
3827
4353
  "payload.data.name must be a non-empty string when provided",
3828
4354
  );
3829
4355
  }
3830
4356
 
3831
4357
  if (data.description !== undefined && !isString(data.description)) {
3832
- return invalidFromErrorFactory(errorFactory,
4358
+ return invalidFromErrorFactory(
4359
+ errorFactory,
3833
4360
  "payload.data.description must be a string when provided",
3834
4361
  );
3835
4362
  }
@@ -3838,41 +4365,61 @@ const validateImageUpdateData = ({ data, errorFactory }) => {
3838
4365
  data.thumbnailFileId !== undefined &&
3839
4366
  !isNonEmptyString(data.thumbnailFileId)
3840
4367
  ) {
3841
- return invalidFromErrorFactory(errorFactory,
4368
+ return invalidFromErrorFactory(
4369
+ errorFactory,
3842
4370
  "payload.data.thumbnailFileId must be a non-empty string when provided",
3843
4371
  );
3844
4372
  }
3845
4373
 
3846
4374
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
3847
- return invalidFromErrorFactory(errorFactory,
4375
+ return invalidFromErrorFactory(
4376
+ errorFactory,
3848
4377
  "payload.data.fileId must be a non-empty string when provided",
3849
4378
  );
3850
4379
  }
3851
4380
 
3852
4381
  if (data.fileType !== undefined && !isString(data.fileType)) {
3853
- return invalidFromErrorFactory(errorFactory, "payload.data.fileType must be a string when provided");
4382
+ return invalidFromErrorFactory(
4383
+ errorFactory,
4384
+ "payload.data.fileType must be a string when provided",
4385
+ );
3854
4386
  }
3855
4387
 
3856
4388
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
3857
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4389
+ return invalidFromErrorFactory(
4390
+ errorFactory,
4391
+ "payload.data.fileSize must be a finite number",
4392
+ );
3858
4393
  }
3859
4394
 
3860
4395
  if (data.width !== undefined && !isFiniteNumber(data.width)) {
3861
- return invalidFromErrorFactory(errorFactory, "payload.data.width must be a finite number");
4396
+ return invalidFromErrorFactory(
4397
+ errorFactory,
4398
+ "payload.data.width must be a finite number",
4399
+ );
3862
4400
  }
3863
4401
 
3864
4402
  if (data.height !== undefined && !isFiniteNumber(data.height)) {
3865
- return invalidFromErrorFactory(errorFactory, "payload.data.height must be a finite number");
4403
+ return invalidFromErrorFactory(
4404
+ errorFactory,
4405
+ "payload.data.height must be a finite number",
4406
+ );
3866
4407
  }
3867
4408
  };
3868
4409
 
3869
4410
  const validateSoundCreateData = ({ data, errorFactory }) => {
3870
4411
  if (!isPlainObject(data)) {
3871
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
4412
+ return invalidFromErrorFactory(
4413
+ errorFactory,
4414
+ "payload.data must be an object",
4415
+ );
3872
4416
  }
3873
4417
 
3874
4418
  if (data.type !== "folder" && data.type !== "sound") {
3875
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'sound'");
4419
+ return invalidFromErrorFactory(
4420
+ errorFactory,
4421
+ "payload.data.type must be 'folder' or 'sound'",
4422
+ );
3876
4423
  }
3877
4424
 
3878
4425
  {
@@ -3900,28 +4447,39 @@ const validateSoundCreateData = ({ data, errorFactory }) => {
3900
4447
  }
3901
4448
 
3902
4449
  if (!isNonEmptyString(data.name)) {
3903
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4450
+ return invalidFromErrorFactory(
4451
+ errorFactory,
4452
+ "payload.data.name must be a non-empty string",
4453
+ );
3904
4454
  }
3905
4455
 
3906
4456
  if (data.description !== undefined && !isString(data.description)) {
3907
- return invalidFromErrorFactory(errorFactory,
4457
+ return invalidFromErrorFactory(
4458
+ errorFactory,
3908
4459
  "payload.data.description must be a string when provided",
3909
4460
  );
3910
4461
  }
3911
4462
 
3912
4463
  if (data.type === "sound") {
3913
4464
  if (!isNonEmptyString(data.fileId)) {
3914
- return invalidFromErrorFactory(errorFactory, "payload.data.fileId must be a non-empty string");
4465
+ return invalidFromErrorFactory(
4466
+ errorFactory,
4467
+ "payload.data.fileId must be a non-empty string",
4468
+ );
3915
4469
  }
3916
4470
 
3917
4471
  if (data.fileType !== undefined && !isString(data.fileType)) {
3918
- return invalidFromErrorFactory(errorFactory,
4472
+ return invalidFromErrorFactory(
4473
+ errorFactory,
3919
4474
  "payload.data.fileType must be a string when provided",
3920
4475
  );
3921
4476
  }
3922
4477
 
3923
4478
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
3924
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4479
+ return invalidFromErrorFactory(
4480
+ errorFactory,
4481
+ "payload.data.fileSize must be a finite number",
4482
+ );
3925
4483
  }
3926
4484
 
3927
4485
  if (
@@ -3929,13 +4487,17 @@ const validateSoundCreateData = ({ data, errorFactory }) => {
3929
4487
  data.waveformDataFileId !== null &&
3930
4488
  !isNonEmptyString(data.waveformDataFileId)
3931
4489
  ) {
3932
- return invalidFromErrorFactory(errorFactory,
4490
+ return invalidFromErrorFactory(
4491
+ errorFactory,
3933
4492
  "payload.data.waveformDataFileId must be a non-empty string or null when provided",
3934
4493
  );
3935
4494
  }
3936
4495
 
3937
4496
  if (data.duration !== undefined && !isFiniteNumber(data.duration)) {
3938
- return invalidFromErrorFactory(errorFactory, "payload.data.duration must be a finite number");
4497
+ return invalidFromErrorFactory(
4498
+ errorFactory,
4499
+ "payload.data.duration must be a finite number",
4500
+ );
3939
4501
  }
3940
4502
  }
3941
4503
  };
@@ -3962,35 +4524,45 @@ const validateSoundUpdateData = ({ data, errorFactory }) => {
3962
4524
  }
3963
4525
 
3964
4526
  if (Object.keys(data).length === 0) {
3965
- return invalidFromErrorFactory(errorFactory,
4527
+ return invalidFromErrorFactory(
4528
+ errorFactory,
3966
4529
  "payload.data must include at least one updatable field",
3967
4530
  );
3968
4531
  }
3969
4532
 
3970
4533
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
3971
- return invalidFromErrorFactory(errorFactory,
4534
+ return invalidFromErrorFactory(
4535
+ errorFactory,
3972
4536
  "payload.data.name must be a non-empty string when provided",
3973
4537
  );
3974
4538
  }
3975
4539
 
3976
4540
  if (data.description !== undefined && !isString(data.description)) {
3977
- return invalidFromErrorFactory(errorFactory,
4541
+ return invalidFromErrorFactory(
4542
+ errorFactory,
3978
4543
  "payload.data.description must be a string when provided",
3979
4544
  );
3980
4545
  }
3981
4546
 
3982
4547
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
3983
- return invalidFromErrorFactory(errorFactory,
4548
+ return invalidFromErrorFactory(
4549
+ errorFactory,
3984
4550
  "payload.data.fileId must be a non-empty string when provided",
3985
4551
  );
3986
4552
  }
3987
4553
 
3988
4554
  if (data.fileType !== undefined && !isString(data.fileType)) {
3989
- return invalidFromErrorFactory(errorFactory, "payload.data.fileType must be a string when provided");
4555
+ return invalidFromErrorFactory(
4556
+ errorFactory,
4557
+ "payload.data.fileType must be a string when provided",
4558
+ );
3990
4559
  }
3991
4560
 
3992
4561
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
3993
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4562
+ return invalidFromErrorFactory(
4563
+ errorFactory,
4564
+ "payload.data.fileSize must be a finite number",
4565
+ );
3994
4566
  }
3995
4567
 
3996
4568
  if (
@@ -3998,23 +4570,33 @@ const validateSoundUpdateData = ({ data, errorFactory }) => {
3998
4570
  data.waveformDataFileId !== null &&
3999
4571
  !isNonEmptyString(data.waveformDataFileId)
4000
4572
  ) {
4001
- return invalidFromErrorFactory(errorFactory,
4573
+ return invalidFromErrorFactory(
4574
+ errorFactory,
4002
4575
  "payload.data.waveformDataFileId must be a non-empty string or null when provided",
4003
4576
  );
4004
4577
  }
4005
4578
 
4006
4579
  if (data.duration !== undefined && !isFiniteNumber(data.duration)) {
4007
- return invalidFromErrorFactory(errorFactory, "payload.data.duration must be a finite number");
4580
+ return invalidFromErrorFactory(
4581
+ errorFactory,
4582
+ "payload.data.duration must be a finite number",
4583
+ );
4008
4584
  }
4009
4585
  };
4010
4586
 
4011
4587
  const validateVideoCreateData = ({ data, errorFactory }) => {
4012
4588
  if (!isPlainObject(data)) {
4013
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
4589
+ return invalidFromErrorFactory(
4590
+ errorFactory,
4591
+ "payload.data must be an object",
4592
+ );
4014
4593
  }
4015
4594
 
4016
4595
  if (data.type !== "folder" && data.type !== "video") {
4017
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'video'");
4596
+ return invalidFromErrorFactory(
4597
+ errorFactory,
4598
+ "payload.data.type must be 'folder' or 'video'",
4599
+ );
4018
4600
  }
4019
4601
 
4020
4602
  {
@@ -4043,42 +4625,60 @@ const validateVideoCreateData = ({ data, errorFactory }) => {
4043
4625
  }
4044
4626
 
4045
4627
  if (!isNonEmptyString(data.name)) {
4046
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4628
+ return invalidFromErrorFactory(
4629
+ errorFactory,
4630
+ "payload.data.name must be a non-empty string",
4631
+ );
4047
4632
  }
4048
4633
 
4049
4634
  if (data.description !== undefined && !isString(data.description)) {
4050
- return invalidFromErrorFactory(errorFactory,
4635
+ return invalidFromErrorFactory(
4636
+ errorFactory,
4051
4637
  "payload.data.description must be a string when provided",
4052
4638
  );
4053
4639
  }
4054
4640
 
4055
4641
  if (data.type === "video") {
4056
4642
  if (!isNonEmptyString(data.fileId)) {
4057
- return invalidFromErrorFactory(errorFactory, "payload.data.fileId must be a non-empty string");
4643
+ return invalidFromErrorFactory(
4644
+ errorFactory,
4645
+ "payload.data.fileId must be a non-empty string",
4646
+ );
4058
4647
  }
4059
4648
 
4060
4649
  if (!isNonEmptyString(data.thumbnailFileId)) {
4061
- return invalidFromErrorFactory(errorFactory,
4650
+ return invalidFromErrorFactory(
4651
+ errorFactory,
4062
4652
  "payload.data.thumbnailFileId must be a non-empty string",
4063
4653
  );
4064
4654
  }
4065
4655
 
4066
4656
  if (data.fileType !== undefined && !isString(data.fileType)) {
4067
- return invalidFromErrorFactory(errorFactory,
4657
+ return invalidFromErrorFactory(
4658
+ errorFactory,
4068
4659
  "payload.data.fileType must be a string when provided",
4069
4660
  );
4070
4661
  }
4071
4662
 
4072
4663
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
4073
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4664
+ return invalidFromErrorFactory(
4665
+ errorFactory,
4666
+ "payload.data.fileSize must be a finite number",
4667
+ );
4074
4668
  }
4075
4669
 
4076
4670
  if (data.width !== undefined && !isFiniteNumber(data.width)) {
4077
- return invalidFromErrorFactory(errorFactory, "payload.data.width must be a finite number");
4671
+ return invalidFromErrorFactory(
4672
+ errorFactory,
4673
+ "payload.data.width must be a finite number",
4674
+ );
4078
4675
  }
4079
4676
 
4080
4677
  if (data.height !== undefined && !isFiniteNumber(data.height)) {
4081
- return invalidFromErrorFactory(errorFactory, "payload.data.height must be a finite number");
4678
+ return invalidFromErrorFactory(
4679
+ errorFactory,
4680
+ "payload.data.height must be a finite number",
4681
+ );
4082
4682
  }
4083
4683
  }
4084
4684
  };
@@ -4106,25 +4706,29 @@ const validateVideoUpdateData = ({ data, errorFactory }) => {
4106
4706
  }
4107
4707
 
4108
4708
  if (Object.keys(data).length === 0) {
4109
- return invalidFromErrorFactory(errorFactory,
4709
+ return invalidFromErrorFactory(
4710
+ errorFactory,
4110
4711
  "payload.data must include at least one updatable field",
4111
4712
  );
4112
4713
  }
4113
4714
 
4114
4715
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4115
- return invalidFromErrorFactory(errorFactory,
4716
+ return invalidFromErrorFactory(
4717
+ errorFactory,
4116
4718
  "payload.data.name must be a non-empty string when provided",
4117
4719
  );
4118
4720
  }
4119
4721
 
4120
4722
  if (data.description !== undefined && !isString(data.description)) {
4121
- return invalidFromErrorFactory(errorFactory,
4723
+ return invalidFromErrorFactory(
4724
+ errorFactory,
4122
4725
  "payload.data.description must be a string when provided",
4123
4726
  );
4124
4727
  }
4125
4728
 
4126
4729
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
4127
- return invalidFromErrorFactory(errorFactory,
4730
+ return invalidFromErrorFactory(
4731
+ errorFactory,
4128
4732
  "payload.data.fileId must be a non-empty string when provided",
4129
4733
  );
4130
4734
  }
@@ -4133,35 +4737,54 @@ const validateVideoUpdateData = ({ data, errorFactory }) => {
4133
4737
  data.thumbnailFileId !== undefined &&
4134
4738
  !isNonEmptyString(data.thumbnailFileId)
4135
4739
  ) {
4136
- return invalidFromErrorFactory(errorFactory,
4740
+ return invalidFromErrorFactory(
4741
+ errorFactory,
4137
4742
  "payload.data.thumbnailFileId must be a non-empty string when provided",
4138
4743
  );
4139
4744
  }
4140
4745
 
4141
4746
  if (data.fileType !== undefined && !isString(data.fileType)) {
4142
- return invalidFromErrorFactory(errorFactory, "payload.data.fileType must be a string when provided");
4747
+ return invalidFromErrorFactory(
4748
+ errorFactory,
4749
+ "payload.data.fileType must be a string when provided",
4750
+ );
4143
4751
  }
4144
4752
 
4145
4753
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
4146
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4754
+ return invalidFromErrorFactory(
4755
+ errorFactory,
4756
+ "payload.data.fileSize must be a finite number",
4757
+ );
4147
4758
  }
4148
4759
 
4149
4760
  if (data.width !== undefined && !isFiniteNumber(data.width)) {
4150
- return invalidFromErrorFactory(errorFactory, "payload.data.width must be a finite number");
4761
+ return invalidFromErrorFactory(
4762
+ errorFactory,
4763
+ "payload.data.width must be a finite number",
4764
+ );
4151
4765
  }
4152
4766
 
4153
4767
  if (data.height !== undefined && !isFiniteNumber(data.height)) {
4154
- return invalidFromErrorFactory(errorFactory, "payload.data.height must be a finite number");
4768
+ return invalidFromErrorFactory(
4769
+ errorFactory,
4770
+ "payload.data.height must be a finite number",
4771
+ );
4155
4772
  }
4156
4773
  };
4157
4774
 
4158
4775
  const validateFontCreateData = ({ data, errorFactory }) => {
4159
4776
  if (!isPlainObject(data)) {
4160
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
4777
+ return invalidFromErrorFactory(
4778
+ errorFactory,
4779
+ "payload.data must be an object",
4780
+ );
4161
4781
  }
4162
4782
 
4163
4783
  if (data.type !== "folder" && data.type !== "font") {
4164
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'font'");
4784
+ return invalidFromErrorFactory(
4785
+ errorFactory,
4786
+ "payload.data.type must be 'folder' or 'font'",
4787
+ );
4165
4788
  }
4166
4789
 
4167
4790
  {
@@ -4180,26 +4803,39 @@ const validateFontCreateData = ({ data, errorFactory }) => {
4180
4803
  }
4181
4804
 
4182
4805
  if (!isNonEmptyString(data.name)) {
4183
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
4806
+ return invalidFromErrorFactory(
4807
+ errorFactory,
4808
+ "payload.data.name must be a non-empty string",
4809
+ );
4184
4810
  }
4185
4811
 
4186
4812
  if (data.type === "font") {
4187
4813
  if (!isNonEmptyString(data.fileId)) {
4188
- return invalidFromErrorFactory(errorFactory, "payload.data.fileId must be a non-empty string");
4814
+ return invalidFromErrorFactory(
4815
+ errorFactory,
4816
+ "payload.data.fileId must be a non-empty string",
4817
+ );
4189
4818
  }
4190
4819
 
4191
4820
  if (!isNonEmptyString(data.fontFamily)) {
4192
- return invalidFromErrorFactory(errorFactory, "payload.data.fontFamily must be a non-empty string");
4821
+ return invalidFromErrorFactory(
4822
+ errorFactory,
4823
+ "payload.data.fontFamily must be a non-empty string",
4824
+ );
4193
4825
  }
4194
4826
 
4195
4827
  if (data.fileType !== undefined && !isString(data.fileType)) {
4196
- return invalidFromErrorFactory(errorFactory,
4828
+ return invalidFromErrorFactory(
4829
+ errorFactory,
4197
4830
  "payload.data.fileType must be a string when provided",
4198
4831
  );
4199
4832
  }
4200
4833
 
4201
4834
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
4202
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4835
+ return invalidFromErrorFactory(
4836
+ errorFactory,
4837
+ "payload.data.fileSize must be a finite number",
4838
+ );
4203
4839
  }
4204
4840
  }
4205
4841
  };
@@ -4218,35 +4854,45 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
4218
4854
  }
4219
4855
 
4220
4856
  if (Object.keys(data).length === 0) {
4221
- return invalidFromErrorFactory(errorFactory,
4857
+ return invalidFromErrorFactory(
4858
+ errorFactory,
4222
4859
  "payload.data must include at least one updatable field",
4223
4860
  );
4224
4861
  }
4225
4862
 
4226
4863
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4227
- return invalidFromErrorFactory(errorFactory,
4864
+ return invalidFromErrorFactory(
4865
+ errorFactory,
4228
4866
  "payload.data.name must be a non-empty string when provided",
4229
4867
  );
4230
4868
  }
4231
4869
 
4232
4870
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
4233
- return invalidFromErrorFactory(errorFactory,
4871
+ return invalidFromErrorFactory(
4872
+ errorFactory,
4234
4873
  "payload.data.fileId must be a non-empty string when provided",
4235
4874
  );
4236
4875
  }
4237
4876
 
4238
4877
  if (data.fontFamily !== undefined && !isNonEmptyString(data.fontFamily)) {
4239
- return invalidFromErrorFactory(errorFactory,
4878
+ return invalidFromErrorFactory(
4879
+ errorFactory,
4240
4880
  "payload.data.fontFamily must be a non-empty string when provided",
4241
4881
  );
4242
4882
  }
4243
4883
 
4244
4884
  if (data.fileType !== undefined && !isString(data.fileType)) {
4245
- return invalidFromErrorFactory(errorFactory, "payload.data.fileType must be a string when provided");
4885
+ return invalidFromErrorFactory(
4886
+ errorFactory,
4887
+ "payload.data.fileType must be a string when provided",
4888
+ );
4246
4889
  }
4247
4890
 
4248
4891
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
4249
- return invalidFromErrorFactory(errorFactory, "payload.data.fileSize must be a finite number");
4892
+ return invalidFromErrorFactory(
4893
+ errorFactory,
4894
+ "payload.data.fileSize must be a finite number",
4895
+ );
4250
4896
  }
4251
4897
  };
4252
4898
 
@@ -4354,11 +5000,17 @@ const validateReferencedFilesInData = ({
4354
5000
 
4355
5001
  const validateColorCreateData = ({ data, errorFactory }) => {
4356
5002
  if (!isPlainObject(data)) {
4357
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5003
+ return invalidFromErrorFactory(
5004
+ errorFactory,
5005
+ "payload.data must be an object",
5006
+ );
4358
5007
  }
4359
5008
 
4360
5009
  if (data.type !== "folder" && data.type !== "color") {
4361
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'color'");
5010
+ return invalidFromErrorFactory(
5011
+ errorFactory,
5012
+ "payload.data.type must be 'folder' or 'color'",
5013
+ );
4362
5014
  }
4363
5015
 
4364
5016
  {
@@ -4375,11 +5027,17 @@ const validateColorCreateData = ({ data, errorFactory }) => {
4375
5027
  }
4376
5028
 
4377
5029
  if (!isNonEmptyString(data.name)) {
4378
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5030
+ return invalidFromErrorFactory(
5031
+ errorFactory,
5032
+ "payload.data.name must be a non-empty string",
5033
+ );
4379
5034
  }
4380
5035
 
4381
5036
  if (data.type === "color" && !isHexColor(data.hex)) {
4382
- return invalidFromErrorFactory(errorFactory, "payload.data.hex must be a #RRGGBB string");
5037
+ return invalidFromErrorFactory(
5038
+ errorFactory,
5039
+ "payload.data.hex must be a #RRGGBB string",
5040
+ );
4383
5041
  }
4384
5042
  };
4385
5043
 
@@ -4397,19 +5055,22 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
4397
5055
  }
4398
5056
 
4399
5057
  if (Object.keys(data).length === 0) {
4400
- return invalidFromErrorFactory(errorFactory,
5058
+ return invalidFromErrorFactory(
5059
+ errorFactory,
4401
5060
  "payload.data must include at least one updatable field",
4402
5061
  );
4403
5062
  }
4404
5063
 
4405
5064
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4406
- return invalidFromErrorFactory(errorFactory,
5065
+ return invalidFromErrorFactory(
5066
+ errorFactory,
4407
5067
  "payload.data.name must be a non-empty string when provided",
4408
5068
  );
4409
5069
  }
4410
5070
 
4411
5071
  if (data.hex !== undefined && !isHexColor(data.hex)) {
4412
- return invalidFromErrorFactory(errorFactory,
5072
+ return invalidFromErrorFactory(
5073
+ errorFactory,
4413
5074
  "payload.data.hex must be a #RRGGBB string when provided",
4414
5075
  );
4415
5076
  }
@@ -4417,18 +5078,26 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
4417
5078
 
4418
5079
  const validateAnimationCreateData = ({ data, errorFactory }) => {
4419
5080
  if (!isPlainObject(data)) {
4420
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5081
+ return invalidFromErrorFactory(
5082
+ errorFactory,
5083
+ "payload.data must be an object",
5084
+ );
4421
5085
  }
4422
5086
 
4423
5087
  if (data.type !== "folder" && data.type !== "animation") {
4424
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'animation'");
5088
+ return invalidFromErrorFactory(
5089
+ errorFactory,
5090
+ "payload.data.type must be 'folder' or 'animation'",
5091
+ );
4425
5092
  }
4426
5093
 
4427
5094
  {
4428
5095
  const result = validateAllowedKeys({
4429
5096
  value: data,
4430
5097
  allowedKeys:
4431
- data.type === "folder" ? ["type", "name"] : ["type", "name", "animation"],
5098
+ data.type === "folder"
5099
+ ? ["type", "name"]
5100
+ : ["type", "name", "animation"],
4432
5101
  path: "payload.data",
4433
5102
  errorFactory,
4434
5103
  });
@@ -4438,7 +5107,10 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
4438
5107
  }
4439
5108
 
4440
5109
  if (!isNonEmptyString(data.name)) {
4441
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5110
+ return invalidFromErrorFactory(
5111
+ errorFactory,
5112
+ "payload.data.name must be a non-empty string",
5113
+ );
4442
5114
  }
4443
5115
 
4444
5116
  if (data.type === "animation") {
@@ -4469,13 +5141,15 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
4469
5141
  }
4470
5142
 
4471
5143
  if (Object.keys(data).length === 0) {
4472
- return invalidFromErrorFactory(errorFactory,
5144
+ return invalidFromErrorFactory(
5145
+ errorFactory,
4473
5146
  "payload.data must include at least one updatable field",
4474
5147
  );
4475
5148
  }
4476
5149
 
4477
5150
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4478
- return invalidFromErrorFactory(errorFactory,
5151
+ return invalidFromErrorFactory(
5152
+ errorFactory,
4479
5153
  "payload.data.name must be a non-empty string when provided",
4480
5154
  );
4481
5155
  }
@@ -4496,11 +5170,17 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
4496
5170
 
4497
5171
  const validateTransformCreateData = ({ data, errorFactory }) => {
4498
5172
  if (!isPlainObject(data)) {
4499
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5173
+ return invalidFromErrorFactory(
5174
+ errorFactory,
5175
+ "payload.data must be an object",
5176
+ );
4500
5177
  }
4501
5178
 
4502
5179
  if (data.type !== "folder" && data.type !== "transform") {
4503
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'transform'");
5180
+ return invalidFromErrorFactory(
5181
+ errorFactory,
5182
+ "payload.data.type must be 'folder' or 'transform'",
5183
+ );
4504
5184
  }
4505
5185
 
4506
5186
  {
@@ -4529,7 +5209,10 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
4529
5209
  }
4530
5210
 
4531
5211
  if (!isNonEmptyString(data.name)) {
4532
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5212
+ return invalidFromErrorFactory(
5213
+ errorFactory,
5214
+ "payload.data.name must be a non-empty string",
5215
+ );
4533
5216
  }
4534
5217
 
4535
5218
  if (data.type === "transform") {
@@ -4543,7 +5226,10 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
4543
5226
  "rotation",
4544
5227
  ]) {
4545
5228
  if (!isFiniteNumber(data[key])) {
4546
- return invalidFromErrorFactory(errorFactory, `payload.data.${key} must be a finite number`);
5229
+ return invalidFromErrorFactory(
5230
+ errorFactory,
5231
+ `payload.data.${key} must be a finite number`,
5232
+ );
4547
5233
  }
4548
5234
  }
4549
5235
  }
@@ -4572,13 +5258,15 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
4572
5258
  }
4573
5259
 
4574
5260
  if (Object.keys(data).length === 0) {
4575
- return invalidFromErrorFactory(errorFactory,
5261
+ return invalidFromErrorFactory(
5262
+ errorFactory,
4576
5263
  "payload.data must include at least one updatable field",
4577
5264
  );
4578
5265
  }
4579
5266
 
4580
5267
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4581
- return invalidFromErrorFactory(errorFactory,
5268
+ return invalidFromErrorFactory(
5269
+ errorFactory,
4582
5270
  "payload.data.name must be a non-empty string when provided",
4583
5271
  );
4584
5272
  }
@@ -4593,7 +5281,8 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
4593
5281
  "rotation",
4594
5282
  ]) {
4595
5283
  if (data[key] !== undefined && !isFiniteNumber(data[key])) {
4596
- return invalidFromErrorFactory(errorFactory,
5284
+ return invalidFromErrorFactory(
5285
+ errorFactory,
4597
5286
  `payload.data.${key} must be a finite number when provided`,
4598
5287
  );
4599
5288
  }
@@ -4602,11 +5291,15 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
4602
5291
 
4603
5292
  const validateVariableCreateData = ({ data, errorFactory }) => {
4604
5293
  if (!isPlainObject(data)) {
4605
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5294
+ return invalidFromErrorFactory(
5295
+ errorFactory,
5296
+ "payload.data must be an object",
5297
+ );
4606
5298
  }
4607
5299
 
4608
5300
  if (data.type !== "folder" && !VARIABLE_TYPE_KEYS.includes(data.type)) {
4609
- return invalidFromErrorFactory(errorFactory,
5301
+ return invalidFromErrorFactory(
5302
+ errorFactory,
4610
5303
  "payload.data.type must be 'folder', 'string', 'number', or 'boolean'",
4611
5304
  );
4612
5305
  }
@@ -4627,12 +5320,16 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
4627
5320
  }
4628
5321
 
4629
5322
  if (!isNonEmptyString(data.name)) {
4630
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5323
+ return invalidFromErrorFactory(
5324
+ errorFactory,
5325
+ "payload.data.name must be a non-empty string",
5326
+ );
4631
5327
  }
4632
5328
 
4633
5329
  if (data.type !== "folder") {
4634
5330
  if (!VARIABLE_SCOPE_KEYS.includes(data.scope)) {
4635
- return invalidFromErrorFactory(errorFactory,
5331
+ return invalidFromErrorFactory(
5332
+ errorFactory,
4636
5333
  "payload.data.scope must be 'context', 'global-device', or 'global-account'",
4637
5334
  );
4638
5335
  }
@@ -4676,19 +5373,22 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
4676
5373
  }
4677
5374
 
4678
5375
  if (Object.keys(data).length === 0) {
4679
- return invalidFromErrorFactory(errorFactory,
5376
+ return invalidFromErrorFactory(
5377
+ errorFactory,
4680
5378
  "payload.data must include at least one updatable field",
4681
5379
  );
4682
5380
  }
4683
5381
 
4684
5382
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4685
- return invalidFromErrorFactory(errorFactory,
5383
+ return invalidFromErrorFactory(
5384
+ errorFactory,
4686
5385
  "payload.data.name must be a non-empty string when provided",
4687
5386
  );
4688
5387
  }
4689
5388
 
4690
5389
  if (data.scope !== undefined && !VARIABLE_SCOPE_KEYS.includes(data.scope)) {
4691
- return invalidFromErrorFactory(errorFactory,
5390
+ return invalidFromErrorFactory(
5391
+ errorFactory,
4692
5392
  "payload.data.scope must be 'context', 'global-device', or 'global-account' when provided",
4693
5393
  );
4694
5394
  }
@@ -4696,11 +5396,17 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
4696
5396
 
4697
5397
  const validateTextStyleCreateData = ({ data, errorFactory }) => {
4698
5398
  if (!isPlainObject(data)) {
4699
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5399
+ return invalidFromErrorFactory(
5400
+ errorFactory,
5401
+ "payload.data must be an object",
5402
+ );
4700
5403
  }
4701
5404
 
4702
5405
  if (data.type !== "folder" && data.type !== "textStyle") {
4703
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'textStyle'");
5406
+ return invalidFromErrorFactory(
5407
+ errorFactory,
5408
+ "payload.data.type must be 'folder' or 'textStyle'",
5409
+ );
4704
5410
  }
4705
5411
 
4706
5412
  {
@@ -4736,7 +5442,10 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
4736
5442
  }
4737
5443
 
4738
5444
  if (!isNonEmptyString(data.name)) {
4739
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5445
+ return invalidFromErrorFactory(
5446
+ errorFactory,
5447
+ "payload.data.name must be a non-empty string",
5448
+ );
4740
5449
  }
4741
5450
 
4742
5451
  if (data.type === "textStyle") {
@@ -4788,20 +5497,23 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
4788
5497
  }
4789
5498
 
4790
5499
  if (Object.keys(data).length === 0) {
4791
- return invalidFromErrorFactory(errorFactory,
5500
+ return invalidFromErrorFactory(
5501
+ errorFactory,
4792
5502
  "payload.data must include at least one updatable field",
4793
5503
  );
4794
5504
  }
4795
5505
 
4796
5506
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4797
- return invalidFromErrorFactory(errorFactory,
5507
+ return invalidFromErrorFactory(
5508
+ errorFactory,
4798
5509
  "payload.data.name must be a non-empty string when provided",
4799
5510
  );
4800
5511
  }
4801
5512
 
4802
5513
  for (const key of ["fontId", "colorId", "strokeColorId"]) {
4803
5514
  if (data[key] !== undefined && !isNonEmptyString(data[key])) {
4804
- return invalidFromErrorFactory(errorFactory,
5515
+ return invalidFromErrorFactory(
5516
+ errorFactory,
4805
5517
  `payload.data.${key} must be a non-empty string when provided`,
4806
5518
  );
4807
5519
  }
@@ -4809,7 +5521,8 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
4809
5521
 
4810
5522
  for (const key of ["fontSize", "lineHeight", "strokeAlpha", "strokeWidth"]) {
4811
5523
  if (data[key] !== undefined && !isFiniteNumber(data[key])) {
4812
- return invalidFromErrorFactory(errorFactory,
5524
+ return invalidFromErrorFactory(
5525
+ errorFactory,
4813
5526
  `payload.data.${key} must be a finite number when provided`,
4814
5527
  );
4815
5528
  }
@@ -4817,22 +5530,30 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
4817
5530
 
4818
5531
  for (const key of ["fontWeight", "previewText", "fontStyle"]) {
4819
5532
  if (data[key] !== undefined && !isString(data[key])) {
4820
- return invalidFromErrorFactory(errorFactory, `payload.data.${key} must be a string when provided`);
5533
+ return invalidFromErrorFactory(
5534
+ errorFactory,
5535
+ `payload.data.${key} must be a string when provided`,
5536
+ );
4821
5537
  }
4822
5538
  }
4823
5539
 
4824
5540
  if (data.breakWords !== undefined && typeof data.breakWords !== "boolean") {
4825
- return invalidFromErrorFactory(errorFactory,
5541
+ return invalidFromErrorFactory(
5542
+ errorFactory,
4826
5543
  "payload.data.breakWords must be a boolean when provided",
4827
5544
  );
4828
5545
  }
4829
5546
 
4830
5547
  if (data.wordWrap !== undefined && typeof data.wordWrap !== "boolean") {
4831
- return invalidFromErrorFactory(errorFactory, "payload.data.wordWrap must be a boolean when provided");
5548
+ return invalidFromErrorFactory(
5549
+ errorFactory,
5550
+ "payload.data.wordWrap must be a boolean when provided",
5551
+ );
4832
5552
  }
4833
5553
 
4834
5554
  if (data.wordWrapWidth !== undefined && !isFiniteNumber(data.wordWrapWidth)) {
4835
- return invalidFromErrorFactory(errorFactory,
5555
+ return invalidFromErrorFactory(
5556
+ errorFactory,
4836
5557
  "payload.data.wordWrapWidth must be a finite number when provided",
4837
5558
  );
4838
5559
  }
@@ -4841,7 +5562,8 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
4841
5562
  data.align !== undefined &&
4842
5563
  !LAYOUT_ELEMENT_TEXT_STYLE_ALIGN_KEYS.includes(data.align)
4843
5564
  ) {
4844
- return invalidFromErrorFactory(errorFactory,
5565
+ return invalidFromErrorFactory(
5566
+ errorFactory,
4845
5567
  "payload.data.align must be 'left', 'center', or 'right' when provided",
4846
5568
  );
4847
5569
  }
@@ -4849,11 +5571,17 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
4849
5571
 
4850
5572
  const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
4851
5573
  if (!isPlainObject(data)) {
4852
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5574
+ return invalidFromErrorFactory(
5575
+ errorFactory,
5576
+ "payload.data must be an object",
5577
+ );
4853
5578
  }
4854
5579
 
4855
5580
  if (data.type !== "folder" && data.type !== "image") {
4856
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'image'");
5581
+ return invalidFromErrorFactory(
5582
+ errorFactory,
5583
+ "payload.data.type must be 'folder' or 'image'",
5584
+ );
4857
5585
  }
4858
5586
 
4859
5587
  {
@@ -4862,7 +5590,15 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
4862
5590
  allowedKeys:
4863
5591
  data.type === "folder"
4864
5592
  ? ["type", "name", "description"]
4865
- : ["type", "name", "fileId", "fileType", "fileSize", "width", "height"],
5593
+ : [
5594
+ "type",
5595
+ "name",
5596
+ "fileId",
5597
+ "fileType",
5598
+ "fileSize",
5599
+ "width",
5600
+ "height",
5601
+ ],
4866
5602
  path: "payload.data",
4867
5603
  errorFactory,
4868
5604
  });
@@ -4872,40 +5608,51 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
4872
5608
  }
4873
5609
 
4874
5610
  if (!isNonEmptyString(data.name)) {
4875
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5611
+ return invalidFromErrorFactory(
5612
+ errorFactory,
5613
+ "payload.data.name must be a non-empty string",
5614
+ );
4876
5615
  }
4877
5616
 
4878
5617
  if (data.type === "image") {
4879
5618
  if (!isNonEmptyString(data.fileId)) {
4880
- return invalidFromErrorFactory(errorFactory, "payload.data.fileId must be a non-empty string");
5619
+ return invalidFromErrorFactory(
5620
+ errorFactory,
5621
+ "payload.data.fileId must be a non-empty string",
5622
+ );
4881
5623
  }
4882
5624
 
4883
5625
  if (data.fileType !== undefined && !isString(data.fileType)) {
4884
- return invalidFromErrorFactory(errorFactory,
5626
+ return invalidFromErrorFactory(
5627
+ errorFactory,
4885
5628
  "payload.data.fileType must be a string when provided",
4886
5629
  );
4887
5630
  }
4888
5631
 
4889
5632
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
4890
- return invalidFromErrorFactory(errorFactory,
5633
+ return invalidFromErrorFactory(
5634
+ errorFactory,
4891
5635
  "payload.data.fileSize must be a finite number when provided",
4892
5636
  );
4893
5637
  }
4894
5638
 
4895
5639
  if (data.width !== undefined && !isFiniteNumber(data.width)) {
4896
- return invalidFromErrorFactory(errorFactory,
5640
+ return invalidFromErrorFactory(
5641
+ errorFactory,
4897
5642
  "payload.data.width must be a finite number when provided",
4898
5643
  );
4899
5644
  }
4900
5645
 
4901
5646
  if (data.height !== undefined && !isFiniteNumber(data.height)) {
4902
- return invalidFromErrorFactory(errorFactory,
5647
+ return invalidFromErrorFactory(
5648
+ errorFactory,
4903
5649
  "payload.data.height must be a finite number when provided",
4904
5650
  );
4905
5651
  }
4906
5652
 
4907
5653
  if (data.description !== undefined && !isString(data.description)) {
4908
- return invalidFromErrorFactory(errorFactory,
5654
+ return invalidFromErrorFactory(
5655
+ errorFactory,
4909
5656
  "payload.data.description must be a string when provided",
4910
5657
  );
4911
5658
  }
@@ -4934,47 +5681,57 @@ const validateCharacterSpriteUpdateData = ({ data, errorFactory }) => {
4934
5681
  }
4935
5682
 
4936
5683
  if (Object.keys(data).length === 0) {
4937
- return invalidFromErrorFactory(errorFactory,
5684
+ return invalidFromErrorFactory(
5685
+ errorFactory,
4938
5686
  "payload.data must include at least one updatable field",
4939
5687
  );
4940
5688
  }
4941
5689
 
4942
5690
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
4943
- return invalidFromErrorFactory(errorFactory,
5691
+ return invalidFromErrorFactory(
5692
+ errorFactory,
4944
5693
  "payload.data.name must be a non-empty string when provided",
4945
5694
  );
4946
5695
  }
4947
5696
 
4948
5697
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
4949
- return invalidFromErrorFactory(errorFactory,
5698
+ return invalidFromErrorFactory(
5699
+ errorFactory,
4950
5700
  "payload.data.fileId must be a non-empty string when provided",
4951
5701
  );
4952
5702
  }
4953
5703
 
4954
5704
  if (data.description !== undefined && !isString(data.description)) {
4955
- return invalidFromErrorFactory(errorFactory,
5705
+ return invalidFromErrorFactory(
5706
+ errorFactory,
4956
5707
  "payload.data.description must be a string when provided",
4957
5708
  );
4958
5709
  }
4959
5710
 
4960
5711
  if (data.fileType !== undefined && !isString(data.fileType)) {
4961
- return invalidFromErrorFactory(errorFactory, "payload.data.fileType must be a string when provided");
5712
+ return invalidFromErrorFactory(
5713
+ errorFactory,
5714
+ "payload.data.fileType must be a string when provided",
5715
+ );
4962
5716
  }
4963
5717
 
4964
5718
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
4965
- return invalidFromErrorFactory(errorFactory,
5719
+ return invalidFromErrorFactory(
5720
+ errorFactory,
4966
5721
  "payload.data.fileSize must be a finite number when provided",
4967
5722
  );
4968
5723
  }
4969
5724
 
4970
5725
  if (data.width !== undefined && !isFiniteNumber(data.width)) {
4971
- return invalidFromErrorFactory(errorFactory,
5726
+ return invalidFromErrorFactory(
5727
+ errorFactory,
4972
5728
  "payload.data.width must be a finite number when provided",
4973
5729
  );
4974
5730
  }
4975
5731
 
4976
5732
  if (data.height !== undefined && !isFiniteNumber(data.height)) {
4977
- return invalidFromErrorFactory(errorFactory,
5733
+ return invalidFromErrorFactory(
5734
+ errorFactory,
4978
5735
  "payload.data.height must be a finite number when provided",
4979
5736
  );
4980
5737
  }
@@ -4982,11 +5739,17 @@ const validateCharacterSpriteUpdateData = ({ data, errorFactory }) => {
4982
5739
 
4983
5740
  const validateCharacterCreateData = ({ data, errorFactory }) => {
4984
5741
  if (!isPlainObject(data)) {
4985
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5742
+ return invalidFromErrorFactory(
5743
+ errorFactory,
5744
+ "payload.data must be an object",
5745
+ );
4986
5746
  }
4987
5747
 
4988
5748
  if (data.type !== "folder" && data.type !== "character") {
4989
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'character'");
5749
+ return invalidFromErrorFactory(
5750
+ errorFactory,
5751
+ "payload.data.type must be 'folder' or 'character'",
5752
+ );
4990
5753
  }
4991
5754
 
4992
5755
  {
@@ -5014,36 +5777,44 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
5014
5777
  }
5015
5778
 
5016
5779
  if (!isNonEmptyString(data.name)) {
5017
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5780
+ return invalidFromErrorFactory(
5781
+ errorFactory,
5782
+ "payload.data.name must be a non-empty string",
5783
+ );
5018
5784
  }
5019
5785
 
5020
5786
  if (data.type === "character") {
5021
5787
  if (data.description !== undefined && !isString(data.description)) {
5022
- return invalidFromErrorFactory(errorFactory,
5788
+ return invalidFromErrorFactory(
5789
+ errorFactory,
5023
5790
  "payload.data.description must be a string when provided",
5024
5791
  );
5025
5792
  }
5026
5793
 
5027
5794
  if (data.shortcut !== undefined && !isString(data.shortcut)) {
5028
- return invalidFromErrorFactory(errorFactory,
5795
+ return invalidFromErrorFactory(
5796
+ errorFactory,
5029
5797
  "payload.data.shortcut must be a string when provided",
5030
5798
  );
5031
5799
  }
5032
5800
 
5033
5801
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
5034
- return invalidFromErrorFactory(errorFactory,
5802
+ return invalidFromErrorFactory(
5803
+ errorFactory,
5035
5804
  "payload.data.fileId must be a non-empty string when provided",
5036
5805
  );
5037
5806
  }
5038
5807
 
5039
5808
  if (data.fileType !== undefined && !isString(data.fileType)) {
5040
- return invalidFromErrorFactory(errorFactory,
5809
+ return invalidFromErrorFactory(
5810
+ errorFactory,
5041
5811
  "payload.data.fileType must be a string when provided",
5042
5812
  );
5043
5813
  }
5044
5814
 
5045
5815
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
5046
- return invalidFromErrorFactory(errorFactory,
5816
+ return invalidFromErrorFactory(
5817
+ errorFactory,
5047
5818
  "payload.data.fileSize must be a finite number when provided",
5048
5819
  );
5049
5820
  }
@@ -5087,39 +5858,50 @@ const validateCharacterUpdateData = ({ data, errorFactory }) => {
5087
5858
  }
5088
5859
 
5089
5860
  if (Object.keys(data).length === 0) {
5090
- return invalidFromErrorFactory(errorFactory,
5861
+ return invalidFromErrorFactory(
5862
+ errorFactory,
5091
5863
  "payload.data must include at least one updatable field",
5092
5864
  );
5093
5865
  }
5094
5866
 
5095
5867
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
5096
- return invalidFromErrorFactory(errorFactory,
5868
+ return invalidFromErrorFactory(
5869
+ errorFactory,
5097
5870
  "payload.data.name must be a non-empty string when provided",
5098
5871
  );
5099
5872
  }
5100
5873
 
5101
5874
  if (data.description !== undefined && !isString(data.description)) {
5102
- return invalidFromErrorFactory(errorFactory,
5875
+ return invalidFromErrorFactory(
5876
+ errorFactory,
5103
5877
  "payload.data.description must be a string when provided",
5104
5878
  );
5105
5879
  }
5106
5880
 
5107
5881
  if (data.shortcut !== undefined && !isString(data.shortcut)) {
5108
- return invalidFromErrorFactory(errorFactory, "payload.data.shortcut must be a string when provided");
5882
+ return invalidFromErrorFactory(
5883
+ errorFactory,
5884
+ "payload.data.shortcut must be a string when provided",
5885
+ );
5109
5886
  }
5110
5887
 
5111
5888
  if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
5112
- return invalidFromErrorFactory(errorFactory,
5889
+ return invalidFromErrorFactory(
5890
+ errorFactory,
5113
5891
  "payload.data.fileId must be a non-empty string when provided",
5114
5892
  );
5115
5893
  }
5116
5894
 
5117
5895
  if (data.fileType !== undefined && !isString(data.fileType)) {
5118
- return invalidFromErrorFactory(errorFactory, "payload.data.fileType must be a string when provided");
5896
+ return invalidFromErrorFactory(
5897
+ errorFactory,
5898
+ "payload.data.fileType must be a string when provided",
5899
+ );
5119
5900
  }
5120
5901
 
5121
5902
  if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
5122
- return invalidFromErrorFactory(errorFactory,
5903
+ return invalidFromErrorFactory(
5904
+ errorFactory,
5123
5905
  "payload.data.fileSize must be a finite number when provided",
5124
5906
  );
5125
5907
  }
@@ -5127,11 +5909,17 @@ const validateCharacterUpdateData = ({ data, errorFactory }) => {
5127
5909
 
5128
5910
  const validateLayoutCreateData = ({ data, errorFactory }) => {
5129
5911
  if (!isPlainObject(data)) {
5130
- return invalidFromErrorFactory(errorFactory, "payload.data must be an object");
5912
+ return invalidFromErrorFactory(
5913
+ errorFactory,
5914
+ "payload.data must be an object",
5915
+ );
5131
5916
  }
5132
5917
 
5133
5918
  if (data.type !== "folder" && data.type !== "layout") {
5134
- return invalidFromErrorFactory(errorFactory, "payload.data.type must be 'folder' or 'layout'");
5919
+ return invalidFromErrorFactory(
5920
+ errorFactory,
5921
+ "payload.data.type must be 'folder' or 'layout'",
5922
+ );
5135
5923
  }
5136
5924
 
5137
5925
  {
@@ -5140,7 +5928,7 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
5140
5928
  allowedKeys:
5141
5929
  data.type === "folder"
5142
5930
  ? ["type", "name"]
5143
- : ["type", "name", "layoutType", "elements"],
5931
+ : ["type", "name", "layoutType", "elements", "keyboard"],
5144
5932
  path: "payload.data",
5145
5933
  errorFactory,
5146
5934
  });
@@ -5150,12 +5938,16 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
5150
5938
  }
5151
5939
 
5152
5940
  if (!isNonEmptyString(data.name)) {
5153
- return invalidFromErrorFactory(errorFactory, "payload.data.name must be a non-empty string");
5941
+ return invalidFromErrorFactory(
5942
+ errorFactory,
5943
+ "payload.data.name must be a non-empty string",
5944
+ );
5154
5945
  }
5155
5946
 
5156
5947
  if (data.type === "layout") {
5157
5948
  if (!LAYOUT_TYPE_KEYS.includes(data.layoutType)) {
5158
- return invalidFromErrorFactory(errorFactory,
5949
+ return invalidFromErrorFactory(
5950
+ errorFactory,
5159
5951
  "payload.data.layoutType must be 'normal', 'dialogue', 'nvl', 'choice', or 'base'",
5160
5952
  );
5161
5953
  }
@@ -5172,6 +5964,17 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
5172
5964
  return result;
5173
5965
  }
5174
5966
  }
5967
+
5968
+ {
5969
+ const result = validateKeyboardMap({
5970
+ value: data.keyboard,
5971
+ path: "payload.data.keyboard",
5972
+ errorFactory,
5973
+ });
5974
+ if (result?.valid === false) {
5975
+ return result;
5976
+ }
5977
+ }
5175
5978
  }
5176
5979
  };
5177
5980
 
@@ -5179,7 +5982,7 @@ const validateLayoutUpdateData = ({ data, errorFactory }) => {
5179
5982
  {
5180
5983
  const result = validateAllowedKeys({
5181
5984
  value: data,
5182
- allowedKeys: ["name", "layoutType"],
5985
+ allowedKeys: ["name", "layoutType", "keyboard"],
5183
5986
  path: "payload.data",
5184
5987
  errorFactory,
5185
5988
  });
@@ -5189,13 +5992,15 @@ const validateLayoutUpdateData = ({ data, errorFactory }) => {
5189
5992
  }
5190
5993
 
5191
5994
  if (Object.keys(data).length === 0) {
5192
- return invalidFromErrorFactory(errorFactory,
5995
+ return invalidFromErrorFactory(
5996
+ errorFactory,
5193
5997
  "payload.data must include at least one updatable field",
5194
5998
  );
5195
5999
  }
5196
6000
 
5197
6001
  if (data.name !== undefined && !isNonEmptyString(data.name)) {
5198
- return invalidFromErrorFactory(errorFactory,
6002
+ return invalidFromErrorFactory(
6003
+ errorFactory,
5199
6004
  "payload.data.name must be a non-empty string when provided",
5200
6005
  );
5201
6006
  }
@@ -5204,10 +6009,22 @@ const validateLayoutUpdateData = ({ data, errorFactory }) => {
5204
6009
  data.layoutType !== undefined &&
5205
6010
  !LAYOUT_TYPE_KEYS.includes(data.layoutType)
5206
6011
  ) {
5207
- return invalidFromErrorFactory(errorFactory,
6012
+ return invalidFromErrorFactory(
6013
+ errorFactory,
5208
6014
  "payload.data.layoutType must be 'normal', 'dialogue', 'nvl', 'choice', or 'base' when provided",
5209
6015
  );
5210
6016
  }
6017
+
6018
+ {
6019
+ const result = validateKeyboardMap({
6020
+ value: data.keyboard,
6021
+ path: "payload.data.keyboard",
6022
+ errorFactory,
6023
+ });
6024
+ if (result?.valid === false) {
6025
+ return result;
6026
+ }
6027
+ }
5211
6028
  };
5212
6029
 
5213
6030
  const validateLayoutElementCreateData = ({ data, errorFactory }) => {
@@ -5237,7 +6054,8 @@ const validateLayoutElementUpdateData = ({ data, errorFactory, replace }) => {
5237
6054
  }
5238
6055
 
5239
6056
  if (replace !== true && Object.keys(data).length === 0) {
5240
- return invalidFromErrorFactory(errorFactory,
6057
+ return invalidFromErrorFactory(
6058
+ errorFactory,
5241
6059
  "payload.data must include at least one updatable field",
5242
6060
  );
5243
6061
  }
@@ -5253,7 +6071,8 @@ const validateLayoutElementReferenceTargets = ({
5253
6071
  if (data.imageId !== undefined) {
5254
6072
  const image = state.images.items[data.imageId];
5255
6073
  if (!isPlainObject(image) || image.type === "folder") {
5256
- return invalidFromErrorFactory(errorFactory,
6074
+ return invalidFromErrorFactory(
6075
+ errorFactory,
5257
6076
  "layout element imageId must reference an existing non-folder image",
5258
6077
  {
5259
6078
  layoutId,
@@ -5268,7 +6087,8 @@ const validateLayoutElementReferenceTargets = ({
5268
6087
  if (data.hoverImageId !== undefined) {
5269
6088
  const image = state.images.items[data.hoverImageId];
5270
6089
  if (!isPlainObject(image) || image.type === "folder") {
5271
- return invalidFromErrorFactory(errorFactory,
6090
+ return invalidFromErrorFactory(
6091
+ errorFactory,
5272
6092
  "layout element hoverImageId must reference an existing non-folder image",
5273
6093
  {
5274
6094
  layoutId,
@@ -5283,7 +6103,8 @@ const validateLayoutElementReferenceTargets = ({
5283
6103
  if (data.clickImageId !== undefined) {
5284
6104
  const image = state.images.items[data.clickImageId];
5285
6105
  if (!isPlainObject(image) || image.type === "folder") {
5286
- return invalidFromErrorFactory(errorFactory,
6106
+ return invalidFromErrorFactory(
6107
+ errorFactory,
5287
6108
  "layout element clickImageId must reference an existing non-folder image",
5288
6109
  {
5289
6110
  layoutId,
@@ -5298,7 +6119,8 @@ const validateLayoutElementReferenceTargets = ({
5298
6119
  if (data.thumbImageId !== undefined) {
5299
6120
  const image = state.images.items[data.thumbImageId];
5300
6121
  if (!isPlainObject(image) || image.type === "folder") {
5301
- return invalidFromErrorFactory(errorFactory,
6122
+ return invalidFromErrorFactory(
6123
+ errorFactory,
5302
6124
  "layout element thumbImageId must reference an existing non-folder image",
5303
6125
  {
5304
6126
  layoutId,
@@ -5313,7 +6135,8 @@ const validateLayoutElementReferenceTargets = ({
5313
6135
  if (data.hoverThumbImageId !== undefined) {
5314
6136
  const image = state.images.items[data.hoverThumbImageId];
5315
6137
  if (!isPlainObject(image) || image.type === "folder") {
5316
- return invalidFromErrorFactory(errorFactory,
6138
+ return invalidFromErrorFactory(
6139
+ errorFactory,
5317
6140
  "layout element hoverThumbImageId must reference an existing non-folder image",
5318
6141
  {
5319
6142
  layoutId,
@@ -5328,7 +6151,8 @@ const validateLayoutElementReferenceTargets = ({
5328
6151
  if (data.barImageId !== undefined) {
5329
6152
  const image = state.images.items[data.barImageId];
5330
6153
  if (!isPlainObject(image) || image.type === "folder") {
5331
- return invalidFromErrorFactory(errorFactory,
6154
+ return invalidFromErrorFactory(
6155
+ errorFactory,
5332
6156
  "layout element barImageId must reference an existing non-folder image",
5333
6157
  {
5334
6158
  layoutId,
@@ -5343,7 +6167,8 @@ const validateLayoutElementReferenceTargets = ({
5343
6167
  if (data.hoverBarImageId !== undefined) {
5344
6168
  const image = state.images.items[data.hoverBarImageId];
5345
6169
  if (!isPlainObject(image) || image.type === "folder") {
5346
- return invalidFromErrorFactory(errorFactory,
6170
+ return invalidFromErrorFactory(
6171
+ errorFactory,
5347
6172
  "layout element hoverBarImageId must reference an existing non-folder image",
5348
6173
  {
5349
6174
  layoutId,
@@ -5358,7 +6183,8 @@ const validateLayoutElementReferenceTargets = ({
5358
6183
  if (data.textStyleId !== undefined) {
5359
6184
  const textStyle = state.textStyles.items[data.textStyleId];
5360
6185
  if (!isPlainObject(textStyle) || textStyle.type === "folder") {
5361
- return invalidFromErrorFactory(errorFactory,
6186
+ return invalidFromErrorFactory(
6187
+ errorFactory,
5362
6188
  "layout element textStyleId must reference an existing non-folder text style",
5363
6189
  {
5364
6190
  layoutId,
@@ -5373,7 +6199,8 @@ const validateLayoutElementReferenceTargets = ({
5373
6199
  if (data.hoverTextStyleId !== undefined) {
5374
6200
  const textStyle = state.textStyles.items[data.hoverTextStyleId];
5375
6201
  if (!isPlainObject(textStyle) || textStyle.type === "folder") {
5376
- return invalidFromErrorFactory(errorFactory,
6202
+ return invalidFromErrorFactory(
6203
+ errorFactory,
5377
6204
  "layout element hoverTextStyleId must reference an existing non-folder text style",
5378
6205
  {
5379
6206
  layoutId,
@@ -5388,7 +6215,8 @@ const validateLayoutElementReferenceTargets = ({
5388
6215
  if (data.clickTextStyleId !== undefined) {
5389
6216
  const textStyle = state.textStyles.items[data.clickTextStyleId];
5390
6217
  if (!isPlainObject(textStyle) || textStyle.type === "folder") {
5391
- return invalidFromErrorFactory(errorFactory,
6218
+ return invalidFromErrorFactory(
6219
+ errorFactory,
5392
6220
  "layout element clickTextStyleId must reference an existing non-folder text style",
5393
6221
  {
5394
6222
  layoutId,
@@ -5403,7 +6231,8 @@ const validateLayoutElementReferenceTargets = ({
5403
6231
  if (data.variableId !== undefined) {
5404
6232
  const variable = state.variables.items[data.variableId];
5405
6233
  if (!isPlainObject(variable) || variable.type === "folder") {
5406
- return invalidFromErrorFactory(errorFactory,
6234
+ return invalidFromErrorFactory(
6235
+ errorFactory,
5407
6236
  "layout element variableId must reference an existing non-folder variable",
5408
6237
  {
5409
6238
  layoutId,
@@ -6026,7 +6855,9 @@ const findReferencedFileUsage = ({ state, fileId }) => {
6026
6855
  }
6027
6856
  }
6028
6857
 
6029
- for (const [characterId, character] of Object.entries(state.characters.items)) {
6858
+ for (const [characterId, character] of Object.entries(
6859
+ state.characters.items,
6860
+ )) {
6030
6861
  if (character.type !== "character") {
6031
6862
  continue;
6032
6863
  }
@@ -6235,9 +7066,7 @@ const COMMAND_DEFINITIONS = [
6235
7066
  }
6236
7067
 
6237
7068
  if (!isNonEmptyString(payload.sceneId)) {
6238
- return invalidPayload(
6239
- "payload.sceneId must be a non-empty string",
6240
- );
7069
+ return invalidPayload("payload.sceneId must be a non-empty string");
6241
7070
  }
6242
7071
 
6243
7072
  if (
@@ -6272,9 +7101,7 @@ const COMMAND_DEFINITIONS = [
6272
7101
  },
6273
7102
  validateAgainstState: ({ state, payload }) => {
6274
7103
  if (Object.hasOwn(state.scenes.items, payload.sceneId)) {
6275
- return invalidPrecondition(
6276
- "payload.sceneId must not already exist",
6277
- );
7104
+ return invalidPrecondition("payload.sceneId must not already exist");
6278
7105
  }
6279
7106
 
6280
7107
  const parentId = payload.parentId ?? null;
@@ -6362,9 +7189,7 @@ const COMMAND_DEFINITIONS = [
6362
7189
  }
6363
7190
 
6364
7191
  if (!isNonEmptyString(payload.sceneId)) {
6365
- return invalidPayload(
6366
- "payload.sceneId must be a non-empty string",
6367
- );
7192
+ return invalidPayload("payload.sceneId must be a non-empty string");
6368
7193
  }
6369
7194
 
6370
7195
  {
@@ -6493,9 +7318,7 @@ const COMMAND_DEFINITIONS = [
6493
7318
  }
6494
7319
 
6495
7320
  if (!isNonEmptyString(payload.sceneId)) {
6496
- return invalidPayload(
6497
- "payload.sceneId must be a non-empty string",
6498
- );
7321
+ return invalidPayload("payload.sceneId must be a non-empty string");
6499
7322
  }
6500
7323
 
6501
7324
  if (
@@ -6629,15 +7452,11 @@ const COMMAND_DEFINITIONS = [
6629
7452
  }
6630
7453
 
6631
7454
  if (!isNonEmptyString(payload.sectionId)) {
6632
- return invalidPayload(
6633
- "payload.sectionId must be a non-empty string",
6634
- );
7455
+ return invalidPayload("payload.sectionId must be a non-empty string");
6635
7456
  }
6636
7457
 
6637
7458
  if (!isNonEmptyString(payload.sceneId)) {
6638
- return invalidPayload(
6639
- "payload.sceneId must be a non-empty string",
6640
- );
7459
+ return invalidPayload("payload.sceneId must be a non-empty string");
6641
7460
  }
6642
7461
 
6643
7462
  if (
@@ -6685,9 +7504,7 @@ const COMMAND_DEFINITIONS = [
6685
7504
  }
6686
7505
 
6687
7506
  if (findSectionLocation({ state, sectionId: payload.sectionId })) {
6688
- return invalidPrecondition(
6689
- "payload.sectionId must not already exist",
6690
- );
7507
+ return invalidPrecondition("payload.sectionId must not already exist");
6691
7508
  }
6692
7509
 
6693
7510
  if (payload.parentId !== undefined && payload.parentId !== null) {
@@ -6779,9 +7596,7 @@ const COMMAND_DEFINITIONS = [
6779
7596
  }
6780
7597
 
6781
7598
  if (!isNonEmptyString(payload.sectionId)) {
6782
- return invalidPayload(
6783
- "payload.sectionId must be a non-empty string",
6784
- );
7599
+ return invalidPayload("payload.sectionId must be a non-empty string");
6785
7600
  }
6786
7601
 
6787
7602
  {
@@ -6915,9 +7730,7 @@ const COMMAND_DEFINITIONS = [
6915
7730
  }
6916
7731
 
6917
7732
  if (!isNonEmptyString(payload.sectionId)) {
6918
- return invalidPayload(
6919
- "payload.sectionId must be a non-empty string",
6920
- );
7733
+ return invalidPayload("payload.sectionId must be a non-empty string");
6921
7734
  }
6922
7735
 
6923
7736
  if (
@@ -7069,9 +7882,7 @@ const COMMAND_DEFINITIONS = [
7069
7882
  }
7070
7883
 
7071
7884
  if (!isNonEmptyString(payload.sectionId)) {
7072
- return invalidPayload(
7073
- "payload.sectionId must be a non-empty string",
7074
- );
7885
+ return invalidPayload("payload.sectionId must be a non-empty string");
7075
7886
  }
7076
7887
 
7077
7888
  {
@@ -7180,9 +7991,7 @@ const COMMAND_DEFINITIONS = [
7180
7991
  }
7181
7992
 
7182
7993
  if (!isNonEmptyString(payload.lineId)) {
7183
- return invalidPayload(
7184
- "payload.lineId must be a non-empty string",
7185
- );
7994
+ return invalidPayload("payload.lineId must be a non-empty string");
7186
7995
  }
7187
7996
 
7188
7997
  {
@@ -7296,15 +8105,11 @@ const COMMAND_DEFINITIONS = [
7296
8105
  }
7297
8106
 
7298
8107
  if (!isNonEmptyString(payload.lineId)) {
7299
- return invalidPayload(
7300
- "payload.lineId must be a non-empty string",
7301
- );
8108
+ return invalidPayload("payload.lineId must be a non-empty string");
7302
8109
  }
7303
8110
 
7304
8111
  if (!isNonEmptyString(payload.toSectionId)) {
7305
- return invalidPayload(
7306
- "payload.toSectionId must be a non-empty string",
7307
- );
8112
+ return invalidPayload("payload.toSectionId must be a non-empty string");
7308
8113
  }
7309
8114
 
7310
8115
  {
@@ -7421,9 +8226,7 @@ const COMMAND_DEFINITIONS = [
7421
8226
  }
7422
8227
 
7423
8228
  if (!isNonEmptyString(payload.imageId)) {
7424
- return invalidPayload(
7425
- "payload.imageId must be a non-empty string",
7426
- );
8229
+ return invalidPayload("payload.imageId must be a non-empty string");
7427
8230
  }
7428
8231
 
7429
8232
  if (
@@ -7458,9 +8261,7 @@ const COMMAND_DEFINITIONS = [
7458
8261
  },
7459
8262
  validateAgainstState: ({ state, payload }) => {
7460
8263
  if (isPlainObject(state.images.items[payload.imageId])) {
7461
- return invalidPrecondition(
7462
- "payload.imageId must not already exist",
7463
- );
8264
+ return invalidPrecondition("payload.imageId must not already exist");
7464
8265
  }
7465
8266
 
7466
8267
  const parentId = payload.parentId ?? null;
@@ -7576,9 +8377,7 @@ const COMMAND_DEFINITIONS = [
7576
8377
  }
7577
8378
 
7578
8379
  if (!isNonEmptyString(payload.imageId)) {
7579
- return invalidPayload(
7580
- "payload.imageId must be a non-empty string",
7581
- );
8380
+ return invalidPayload("payload.imageId must be a non-empty string");
7582
8381
  }
7583
8382
 
7584
8383
  {
@@ -7720,9 +8519,7 @@ const COMMAND_DEFINITIONS = [
7720
8519
  }
7721
8520
 
7722
8521
  if (!isNonEmptyString(payload.imageId)) {
7723
- return invalidPayload(
7724
- "payload.imageId must be a non-empty string",
7725
- );
8522
+ return invalidPayload("payload.imageId must be a non-empty string");
7726
8523
  }
7727
8524
 
7728
8525
  if (
@@ -7855,9 +8652,7 @@ const COMMAND_DEFINITIONS = [
7855
8652
  }
7856
8653
 
7857
8654
  if (!isNonEmptyString(payload.soundId)) {
7858
- return invalidPayload(
7859
- "payload.soundId must be a non-empty string",
7860
- );
8655
+ return invalidPayload("payload.soundId must be a non-empty string");
7861
8656
  }
7862
8657
 
7863
8658
  if (
@@ -7892,9 +8687,7 @@ const COMMAND_DEFINITIONS = [
7892
8687
  },
7893
8688
  validateAgainstState: ({ state, payload }) => {
7894
8689
  if (isPlainObject(state.sounds.items[payload.soundId])) {
7895
- return invalidPrecondition(
7896
- "payload.soundId must not already exist",
7897
- );
8690
+ return invalidPrecondition("payload.soundId must not already exist");
7898
8691
  }
7899
8692
 
7900
8693
  const parentId = payload.parentId ?? null;
@@ -8008,9 +8801,7 @@ const COMMAND_DEFINITIONS = [
8008
8801
  }
8009
8802
 
8010
8803
  if (!isNonEmptyString(payload.soundId)) {
8011
- return invalidPayload(
8012
- "payload.soundId must be a non-empty string",
8013
- );
8804
+ return invalidPayload("payload.soundId must be a non-empty string");
8014
8805
  }
8015
8806
 
8016
8807
  {
@@ -8152,9 +8943,7 @@ const COMMAND_DEFINITIONS = [
8152
8943
  }
8153
8944
 
8154
8945
  if (!isNonEmptyString(payload.soundId)) {
8155
- return invalidPayload(
8156
- "payload.soundId must be a non-empty string",
8157
- );
8946
+ return invalidPayload("payload.soundId must be a non-empty string");
8158
8947
  }
8159
8948
 
8160
8949
  if (
@@ -8287,9 +9076,7 @@ const COMMAND_DEFINITIONS = [
8287
9076
  }
8288
9077
 
8289
9078
  if (!isNonEmptyString(payload.videoId)) {
8290
- return invalidPayload(
8291
- "payload.videoId must be a non-empty string",
8292
- );
9079
+ return invalidPayload("payload.videoId must be a non-empty string");
8293
9080
  }
8294
9081
 
8295
9082
  if (
@@ -8324,9 +9111,7 @@ const COMMAND_DEFINITIONS = [
8324
9111
  },
8325
9112
  validateAgainstState: ({ state, payload }) => {
8326
9113
  if (isPlainObject(state.videos.items[payload.videoId])) {
8327
- return invalidPrecondition(
8328
- "payload.videoId must not already exist",
8329
- );
9114
+ return invalidPrecondition("payload.videoId must not already exist");
8330
9115
  }
8331
9116
 
8332
9117
  const parentId = payload.parentId ?? null;
@@ -8440,9 +9225,7 @@ const COMMAND_DEFINITIONS = [
8440
9225
  }
8441
9226
 
8442
9227
  if (!isNonEmptyString(payload.videoId)) {
8443
- return invalidPayload(
8444
- "payload.videoId must be a non-empty string",
8445
- );
9228
+ return invalidPayload("payload.videoId must be a non-empty string");
8446
9229
  }
8447
9230
 
8448
9231
  {
@@ -8584,9 +9367,7 @@ const COMMAND_DEFINITIONS = [
8584
9367
  }
8585
9368
 
8586
9369
  if (!isNonEmptyString(payload.videoId)) {
8587
- return invalidPayload(
8588
- "payload.videoId must be a non-empty string",
8589
- );
9370
+ return invalidPayload("payload.videoId must be a non-empty string");
8590
9371
  }
8591
9372
 
8592
9373
  if (
@@ -8719,9 +9500,7 @@ const COMMAND_DEFINITIONS = [
8719
9500
  }
8720
9501
 
8721
9502
  if (!isNonEmptyString(payload.animationId)) {
8722
- return invalidPayload(
8723
- "payload.animationId must be a non-empty string",
8724
- );
9503
+ return invalidPayload("payload.animationId must be a non-empty string");
8725
9504
  }
8726
9505
 
8727
9506
  if (
@@ -8840,9 +9619,7 @@ const COMMAND_DEFINITIONS = [
8840
9619
  }
8841
9620
 
8842
9621
  if (!isNonEmptyString(payload.animationId)) {
8843
- return invalidPayload(
8844
- "payload.animationId must be a non-empty string",
8845
- );
9622
+ return invalidPayload("payload.animationId must be a non-empty string");
8846
9623
  }
8847
9624
 
8848
9625
  {
@@ -8964,9 +9741,7 @@ const COMMAND_DEFINITIONS = [
8964
9741
  }
8965
9742
 
8966
9743
  if (!isNonEmptyString(payload.animationId)) {
8967
- return invalidPayload(
8968
- "payload.animationId must be a non-empty string",
8969
- );
9744
+ return invalidPayload("payload.animationId must be a non-empty string");
8970
9745
  }
8971
9746
 
8972
9747
  if (
@@ -9099,9 +9874,7 @@ const COMMAND_DEFINITIONS = [
9099
9874
  }
9100
9875
 
9101
9876
  if (!isNonEmptyString(payload.fontId)) {
9102
- return invalidPayload(
9103
- "payload.fontId must be a non-empty string",
9104
- );
9877
+ return invalidPayload("payload.fontId must be a non-empty string");
9105
9878
  }
9106
9879
 
9107
9880
  if (
@@ -9136,9 +9909,7 @@ const COMMAND_DEFINITIONS = [
9136
9909
  },
9137
9910
  validateAgainstState: ({ state, payload }) => {
9138
9911
  if (isPlainObject(state.fonts.items[payload.fontId])) {
9139
- return invalidPrecondition(
9140
- "payload.fontId must not already exist",
9141
- );
9912
+ return invalidPrecondition("payload.fontId must not already exist");
9142
9913
  }
9143
9914
 
9144
9915
  const parentId = payload.parentId ?? null;
@@ -9242,9 +10013,7 @@ const COMMAND_DEFINITIONS = [
9242
10013
  }
9243
10014
 
9244
10015
  if (!isNonEmptyString(payload.fontId)) {
9245
- return invalidPayload(
9246
- "payload.fontId must be a non-empty string",
9247
- );
10016
+ return invalidPayload("payload.fontId must be a non-empty string");
9248
10017
  }
9249
10018
 
9250
10019
  {
@@ -9384,9 +10153,7 @@ const COMMAND_DEFINITIONS = [
9384
10153
  }
9385
10154
 
9386
10155
  if (!isNonEmptyString(payload.fontId)) {
9387
- return invalidPayload(
9388
- "payload.fontId must be a non-empty string",
9389
- );
10156
+ return invalidPayload("payload.fontId must be a non-empty string");
9390
10157
  }
9391
10158
 
9392
10159
  if (
@@ -9519,9 +10286,7 @@ const COMMAND_DEFINITIONS = [
9519
10286
  }
9520
10287
 
9521
10288
  if (!isNonEmptyString(payload.colorId)) {
9522
- return invalidPayload(
9523
- "payload.colorId must be a non-empty string",
9524
- );
10289
+ return invalidPayload("payload.colorId must be a non-empty string");
9525
10290
  }
9526
10291
 
9527
10292
  if (
@@ -9556,9 +10321,7 @@ const COMMAND_DEFINITIONS = [
9556
10321
  },
9557
10322
  validateAgainstState: ({ state, payload }) => {
9558
10323
  if (isPlainObject(state.colors.items[payload.colorId])) {
9559
- return invalidPrecondition(
9560
- "payload.colorId must not already exist",
9561
- );
10324
+ return invalidPrecondition("payload.colorId must not already exist");
9562
10325
  }
9563
10326
 
9564
10327
  const parentId = payload.parentId ?? null;
@@ -9640,9 +10403,7 @@ const COMMAND_DEFINITIONS = [
9640
10403
  }
9641
10404
 
9642
10405
  if (!isNonEmptyString(payload.colorId)) {
9643
- return invalidPayload(
9644
- "payload.colorId must be a non-empty string",
9645
- );
10406
+ return invalidPayload("payload.colorId must be a non-empty string");
9646
10407
  }
9647
10408
 
9648
10409
  {
@@ -9761,9 +10522,7 @@ const COMMAND_DEFINITIONS = [
9761
10522
  }
9762
10523
 
9763
10524
  if (!isNonEmptyString(payload.colorId)) {
9764
- return invalidPayload(
9765
- "payload.colorId must be a non-empty string",
9766
- );
10525
+ return invalidPayload("payload.colorId must be a non-empty string");
9767
10526
  }
9768
10527
 
9769
10528
  if (
@@ -10152,6 +10911,11 @@ const COMMAND_DEFINITIONS = [
10152
10911
  ? {
10153
10912
  layoutType: payload.data.layoutType,
10154
10913
  elements: structuredClone(payload.data.elements),
10914
+ ...(payload.data.keyboard !== undefined
10915
+ ? {
10916
+ keyboard: structuredClone(payload.data.keyboard),
10917
+ }
10918
+ : {}),
10155
10919
  }
10156
10920
  : {}),
10157
10921
  }),
@@ -10190,15 +10954,11 @@ const COMMAND_DEFINITIONS = [
10190
10954
  }
10191
10955
 
10192
10956
  if (!isNonEmptyString(payload.characterId)) {
10193
- return invalidPayload(
10194
- "payload.characterId must be a non-empty string",
10195
- );
10957
+ return invalidPayload("payload.characterId must be a non-empty string");
10196
10958
  }
10197
10959
 
10198
10960
  if (!isNonEmptyString(payload.spriteId)) {
10199
- return invalidPayload(
10200
- "payload.spriteId must be a non-empty string",
10201
- );
10961
+ return invalidPayload("payload.spriteId must be a non-empty string");
10202
10962
  }
10203
10963
 
10204
10964
  if (
@@ -10245,9 +11005,7 @@ const COMMAND_DEFINITIONS = [
10245
11005
  });
10246
11006
 
10247
11007
  if (isPlainObject(collection.items[payload.spriteId])) {
10248
- return invalidPrecondition(
10249
- "payload.spriteId must not already exist",
10250
- );
11008
+ return invalidPrecondition("payload.spriteId must not already exist");
10251
11009
  }
10252
11010
 
10253
11011
  const parentId = payload.parentId ?? null;
@@ -10337,15 +11095,11 @@ const COMMAND_DEFINITIONS = [
10337
11095
  }
10338
11096
 
10339
11097
  if (!isNonEmptyString(payload.characterId)) {
10340
- return invalidPayload(
10341
- "payload.characterId must be a non-empty string",
10342
- );
11098
+ return invalidPayload("payload.characterId must be a non-empty string");
10343
11099
  }
10344
11100
 
10345
11101
  if (!isNonEmptyString(payload.spriteId)) {
10346
- return invalidPayload(
10347
- "payload.spriteId must be a non-empty string",
10348
- );
11102
+ return invalidPayload("payload.spriteId must be a non-empty string");
10349
11103
  }
10350
11104
 
10351
11105
  {
@@ -10434,9 +11188,7 @@ const COMMAND_DEFINITIONS = [
10434
11188
  }
10435
11189
 
10436
11190
  if (!isNonEmptyString(payload.characterId)) {
10437
- return invalidPayload(
10438
- "payload.characterId must be a non-empty string",
10439
- );
11191
+ return invalidPayload("payload.characterId must be a non-empty string");
10440
11192
  }
10441
11193
 
10442
11194
  {
@@ -10523,15 +11275,11 @@ const COMMAND_DEFINITIONS = [
10523
11275
  }
10524
11276
 
10525
11277
  if (!isNonEmptyString(payload.characterId)) {
10526
- return invalidPayload(
10527
- "payload.characterId must be a non-empty string",
10528
- );
11278
+ return invalidPayload("payload.characterId must be a non-empty string");
10529
11279
  }
10530
11280
 
10531
11281
  if (!isNonEmptyString(payload.spriteId)) {
10532
- return invalidPayload(
10533
- "payload.spriteId must be a non-empty string",
10534
- );
11282
+ return invalidPayload("payload.spriteId must be a non-empty string");
10535
11283
  }
10536
11284
 
10537
11285
  if (
@@ -10675,15 +11423,11 @@ const COMMAND_DEFINITIONS = [
10675
11423
  }
10676
11424
 
10677
11425
  if (!isNonEmptyString(payload.layoutId)) {
10678
- return invalidPayload(
10679
- "payload.layoutId must be a non-empty string",
10680
- );
11426
+ return invalidPayload("payload.layoutId must be a non-empty string");
10681
11427
  }
10682
11428
 
10683
11429
  if (!isNonEmptyString(payload.elementId)) {
10684
- return invalidPayload(
10685
- "payload.elementId must be a non-empty string",
10686
- );
11430
+ return invalidPayload("payload.elementId must be a non-empty string");
10687
11431
  }
10688
11432
 
10689
11433
  if (
@@ -10730,9 +11474,7 @@ const COMMAND_DEFINITIONS = [
10730
11474
  });
10731
11475
 
10732
11476
  if (isPlainObject(collection.items[payload.elementId])) {
10733
- return invalidPrecondition(
10734
- "payload.elementId must not already exist",
10735
- );
11477
+ return invalidPrecondition("payload.elementId must not already exist");
10736
11478
  }
10737
11479
 
10738
11480
  const parentId = payload.parentId ?? null;
@@ -10947,9 +11689,7 @@ const COMMAND_DEFINITIONS = [
10947
11689
  }
10948
11690
 
10949
11691
  if (!isNonEmptyString(payload.layoutId)) {
10950
- return invalidPayload(
10951
- "payload.layoutId must be a non-empty string",
10952
- );
11692
+ return invalidPayload("payload.layoutId must be a non-empty string");
10953
11693
  }
10954
11694
 
10955
11695
  {
@@ -11037,15 +11777,11 @@ const COMMAND_DEFINITIONS = [
11037
11777
  }
11038
11778
 
11039
11779
  if (!isNonEmptyString(payload.layoutId)) {
11040
- return invalidPayload(
11041
- "payload.layoutId must be a non-empty string",
11042
- );
11780
+ return invalidPayload("payload.layoutId must be a non-empty string");
11043
11781
  }
11044
11782
 
11045
11783
  if (!isNonEmptyString(payload.elementId)) {
11046
- return invalidPayload(
11047
- "payload.elementId must be a non-empty string",
11048
- );
11784
+ return invalidPayload("payload.elementId must be a non-empty string");
11049
11785
  }
11050
11786
 
11051
11787
  if (