@@ -133,4 +133,217 @@ describe('query.dcql', () => {
133133 ] ) ;
134134 } ) ;
135135 } ) ;
136+ it ( 'should process array of arrays query' , async ( ) => {
137+ const dcqlCredentialQuery = _fromQueryByExampleQuery ( {
138+ credentialQuery : {
139+ reason : 'Present your geolocation credential to claim the prize.' ,
140+ example : {
141+ '@context' : [
142+ 'https://www.w3.org/ns/credentials/v2' ,
143+ 'https://www.w3.org/ns/credentials/examples/v2'
144+ ] ,
145+ type : [
146+ 'ExampleGeoLocationCredential'
147+ ] ,
148+ credentialSubject : {
149+ type : 'ExampleGeoLocation' ,
150+ location : [ [ 0 , 1 ] , [ 2 , 3 ] ]
151+ }
152+ }
153+ }
154+ } ) ;
155+ expect ( dcqlCredentialQuery . id ) . to . exist ;
156+ expect ( dcqlCredentialQuery . format ) . to . eql ( 'ldp_vc' ) ;
157+ expect ( dcqlCredentialQuery . meta . type_values ) . to . deep . equal ( [
158+ 'https://www.w3.org/2018/credentials#VerifiableCredential'
159+ ] ) ;
160+ expect ( dcqlCredentialQuery . claims ) . to . deep . equal ( [
161+ {
162+ path : [ '@context' , 0 ] ,
163+ values : [ 'https://www.w3.org/ns/credentials/v2' ]
164+ } ,
165+ {
166+ path : [ '@context' , 1 ] ,
167+ values : [ 'https://www.w3.org/ns/credentials/examples/v2' ]
168+ } ,
169+ {
170+ path : [ 'type' ] ,
171+ values : [ 'ExampleGeoLocationCredential' ] } ,
172+ {
173+ path : [ 'credentialSubject' , 'type' ] ,
174+ values : [ 'ExampleGeoLocation' ]
175+ } ,
176+ {
177+ path : [ 'credentialSubject' , 'location' , 0 , 0 ] ,
178+ values : [ 0 ]
179+ } ,
180+ {
181+ path : [ 'credentialSubject' , 'location' , 0 , 1 ] ,
182+ values : [ 1 ]
183+ } ,
184+ {
185+ path : [ 'credentialSubject' , 'location' , 1 , 0 ] ,
186+ values : [ 2 ]
187+ } ,
188+ {
189+ path : [ 'credentialSubject' , 'location' , 1 , 1 ] ,
190+ values : [ 3 ]
191+ }
192+ ] ) ;
193+ } ) ;
194+ it ( 'should process array of arrays of arrays query' , async ( ) => {
195+ const dcqlCredentialQuery = _fromQueryByExampleQuery ( {
196+ credentialQuery : {
197+ reason : 'Present your tensor credential to claim the prize.' ,
198+ example : {
199+ '@context' : [
200+ 'https://www.w3.org/ns/credentials/v2' ,
201+ 'https://www.w3.org/ns/credentials/examples/v2'
202+ ] ,
203+ type : [
204+ 'ExampleTensorCredential'
205+ ] ,
206+ credentialSubject : {
207+ type : 'ExampleTensor' ,
208+ tensor : [ [ [ 0 , 1 ] , [ 2 , 3 ] ] , [ [ 4 , 5 ] , [ 6 , 7 ] ] ]
209+ }
210+ }
211+ }
212+ } ) ;
213+ expect ( dcqlCredentialQuery . id ) . to . exist ;
214+ expect ( dcqlCredentialQuery . format ) . to . eql ( 'ldp_vc' ) ;
215+ expect ( dcqlCredentialQuery . meta . type_values ) . to . deep . equal ( [
216+ 'https://www.w3.org/2018/credentials#VerifiableCredential'
217+ ] ) ;
218+ expect ( dcqlCredentialQuery . claims ) . to . deep . equal ( [
219+ {
220+ path : [ '@context' , 0 ] ,
221+ values : [ 'https://www.w3.org/ns/credentials/v2' ]
222+ } ,
223+ {
224+ path : [ '@context' , 1 ] ,
225+ values : [ 'https://www.w3.org/ns/credentials/examples/v2' ]
226+ } ,
227+ {
228+ path : [ 'type' ] ,
229+ values : [ 'ExampleTensorCredential' ] } ,
230+ {
231+ path : [ 'credentialSubject' , 'type' ] ,
232+ values : [ 'ExampleTensor' ]
233+ } ,
234+ {
235+ path : [ 'credentialSubject' , 'tensor' , 0 , 0 , 0 ] ,
236+ values : [ 0 ]
237+ } ,
238+ {
239+ path : [ 'credentialSubject' , 'tensor' , 0 , 0 , 1 ] ,
240+ values : [ 1 ]
241+ } ,
242+ {
243+ path : [ 'credentialSubject' , 'tensor' , 0 , 1 , 0 ] ,
244+ values : [ 2 ]
245+ } ,
246+ {
247+ path : [ 'credentialSubject' , 'tensor' , 0 , 1 , 1 ] ,
248+ values : [ 3 ]
249+ } ,
250+ {
251+ path : [ 'credentialSubject' , 'tensor' , 1 , 0 , 0 ] ,
252+ values : [ 4 ]
253+ } ,
254+ {
255+ path : [ 'credentialSubject' , 'tensor' , 1 , 0 , 1 ] ,
256+ values : [ 5 ]
257+ } ,
258+ {
259+ path : [ 'credentialSubject' , 'tensor' , 1 , 1 , 0 ] ,
260+ values : [ 6 ]
261+ } ,
262+ {
263+ path : [ 'credentialSubject' , 'tensor' , 1 , 1 , 1 ] ,
264+ values : [ 7 ]
265+ }
266+ ] ) ;
267+ } ) ;
268+ it . only ( 'should process array of arrays inside objects query' , async ( ) => {
269+ const dcqlCredentialQuery = _fromQueryByExampleQuery ( {
270+ credentialQuery : {
271+ reason : 'Present your dimensions credential to claim the prize.' ,
272+ example : {
273+ '@context' : [
274+ 'https://www.w3.org/ns/credentials/v2' ,
275+ 'https://www.w3.org/ns/credentials/examples/v2'
276+ ] ,
277+ type : [
278+ 'ExampleDimensionsCredential'
279+ ] ,
280+ credentialSubject : {
281+ type : 'ExampleDimensions' ,
282+ outer : [
283+ [ {
284+ inner : [ [ 0 , 1 ] , [ 2 , 3 ] ]
285+ } ] ,
286+ [ {
287+ inner : [ [ 4 , 5 ] , [ 6 , 7 ] ]
288+ } ]
289+ ]
290+ }
291+ }
292+ }
293+ } ) ;
294+ expect ( dcqlCredentialQuery . id ) . to . exist ;
295+ expect ( dcqlCredentialQuery . format ) . to . eql ( 'ldp_vc' ) ;
296+ expect ( dcqlCredentialQuery . meta . type_values ) . to . deep . equal ( [
297+ 'https://www.w3.org/2018/credentials#VerifiableCredential'
298+ ] ) ;
299+ expect ( dcqlCredentialQuery . claims ) . to . deep . equal ( [
300+ {
301+ path : [ '@context' , 0 ] ,
302+ values : [ 'https://www.w3.org/ns/credentials/v2' ]
303+ } ,
304+ {
305+ path : [ '@context' , 1 ] ,
306+ values : [ 'https://www.w3.org/ns/credentials/examples/v2' ]
307+ } ,
308+ {
309+ path : [ 'type' ] ,
310+ values : [ 'ExampleDimensionsCredential' ] } ,
311+ {
312+ path : [ 'credentialSubject' , 'type' ] ,
313+ values : [ 'ExampleDimensions' ]
314+ } ,
315+ {
316+ path : [ 'credentialSubject' , 'outer' , 0 , 0 , 'inner' , 0 , 0 ] ,
317+ values : [ 0 ]
318+ } ,
319+ {
320+ path : [ 'credentialSubject' , 'outer' , 0 , 0 , 'inner' , 0 , 1 ] ,
321+ values : [ 1 ]
322+ } ,
323+ {
324+ path : [ 'credentialSubject' , 'outer' , 0 , 0 , 'inner' , 1 , 0 ] ,
325+ values : [ 2 ]
326+ } ,
327+ {
328+ path : [ 'credentialSubject' , 'outer' , 0 , 0 , 'inner' , 1 , 1 ] ,
329+ values : [ 3 ]
330+ } ,
331+ {
332+ path : [ 'credentialSubject' , 'outer' , 1 , 0 , 'inner' , 0 , 0 ] ,
333+ values : [ 4 ]
334+ } ,
335+ {
336+ path : [ 'credentialSubject' , 'outer' , 1 , 0 , 'inner' , 0 , 1 ] ,
337+ values : [ 5 ]
338+ } ,
339+ {
340+ path : [ 'credentialSubject' , 'outer' , 1 , 0 , 'inner' , 1 , 0 ] ,
341+ values : [ 6 ]
342+ } ,
343+ {
344+ path : [ 'credentialSubject' , 'outer' , 1 , 0 , 'inner' , 1 , 1 ] ,
345+ values : [ 7 ]
346+ }
347+ ] ) ;
348+ } ) ;
136349} ) ;
0 commit comments