- Zip up the
config
directory undersrc
and deploy it to your tenant - Post a lambda request to the tenant with operation
getStatelessRating
and an array of PolicyCreationRequest objects. You can generate a full request from test fixtures with simplenpm
commands, detailed below.
This demo repository is structured to exhibit the following properties:
- You can modify the contents of the
config
directory directly and do not need to use any third-party libraries or build steps for deployment. - Tests...
- are optional but recommended.
- exist outside of
config
but exerciseconfig
components. - employ popular third-party libraries (e.g.
jest
) and may leverage JavaScript features unavailable to plugin scripts.
Note, then, that you can use this demo as the basis for a stateless rating implementation without using any JavaScript/Node tooling. If you would like to leverage automated tests or build your lamba requests directly from fixtures
,
- Ensure a recent version of Node is installed (e.g. LTS 16.x)
- Run
npm install
from the root directory of this repository - Execute
npm run test
to run tests - Execute
npm run-script makeLambdaRequest
to generate a lambda request body based on test fixtures. By default, the generated request body will be available in thetest
directory aslambdaRequestBody.json
You can further develop the provided tests in tandem with any modifications to the essential components (BuildSocotraPolicy
, lambda
, rater
) to help ensure that your deployment will work as expected. For example, if you wanted to use this demo repository as the basis for your own stateless rating implementation, you can follow this procedure:
- Place your expected policy request variants as separate files in
test/fixtures
- Update
test/utils.js
to ensure that it exports the JSON for your creation request file(s) intest/fixtures
- Update tests in
test/BuildSocotraPolicy.test.js
to affirm that itsgetPolicy
method returns aPolicyResponse
object with all the attributes that are relevant to your production rater's logic.- Iterate on updates to
BuildSocotraPolicy
and the correspondingBuildSocotraPolicy.test.js
until you are confident that the component is producing thePolicyResponse
you need for your expected policy creation variants. - Note that you can run just the BuildSocotraPolicy test by running
npx jest BuildSocotraPolicy
.
- Iterate on updates to
- Swap out this demo's
rater.js
with your production rater. Updaterater.test.js
to inspect results and ensure that your rater returns values you expect for your policy creation test variations. If you find that yourrater.js
requires updates, make sure that any such changes do not conflict with established requirements. - Update
lambda.test.js
to ensure that it, too, yields the expected pricing results corresponding to your array ofPolicyCreationRequest
objects. - Copy your completed components (
lambda.js
,BuildSocotraPolicy.js
, and, if updated,rater.js
) to your production configuration set for deployment to a staging tenant. If your configuration has an existinglambda.js
, simply add the requisite logic (script imports, operation) from this repository'slambda.js
to it. - Test your stateless rater in a staging tenant by issuing an API request against it. You can update the
./test/makeLambdaRequest.js
utility to generate a request body from your test fixtures.