jsPolicy SDK
While there are many ways to write policies, you can use the jsPolicy SDK to get up and running faster and build on best practices. The jsPolicy SDK provides a project structure, some development and testing tools as well as some guidance on how to efficiently write, test and publish policies using TypeScript (or JavaScript).
#
Using jsPolicy SDKThe jsPolicy SDK project on GitHub is desined as a template for you to get started with.
#
1. Clone Template ProjectSo, to use jsPolicy SDK, clone the project:
#
2. Install Dev DependenciesThis project has several devDependencies
defined in the package.json
, so let's install them:
#
3. Write & Compile PoliciesThe project is structured like this:
To compile the policies defined in src/policies
to ready-to-use JsPolicy
+ JsPolicyBundle
combos, run:
For a more efficient hot reloading workflow, run:
To also apply the policies after each iterative compile process, run:
#
4. Test PoliciesThe project is configured to use Jest
and execute all files in tests/
as test suites. You can run the tests with this command:
#
5. Publish Policy LogicIf you want to share policy logic from your lib/
folder, make sure you export the functions you want to make available by adding these functions in src/index.ts
and then publish the project: