Support checked keyed relationships across portable operations and queries

This commit is contained in:
Timothy J. Aveni
2026-09-25 12:02:05 -07:00
parent e0e8563224
commit 1bc3c69de3
23 changed files with 1203 additions and 949 deletions
+8 -1
View File
@@ -1,3 +1,6 @@
import interface PresentationStates;
import interface ReaderNavigation;
external atom ReaderNavigationRecord id "reader-navigation-record";
import interface PresentationState;
import interface PresentationMount;
import interface StateFactory;
@@ -12,7 +15,7 @@ package PresentationRuntime id "presentation-runtime" revision "presentation-run
interface metadata id "state" : PresentationState using [presentationMount.resolve,parent.resolve] from input;
};
operation ensure<object Navigation implements PresentationState> id "presentation-runtime:ensure" : record {presentationMount:interface-ref<PresentationMount>;occurrence:string;parent:optional<interface-ref<PresentationState>>;} -> ref<Navigation> mode call execution transaction targets [browser,server] receiver any requires {
edge states id "states" : many-unique object Navigation [resolve,connect];
edge states id "states" : many-unique object Navigation keyed "string" [resolve,connect];
interface metadata id "state" : PresentationState using [occurrence.get,presentationMount.resolve,parent.resolve] from input;
interface presentationMount id "presentationMount" : PresentationMount using [attach.call] from input;
interface factory id "factory" : StateFactory<Navigation> using [create.call];
@@ -20,4 +23,8 @@ package PresentationRuntime id "presentation-runtime" revision "presentation-run
function createState<object Navigation> id "presentation-runtime:create-state" : record {occurrence:string;parent:optional<interface-ref<PresentationState>>;} -> ref<Navigation> execution transaction targets [browser,server] requires {
creation navigation id "navigation" : Navigation input record {occurrence:string;parent:optional<interface-ref<PresentationState>>;};
};
query ReaderStateInputs id "reader-state:inputs" root PresentationStates<atom ReaderNavigationRecord> document "queries/reader-inputs.graphql" operation "ReaderState" { replica; view ReaderNavigationRecord as ReaderNavigation; max rows 100; }
query ReaderStateView id "reader-state:view" root PresentationStates<atom ReaderNavigationRecord> document "queries/reader-state.graphql" operation "ReaderState" { local from ReaderStateInputs; watch; view ReaderNavigationRecord as ReaderNavigation; max rows 100; }
query ReaderWindowInputs id "reader-state:window-inputs" root PresentationStates<atom ReaderNavigationRecord> document "queries/reader-window.graphql" operation "ReaderState" { replica; view ReaderNavigationRecord as ReaderNavigation; max rows 100; }
query ReaderWindowView id "reader-state:window-view" root PresentationStates<atom ReaderNavigationRecord> document "queries/reader-window.graphql" operation "ReaderState" { local from ReaderWindowInputs; watch; view ReaderNavigationRecord as ReaderNavigation; max rows 100; }
}
+1 -1
View File
@@ -1,7 +1,7 @@
import interface PresentationState;
import interface PresentationMount;
interface PresentationStates<object Navigation implements PresentationState> id "presentation-states" revision "presentation-states@1" {
queryable relation states id "presentation-states:states" : many-unique object Navigation {
queryable relation states id "presentation-states:states" : many-unique object Navigation keyed "string" {
resolve id "presentation-states:states:resolve" execution snapshot targets [browser,server];
}
operation ensure id "presentation-states:ensure" : record {presentationMount:interface-ref<PresentationMount>;occurrence:string;parent:optional<interface-ref<PresentationState>>;} -> ref<Navigation> {
@@ -0,0 +1,7 @@
query ReaderState {
root {
states(all: 100) {
entries { key mapKey node { _camino { ref } page } }
}
}
}
@@ -0,0 +1,7 @@
query ReaderState($key: String!) {
root {
states(all: 100, where: {_camino: {mapKey: {eq: $key}}}) {
entries { key mapKey node { _camino { ref } page } }
}
}
}
@@ -0,0 +1,7 @@
query ReaderState($key: String!) {
root {
states(first: 100, where: {_camino: {mapKey: {eq: $key}}}) {
entries { key mapKey node { _camino { ref } page } }
}
}
}
+9 -2
View File
@@ -10,6 +10,7 @@ workspace Example id "presentation-example" revision "presentation-example@1" co
import package PresentationRuntime;
atom PresentationMountRecord id "presentation-mount-record";
atom Library id "library";
atom OtherLibrary id "other-library";
atom Document id "document";
atom ReaderNavigationRecord id "reader-navigation-record";
atom DocumentNavigationRecord id "document-navigation-record";
@@ -34,8 +35,8 @@ workspace Example id "presentation-example" revision "presentation-example@1" co
}
conform<object Navigation implements PresentationState> Presentation<Navigation> as PresentationStates<Navigation> id "presentation:state-association" {
private edge States id "presentation:states-edge" {
atom Self projection states id "presentation:states-projection" many-unique;
object Navigation projection subject id "presentation:subject-projection" exactly-one;
atom Self projection states id "presentation:states-projection" many-unique keyed "string";
object Navigation projection subject id "presentation:subject-projection" optional-one;
}
bind states.resolve to edge States.states.resolve;
bind ensure.call to package PresentationRuntime.ensure<Navigation> with {
@@ -78,4 +79,10 @@ workspace Example id "presentation-example" revision "presentation-example@1" co
}
conform Library as Presentation<atom ReaderNavigationRecord> id "library:presentation" {}
conform Document as Presentation<atom DocumentNavigationRecord> id "document:presentation" {}
conform OtherLibrary as StateFactory<atom ReaderNavigationRecord> id "other-reader:factory" {
bind create.call to package PresentationRuntime.createState<atom ReaderNavigationRecord> with {
navigation to creation ReaderNavigationRecord with {PresentationState from input;};
};
}
conform OtherLibrary as Presentation<atom ReaderNavigationRecord> id "other-library:presentation" {}
}