Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

766 store circuit inputs translation schema #783

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

ognjenkurtic
Copy link
Collaborator

Description

Implements an endpoint through which a circuit input translation schema can be attached to a workstep.
Implements a command handler that validates the provided schema and stores it.
Implements a method in the CircuitInputsParserService for schema validation together with tests
Extends the e2e test to trigger dummy schema creation, in preparation for #777

Related Issue

#766

Motivation and Context

Given in the discussions in the related issues and docs

How Has This Been Tested

Wrote a set of new unit tests
Extended e2e tests
Added an endpoint to Postman collection and tested manually

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Request to be added as a Code Owner/Maintainer

Checklist

  • My code follows the code style of this project.
  • [] My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I commit to abide by the Responsibilities of Code Owners/Maintainers.

…cuit input is provided in the circuit input parser; Simplify calculateStringCharCodeSum call in case of string type
…d to postman collection; Rename add cis command to set cis command;
@ognjenkurtic ognjenkurtic changed the base branch from main to feat/776-circuit-inputs-parser January 22, 2024 22:38
Copy link
Collaborator

@Therecanbeonlyone1969 Therecanbeonlyone1969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ognjenkurtic left some questions. Bit confused.

@ognjenkurtic
Copy link
Collaborator Author

@ognjenkurtic left some questions. Bit confused.

@Therecanbeonlyone1969 Please have a look at my answers and let me know if there is anything else to clarify

@Therecanbeonlyone1969
Copy link
Collaborator

@ognjenkurtic left some questions. Bit confused.

@Therecanbeonlyone1969 Please have a look at my answers and let me know if there is anything else to clarify

see my replies ... JSON and use a library such as suretype. @ognjenkurtic

Copy link
Collaborator

@skosito skosito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

regarding string vs json, it seems that using json in prisma is straightforward (sorry if assumption is wrong) so maybe lets just do it in this PR

examples/bri-3/prisma/schema.prisma Outdated Show resolved Hide resolved
public throwIfCircuitInputTranslationSchemaInvalid(schema): void {
const [result, error] =
this.cips.validateCircuitInputTranslationSchema(schema);
if (!result) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should check if there is error instead of result and returning error imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed 'result' to 'valid' for better readability

workstepToUpdate: Workstep,
schema: string,
): void {
workstepToUpdate.updateCircuitInputTranslationSchema(schema);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can error occur here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, asigning string value

@@ -71,6 +73,17 @@ export class WorkstepController {
);
}

@Put('/:id/circuitinputsschema')
@CheckAuthz({ action: 'update', type: 'Workstep' })
async setCircuitInputsSchemaCommand(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small thing but i would name this update instead of set to be clear, but up to you

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

return [true, ''];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think we should return both boolean and error, looks kinda weird in javascript, lets just return error which implies that validation is true or false? but up to you

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ike it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ognjenkurtic are you going to leave it like that? L57 still returns a boolean and error message. Same with L55 ... I would return a No-Error Message

Base automatically changed from feat/776-circuit-inputs-parser to main February 5, 2024 21:44
@CLAassistant
Copy link

CLAassistant commented Apr 8, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@Therecanbeonlyone1969 Therecanbeonlyone1969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had one comment as a follow-up. Once addressed, good to be merged after resolving merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants