Acquire installed portable operations with explicit authority and input coverage
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
external atom Comment id "atom:reader:comment";
|
||||
interface CommentFactory id "interface:reader:comment-factory"
|
||||
revision "interface:reader:comment-factory@1" {
|
||||
operation prepareComment id "document:prepare-comment" : bool -> atom-ref<Comment> {
|
||||
call id "document:prepare-comment:call" execution transaction targets [browser, server];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
external atom Document id "atom:reader:document";
|
||||
external atom Comment id "atom:reader:comment";
|
||||
import interface CommentData;
|
||||
type CommentSeed = record { content: record { text: string; tags: list<string>; }; };
|
||||
package CommentRuntime id "package:comment-runtime" revision "package:comment-runtime@1" {
|
||||
operation prepareComment id "comment:prepare"
|
||||
: bool -> atom-ref<Comment> mode call execution transaction targets [browser, server]
|
||||
receiver atom Document requires {
|
||||
creation comment id "comment:prepare:comment" : Comment input CommentSeed;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Shared record definitions, repeated explicitly in independently locked resources.
|
||||
external atom Document id "atom:reader:document";
|
||||
external atom Highlight id "atom:reader:highlight";
|
||||
external atom Comment id "atom:reader:comment";
|
||||
|
||||
type SourceRange = record {
|
||||
sourceRevision: string;
|
||||
start: int32;
|
||||
end: int32;
|
||||
};
|
||||
|
||||
type CommentContent = record {
|
||||
text: string;
|
||||
tags: list<string>;
|
||||
};
|
||||
|
||||
type DocumentSeed = record { document: record { sourceRevision: string; content: string; }; metadata: record { label: string; }; };
|
||||
|
||||
interface DocumentFactory id "interface:reader:document-factory"
|
||||
revision "interface:reader:document-factory@1" {
|
||||
static operation create id "document:create" : DocumentSeed -> atom-ref<Document> {
|
||||
call id "document:create:call"
|
||||
execution transaction targets [browser, server];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
interface DocumentMetadata id "interface:reader:document-metadata"
|
||||
revision "interface:reader:document-metadata@1" {
|
||||
queryable value label id "document:label" : string {
|
||||
get id "document:label:get" execution snapshot targets [browser, server];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// Shared record definitions, repeated explicitly in independently locked resources.
|
||||
external atom Document id "atom:reader:document";
|
||||
external atom Highlight id "atom:reader:highlight";
|
||||
external atom Comment id "atom:reader:comment";
|
||||
|
||||
type SourceRange = record {
|
||||
sourceRevision: string;
|
||||
start: int32;
|
||||
end: int32;
|
||||
};
|
||||
|
||||
type CommentContent = record {
|
||||
text: string;
|
||||
tags: list<string>;
|
||||
};
|
||||
|
||||
type DocumentSeed = record { document: record { sourceRevision: string; content: string; }; metadata: record { label: string; }; };
|
||||
|
||||
import interface DocumentData;
|
||||
import interface CommentFactory;
|
||||
import interface HighlightData;
|
||||
import interface CommentData;
|
||||
type CommentSeed = record { content: CommentContent; };
|
||||
type HighlightSeed = record {
|
||||
range: SourceRange;
|
||||
comments: list<record { key: string; target: atom-ref<Comment>; }>;
|
||||
};
|
||||
|
||||
package ReaderRuntime id "package:reader-runtime"
|
||||
revision "package:reader-runtime@1" {
|
||||
operation addHighlight id "reader:add-highlight"
|
||||
: SourceRange -> atom-ref<Highlight>
|
||||
mode call execution transaction targets [browser, server]
|
||||
receiver atom Document requires {
|
||||
interface document id "reader:add:document" : DocumentData
|
||||
using [sourceRevision.get, content.get, highlights.connect];
|
||||
creation highlight id "reader:add:highlight" : Highlight input HighlightSeed;
|
||||
interface comments id "reader:add:comments" : CommentFactory using [prepareComment.call];
|
||||
};
|
||||
|
||||
operation excerpt id "reader:excerpt" : unit -> string
|
||||
mode call execution snapshot targets [browser, server]
|
||||
receiver atom Highlight requires {
|
||||
state range id "reader:excerpt:range" : SourceRange [read];
|
||||
interface document id "reader:excerpt:document" : DocumentData
|
||||
using [sourceRevision.get, content.get];
|
||||
};
|
||||
|
||||
// A receiverless function needs no synthetic service object.
|
||||
function validateRange id "reader:validate-range"
|
||||
: record { range: SourceRange; content: string; } -> bool
|
||||
execution snapshot targets [browser, server];
|
||||
|
||||
function createDocument id "reader:create-document"
|
||||
: DocumentSeed -> atom-ref<Document>
|
||||
execution transaction targets [browser, server] requires {
|
||||
creation document id "reader:create:document" : Document input DocumentSeed;
|
||||
};
|
||||
query ReplicaInputs id "reader:replica-inputs" root DocumentData
|
||||
document "queries/replica-inputs.graphql" operation "ReplicaInputs" {
|
||||
replica;
|
||||
view Highlight as HighlightData;
|
||||
view Comment as CommentData;
|
||||
max rows 5000;
|
||||
max depth 8;
|
||||
max result-bytes 8388608;
|
||||
}
|
||||
|
||||
query ReaderScreen id "reader:screen" root DocumentData
|
||||
document "queries/reader-screen.graphql" operation "ReaderScreen" {
|
||||
local from ReplicaInputs;
|
||||
view Highlight as HighlightData;
|
||||
view Comment as CommentData;
|
||||
max rows 5000;
|
||||
max depth 8;
|
||||
max result-bytes 8388608;
|
||||
watch;
|
||||
}
|
||||
|
||||
query HighlightScope id "reader:highlight-scope" root workspace HighlightData document "queries/highlight-scope.graphql" operation "HighlightScope" { view Comment as CommentData; replica; max rows 200; }
|
||||
query HighlightList id "reader:highlight-list" root workspace HighlightData document "queries/highlight-list.graphql" operation "HighlightList" { view Comment as CommentData; local from HighlightScope; max rows 200; watch; }
|
||||
query HighlightEditorInputs id "reader:editor-inputs" root HighlightData document "queries/editor-inputs.graphql" operation "HighlightEditorInputs" { view Comment as CommentData; replica; max rows 1; }
|
||||
query HighlightEditorView id "reader:editor-view" root HighlightData document "queries/editor-view.graphql" operation "HighlightEditorView" { view Comment as CommentData; local from HighlightEditorInputs; max rows 1; watch; }
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
workspace Reader id "workspace:reader" revision "workspace:reader@1" commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" {
|
||||
import interface DocumentData;
|
||||
import interface HighlightData;
|
||||
import interface CommentData;
|
||||
import interface DocumentActions;
|
||||
import interface DocumentFactory;
|
||||
import package ReaderRuntime;
|
||||
import package CommentRuntime;
|
||||
import interface DocumentMetadata;
|
||||
import interface CommentFactory;
|
||||
// Shared record definitions, repeated explicitly in independently locked resources.
|
||||
|
||||
type SourceRange = record {
|
||||
sourceRevision: string;
|
||||
start: int32;
|
||||
end: int32;
|
||||
};
|
||||
|
||||
type CommentContent = record {
|
||||
text: string;
|
||||
tags: list<string>;
|
||||
};
|
||||
|
||||
type DocumentSeed = record { sourceRevision: string; content: string; };
|
||||
|
||||
atom Document id "atom:reader:document";
|
||||
atom Highlight id "atom:reader:highlight";
|
||||
atom Comment id "atom:reader:comment";
|
||||
|
||||
conform Document as DocumentData id "conformance:reader:document-data" {
|
||||
private state Revision id "slot:document:revision"
|
||||
on Document : string policy register;
|
||||
private state Content id "slot:document:content"
|
||||
on Document : string policy register;
|
||||
private edge DocumentHighlights id "edge:document-highlights" {
|
||||
atom Document projection highlights id "projection:highlights" many-unique;
|
||||
atom Highlight projection document id "projection:document"
|
||||
exactly-one public-traversal;
|
||||
}
|
||||
initialize {
|
||||
sourceRevision to state Revision;
|
||||
content to state Content;
|
||||
};
|
||||
bind sourceRevision.get to state Revision.read;
|
||||
bind content.get to state Content.read;
|
||||
bind highlights.resolve to edge DocumentHighlights.highlights.resolve;
|
||||
bind highlights.connect to edge DocumentHighlights.highlights.connect;
|
||||
}
|
||||
|
||||
conform Document as DocumentActions id "conformance:reader:document-actions" {
|
||||
|
||||
bind annotate.call to package ReaderRuntime.addHighlight with {
|
||||
document to interface DocumentData;
|
||||
highlight to creation Highlight with { HighlightData from input; };
|
||||
comments to interface CommentFactory;
|
||||
};
|
||||
}
|
||||
|
||||
conform Document as CommentFactory id "conformance:reader:comment-factory" {
|
||||
bind prepareComment.call to package CommentRuntime.prepareComment with {
|
||||
comment to creation Comment with { CommentData from input; };
|
||||
};
|
||||
}
|
||||
|
||||
conform Document as DocumentMetadata id "conformance:reader:document-metadata" {
|
||||
private state Label id "slot:document:label" on Document : string policy register;
|
||||
initialize { label to state Label; };
|
||||
bind label.get to state Label.read;
|
||||
}
|
||||
|
||||
conform Document as DocumentFactory id "conformance:reader:document-factory" {
|
||||
bind create.call to package ReaderRuntime.createDocument with {
|
||||
document to creation Document with { DocumentData from input.document; DocumentMetadata from input.metadata; };
|
||||
};
|
||||
}
|
||||
|
||||
conform Highlight as HighlightData id "conformance:reader:highlight-data" {
|
||||
private state Range id "slot:highlight:range"
|
||||
on Highlight : SourceRange policy register;
|
||||
private state Color id "slot:highlight:color"
|
||||
on Highlight : string policy register default "yellow";
|
||||
private edge HighlightComments id "edge:highlight-comments" {
|
||||
atom Highlight projection comments id "projection:comments" many-unique;
|
||||
atom Comment projection highlight id "projection:highlight"
|
||||
exactly-one public-traversal;
|
||||
}
|
||||
initialize {
|
||||
range to state Range;
|
||||
comments to edge HighlightComments.comments;
|
||||
};
|
||||
bind range.get to state Range.read;
|
||||
bind color.get to state Color.read;
|
||||
bind color.set to state Color.write;
|
||||
bind comments.resolve to edge HighlightComments.comments.resolve;
|
||||
bind excerpt.get to package ReaderRuntime.excerpt with {
|
||||
range to state Range;
|
||||
document to interface DocumentData via edge DocumentHighlights.document;
|
||||
};
|
||||
}
|
||||
|
||||
conform Comment as CommentData id "conformance:reader:comment-data" {
|
||||
private state CommentBody id "slot:comment:content"
|
||||
on Comment : CommentContent policy crdt(CommentContent);
|
||||
initialize { content to state CommentBody; };
|
||||
bind content.get to state CommentBody.read;
|
||||
bind content.edit to state CommentBody.edit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user