Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events: support any kind of objectSpec #342

Open
tpluscode opened this issue Apr 14, 2022 · 0 comments
Open

Events: support any kind of objectSpec #342

tpluscode opened this issue Apr 14, 2022 · 0 comments
Labels
good first issue Good for newcomers

Comments

@tpluscode
Copy link
Member

Right now only types are matched to find event handler to execute.

Here's an improved query which could be used to find handlers which can support any kind of eventSpec and only find such handlers which satisfy all conditions

PREFIX as: <https://www.w3.org/ns/activitystreams#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX hydra: <http://www.w3.org/ns/hydra/core#>
prefix event: <https://hypermedia.app/events#>
prefix code: <https://code.described.at/>

DESCRIBE ?handler
WHERE {
    {
        select ?handler (count(?spec) as ?allSpecs) (count(?match) as ?matchedSpecs) {
            VALUES ?activity { as:Activity as:Create }
            BIND (<https://creta-todos.lndo.site/todos/item/Ride%20Corbet%27s%20couloir> as ?object)

            ?handler a event:EventHandler ;
                event:eventSpec
                    [
                        rdf:predicate rdf:type ;
                        rdf:object ?activity
                    ] ;
                event:objectSpec ?spec ;
                code:implementedBy ?impl ;
                hydra:apiDocumentation <https://creta-todos.lndo.site/todos/api> .

            optional {
                ?spec rdf:predicate ?p ;
                    rdf:object ?o .
                ?object ?p ?o .
                BIND(?spec as ?match)
            }
        }
        group by ?handler
        having (count(?spec) = count(?match))
    }
}

Thus, if a handler was defined as

<>
  events:objectSpec
    [
      rdf:predicate rdf:type ;
      rdf:object </api/TodoItem> ;
    ],
    [
      rdf:predicate schema:status ;
      rdf:object "IN PROGRESS" ; 
    ] .

it would only execute when the resource above was

<https://creta-todos.lndo.site/todos/item/Ride%20Corbet%27s%20couloir>
  a </api/TodoItem> ;
  schema:status "IN PROGRESS" ;
.
@tpluscode tpluscode added the good first issue Good for newcomers label Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant