@@ -275,75 +275,106 @@ export async function universityDegreesExample(): Promise<void> {
275275 const honorsLevel = new PropertyName ( [ "honors" , "level" ] ) ;
276276
277277 // Add degree completion properties with specific allowed values
278- const degreeValues = [
279- PropertyValue . newText ( "completed" ) ,
280- PropertyValue . newText ( "in_progress" ) ,
281- PropertyValue . newText ( "withdrawn" ) ,
282- ] ;
283278
284279 await hierarchies
285- . addProperty ( universityConsortium . id , new FederationProperty ( degreeBachelor ) . withAllowedValues ( degreeValues ) )
280+ . addProperty (
281+ universityConsortium . id ,
282+ new FederationProperty ( degreeBachelor ) . withAllowedValues ( [
283+ PropertyValue . newText ( "completed" ) ,
284+ PropertyValue . newText ( "in_progress" ) ,
285+ PropertyValue . newText ( "withdrawn" ) ,
286+ ] ) ,
287+ )
286288 . buildAndExecute ( hierarchies ) ;
287289
288290 await hierarchies
289- . addProperty ( universityConsortium . id , new FederationProperty ( degreeMaster ) . withAllowedValues ( degreeValues ) )
291+ . addProperty (
292+ universityConsortium . id ,
293+ new FederationProperty ( degreeMaster ) . withAllowedValues ( [
294+ PropertyValue . newText ( "completed" ) ,
295+ PropertyValue . newText ( "in_progress" ) ,
296+ PropertyValue . newText ( "withdrawn" ) ,
297+ ] ) ,
298+ )
290299 . buildAndExecute ( hierarchies ) ;
291300
292301 await hierarchies
293- . addProperty ( universityConsortium . id , new FederationProperty ( degreePhd ) . withAllowedValues ( degreeValues ) )
302+ . addProperty (
303+ universityConsortium . id ,
304+ new FederationProperty ( degreePhd ) . withAllowedValues ( [
305+ PropertyValue . newText ( "completed" ) ,
306+ PropertyValue . newText ( "in_progress" ) ,
307+ PropertyValue . newText ( "withdrawn" ) ,
308+ ] ) ,
309+ )
294310 . buildAndExecute ( hierarchies ) ;
295311
296312 // Add field of study properties (boolean - true if student studied this field)
297- const booleanValues = [
298- PropertyValue . newText ( "true" ) ,
299- PropertyValue . newText ( "false" ) ,
300- ] ;
301313
302314 await hierarchies
303- . addProperty ( universityConsortium . id , new FederationProperty ( fieldCs ) . withAllowedValues ( booleanValues ) )
315+ . addProperty (
316+ universityConsortium . id ,
317+ new FederationProperty ( fieldCs ) . withAllowedValues ( [
318+ PropertyValue . newText ( "true" ) ,
319+ PropertyValue . newText ( "false" ) ,
320+ ] ) ,
321+ )
304322 . buildAndExecute ( hierarchies ) ;
305323
306324 await hierarchies
307- . addProperty ( universityConsortium . id , new FederationProperty ( fieldEngineering ) . withAllowedValues ( booleanValues ) )
325+ . addProperty (
326+ universityConsortium . id ,
327+ new FederationProperty ( fieldEngineering ) . withAllowedValues ( [
328+ PropertyValue . newText ( "true" ) ,
329+ PropertyValue . newText ( "false" ) ,
330+ ] ) ,
331+ )
308332 . buildAndExecute ( hierarchies ) ;
309333
310334 await hierarchies
311- . addProperty ( universityConsortium . id , new FederationProperty ( fieldMathematics ) . withAllowedValues ( booleanValues ) )
335+ . addProperty (
336+ universityConsortium . id ,
337+ new FederationProperty ( fieldMathematics ) . withAllowedValues ( [
338+ PropertyValue . newText ( "true" ) ,
339+ PropertyValue . newText ( "false" ) ,
340+ ] ) ,
341+ )
312342 . buildAndExecute ( hierarchies ) ;
313343
314344 // Add GPA property with advanced numeric validation (must be between 2.0-4.0)
315- const gpaValues = [
316- PropertyValue . newNumber ( 200n ) ,
317- PropertyValue . newNumber ( 250n ) ,
318- PropertyValue . newNumber ( 300n ) ,
319- PropertyValue . newNumber ( 320n ) ,
320- PropertyValue . newNumber ( 350n ) ,
321- PropertyValue . newNumber ( 380n ) ,
322- PropertyValue . newNumber ( 400n ) , // Common GPA ranges: 2.0, 2.5, 3.0, 3.2, 3.5, 3.8, 4.0
323- ] ;
324345 await hierarchies
325- . addProperty ( universityConsortium . id , new FederationProperty ( gradeGpa ) . withAllowedValues ( gpaValues ) )
346+ . addProperty (
347+ universityConsortium . id ,
348+ new FederationProperty ( gradeGpa ) . withAllowedValues ( [
349+ PropertyValue . newNumber ( 200n ) ,
350+ PropertyValue . newNumber ( 250n ) ,
351+ PropertyValue . newNumber ( 300n ) ,
352+ PropertyValue . newNumber ( 320n ) ,
353+ PropertyValue . newNumber ( 350n ) ,
354+ PropertyValue . newNumber ( 380n ) ,
355+ PropertyValue . newNumber ( 400n ) ,
356+ ] ) ,
357+ )
326358 . buildAndExecute ( hierarchies ) ;
327359
328360 // Add graduation year with range validation (must be recent - from 1950 onwards)
329- const graduationYearValues = [
330- PropertyValue . newNumber ( 1950n ) ,
331- PropertyValue . newNumber ( 1960n ) ,
332- PropertyValue . newNumber ( 1970n ) ,
333- PropertyValue . newNumber ( 1980n ) ,
334- PropertyValue . newNumber ( 1990n ) ,
335- PropertyValue . newNumber ( 2000n ) ,
336- PropertyValue . newNumber ( 2010n ) ,
337- PropertyValue . newNumber ( 2020n ) ,
338- PropertyValue . newNumber ( 2021n ) ,
339- PropertyValue . newNumber ( 2022n ) ,
340- PropertyValue . newNumber ( 2023n ) ,
341- PropertyValue . newNumber ( 2024n ) ,
342- ] ;
343361 await hierarchies
344362 . addProperty (
345363 universityConsortium . id ,
346- new FederationProperty ( graduationYear ) . withAllowedValues ( graduationYearValues ) ,
364+ new FederationProperty ( graduationYear ) . withAllowedValues ( [
365+ PropertyValue . newNumber ( 1950n ) ,
366+ PropertyValue . newNumber ( 1960n ) ,
367+ PropertyValue . newNumber ( 1970n ) ,
368+ PropertyValue . newNumber ( 1980n ) ,
369+ PropertyValue . newNumber ( 1990n ) ,
370+ PropertyValue . newNumber ( 2000n ) ,
371+ PropertyValue . newNumber ( 2010n ) ,
372+ PropertyValue . newNumber ( 2020n ) ,
373+ PropertyValue . newNumber ( 2021n ) ,
374+ PropertyValue . newNumber ( 2022n ) ,
375+ PropertyValue . newNumber ( 2023n ) ,
376+ PropertyValue . newNumber ( 2024n ) ,
377+ ] ) ,
347378 )
348379 . buildAndExecute ( hierarchies ) ;
349380
@@ -353,19 +384,27 @@ export async function universityDegreesExample(): Promise<void> {
353384 . buildAndExecute ( hierarchies ) ;
354385
355386 // Add honors level with specific validation
356- const honorsValues = [
357- PropertyValue . newText ( "magna_cum_laude" ) ,
358- PropertyValue . newText ( "summa_cum_laude" ) ,
359- PropertyValue . newText ( "cum_laude" ) ,
360- PropertyValue . newText ( "none" ) ,
361- ] ;
362387 await hierarchies
363- . addProperty ( universityConsortium . id , new FederationProperty ( honorsLevel ) . withAllowedValues ( honorsValues ) )
388+ . addProperty (
389+ universityConsortium . id ,
390+ new FederationProperty ( honorsLevel ) . withAllowedValues ( [
391+ PropertyValue . newText ( "magna_cum_laude" ) ,
392+ PropertyValue . newText ( "summa_cum_laude" ) ,
393+ PropertyValue . newText ( "cum_laude" ) ,
394+ PropertyValue . newText ( "none" ) ,
395+ ] ) ,
396+ )
364397 . buildAndExecute ( hierarchies ) ;
365398
366399 // Add student verification status
367400 await hierarchies
368- . addProperty ( universityConsortium . id , new FederationProperty ( studentVerified ) . withAllowedValues ( booleanValues ) )
401+ . addProperty (
402+ universityConsortium . id ,
403+ new FederationProperty ( studentVerified ) . withAllowedValues ( [
404+ PropertyValue . newText ( "true" ) ,
405+ PropertyValue . newText ( "false" ) ,
406+ ] ) ,
407+ )
369408 . buildAndExecute ( hierarchies ) ;
370409
371410 console . log ( "✅ Academic properties defined with advanced validation:" ) ;
@@ -411,18 +450,17 @@ export async function universityDegreesExample(): Promise<void> {
411450
412451 // Harvard delegates accreditation rights to its CS Faculty
413452 // This allows the faculty to further delegate to registrars and professors
414- const csFacultyProperties = [
415- new FederationProperty ( degreeBachelor ) . withAllowAny ( true ) ,
416- new FederationProperty ( degreeMaster ) . withAllowAny ( true ) ,
417- new FederationProperty ( degreePhd ) . withAllowAny ( true ) ,
418- new FederationProperty ( fieldCs ) . withAllowAny ( true ) ,
419- new FederationProperty ( gradeGpa ) . withAllowAny ( true ) ,
420- new FederationProperty ( graduationYear ) . withAllowAny ( true ) ,
421- new FederationProperty ( studentVerified ) . withAllowAny ( true ) ,
422- ] ;
423453
424454 await hierarchies
425- . createAccreditationToAccredit ( universityConsortium . id , harvardCsFaculty , csFacultyProperties )
455+ . createAccreditationToAccredit ( universityConsortium . id , harvardCsFaculty , [
456+ new FederationProperty ( degreeBachelor ) . withAllowAny ( true ) ,
457+ new FederationProperty ( degreeMaster ) . withAllowAny ( true ) ,
458+ new FederationProperty ( degreePhd ) . withAllowAny ( true ) ,
459+ new FederationProperty ( fieldCs ) . withAllowAny ( true ) ,
460+ new FederationProperty ( gradeGpa ) . withAllowAny ( true ) ,
461+ new FederationProperty ( graduationYear ) . withAllowAny ( true ) ,
462+ new FederationProperty ( studentVerified ) . withAllowAny ( true ) ,
463+ ] )
426464 . buildAndExecute ( hierarchies ) ;
427465
428466 console . log ( "✅ Harvard CS Faculty granted accreditation rights:" ) ;
@@ -440,7 +478,15 @@ export async function universityDegreesExample(): Promise<void> {
440478 // CS Faculty delegates attestation rights to the CS Registrar
441479 // Registrar can now create attestations (issue degrees) but not delegate further
442480 await hierarchies
443- . createAccreditationToAttest ( universityConsortium . id , harvardCsRegistrar , csFacultyProperties )
481+ . createAccreditationToAttest ( universityConsortium . id , harvardCsRegistrar , [
482+ new FederationProperty ( degreeBachelor ) . withAllowAny ( true ) ,
483+ new FederationProperty ( degreeMaster ) . withAllowAny ( true ) ,
484+ new FederationProperty ( degreePhd ) . withAllowAny ( true ) ,
485+ new FederationProperty ( fieldCs ) . withAllowAny ( true ) ,
486+ new FederationProperty ( gradeGpa ) . withAllowAny ( true ) ,
487+ new FederationProperty ( graduationYear ) . withAllowAny ( true ) ,
488+ new FederationProperty ( studentVerified ) . withAllowAny ( true ) ,
489+ ] )
444490 . buildAndExecute ( hierarchies ) ;
445491
446492 console . log ( "✅ Harvard CS Registrar granted attestation rights:" ) ;
@@ -459,7 +505,7 @@ export async function universityDegreesExample(): Promise<void> {
459505 console . log ( "📜 Issuing Bachelor's degree in Computer Science to Alice..." ) ;
460506
461507 // Create Alice's degree attestation data with advanced property validation
462- const aliceProperties = [
508+ const aliceProperties : FederationProperty [ ] = [
463509 new FederationProperty ( degreeBachelor ) . withAllowedValues ( [ PropertyValue . newText ( "completed" ) ] ) ,
464510 new FederationProperty ( fieldCs ) . withAllowedValues ( [ PropertyValue . newText ( "true" ) ] ) ,
465511 new FederationProperty ( gradeGpa ) . withAllowedValues ( [ PropertyValue . newNumber ( 385n ) ] ) , // 3.85 GPA (stored as 385 for precision)
@@ -505,7 +551,7 @@ export async function universityDegreesExample(): Promise<void> {
505551
506552 console . log ( "\n📜 Issuing Master's degree in Computer Science to Bob..." ) ;
507553
508- const bobProperties = [
554+ const bobProperties : FederationProperty [ ] = [
509555 new FederationProperty ( degreeMaster ) . withAllowedValues ( [ PropertyValue . newText ( "completed" ) ] ) ,
510556 new FederationProperty ( fieldCs ) . withAllowedValues ( [ PropertyValue . newText ( "true" ) ] ) ,
511557 new FederationProperty ( gradeGpa ) . withAllowedValues ( [ PropertyValue . newNumber ( 392n ) ] ) , // 3.92 GPA (stored as 392 for precision)
0 commit comments