workspace AsyncObjects id "workspace:async" revision "workspace:async@1" commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" { import interface DocumentData; import interface SummaryController; import interface Summarizer; import package ControllerRuntime; import package ProviderRuntime; atom Document id "async:document"; atom Provider id "async:provider"; conform Document as DocumentData id "async:document:data" { private state Content id "async:state:content" on Document : string policy register; private state Summary id "async:state:summary" on Document : record { text: string; basedOn: string; } policy register default { "text": "", "basedOn": "" }; private state PendingJob id "async:state:pending-job" on Document : optional policy register default null; private edge ProviderLink id "async:provider-link" { atom Document projection provider id "async:provider-projection" exactly-one public-traversal; atom Provider projection documents id "async:documents-projection" many-unique; } initialize { content to state Content; provider to edge ProviderLink.provider; }; bind content.get to state Content.read; bind summary.get to state Summary.read; bind summary.set to state Summary.write; bind pendingJob.get to state PendingJob.read; bind pendingJob.set to state PendingJob.write; bind recordSummary.call to package ControllerRuntime.finish with { job to state PendingJob; summary to state Summary; }; } conform Document as SummaryController id "async:document:controller" { bind refresh.call to package ControllerRuntime.refresh with { document to interface DocumentData; provider to interface Summarizer via edge ProviderLink.provider; }; bind processPending.call to package ControllerRuntime.runPending with { document to interface DocumentData; provider to interface Summarizer via edge ProviderLink.provider; }; } conform Provider as Summarizer id "async:provider:summarizer" { bind summarize.call to package ProviderRuntime.summarize; } }