@@ -3,7 +3,7 @@ import type {
33 Authorization ,
44 AuthorizationError ,
55 Await ,
6- Cause ,
6+ CauseString ,
77 Clock ,
88 Command ,
99 ConnectionError ,
@@ -14,14 +14,14 @@ import type {
1414 ConsumerResultFor ,
1515 DID ,
1616 EnhancedCommit ,
17- Entity ,
1817 Fact ,
1918 FactSelection ,
2019 InferOf ,
2120 Invocation ,
2221 InvocationURL ,
2322 JSONValue ,
2423 MemorySpace ,
24+ MIME ,
2525 OfTheCause ,
2626 Proto ,
2727 Protocol ,
@@ -39,13 +39,14 @@ import type {
3939 SchemaSelector ,
4040 Seconds ,
4141 Select ,
42+ SelectAll ,
4243 Selection ,
4344 Selector ,
4445 Signer ,
45- The ,
4646 Transaction ,
4747 TransactionResult ,
4848 UCAN ,
49+ URI ,
4950 UTCUnixTimestampInSeconds ,
5051} from "./interface.ts" ;
5152import { fromJSON , refer } from "./reference.ts" ;
@@ -367,18 +368,22 @@ class MemorySpaceConsumerSession<Space extends MemorySpace>
367368 }
368369
369370 private static asSelectSchema ( queryArg : QueryArgs ) : SchemaQueryArgs {
370- const selectSchema : OfTheCause < SchemaPathSelector > = { } ;
371+ const selectSchema : Select <
372+ URI ,
373+ Select < MIME , Select < CauseString , SchemaPathSelector > >
374+ > = { } ;
371375 for ( const [ of , attributes ] of Object . entries ( queryArg . select ) ) {
372- const entityEntry : Select < The , Select < Cause , SchemaPathSelector > > = { } ;
373- selectSchema [ of as Entity ] = entityEntry ;
376+ const entityEntry : Select < MIME , Select < CauseString , SchemaPathSelector > > =
377+ { } ;
378+ selectSchema [ of as URI | SelectAll ] = entityEntry ;
374379 let attrEntries = Object . entries ( attributes ) ;
375380 // A Selector may not have a "the", but SchemaSelector needs all three levels
376381 if ( attrEntries . length === 0 ) {
377382 attrEntries = [ [ "_" , { } ] ] ;
378383 }
379384 for ( const [ the , causes ] of attrEntries ) {
380- const attributeEntry : Select < Cause , SchemaPathSelector > = { } ;
381- entityEntry [ the ] = attributeEntry ;
385+ const attributeEntry : Select < CauseString , SchemaPathSelector > = { } ;
386+ entityEntry [ the as MIME | SelectAll ] = attributeEntry ;
382387 // A Selector may not have a cause, but SchemaSelector needs all three levels
383388 let causeEntries = Object . entries ( causes ) ;
384389 if ( causeEntries . length === 0 ) {
@@ -390,7 +395,7 @@ class MemorySpaceConsumerSession<Space extends MemorySpace>
390395 schemaContext : SchemaNone ,
391396 ...selector . is ? { is : selector . is } : { } ,
392397 } ;
393- attributeEntry [ cause ] = causeEntry ;
398+ attributeEntry [ cause as CauseString | SelectAll ] = causeEntry ;
394399 }
395400 }
396401 }
@@ -412,7 +417,7 @@ interface Job<Ability, Protocol extends Proto> {
412417 perform ( effect : ConsumerEffectFor < Ability , Protocol > ) : void ;
413418}
414419
415- class ConsumerInvocation < Ability extends The , Protocol extends Proto > {
420+ class ConsumerInvocation < Ability extends string , Protocol extends Proto > {
416421 promise : Promise < ConsumerResultFor < Ability , Protocol > > ;
417422
418423 return : ( input : ConsumerResultFor < Ability , Protocol > ) => boolean ;
@@ -421,7 +426,7 @@ class ConsumerInvocation<Ability extends The, Protocol extends Proto> {
421426
422427 #reference: Reference < Invocation > ;
423428
424- static create < Ability extends The , Protocol extends Proto > (
429+ static create < Ability extends string , Protocol extends Proto > (
425430 as : DID ,
426431 { cmd, sub, args, nonce } : Command < Ability , InferOf < Protocol > > ,
427432 time : UTCUnixTimestampInSeconds ,
@@ -605,7 +610,7 @@ class QuerySubscriptionInvocation<
605610 controller :
606611 | undefined
607612 | ReadableStreamDefaultController < EnhancedCommit < Space > > ;
608- patterns : { the ?: The ; of ?: Entity ; cause ?: Cause } [ ] ;
613+ patterns : { the ?: MIME ; of ?: URI ; cause ?: CauseString } [ ] ;
609614
610615 selection : Selection < Space > ;
611616 constructor ( public query : QueryView < Space , MemoryProtocol > ) {
@@ -654,7 +659,7 @@ class QuerySubscriptionInvocation<
654659 const fact = toRevision ( commit . commit ) ;
655660
656661 const { the, of, is } = fact ;
657- const cause = fact . cause . toString ( ) ;
662+ const cause = fact . cause . toString ( ) as CauseString ;
658663 const { transaction, since } = is ;
659664 const matchCommit = this . patterns . some ( ( pattern ) =>
660665 ( ! pattern . of || pattern . of === of ) &&
@@ -666,8 +671,10 @@ class QuerySubscriptionInvocation<
666671 // Update the main application/commit+json record for the space
667672 setRevision ( differential , of , the , cause , { is, since } ) ;
668673 }
669- for ( const [ of , attributes ] of Object . entries ( transaction . args . changes ) ) {
670- for ( const [ the , changes ] of Object . entries ( attributes ) ) {
674+ for ( const [ k1 , attributes ] of Object . entries ( transaction . args . changes ) ) {
675+ const of = k1 as URI ;
676+ for ( const [ k2 , changes ] of Object . entries ( attributes ) ) {
677+ const the = k2 as MIME ;
671678 const causeEntries = Object . entries ( changes ) ;
672679 if ( causeEntries . length === 0 ) {
673680 // A classified object will not have a cause/change pair
@@ -676,13 +683,14 @@ class QuerySubscriptionInvocation<
676683 ( ! pattern . the || pattern . the === the ) && ! pattern . cause
677684 ) ;
678685 if ( matchDoc ) {
679- setEmptyObj ( differential , of as Entity , the ) ;
686+ setEmptyObj ( differential , of , the ) ;
680687 }
681688 } else {
682- const [ [ cause , change ] ] = causeEntries ;
689+ const [ [ k3 , change ] ] = causeEntries ;
690+ const cause = k3 as CauseString ;
683691 if ( change !== true ) {
684692 const state = Object . entries (
685- selection ?. [ of as Entity ] ?. [ the ] ?? { } ,
693+ selection ?. [ of ] ?. [ the ] ?? { } ,
686694 ) ;
687695 const [ current ] = state . length > 0 ? state [ 0 ] : [ ] ;
688696 if ( cause !== current ) {
@@ -696,7 +704,7 @@ class QuerySubscriptionInvocation<
696704 const value = change . is
697705 ? { is : change . is , since : since }
698706 : { since : since } ;
699- setRevision ( differential , of as Entity , the , cause , value ) ;
707+ setRevision ( differential , of , the , cause , value ) ;
700708 }
701709 }
702710 }
0 commit comments