File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
packages/client-search/src/methods/client Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 9898 "bundlesize" : [
9999 {
100100 "path" : " packages/algoliasearch/dist/algoliasearch.umd.js" ,
101- "maxSize" : " 7.95KB "
101+ "maxSize" : " 8KB "
102102 },
103103 {
104104 "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';
99import { RequestOptions } from '@algolia/transporter' ;
1010
1111import {
12+ ApiKeyACLType ,
1213 getApiKey ,
1314 GetApiKeyResponse ,
1415 SearchClient ,
@@ -37,14 +38,32 @@ export const updateApiKey = (base: SearchClient) => {
3738 'maxHitsPerQuery' ,
3839 ] as const ;
3940
41+ // Check that all the fields retrieved through getApiKey are the same as the ones we wanted to update
4042 const hasChanged = ( getApiKeyResponse : GetApiKeyResponse ) : boolean => {
4143 return Object . keys ( updatedFields )
4244 . filter (
4345 ( updatedField : any ) : updatedField is typeof apiKeyFields [ number ] =>
4446 apiKeyFields . indexOf ( updatedField ) !== - 1
4547 )
4648 . 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+ }
4867 } ) ;
4968 } ;
5069
You can’t perform that action at this time.
0 commit comments