# baseURI: http://extensionsamples.topbraid.org/multifunctions/scriptmultifunctionexample.api

@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://extensionsamples.topbraid.org/multifunctions/scriptmultifunctionexample.api#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://extensionsamples.topbraid.org/multifunctions/scriptmultifunctionexample.api>
  a owl:Ontology ;
  <http://topbraid.org/swa#defaultNamespace> "http://extensionsamples.topbraid.org/multifunctions/scriptmultifunctionexample.api#" ;
  rdfs:label "ScriptMultiFunctionExample.api.ttl" ;
  owl:imports <http://datashapes.org/dash> ;
.
ex:generateItems
  a dash:ScriptMultiFunction ;
  dash:apiStatus dash:Experimental ;
  dash:js """let results = [];

for(let i = 0; i < count; i++) {
	results.push({
		index: i,
		label: `Item ${i + 1}`
	})
}

results;""" ;
  dash:resultVariable ex:generateItems-index ;
  dash:resultVariable ex:generateItems-label ;
  rdfs:comment "A sample multi-function that takes an integer (count) and returns as many result rows/objects with an index and a label based on the current index." ;
  rdfs:label "generate items" ;
  sh:parameter ex:generateItems-count ;
.
ex:generateItems-count
  a sh:Parameter ;
  sh:path ex:count ;
  sh:datatype xsd:integer ;
  sh:description "The number of results to produce." ;
  sh:name "count" ;
.
ex:generateItems-index
  a sh:Parameter ;
  sh:path ex:index ;
  sh:datatype xsd:integer ;
  sh:description "The current index of each result, starting with 0." ;
  sh:name "index" ;
.
ex:generateItems-label
  a sh:Parameter ;
  sh:path ex:label ;
  sh:datatype xsd:string ;
  sh:description "The label such as \"Item 1\" for the first item." ;
  sh:name "label" ;
  sh:order "1"^^xsd:decimal ;
.
