File tree 2 files changed +21
-2
lines changed
packages/client-search/src/methods/client
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 98
98
"bundlesize" : [
99
99
{
100
100
"path" : " packages/algoliasearch/dist/algoliasearch.umd.js" ,
101
- "maxSize" : " 7.95KB "
101
+ "maxSize" : " 8KB "
102
102
},
103
103
{
104
104
"path" : " packages/algoliasearch/dist/algoliasearch-lite.umd.js" ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { MethodEnum } from '@algolia/requester-common';
9
9
import { RequestOptions } from '@algolia/transporter' ;
10
10
11
11
import {
12
+ ApiKeyACLType ,
12
13
getApiKey ,
13
14
GetApiKeyResponse ,
14
15
SearchClient ,
@@ -37,14 +38,32 @@ export const updateApiKey = (base: SearchClient) => {
37
38
'maxHitsPerQuery' ,
38
39
] as const ;
39
40
41
+ // Check that all the fields retrieved through getApiKey are the same as the ones we wanted to update
40
42
const hasChanged = ( getApiKeyResponse : GetApiKeyResponse ) : boolean => {
41
43
return Object . keys ( updatedFields )
42
44
. filter (
43
45
( updatedField : any ) : updatedField is typeof apiKeyFields [ number ] =>
44
46
apiKeyFields . indexOf ( updatedField ) !== - 1
45
47
)
46
48
. every ( updatedField => {
47
- return getApiKeyResponse [ updatedField ] === updatedFields [ updatedField ] ;
49
+ // If the field is an array, we need to check that they are the same length and that all the values are the same
50
+ if (
51
+ Array . isArray ( getApiKeyResponse [ updatedField ] ) &&
52
+ Array . isArray ( updatedFields [ updatedField ] )
53
+ ) {
54
+ const getApiKeyResponseArray = getApiKeyResponse [ updatedField ] as
55
+ | readonly ApiKeyACLType [ ]
56
+ | readonly string [ ] ;
57
+
58
+ return (
59
+ getApiKeyResponseArray . length === updatedFields [ updatedField ] . length &&
60
+ getApiKeyResponseArray . every (
61
+ ( value , index ) => value === updatedFields [ updatedField ] [ index ]
62
+ )
63
+ ) ;
64
+ } else {
65
+ return getApiKeyResponse [ updatedField ] === updatedFields [ updatedField ] ;
66
+ }
48
67
} ) ;
49
68
} ;
50
69
You can’t perform that action at this time.
0 commit comments