Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
572 changes: 377 additions & 195 deletions src/Arazzo.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/Rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Rules {
this.successRules.push(...successActions);
}

runRules(successRules) {
runRules(successRules = false) {
if (successRules) {
this.buildSuccessRules();
} else {
Expand All @@ -48,6 +48,13 @@ class Rules {
obj.goto = true;
if (rule.stepId) obj.stepId = rule.stepId;
else obj.workflowId = rule.workflowId;
} else {
obj.name = rule.name;
obj.retry = true;
if (rule.stepId) obj.stepId = rule.stepId;
if (rule.workflowId) obj.workflowId = rule.workflowId;
obj.retryLimit = rule?.retryLimit || 1;
if (rule.retryAfter) obj.retryAfter = rule.retryAfter;
}
}
}
Expand All @@ -65,7 +72,7 @@ class Rules {
const hasPassedCheck = this.expression.checkSimpleExpression(
criteriaObject.condition,
);

// console.log(criteriaObject.condition);
if (hasPassedCheck) passedCriteria.push(hasPassedCheck);
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/mocks/inputs/userInput.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,33 @@
},
"loginUser": {
"password": "--p4ssW0rd"
},
"createUserWithMoreSteps": {
"user": {
"username": "DannyB",
"firstName": "Danny",
"lastName": "Brown",
"email": "dannyb@example.com",
"phone": "+443333333333",
"userStatus": 1
},
"userArray": [
{
"username": "SlimS",
"firstName": "Marshall",
"lastName": "Mathers",
"email": "MarshamM@example.com",
"phone": "+442222222222",
"userStatus": 1
},
{
"username": "IceC",
"firstName": "O'Shea",
"lastName": "Jackson",
"email": "OSheaJ@example.com",
"phone": "+444444444444",
"userStatus": 1
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/serverless-arazzo-workflows/refs/heads/main/test/serverless-users/openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "createUserMultiStep",
"summary": "Create a new User",
"description": "A Workflow to create a new User",
"inputs": {
"type": "object",
"properties": {
"user": {
"type": "object",
"properties": {
"username": { "type": "string" },
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"email": { "type": "string" },
"password": { "type": "string" },
"phone": { "type": "string" },
"userStatus": { "type": "integer" }
}
}
}
},
"steps": [
{
"stepId": "createAUser",
"operationId": "createUser",
"requestBody": {
"contentType": "application/json",
"payload": "$inputs.user"
},
"outputs": { "username": "$response.body#/username" },
"successCriteria": [
{
"condition": "$statusCode == 201"
}
]
}
],
"outputs": {
"username": "$steps.createAUser.outputs.username"
}
},
{
"workflowId": "loginUser",
"summary": "Logs a user in",
"description": "Logs a user in",
"inputs": {
"type": "object",
"properties": {
"password": { "type": "string" }
}
},
"steps": [
{
"stepId": "LogUserIn",
"operationId": "loginUser",
"requestBody": {
"contentType": "application/json",
"payload": {
"username": "$workflows.createUserMultiStep.outputs.username",
"password": "$inputs.password"
}
},
"successCriteria": [
{
"condition": "$statusCode == 200"
}
],
"onFailure": [
{
"name": "retryStepOnce",
"workflowId": "createUserMultiStep",
"type": "retry",
"criteria": [
{
"condition": "$statusCode == 404"
}
]
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/serverless-arazzo-workflows/refs/heads/main/test/serverless-users/openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "createUser",
"summary": "Create a new User",
"description": "A Workflow to create a new User",
"inputs": {
"type": "object",
"properties": {
"user": {
"type": "object",
"properties": {
"username": { "type": "string" },
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"email": { "type": "string" },
"password": { "type": "string" },
"phone": { "type": "string" },
"userStatus": { "type": "integer" }
}
}
}
},
"steps": [
{
"stepId": "createAUser",
"operationId": "createUser",
"requestBody": {
"contentType": "application/json",
"payload": "$inputs.user"
},
"successCriteria": [
{
"condition": "$statusCode == 201"
}
],
"onSuccess": [
{
"name": "gotoLoginUser",
"type": "goto",
"workflowId": "loginUser",
"criteria": [
{
"condition": "$statusCode == 201"
}
]
}
],
"outputs": { "username": "$response.body#/username" }
}
],
"outputs": {
"username": "$steps.createAUser.outputs.username"
}
},
{
"workflowId": "loginUser",
"summary": "Logs a user in",
"description": "Logs a user in",
"inputs": {
"type": "object",
"properties": {
"password": { "type": "string" }
}
},
"steps": [
{
"stepId": "LogUserIn",
"operationId": "loginUser",
"requestBody": {
"contentType": "application/json",
"payload": {
"username": "$workflow.createUser.outputs.username",
"password": "$inputs.password"
}
},
"successCriteria": [
{
"condition": "$statusCode == 200"
}
],
"onFailure": [
{
"name": "gotoCreateUser",
"type": "goto",
"workflowId": "createUser",
"criteria": [
{
"condition": "$statusCode == 400"
}
]
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"$schema": "https://spec.openapis.org/arazzo/1.0/schema/2025-10-15",
"arazzo": "1.0.1",
"info": {
"title": "users",
"description": "The Arazzo Workflow for a Pet Store User",
"summary": "Araazo Workflow for Pet Store User",
"version": "1.0.0"
},
"sourceDescriptions": [
{
"name": "users-openAPI",
"url": "https://raw.githubusercontent.com/JaredCE/serverless-arazzo-workflows/refs/heads/main/test/serverless-users/openapi.json",
"type": "openapi"
}
],
"workflows": [
{
"workflowId": "createUserWithMoreSteps",
"summary": "Create a few Users",
"description": "A Workflow to create a few Users",
"inputs": {
"type": "object",
"properties": {
"user": {
"type": "object",
"properties": {
"username": { "type": "string" },
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"email": { "type": "string" },
"password": { "type": "string" },
"phone": { "type": "string" },
"userStatus": { "type": "integer" }
}
},
"userArray": {
"type": "array",
"items": {
"type": "object",
"properties": {
"username": { "type": "string" },
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"email": { "type": "string" },
"password": { "type": "string" },
"phone": { "type": "string" },
"userStatus": { "type": "integer" }
}
}
}
}
},
"steps": [
{
"stepId": "createAUser",
"operationId": "createUser",
"requestBody": {
"contentType": "application/json",
"payload": "$inputs.user"
},
"successCriteria": [
{
"condition": "$statusCode == 201"
}
],
"outputs": { "username": "$response.body#/username" }
},
{
"stepId": "createAUserWithArray",
"operationId": "createUsersWithArrayInput",
"requestBody": {
"contentType": "application/json",
"payload": "$inputs.userArray"
},
"successCriteria": [
{
"condition": "$statusCode == 201"
}
],
"outputs": { "username": "$response.body#/username" }
},
{
"stepId": "getAUser",
"operationId": "getUserByName",
"parameters": [
{
"name": "username",
"in": "path",
"value": "$steps.createAUser.outputs.username"
}
],
"outputs": { "id": "$response.body#/id" },
"successCriteria": [
{
"condition": "$statusCode == 200"
}
],
"onFailure": [
{
"name": "retryStepOnce",
"stepId": "createAUser",
"type": "retry",
"criteria": [
{
"condition": "$statusCode == 404"
}
]
}
]
}
]
}
]
}
Loading