Skip to content

Commit

Permalink
Updated schema context params and postman requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiran-rean committed Nov 26, 2024
1 parent f1f22a9 commit 20c4aa6
Show file tree
Hide file tree
Showing 22 changed files with 179 additions and 135 deletions.
20 changes: 10 additions & 10 deletions bruno/Workflow service/03 - Moderator logs in/moderator logs in.bru
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ body:json {

}

script:pre-request {
//bru.setEnvVar("ADMIN_PASSWORD", jsonRes.Data.Client.id);
script:post-response {
let status = res.getStatus();
console.log(status)
if (status == 200) {
bru.setEnvVar("MODERATOR_ACCESS_TOKEN", res.body.Data.AccessToken);
bru.setEnvVar("MODERATOR_SESSION_ID", res.body.Data.User.SessionId);
bru.setEnvVar("MODERATOR_USER_ID",res.body.Data.User.UserId);
bru.setEnvVar("MODERATOR_USER_JWT",res.body.Data.AccessToken);
}

}

tests {
try {
var jsonRes = res.getBody();
bru.setEnvVar("MODERATOR_USER_JWT", jsonRes.Data.AccessToken);
}
catch (error) {
console.log(error.message);
}

test("Request is successfull", function () {
expect(res.getStatus()).to.equal(200);
var jsonRes = res.getBody();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
meta {
name: Create schema
type: http
seq: 1
}

post {
url: {{BASE_URL}}/engine/schema
body: json
auth: none
}

headers {
Content-Type: application/json
x-api-key: {{API_KEY}}
Authorization: Bearer {{MODERATOR_USER_JWT}}
}

body:json {
{
"TenantId": "{{TENANT_ID}}",
"Name": "Alert V1",
"Description": "This chema represents a workflow for ALERT emergency response management.",
"Type": "ChatBot",
"ContextParams": {
"Name": "Schema instance context",
"Params": [
{
"Name": "Phone",
"Type": "Phonenumber",
"Description": "This is phone number of CFR responding to emergency",
"Value": "+91-9970155165"
},
{
"Name": "Location",
"Description": "This is the location where the emergency has occurred.",
"Value": {
"Longitude": 23.434343,
"Lattitude": 43.454353
}
},
{
"Name": "Timestamp",
"Description": "This is the timestamp the emergency has been reported.",
"Value": "2024-11-26T10:07:56.255Z"
}
]
},
"RootNode": {
"Type": "ExecutionNode",
"Name": "Root Node",
"Description": "Send first message upon triggering of the workflow",
"Action": {
"ActionType": "SendMessage",
"Name": "Send First message",
"Input": {
"Params": [
{
"ActionType": "SendMessage",
"Type": "Phonenumber",
"Value": null,
"Source": "Almanac",
"Key": "ContextParams:Phone"
},
{
"ActionType": "Send Message",
"Type": "Text",
"Value": "Hope you are safe."
}
]
}
}
}
}
}

tests {
try {
var jsonRes = res.getBody();
bru.setEnvVar("SCHEMA_ID", jsonRes.Data.id);
bru.setEnvVar("SCHEMA_ROOT_NODE_ID", jsonRes.Data.RootNode.id);
bru.setEnvVar("NODE_01_ID", jsonRes.Data.RootNode.id);
}
catch (error) {
console.log(error.message);
}

test("Request is successfull", function () {
expect(res.getStatus()).to.equal(201);
var jsonRes = res.getBody();
expect(jsonRes.Status).to.eql('success');
});

test("Schema is created", function () {
var jsonRes = res.getBody();
expect(jsonRes.Data).to.have.property('id');
expect(jsonRes.Data).to.have.property('Client');
expect(jsonRes.Data.Client).to.have.property('id');
expect(jsonRes.Data).to.have.property('Name');
expect(jsonRes.Data).to.have.property('Description');
expect(jsonRes.Data).to.have.property('ValidFrom');
expect(jsonRes.Data).to.have.property('RootNode');
});

}

docs {
User login with username/phone/email and password.

'LoginRoleId' is the role id through which user wants to log into the system provided the user has the role.
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: 01 - Get root Node - Extract nutrition data
type: http
seq: 2
seq: 1
}

get {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: 02 - Create next node - Calculate Continuity
type: http
seq: 3
seq: 2
}

post {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: 03 - Create next node - Extract existing badges
type: http
seq: 5
seq: 4
}

post {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: 04 - Create next node - Compare badges
type: http
seq: 7
seq: 6
}

post {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: 05 - Create next node - Store updated badges
type: http
seq: 9
seq: 8
}

post {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Get schema by Id
type: http
seq: 11
seq: 10
}

get {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Update next node for node 01
type: http
seq: 4
seq: 3
}

put {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Update next node for node 02
type: http
seq: 6
seq: 5
}

put {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Update next node for node 03
type: http
seq: 8
seq: 7
}

put {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Update next node for node 04
type: http
seq: 10
seq: 9
}

put {
Expand Down
2 changes: 2 additions & 0 deletions bruno/Workflow service/environments/workflow-local.bru
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ vars {
ADMIN_ACCESS_TOKEN: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIxMzE5Yzc2OC03MmU0LTQzMTctODZlNS1lNWYxYzdiOTI2NmEiLCJVc2VyTmFtZSI6ImFkbWluIiwiRGlzcGxheU5hbWUiOiJBZG1pbiBTeXN0ZW0iLCJTZXNzaW9uSWQiOiJmNzRjNjU3OS1jYmQ1LTQ3MGMtYmFkMi01NjI4NDIzYzc0ZDgiLCJQaG9uZSI6Iis5MS0wMDAwMDAwMDAwIiwiRW1haWwiOm51bGwsImlhdCI6MTczMjU1MTEzMCwiZXhwIjoxNzM1MTQzMTMwfQ.dLOX78PfK_7aA9-CIGUtSDD4itoL1IBmGrqTkj2ibRg
ADMIN_SESSION_ID: f74c6579-cbd5-470c-bad2-5628423c74d8
ADMIN_USER_ID: 1319c768-72e4-4317-86e5-e5f1c7b9266a
MODERATOR_USER_NAME: moderator
MODERATOR_PASSWORD: DcgH2TvvZ5zM
}
vars:secret [
ADMIN_PASSWORD,
Expand Down
1 change: 0 additions & 1 deletion src/api/engine/schema/schema.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { SchemaService } from '../../../database/services/engine/schema.service'
import { ErrorHandler } from '../../../common/handlers/error.handler';
import { SchemaCreateModel, SchemaSearchFilters, SchemaUpdateModel } from '../../../domain.types/engine/schema.domain.types';
import { uuid } from '../../../domain.types/miscellaneous/system.types';
import { XSchema } from '../../../domain.types/engine/intermediate.types';

///////////////////////////////////////////////////////////////////////////////////////

Expand Down
27 changes: 27 additions & 0 deletions src/domain.types/engine/engine.enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ export enum SchemaType {
Application = 'Application',
}

export enum ParamType {
Phonenumber = "Phonenumber",
Email = "Email",
Location = "Location",
Date = "Date",
DateTime = "DateTime",
Float = 'Float',
Integer = 'Integer',
Boolean = 'Boolean',
Text = 'Text',
Array = 'Array',
Object = 'Object',
Placeholder = 'Placeholder',
Unknown = 'Unknown',
}

export const SchemaTypeList: SchemaType[] = [
SchemaType.ChatBot,
SchemaType.Application,
Expand Down Expand Up @@ -236,5 +252,16 @@ export const InputSourceTypeList: InputSourceType[] = [
InputSourceType.JSON,
InputSourceType.JSONFile,
InputSourceType.CustomObject,
];

export enum OutputDestinationType {
Database = "Database",
Almanac = "Almanac",
ApiEndpoint = "ApiEndpoint",
}

export const OutputSourceTypeList: OutputDestinationType[] = [
OutputDestinationType.Database,
OutputDestinationType.Almanac,
OutputDestinationType.ApiEndpoint,
];
Loading

0 comments on commit 20c4aa6

Please # to comment.