-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.js
49 lines (43 loc) · 1.71 KB
/
tasks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {sparqlEscapeUri} from 'mu';
import {updateSudo as update} from '@lblod/mu-auth-sudo';
import {v4 as uuid} from 'uuid';
export async function sendSavedOrderTask(orderId) {
const query = `
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
INSERT DATA { GRAPH <http://mu.semte.ch/graphs/tasks> {
<http://mu.semte.ch/graphs/tasks#${uuid()}> a ext:Task;
ext:taskType ext:SavedOrderTask;
ext:dataFlow ext:DbToPod;
ext:order ${sparqlEscapeUri(orderId)};
ext:taskStatus "pending";
ext:taskCreatedAt "${new Date().toISOString()}".
} }`;
return update(query);
}
export async function sendUpdatedOrderTask(orderId) {
const query = `
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
INSERT DATA { GRAPH <http://mu.semte.ch/graphs/tasks> {
<http://mu.semte.ch/graphs/tasks#${uuid()}> a ext:Task;
ext:taskType ext:UpdatedOrderTask;
ext:dataFlow ext:DbToPod;
ext:order ${sparqlEscapeUri(orderId)};
ext:taskStatus "pending";
ext:taskCreatedAt "${new Date().toISOString()}".
} }`;
return update(query);
}
export async function sendSyncOfferingsTask(webId, pod) {
const query = `
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
INSERT DATA { GRAPH <http://mu.semte.ch/graphs/tasks> {
<http://mu.semte.ch/graphs/tasks#${uuid()}> a ext:Task;
ext:taskType ext:SyncOfferingsTask;
ext:dataFlow ext:PodToDb;
ext:webId ${sparqlEscapeUri(webId)};
ext:pod ${sparqlEscapeUri(pod)};
ext:taskStatus "pending";
ext:taskCreatedAt "${new Date().toISOString()}".
} }`;
return update(query);
}