-
Notifications
You must be signed in to change notification settings - Fork 1
To implement intepretation functions for processing create #23
Description
For implementing the functions defined in the intepretation section for processing create,
following folder structure shall be followed
server/
functions/
interpretation/
templates/
Create.js
Create.test.js
Update.js
Update.test.js
Delete.js
Delete.test.js
List.js
List.test.js
Inform.js
Inform.test.js
Implementation of each function as per the specification here https://github.com/openBackhaul/ControllerDomainManager/blob/develop/spec/Functions/Interpretation/ProcessingCreate.md
shall be included here.
Later , this implementation shall be utilized by the appropriate APIs.
Please look into the issues#24 , where we have a generic work flow processor that takes care of all the repeated steps.
So, the implementation of the function should be in the following format , so that it shall be integrated with the generic work flow.
For example , for the /v1/create-mount-point-template API,
/**
*
* steps specific for /v1/create-mount-point-template:
* - Create a logical object using the data from requestBody
*
* NOTE:
* - Validation is NOT done here — the generic wrapper calls validationOrchestrator.
* - No commit to RunningDS happens here — the wrapper handles commit/rollback.
*/
async function doWorkInCandidate(requestBody) {
const { mountPointTemplateName, sleepFactor, ...attributes } = requestBody;
// Basic input presence check (optional)
// Create mount point template object inside CandidateDS
// Implementation detail depends on your datastore:
await CandidateDS.createLogicalObject({
mountPointTemplateName, sleepFactor, ...attributes
});
}Remember , the doWorkInCandidate will be further passed as an attribute to the "processWithCandidateDS" function that executes this in its flow,
await processWithCandidateDS({
requestBody: req.body,
doWorkInCandidate, // the small function defined above
// afterCommit: () => {} // optional; this operation does not need it
});Acceptance Criteria
-
Create the required folder structure under
server/functions/interpretation/templates/containing:
Create.js,Update.js,Delete.js,List.js,Inform.jsand corresponding*.test.jsfiles. -
Implement
doWorkInCandidate()inside each operation file (Create/Update/Delete/List/Inform) following the rules:- No validation inside the function
- No commit/rollback to RunningDS
- Only operate on CandidateDS
- Follow functional behavior defined in
spec/Functions/Interpretation/ProcessingCreate.md - Export the function so it integrates with
processWithCandidateDS({ doWorkInCandidate, requestBody })
-
Ensure all functions are compatible with the generic workflow engine (
processWithCandidateDS)
and can be invoked exactly like:await processWithCandidateDS({ requestBody: req.body, doWorkInCandidate });
-
Add unit tests for each operation function (
*.test.js) covering:- Successful execution of
doWorkInCandidate() - Interaction with CandidateDS (e.g., create/get/update/delete)
- Correct error propagation
- Ensure no validation or commit logic is called inside the function
- Successful execution of