Skip to content

Commit 91f122d

Browse files
committed
latest updates
1 parent 7fc0ded commit 91f122d

18 files changed

+1059
-522
lines changed

Validator/component.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,54 @@
1616
"metadata": {
1717
"out": {}
1818
}
19+
},
20+
"validateTask": {
21+
"main": "./lib/actions/validateTask.js",
22+
"description": "Validate incoming Task object against master data model",
23+
"title": "Collaboration Model - Validate Task",
24+
"metadata": {
25+
"out": {}
26+
}
27+
},
28+
"validateEmail": {
29+
"main": "./lib/actions/validateEmail.js",
30+
"description": "Validate incoming Email object against master data model",
31+
"title": "Collaboration Model - Validate Email",
32+
"metadata": {
33+
"out": {}
34+
}
35+
},
36+
"validateCalendarevent": {
37+
"main": "./lib/actions/validateCalendarEvent.js",
38+
"description": "Validate incoming Calendarevent object against master data model",
39+
"title": "Collaboration Model - Validate Calendarevent",
40+
"metadata": {
41+
"out": {}
42+
}
43+
},
44+
"validateRelation": {
45+
"main": "./lib/actions/validateRelation.js",
46+
"description": "Validate incoming document relation object against master data model",
47+
"title": "Document Model - Validate Relation",
48+
"metadata": {
49+
"out": {}
50+
}
51+
},
52+
"validateFolder": {
53+
"main": "./lib/actions/validateFolder.js",
54+
"description": "Validate incoming folder object against master data model",
55+
"title": "Document Model - Validate Folder",
56+
"metadata": {
57+
"out": {}
58+
}
59+
},
60+
"validateDocument": {
61+
"main": "./lib/actions/validateDocument.js",
62+
"description": "Validate incoming document object against master data model",
63+
"title": "Document Model - Validate Document",
64+
"metadata": {
65+
"out": {}
66+
}
1967
}
2068
}
2169
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright 2018 Cloud Ecosystem e.V.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
"use strict";
18+
const eioUtils = require('elasticio-node').messages;
19+
const request = require('request-promise');
20+
const Ajv = require('ajv');
21+
const document = require('../schemas/documents/document.json');
22+
const object = require('../schemas/documents/object.json');
23+
const sharedDef = require('../schemas/documents/sharedDefinitions.json');
24+
const record = require('../schemas/oih-data-record.json');
25+
26+
27+
/**
28+
* Executes the action's logic by sending a request to the Petstore API and emitting response to the platform.
29+
* The function returns a Promise sending a request and resolving the response as platform message.
30+
*
31+
* @param msg incoming messages which is empty for triggers
32+
* @param cfg object to retrieve triggers configuration values, such as apiKey and pet status
33+
* @returns promise resolving a message to be emitted to the platform
34+
*/
35+
async function processAction(msg, cfg) {
36+
37+
try{
38+
let ajv = new Ajv();
39+
let validate = ajv.addSchema(object).addSchema(record).addSchema(sharedDef).compile(document);
40+
let valid = validate(msg.body);
41+
42+
if (valid) {
43+
console.log(`FLAG 1`);
44+
console.log('Validation successful');
45+
return eioUtils.newMessageWithBody(msg.body);
46+
} else {
47+
console.log(`FLAG 2`);
48+
console.log(JSON.stringify(validate.errors));
49+
throw new Error(JSON.stringify(validate.errors));
50+
}
51+
52+
} catch (e) {
53+
throw new Error(e);
54+
}
55+
}
56+
57+
module.exports.process = processAction;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright 2018 Cloud Ecosystem e.V.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
"use strict";
18+
const eioUtils = require('elasticio-node').messages;
19+
const request = require('request-promise');
20+
const Ajv = require('ajv');
21+
const folder = require('../schemas/documents/folder.json');
22+
const object = require('../schemas/documents/object.json');
23+
const record = require('../schemas/oih-data-record.json');
24+
const sharedDefinitions = require('../schemas/documents/sharedDefinitions.json');
25+
26+
27+
/**
28+
* Executes the action's logic by sending a request to the Petstore API and emitting response to the platform.
29+
* The function returns a Promise sending a request and resolving the response as platform message.
30+
*
31+
* @param msg incoming messages which is empty for triggers
32+
* @param cfg object to retrieve triggers configuration values, such as apiKey and pet status
33+
* @returns promise resolving a message to be emitted to the platform
34+
*/
35+
async function processAction(msg, cfg) {
36+
37+
try{
38+
let ajv = new Ajv();
39+
let validate = ajv.addSchema(sharedDefinitions).addSchema(object).addSchema(record).compile(folder);
40+
let valid = validate(msg.body);
41+
42+
if (valid) {
43+
console.log(`FLAG 1`);
44+
console.log('Validation successful');
45+
return eioUtils.newMessageWithBody(msg.body);
46+
} else {
47+
console.log(`FLAG 2`);
48+
console.log(JSON.stringify(validate.errors));
49+
throw new Error(JSON.stringify(validate.errors));
50+
}
51+
52+
} catch (e) {
53+
throw new Error(e);
54+
}
55+
}
56+
57+
module.exports.process = processAction;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright 2018 Cloud Ecosystem e.V.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
"use strict";
18+
const eioUtils = require('elasticio-node').messages;
19+
const request = require('request-promise');
20+
const Ajv = require('ajv');
21+
const relation = require('../schemas/documents/relation.json');
22+
const record = require('../schemas/oih-data-record.json');
23+
24+
25+
/**
26+
* Executes the action's logic by sending a request to the Petstore API and emitting response to the platform.
27+
* The function returns a Promise sending a request and resolving the response as platform message.
28+
*
29+
* @param msg incoming messages which is empty for triggers
30+
* @param cfg object to retrieve triggers configuration values, such as apiKey and pet status
31+
* @returns promise resolving a message to be emitted to the platform
32+
*/
33+
async function processAction(msg, cfg) {
34+
35+
try{
36+
let ajv = new Ajv();
37+
let validate = ajv.addSchema(record).compile(relation);
38+
let valid = validate(msg.body);
39+
40+
if (valid) {
41+
console.log(`FLAG 1`);
42+
console.log('Validation successful');
43+
return eioUtils.newMessageWithBody(msg.body);
44+
} else {
45+
console.log(`FLAG 2`);
46+
console.log(JSON.stringify(validate.errors));
47+
throw new Error(JSON.stringify(validate.errors));
48+
}
49+
50+
} catch (e) {
51+
throw new Error(e);
52+
}
53+
}
54+
55+
module.exports.process = processAction;

Validator/lib/schemas/addresses/organizationV2.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
"$id": "https://github.com/openintegrationhub/Data-and-Domain-Models/blob/master/src/main/schema/addresses/organizationV2.json",
44
"title": "Organization",
55
"type": "object",
6-
"allOf": [
7-
{
8-
"$ref": "../oih-data-record.json"
9-
}
10-
],
116
"properties": {
127
"name": {
138
"type": "string",

Validator/lib/schemas/addresses/personV2.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"title": "Person",
55
"description": "Describes a natural person",
66
"type": "object",
7-
"allOf": [
8-
{
9-
"$ref": "../oih-data-record.json"
10-
}
11-
],
127
"properties": {
138
"title":
149
{

Validator/lib/schemas/collaboration/calendarevent.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"title":"CalendarEvent",
55
"description":"Describes the CalendarEvent",
66
"type":"object",
7-
"allOf":[
8-
{
9-
"$ref":"../oih-data-record.json"
10-
}
11-
],
127
"properties":{
138
"collaborationElement":{
149
"description":"CollaborationElement Data",

0 commit comments

Comments
 (0)