prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add inference benchmark for permission-sets

authored by

JP Hastings-Spital and committed by
Tyler Lawson
e3f2cc1f 1ee27c6e

+114
+114
packages/prototypey/core/tests/infer.bench.ts
··· 326 326 }); 327 327 return schema["~infer"]; 328 328 }).types([513, "instantiations"]); 329 + 330 + bench("infer with simple permission set", () => { 331 + const schema = lx.lexicon("com.example.authCore", { 332 + main: lx.permissionSet({ 333 + title: "Core functionality", 334 + detail: "Grants core access", 335 + permissions: [ 336 + lx.repoPermission({ 337 + collection: ["com.example.post"], 338 + action: ["create", "update"], 339 + }), 340 + ], 341 + }), 342 + }); 343 + return schema["~infer"]; 344 + }).types([271, "instantiations"]); 345 + 346 + bench("infer with complex permission set", () => { 347 + const schema = lx.lexicon("com.example.fullPerms", { 348 + main: lx.permissionSet({ 349 + title: "Full permissions", 350 + detail: "All permission types", 351 + permissions: [ 352 + lx.repoPermission({ 353 + collection: ["com.example.post", "com.example.like"], 354 + action: ["create", "update", "delete"], 355 + }), 356 + lx.rpcPermission({ 357 + lxm: ["com.example.doThing"], 358 + aud: "did:web:example.com", 359 + }), 360 + lx.blobPermission({ 361 + accept: ["image/*", "video/mp4"], 362 + }), 363 + lx.accountPermission({ 364 + attr: "email", 365 + action: "read", 366 + }), 367 + lx.identityPermission({ 368 + attr: "handle", 369 + }), 370 + ], 371 + }), 372 + }); 373 + return schema["~infer"]; 374 + }).types([277, "instantiations"]); 375 + 376 + bench("fromJSON infer with simple permission set", () => { 377 + const schema = fromJSON({ 378 + id: "com.example.authCore", 379 + defs: { 380 + main: { 381 + type: "permission-set", 382 + key: "literal:self", 383 + title: "Core functionality", 384 + detail: "Grants core access", 385 + permissions: [ 386 + { 387 + type: "permission", 388 + resource: "repo", 389 + collection: ["com.example.post"], 390 + action: ["create", "update"], 391 + }, 392 + ], 393 + }, 394 + }, 395 + }); 396 + return schema["~infer"]; 397 + }).types([288, "instantiations"]); 398 + 399 + bench("fromJSON infer with complex permission set", () => { 400 + const schema = fromJSON({ 401 + id: "com.example.fullPerms", 402 + defs: { 403 + main: { 404 + type: "permission-set", 405 + key: "literal:self", 406 + title: "Full permissions", 407 + detail: "All permission types", 408 + permissions: [ 409 + { 410 + type: "permission", 411 + resource: "repo", 412 + collection: ["com.example.post", "com.example.like"], 413 + action: ["create", "update", "delete"], 414 + }, 415 + { 416 + type: "permission", 417 + resource: "rpc", 418 + lxm: ["com.example.doThing"], 419 + aud: "did:web:example.com", 420 + }, 421 + { 422 + type: "permission", 423 + resource: "blob", 424 + accept: ["image/*", "video/mp4"], 425 + }, 426 + { 427 + type: "permission", 428 + resource: "account", 429 + attr: "email", 430 + action: "read", 431 + }, 432 + { 433 + type: "permission", 434 + resource: "identity", 435 + attr: "handle", 436 + }, 437 + ], 438 + }, 439 + }, 440 + }); 441 + return schema["~infer"]; 442 + }).types([336, "instantiations"]);