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

Merged
merged 18 commits into from
Jun 25, 2024

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.

@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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

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.

@ognjenkurtic
Copy link
Collaborator Author

@skosito @Therecanbeonlyone1969 waiting for the other one to be merged to main so that i can resolve confilcts here and verify the e2e test. Everything else is addressed.

@ognjenkurtic ognjenkurtic force-pushed the 766-store-circuit-inputs-translation-schema branch from 9295224 to 3c9230d Compare June 20, 2024 14:03
@ognjenkurtic
Copy link
Collaborator Author

@Therecanbeonlyone1969 @biscuitdey @skosito ready for rereview. tests green, rebased on top of main.

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.

LGTM

Copy link
Collaborator

@biscuitdey biscuitdey 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!

@biscuitdey biscuitdey merged commit 1f57a18 into main Jun 25, 2024
2 checks passed
@biscuitdey biscuitdey deleted the 766-store-circuit-inputs-translation-schema branch June 25, 2024 08:48
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.

5 participants