@adobe/spacecat-shared-tokowaka-client 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +9 -3
- package/test/index.test.js +297 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-tokowaka-client-v1.5.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.5.2...@adobe/spacecat-shared-tokowaka-client-v1.5.3) (2026-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update tokowaka config ([#1275](https://github.com/adobe/spacecat-shared/issues/1275)) ([06cedcd](https://github.com/adobe/spacecat-shared/commit/06cedcd3d6f5956d895f7dedb7579d2eefffe58e))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-tokowaka-client-v1.5.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.5.1...@adobe/spacecat-shared-tokowaka-client-v1.5.2) (2026-01-21)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -349,15 +349,21 @@ class TokowakaClient {
|
|
|
349
349
|
|
|
350
350
|
// dont override api keys
|
|
351
351
|
// if patches exist, they cannot reset to empty object
|
|
352
|
+
const hasForceFail = options.forceFail !== undefined
|
|
353
|
+
|| existingMetaconfig.forceFail !== undefined;
|
|
354
|
+
const forceFail = options.forceFail
|
|
355
|
+
?? existingMetaconfig.forceFail
|
|
356
|
+
?? false;
|
|
357
|
+
|
|
352
358
|
const metaconfig = {
|
|
353
359
|
siteId,
|
|
354
360
|
apiKeys: existingMetaconfig.apiKeys,
|
|
355
|
-
tokowakaEnabled: options.tokowakaEnabled ?? true,
|
|
356
|
-
enhancements: options.enhancements ?? true,
|
|
361
|
+
tokowakaEnabled: options.tokowakaEnabled ?? existingMetaconfig.tokowakaEnabled ?? true,
|
|
362
|
+
enhancements: options.enhancements ?? existingMetaconfig.enhancements ?? true,
|
|
357
363
|
patches: isNonEmptyObject(options.patches)
|
|
358
364
|
? options.patches
|
|
359
365
|
: (existingMetaconfig.patches ?? {}),
|
|
360
|
-
...(
|
|
366
|
+
...(hasForceFail && { forceFail }),
|
|
361
367
|
};
|
|
362
368
|
|
|
363
369
|
const s3Path = await this.uploadMetaconfig(url, metaconfig);
|
package/test/index.test.js
CHANGED
|
@@ -598,8 +598,9 @@ describe('TokowakaClient', () => {
|
|
|
598
598
|
expect(result).to.have.property('siteId', siteId);
|
|
599
599
|
expect(result).to.have.property('apiKeys');
|
|
600
600
|
expect(result.apiKeys).to.deep.equal(['existing-api-key-123']);
|
|
601
|
-
|
|
602
|
-
expect(result).to.have.property('
|
|
601
|
+
// Should preserve existing metaconfig values when options not provided
|
|
602
|
+
expect(result).to.have.property('tokowakaEnabled', false);
|
|
603
|
+
expect(result).to.have.property('enhancements', false);
|
|
603
604
|
expect(result.patches).to.deep.equal({ 'existing-patch': 'value' });
|
|
604
605
|
expect(result).to.not.have.property('forceFail');
|
|
605
606
|
});
|
|
@@ -611,7 +612,7 @@ describe('TokowakaClient', () => {
|
|
|
611
612
|
const result = await client.updateMetaconfig(url, siteId, { tokowakaEnabled: false });
|
|
612
613
|
|
|
613
614
|
expect(result).to.have.property('tokowakaEnabled', false);
|
|
614
|
-
expect(result).to.have.property('enhancements',
|
|
615
|
+
expect(result).to.have.property('enhancements', false);
|
|
615
616
|
expect(result.patches).to.deep.equal({ 'existing-patch': 'value' });
|
|
616
617
|
expect(result).to.not.have.property('forceFail');
|
|
617
618
|
});
|
|
@@ -623,8 +624,9 @@ describe('TokowakaClient', () => {
|
|
|
623
624
|
const result = await client.updateMetaconfig(url, siteId, { tokowakaEnabled: true });
|
|
624
625
|
|
|
625
626
|
expect(result).to.have.property('tokowakaEnabled', true);
|
|
626
|
-
expect(result).to.have.property('enhancements',
|
|
627
|
+
expect(result).to.have.property('enhancements', false);
|
|
627
628
|
expect(result.patches).to.deep.equal({ 'existing-patch': 'value' });
|
|
629
|
+
expect(result).to.not.have.property('forceFail');
|
|
628
630
|
});
|
|
629
631
|
|
|
630
632
|
it('should update metaconfig with enhancements set to false', async () => {
|
|
@@ -633,9 +635,10 @@ describe('TokowakaClient', () => {
|
|
|
633
635
|
|
|
634
636
|
const result = await client.updateMetaconfig(url, siteId, { enhancements: false });
|
|
635
637
|
|
|
636
|
-
expect(result).to.have.property('tokowakaEnabled',
|
|
638
|
+
expect(result).to.have.property('tokowakaEnabled', false);
|
|
637
639
|
expect(result).to.have.property('enhancements', false);
|
|
638
640
|
expect(result.patches).to.deep.equal({ 'existing-patch': 'value' });
|
|
641
|
+
expect(result).to.not.have.property('forceFail');
|
|
639
642
|
});
|
|
640
643
|
|
|
641
644
|
it('should update metaconfig with enhancements set to true explicitly', async () => {
|
|
@@ -644,9 +647,10 @@ describe('TokowakaClient', () => {
|
|
|
644
647
|
|
|
645
648
|
const result = await client.updateMetaconfig(url, siteId, { enhancements: true });
|
|
646
649
|
|
|
647
|
-
expect(result).to.have.property('tokowakaEnabled',
|
|
650
|
+
expect(result).to.have.property('tokowakaEnabled', false);
|
|
648
651
|
expect(result).to.have.property('enhancements', true);
|
|
649
652
|
expect(result.patches).to.deep.equal({ 'existing-patch': 'value' });
|
|
653
|
+
expect(result).to.not.have.property('forceFail');
|
|
650
654
|
});
|
|
651
655
|
|
|
652
656
|
it('should override patches when non-empty patches object is provided', async () => {
|
|
@@ -708,13 +712,13 @@ describe('TokowakaClient', () => {
|
|
|
708
712
|
expect(result).to.have.property('forceFail', true);
|
|
709
713
|
});
|
|
710
714
|
|
|
711
|
-
it('should
|
|
715
|
+
it('should include forceFail when set to false', async () => {
|
|
712
716
|
const siteId = 'site-789';
|
|
713
717
|
const url = 'https://example.com';
|
|
714
718
|
|
|
715
719
|
const result = await client.updateMetaconfig(url, siteId, { forceFail: false });
|
|
716
720
|
|
|
717
|
-
expect(result).to.
|
|
721
|
+
expect(result).to.have.property('forceFail', false);
|
|
718
722
|
});
|
|
719
723
|
|
|
720
724
|
it('should not include forceFail when undefined', async () => {
|
|
@@ -726,6 +730,38 @@ describe('TokowakaClient', () => {
|
|
|
726
730
|
expect(result).to.not.have.property('forceFail');
|
|
727
731
|
});
|
|
728
732
|
|
|
733
|
+
it('should use forceFail as false when options.forceFail is null and existingMetaconfig has no forceFail', async () => {
|
|
734
|
+
const siteId = 'site-789';
|
|
735
|
+
const url = 'https://example.com';
|
|
736
|
+
|
|
737
|
+
const result = await client.updateMetaconfig(url, siteId, { forceFail: null });
|
|
738
|
+
|
|
739
|
+
expect(result).to.have.property('forceFail', false);
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
it('should preserve existingMetaconfig forceFail when options.forceFail is null', async () => {
|
|
743
|
+
const configWithForceFail = {
|
|
744
|
+
siteId: 'site-456',
|
|
745
|
+
apiKeys: ['existing-api-key-123'],
|
|
746
|
+
tokowakaEnabled: true,
|
|
747
|
+
enhancements: true,
|
|
748
|
+
patches: {},
|
|
749
|
+
forceFail: true,
|
|
750
|
+
};
|
|
751
|
+
s3Client.send.onFirstCall().resolves({
|
|
752
|
+
Body: {
|
|
753
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithForceFail)),
|
|
754
|
+
},
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
const siteId = 'site-789';
|
|
758
|
+
const url = 'https://example.com';
|
|
759
|
+
|
|
760
|
+
const result = await client.updateMetaconfig(url, siteId, { forceFail: null });
|
|
761
|
+
|
|
762
|
+
expect(result).to.have.property('forceFail', true);
|
|
763
|
+
});
|
|
764
|
+
|
|
729
765
|
it('should update metaconfig with multiple options', async () => {
|
|
730
766
|
const siteId = 'site-789';
|
|
731
767
|
const url = 'https://example.com';
|
|
@@ -855,6 +891,259 @@ describe('TokowakaClient', () => {
|
|
|
855
891
|
|
|
856
892
|
expect(result.patches).to.deep.equal(singlePatch);
|
|
857
893
|
});
|
|
894
|
+
|
|
895
|
+
it('should preserve existing patches when options.patches is null', async () => {
|
|
896
|
+
const siteId = 'site-789';
|
|
897
|
+
const url = 'https://example.com';
|
|
898
|
+
|
|
899
|
+
const result = await client.updateMetaconfig(url, siteId, { patches: null });
|
|
900
|
+
|
|
901
|
+
expect(result.patches).to.deep.equal({ 'existing-patch': 'value' });
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
it('should preserve tokowakaEnabled=true from existingMetaconfig when options not provided', async () => {
|
|
905
|
+
const configWithTokowakaEnabled = {
|
|
906
|
+
siteId: 'site-456',
|
|
907
|
+
apiKeys: ['existing-api-key-123'],
|
|
908
|
+
tokowakaEnabled: true,
|
|
909
|
+
enhancements: false,
|
|
910
|
+
patches: {},
|
|
911
|
+
};
|
|
912
|
+
s3Client.send.onFirstCall().resolves({
|
|
913
|
+
Body: {
|
|
914
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithTokowakaEnabled)),
|
|
915
|
+
},
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
const siteId = 'site-789';
|
|
919
|
+
const url = 'https://example.com';
|
|
920
|
+
|
|
921
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
922
|
+
|
|
923
|
+
expect(result).to.have.property('tokowakaEnabled', true);
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
it('should preserve enhancements=true from existingMetaconfig when options not provided', async () => {
|
|
927
|
+
const configWithEnhancements = {
|
|
928
|
+
siteId: 'site-456',
|
|
929
|
+
apiKeys: ['existing-api-key-123'],
|
|
930
|
+
tokowakaEnabled: false,
|
|
931
|
+
enhancements: true,
|
|
932
|
+
patches: {},
|
|
933
|
+
};
|
|
934
|
+
s3Client.send.onFirstCall().resolves({
|
|
935
|
+
Body: {
|
|
936
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithEnhancements)),
|
|
937
|
+
},
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
const siteId = 'site-789';
|
|
941
|
+
const url = 'https://example.com';
|
|
942
|
+
|
|
943
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
944
|
+
|
|
945
|
+
expect(result).to.have.property('enhancements', true);
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
it('should default tokowakaEnabled to true when not in existingMetaconfig or options', async () => {
|
|
949
|
+
const configWithoutTokowakaEnabled = {
|
|
950
|
+
siteId: 'site-456',
|
|
951
|
+
apiKeys: ['existing-api-key-123'],
|
|
952
|
+
enhancements: false,
|
|
953
|
+
patches: {},
|
|
954
|
+
};
|
|
955
|
+
s3Client.send.onFirstCall().resolves({
|
|
956
|
+
Body: {
|
|
957
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithoutTokowakaEnabled)),
|
|
958
|
+
},
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
const siteId = 'site-789';
|
|
962
|
+
const url = 'https://example.com';
|
|
963
|
+
|
|
964
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
965
|
+
|
|
966
|
+
expect(result).to.have.property('tokowakaEnabled', true);
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
it('should default enhancements to true when not in existingMetaconfig or options', async () => {
|
|
970
|
+
const configWithoutEnhancements = {
|
|
971
|
+
siteId: 'site-456',
|
|
972
|
+
apiKeys: ['existing-api-key-123'],
|
|
973
|
+
tokowakaEnabled: false,
|
|
974
|
+
patches: {},
|
|
975
|
+
};
|
|
976
|
+
s3Client.send.onFirstCall().resolves({
|
|
977
|
+
Body: {
|
|
978
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithoutEnhancements)),
|
|
979
|
+
},
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
const siteId = 'site-789';
|
|
983
|
+
const url = 'https://example.com';
|
|
984
|
+
|
|
985
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
986
|
+
|
|
987
|
+
expect(result).to.have.property('enhancements', true);
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
it('should preserve forceFail=true from existingMetaconfig when options not provided', async () => {
|
|
991
|
+
const configWithForceFail = {
|
|
992
|
+
siteId: 'site-456',
|
|
993
|
+
apiKeys: ['existing-api-key-123'],
|
|
994
|
+
tokowakaEnabled: true,
|
|
995
|
+
enhancements: true,
|
|
996
|
+
patches: {},
|
|
997
|
+
forceFail: true,
|
|
998
|
+
};
|
|
999
|
+
s3Client.send.onFirstCall().resolves({
|
|
1000
|
+
Body: {
|
|
1001
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithForceFail)),
|
|
1002
|
+
},
|
|
1003
|
+
});
|
|
1004
|
+
|
|
1005
|
+
const siteId = 'site-789';
|
|
1006
|
+
const url = 'https://example.com';
|
|
1007
|
+
|
|
1008
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
1009
|
+
|
|
1010
|
+
expect(result).to.have.property('forceFail', true);
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
it('should override existingMetaconfig forceFail when explicitly set to false in options', async () => {
|
|
1014
|
+
const configWithForceFail = {
|
|
1015
|
+
siteId: 'site-456',
|
|
1016
|
+
apiKeys: ['existing-api-key-123'],
|
|
1017
|
+
tokowakaEnabled: true,
|
|
1018
|
+
enhancements: true,
|
|
1019
|
+
patches: {},
|
|
1020
|
+
forceFail: true,
|
|
1021
|
+
};
|
|
1022
|
+
s3Client.send.onFirstCall().resolves({
|
|
1023
|
+
Body: {
|
|
1024
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithForceFail)),
|
|
1025
|
+
},
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
const siteId = 'site-789';
|
|
1029
|
+
const url = 'https://example.com';
|
|
1030
|
+
|
|
1031
|
+
const result = await client.updateMetaconfig(url, siteId, { forceFail: false });
|
|
1032
|
+
|
|
1033
|
+
expect(result).to.have.property('forceFail', false);
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
it('should override existingMetaconfig forceFail when explicitly set to true in options', async () => {
|
|
1037
|
+
const configWithoutForceFail = {
|
|
1038
|
+
siteId: 'site-456',
|
|
1039
|
+
apiKeys: ['existing-api-key-123'],
|
|
1040
|
+
tokowakaEnabled: true,
|
|
1041
|
+
enhancements: true,
|
|
1042
|
+
patches: {},
|
|
1043
|
+
forceFail: false,
|
|
1044
|
+
};
|
|
1045
|
+
s3Client.send.onFirstCall().resolves({
|
|
1046
|
+
Body: {
|
|
1047
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithoutForceFail)),
|
|
1048
|
+
},
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
const siteId = 'site-789';
|
|
1052
|
+
const url = 'https://example.com';
|
|
1053
|
+
|
|
1054
|
+
const result = await client.updateMetaconfig(url, siteId, { forceFail: true });
|
|
1055
|
+
|
|
1056
|
+
expect(result).to.have.property('forceFail', true);
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
it('should preserve forceFail=false from existingMetaconfig when options not provided', async () => {
|
|
1060
|
+
const configWithForceFail = {
|
|
1061
|
+
siteId: 'site-456',
|
|
1062
|
+
apiKeys: ['existing-api-key-123'],
|
|
1063
|
+
tokowakaEnabled: true,
|
|
1064
|
+
enhancements: true,
|
|
1065
|
+
patches: {},
|
|
1066
|
+
forceFail: false,
|
|
1067
|
+
};
|
|
1068
|
+
s3Client.send.onFirstCall().resolves({
|
|
1069
|
+
Body: {
|
|
1070
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithForceFail)),
|
|
1071
|
+
},
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
const siteId = 'site-789';
|
|
1075
|
+
const url = 'https://example.com';
|
|
1076
|
+
|
|
1077
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
1078
|
+
|
|
1079
|
+
expect(result).to.have.property('forceFail', false);
|
|
1080
|
+
});
|
|
1081
|
+
|
|
1082
|
+
it('should override existingMetaconfig tokowakaEnabled=false when explicitly set to true', async () => {
|
|
1083
|
+
const siteId = 'site-789';
|
|
1084
|
+
const url = 'https://example.com';
|
|
1085
|
+
// existingMetaconfig has tokowakaEnabled: false
|
|
1086
|
+
|
|
1087
|
+
const result = await client.updateMetaconfig(url, siteId, { tokowakaEnabled: true });
|
|
1088
|
+
|
|
1089
|
+
expect(result).to.have.property('tokowakaEnabled', true);
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
it('should override existingMetaconfig enhancements=false when explicitly set to true', async () => {
|
|
1093
|
+
const siteId = 'site-789';
|
|
1094
|
+
const url = 'https://example.com';
|
|
1095
|
+
// existingMetaconfig has enhancements: false
|
|
1096
|
+
|
|
1097
|
+
const result = await client.updateMetaconfig(url, siteId, { enhancements: true });
|
|
1098
|
+
|
|
1099
|
+
expect(result).to.have.property('enhancements', true);
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
it('should handle case where options.forceFail and existingMetaconfig.forceFail are both true', async () => {
|
|
1103
|
+
const configWithForceFail = {
|
|
1104
|
+
siteId: 'site-456',
|
|
1105
|
+
apiKeys: ['existing-api-key-123'],
|
|
1106
|
+
tokowakaEnabled: true,
|
|
1107
|
+
enhancements: true,
|
|
1108
|
+
patches: {},
|
|
1109
|
+
forceFail: true,
|
|
1110
|
+
};
|
|
1111
|
+
s3Client.send.onFirstCall().resolves({
|
|
1112
|
+
Body: {
|
|
1113
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithForceFail)),
|
|
1114
|
+
},
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
const siteId = 'site-789';
|
|
1118
|
+
const url = 'https://example.com';
|
|
1119
|
+
|
|
1120
|
+
const result = await client.updateMetaconfig(url, siteId, { forceFail: true });
|
|
1121
|
+
|
|
1122
|
+
expect(result).to.have.property('forceFail', true);
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
it('should handle case where options.forceFail and existingMetaconfig.forceFail are both false', async () => {
|
|
1126
|
+
const configWithForceFail = {
|
|
1127
|
+
siteId: 'site-456',
|
|
1128
|
+
apiKeys: ['existing-api-key-123'],
|
|
1129
|
+
tokowakaEnabled: true,
|
|
1130
|
+
enhancements: true,
|
|
1131
|
+
patches: {},
|
|
1132
|
+
forceFail: false,
|
|
1133
|
+
};
|
|
1134
|
+
s3Client.send.onFirstCall().resolves({
|
|
1135
|
+
Body: {
|
|
1136
|
+
transformToString: sinon.stub().resolves(JSON.stringify(configWithForceFail)),
|
|
1137
|
+
},
|
|
1138
|
+
});
|
|
1139
|
+
|
|
1140
|
+
const siteId = 'site-789';
|
|
1141
|
+
const url = 'https://example.com';
|
|
1142
|
+
|
|
1143
|
+
const result = await client.updateMetaconfig(url, siteId);
|
|
1144
|
+
|
|
1145
|
+
expect(result).to.have.property('forceFail', false);
|
|
1146
|
+
});
|
|
858
1147
|
});
|
|
859
1148
|
|
|
860
1149
|
describe('uploadConfig', () => {
|