Skip to content

Commit 1c62d09

Browse files
author
A.P.A. Slaa
committed
fix: updated to robuster typing and added all-in-one example also added typedoc to create documentation
1 parent 3ed816e commit 1c62d09

7 files changed

Lines changed: 9244 additions & 456 deletions

File tree

.github/workflows/docs.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [ main ] # or 'master', depending on your default branch
6+
workflow_dispatch: # allows manual trigger
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: true
16+
17+
jobs:
18+
deploy-docs:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build documentation
34+
run: npm run docs:build
35+
36+
- name: Setup Pages
37+
uses: actions/configure-pages@v4
38+
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: ./docs
43+
44+
- name: Deploy to GitHub Pages
45+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,6 @@ dist
139139
# Vite logs files
140140
vite.config.js.timestamp-*
141141
vite.config.ts.timestamp-*
142+
143+
# Autogenerated Documentation
144+
docs

examples/all-in-one.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {OPAClient} from "../src"; //<< !!! Don't use this if your using the package from npm
2+
// import {OPAClient} from "@sourceregistry/node-opa";
3+
4+
const client = new OPAClient();
5+
6+
const regoPolicy = `
7+
package opa.examples
8+
9+
import input.example.flag
10+
11+
allow_request if flag == true
12+
`
13+
14+
async function main() {
15+
16+
const policy = await client.policy.create("opa/examples/allow_request", regoPolicy, true, true)
17+
console.log(policy);
18+
19+
20+
const result = await client.data.post("opa/examples/allow_request", {
21+
"input": {
22+
"example": {
23+
"flag": true
24+
}
25+
}
26+
})
27+
28+
console.log('result', result);
29+
30+
}
31+
32+
main().catch(console.error);

0 commit comments

Comments
 (0)