@@ -206,31 +206,29 @@ const filterResults = async function (o, dontDecryptInSso) {
206
206
}
207
207
if ( EcArray . isArray ( o ) ) {
208
208
let me = this ;
209
- return ( await Promise . all ( o . map ( x => {
210
- return new Promise ( ( resolve , reject ) => {
211
- try {
212
- resolve ( filterResults . call ( me , x , dontDecryptInSso ) ) ;
213
- } catch ( ex ) {
214
- if ( ex != null && ex . toString ( ) . indexOf ( 'Object not found or you did not supply sufficient permissions to access the object.' ) == - 1 ) {
215
- reject ( ex ) ; // NOSONAR -- Rethrowing error.
216
- }
217
- resolve ( null ) ;
209
+ return ( await Promise . all ( o . map ( async ( x ) => {
210
+ try {
211
+ return await filterResults . call ( me , x , dontDecryptInSso ) ;
212
+ } catch ( ex ) {
213
+ if ( ex != null && ex . toString ( ) . indexOf ( 'Object not found or you did not supply sufficient permissions to access the object.' ) == - 1 ) {
214
+ throw ex ;
218
215
}
219
- } ) ;
220
- } ) ) ) . filter ( x => x ) ;
216
+ return null ;
217
+ }
218
+ } ) ) ) . filter ( ( x ) => x ) ;
221
219
} else if ( EcObject . isObject ( o ) ) {
222
220
delete o . decryptedSecret ;
223
221
const rld = new EcRemoteLinkedData ( ( o ) [ '@context' ] , ( o ) [ '@type' ] ) ;
224
222
rld . copyFrom ( o ) ;
225
223
if ( ( rld . reader != null && rld . reader . length != 0 ) || isEncryptedType ( rld ) ) {
226
224
const signatures = await ( signatureSheet ) . call ( this ) ;
227
225
let foundSignature = false ;
228
- for ( let i = 0 ; i < signatures . length ; i ++ ) {
229
- if ( JSON . stringify ( o ) . indexOf ( signatures [ i ] . owner ) != - 1 ) {
226
+ for ( let signature of signatures ) {
227
+ if ( JSON . stringify ( o ) . indexOf ( signature . owner ) != - 1 ) {
230
228
foundSignature = true ;
231
229
break ;
232
230
}
233
- if ( EcPk . fromPem ( skyrepoAdminPk ( ) ) . equals ( EcPk . fromPem ( signatures [ i ] . owner ) ) ) {
231
+ if ( EcPk . fromPem ( skyrepoAdminPk ( ) ) . equals ( EcPk . fromPem ( signature . owner ) ) ) {
234
232
foundSignature = true ;
235
233
break ;
236
234
}
@@ -252,10 +250,9 @@ const filterResults = async function (o, dontDecryptInSso) {
252
250
}
253
251
}
254
252
const keys = EcObject . keys ( o ) ;
255
- for ( let i = 0 ; i < keys . length ; i ++ ) {
256
- const key = keys [ i ] ;
253
+ for ( let key of keys ) {
257
254
let result = null ;
258
- try {
255
+ try {
259
256
result = await ( filterResults ) . call ( this , ( o ) [ key ] , dontDecryptInSso ) ;
260
257
} catch ( ex ) {
261
258
if ( ex != null && ex . toString ( ) . indexOf ( 'Object not found or you did not supply sufficient permissions to access the object.' ) == - 1 ) {
@@ -8451,7 +8448,7 @@ const getTypeForObject = function (o, type) {
8451
8448
return inferTypeFromObj ( o , type ) ;
8452
8449
}
8453
8450
} ;
8454
- const removeNonIndexables = function ( o ) {
8451
+ const removeNonIndexables = function ( o ) {
8455
8452
if ( o != null && EcObject . isObject ( o ) ) {
8456
8453
const keys = EcObject . keys ( o ) ;
8457
8454
for ( let i = 0 ; i < keys . length ; i ++ ) {
@@ -8913,34 +8910,40 @@ const skyrepoGetIndexSearch = async function (id, version, type) {
8913
8910
} ;
8914
8911
8915
8912
const skyrepoManyGetIndexSearch = async function ( ary ) {
8916
- if ( ary . length === 0 ) {
8917
- return [ ] ;
8918
- }
8919
- let microSearchUrl = elasticEndpoint + '/_search?version&q=' ;
8920
- for ( let i = 0 ; i < ary . length ; i ++ ) {
8921
- microSearchUrl += '_id:"' + ary [ i ] . id + '"' ;
8922
- if ( i < ary . length - 1 ) {
8923
- microSearchUrl += ' OR ' ;
8913
+ let results = [ ] ;
8914
+ if ( ary . length == 0 ) {
8915
+ return results ;
8916
+ }
8917
+ while ( ary . length > 0 ) {
8918
+ let batch = ary . splice ( 0 , 50 ) ;
8919
+ let microSearchUrl = elasticEndpoint + '/_search?version&q=' ;
8920
+ for ( let i = 0 ; i < batch . length ; i ++ ) {
8921
+ microSearchUrl += '_id:"' + batch [ i ] . id + '"' ;
8922
+ if ( i < batch . length - 1 ) {
8923
+ microSearchUrl += ' OR ' ;
8924
+ }
8924
8925
}
8925
- }
8926
8926
8927
- const microSearch = await httpGet ( microSearchUrl , true , elasticHeaders ( ) ) ;
8927
+ const microSearch = await httpGet ( microSearchUrl , true , elasticHeaders ( ) ) ;
8928
8928
8929
- if ( global . skyrepoDebug ) {
8930
- global . auditLogger . report ( global . auditLogger . LogCategory . NETWORK , global . auditLogger . Severity . DEBUG , 'SkyrepManyGetIndexSearch' , microSearchUrl ) ;
8931
- }
8932
- if ( microSearch == null ) {
8933
- return [ ] ;
8934
- }
8935
- const hitshits = ( microSearch ) [ 'hits' ] ;
8936
- if ( hitshits == null ) {
8937
- return [ ] ;
8938
- }
8939
- const hits = ( hitshits ) [ 'hits' ] ;
8940
- if ( hits . length == 0 ) {
8941
- return [ ] ;
8929
+ if ( global . skyrepoDebug ) {
8930
+ global . auditLogger . report ( global . auditLogger . LogCategory . NETWORK , global . auditLogger . Severity . DEBUG , 'SkyrepManyGetIndexSearch' , microSearchUrl ) ;
8931
+ }
8932
+ if ( microSearch == null ) {
8933
+ return [ ] ;
8934
+ }
8935
+ const hitshits = ( microSearch ) [ 'hits' ] ;
8936
+ if ( hitshits == null ) {
8937
+ return [ ] ;
8938
+ }
8939
+ const hits = ( hitshits ) [ 'hits' ] ;
8940
+ if ( hits . length == 0 ) {
8941
+ return [ ] ;
8942
+ }
8943
+ for ( let hit of hits )
8944
+ results . push ( hit ) ;
8942
8945
}
8943
- return hits ;
8946
+ return results ;
8944
8947
} ;
8945
8948
8946
8949
let skyrepoGetIndexRecords = async function ( id ) {
@@ -9132,14 +9135,13 @@ global.skyrepoManyGetInternal = async function (manyParseParams) {
9132
9135
}
9133
9136
9134
9137
if ( global . skyrepoDebug && notFoundInPermanent . length > 0 ) {
9135
- global . auditLogger . report ( global . auditLogger . LogCategory . NETWORK , global . auditLogger . Severity . DEBUG , 'SkyrepManyGetInternal' , 'Failed to find ' + manyParseParams + ' -- trying degraded form from search index.' ) ;
9138
+ global . auditLogger . report ( global . auditLogger . LogCategory . NETWORK , global . auditLogger . Severity . DEBUG , 'SkyrepManyGetInternal' , 'Failed to find ' + notFoundInPermanent + ' -- trying degraded form from search index.' ) ;
9136
9139
}
9137
9140
9138
9141
response = await ( skyrepoManyGetIndex ) . call ( this , notFoundInPermanent ) ;
9139
- resultDocs = ( response ) [ 'docs' ] ;
9140
- if ( resultDocs != null ) {
9141
- for ( let i = 0 ; i < resultDocs . length ; i ++ ) {
9142
- let doc = resultDocs [ i ] ;
9142
+ let resultDocs2 = ( response ) [ 'docs' ] ;
9143
+ if ( resultDocs2 != null ) {
9144
+ for ( let doc of resultDocs2 ) {
9143
9145
if ( ( doc ) [ 'found' ] ) {
9144
9146
delete ( lookup ) [ ( ( doc ) [ '_id' ] ) . substring ( 0 , ( ( doc ) [ '_id' ] ) . length - 1 ) ] ;
9145
9147
results . push ( JSON . parse ( ( ( doc ) [ '_source' ] ) [ 'data' ] ) ) ;
0 commit comments