├── .changeset ├── README.md └── config.json ├── .github ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── dependency-review.yml │ ├── docs_manual.yaml │ ├── jsr_manual.yaml │ ├── publish.yaml │ ├── pull-request.yaml │ └── sdk_generation.yaml ├── .gitignore ├── .node-version ├── .speakeasy ├── gen.yaml ├── overlay.yaml ├── workflow.lock └── workflow.yaml ├── .typedoc └── favicon.ico ├── DEVELOPMENT.md ├── LICENSE ├── README.md ├── build ├── compile-opa.sh └── opa-release-notes.sh ├── package-lock.json ├── package.json ├── packages ├── opa-react │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── authz-provider.tsx │ │ ├── authz.tsx │ │ ├── index.ts │ │ └── use-authz.ts │ ├── tests │ │ ├── authz.test.tsx │ │ ├── setup.ts │ │ └── use-authz.test.tsx │ ├── tsconfig.docs.json │ ├── tsconfig.json │ ├── typedoc.json │ └── vitest.config.mts ├── opa │ ├── .genignore │ ├── .gitattributes │ ├── .gitignore │ ├── .npmignore │ ├── .speakeasy │ │ └── gen.lock │ ├── FUNCTIONS.md │ ├── README.md │ ├── RELEASES.md │ ├── RUNTIMES.md │ ├── USAGE.md │ ├── docs │ │ ├── lib │ │ │ └── utils │ │ │ │ └── retryconfig.md │ │ ├── sdk │ │ │ └── models │ │ │ │ ├── components │ │ │ │ ├── batchmixedresults.md │ │ │ │ ├── batchsuccessfulpolicyevaluation.md │ │ │ │ ├── compileoptions.md │ │ │ │ ├── compileresultjson.md │ │ │ │ ├── compileresultjsonresult.md │ │ │ │ ├── compileresultmultitarget.md │ │ │ │ ├── compileresultmultitargetquery.md │ │ │ │ ├── compileresultmultitargetresult.md │ │ │ │ ├── compileresultsql.md │ │ │ │ ├── compileresultsqlresult.md │ │ │ │ ├── compileresultucast.md │ │ │ │ ├── compileresultucastresult.md │ │ │ │ ├── errors.md │ │ │ │ ├── explain.md │ │ │ │ ├── gzipacceptencoding.md │ │ │ │ ├── gzipcontentencoding.md │ │ │ │ ├── healthyserver.md │ │ │ │ ├── httpmetadata.md │ │ │ │ ├── input.md │ │ │ │ ├── location.md │ │ │ │ ├── maskingrule.md │ │ │ │ ├── mysql.md │ │ │ │ ├── one.md │ │ │ │ ├── postgresql.md │ │ │ │ ├── provenance.md │ │ │ │ ├── query.md │ │ │ │ ├── replace.md │ │ │ │ ├── responses.md │ │ │ │ ├── result.md │ │ │ │ ├── revision.md │ │ │ │ ├── security.md │ │ │ │ ├── servererror.md │ │ │ │ ├── servererrorwithstatuscode.md │ │ │ │ ├── sqlite.md │ │ │ │ ├── sqlserver.md │ │ │ │ ├── successfulpolicyresponse.md │ │ │ │ ├── successfulpolicyresponsewithstatuscode.md │ │ │ │ ├── support.md │ │ │ │ ├── targetdialects.md │ │ │ │ ├── targets.md │ │ │ │ ├── targetsqltablemappings.md │ │ │ │ └── ucast.md │ │ │ │ ├── errors │ │ │ │ ├── batchservererror.md │ │ │ │ ├── clienterror.md │ │ │ │ ├── errors.md │ │ │ │ ├── location.md │ │ │ │ ├── servererror.md │ │ │ │ ├── servererrorerrors.md │ │ │ │ ├── servererrorlocation.md │ │ │ │ └── unhealthyserver.md │ │ │ │ └── operations │ │ │ │ ├── compilequerywithpartialevaluationrequest.md │ │ │ │ ├── compilequerywithpartialevaluationrequestapplicationjsonrequestbody.md │ │ │ │ ├── compilequerywithpartialevaluationresponse.md │ │ │ │ ├── executebatchpolicywithinputrequest.md │ │ │ │ ├── executebatchpolicywithinputrequestbody.md │ │ │ │ ├── executebatchpolicywithinputresponse.md │ │ │ │ ├── executedefaultpolicywithinputrequest.md │ │ │ │ ├── executedefaultpolicywithinputresponse.md │ │ │ │ ├── executepolicyrequest.md │ │ │ │ ├── executepolicyresponse.md │ │ │ │ ├── executepolicywithinputrequest.md │ │ │ │ ├── executepolicywithinputrequestbody.md │ │ │ │ ├── executepolicywithinputresponse.md │ │ │ │ ├── healthrequest.md │ │ │ │ └── healthresponse.md │ │ └── sdks │ │ │ └── opaapiclient │ │ │ └── README.md │ ├── eslint.config.mjs │ ├── jsr.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── core.ts │ │ ├── funcs │ │ │ ├── compileQueryWithPartialEvaluation.ts │ │ │ ├── executeBatchPolicyWithInput.ts │ │ │ ├── executeDefaultPolicyWithInput.ts │ │ │ ├── executePolicy.ts │ │ │ ├── executePolicyWithInput.ts │ │ │ └── health.ts │ │ ├── hooks │ │ │ ├── hooks.ts │ │ │ ├── index.ts │ │ │ ├── registration.ts │ │ │ ├── request-path-hook.ts │ │ │ └── types.ts │ │ ├── index.ts │ │ ├── lib │ │ │ ├── base64.ts │ │ │ ├── config.ts │ │ │ ├── dlv.ts │ │ │ ├── encodings.ts │ │ │ ├── files.ts │ │ │ ├── http.ts │ │ │ ├── index.ts │ │ │ ├── is-plain-object.ts │ │ │ ├── logger.ts │ │ │ ├── matchers.ts │ │ │ ├── primitives.ts │ │ │ ├── retries.ts │ │ │ ├── schemas.ts │ │ │ ├── sdks.ts │ │ │ ├── security.ts │ │ │ └── url.ts │ │ ├── opaclient.ts │ │ ├── sdk │ │ │ ├── index.ts │ │ │ ├── models │ │ │ │ ├── components │ │ │ │ │ ├── batchmixedresults.ts │ │ │ │ │ ├── batchsuccessfulpolicyevaluation.ts │ │ │ │ │ ├── compileoptions.ts │ │ │ │ │ ├── compileresultjson.ts │ │ │ │ │ ├── compileresultmultitarget.ts │ │ │ │ │ ├── compileresultsql.ts │ │ │ │ │ ├── compileresultucast.ts │ │ │ │ │ ├── explain.ts │ │ │ │ │ ├── gzipacceptencoding.ts │ │ │ │ │ ├── gzipcontentencoding.ts │ │ │ │ │ ├── healthyserver.ts │ │ │ │ │ ├── httpmetadata.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── input.ts │ │ │ │ │ ├── maskingrule.ts │ │ │ │ │ ├── provenance.ts │ │ │ │ │ ├── result.ts │ │ │ │ │ ├── security.ts │ │ │ │ │ ├── servererror.ts │ │ │ │ │ └── successfulpolicyresponse.ts │ │ │ │ ├── errors │ │ │ │ │ ├── batchservererror.ts │ │ │ │ │ ├── clienterror.ts │ │ │ │ │ ├── httpclienterrors.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── sdkerror.ts │ │ │ │ │ ├── sdkvalidationerror.ts │ │ │ │ │ ├── servererror.ts │ │ │ │ │ └── unhealthyserver.ts │ │ │ │ └── operations │ │ │ │ │ ├── compilequerywithpartialevaluation.ts │ │ │ │ │ ├── executebatchpolicywithinput.ts │ │ │ │ │ ├── executedefaultpolicywithinput.ts │ │ │ │ │ ├── executepolicy.ts │ │ │ │ │ ├── executepolicywithinput.ts │ │ │ │ │ ├── health.ts │ │ │ │ │ └── index.ts │ │ │ └── sdk.ts │ │ └── types │ │ │ ├── async.ts │ │ │ ├── blobs.ts │ │ │ ├── constdatetime.ts │ │ │ ├── enums.ts │ │ │ ├── fp.ts │ │ │ ├── index.ts │ │ │ ├── operations.ts │ │ │ ├── rfcdate.ts │ │ │ └── streams.ts │ ├── tests │ │ ├── authorizer.test.ts │ │ └── compile.test.ts │ ├── tsconfig.json │ └── typedoc.config.cjs └── ucast-prisma │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ ├── adapter.ts │ ├── index.ts │ ├── instructions.ts │ ├── interpreter.ts │ ├── interpreters.ts │ └── masks.ts │ ├── tests │ ├── adapter.test.ts │ ├── interpreters.test.ts │ └── masks.test.ts │ └── tsconfig.json └── typedoc.json /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "restricted", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | directory: "/packages/opa-react/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "npm" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | groups: 12 | eslint: 13 | patterns: 14 | - "@typescript-eslint/*" 15 | - "eslint-*" 16 | - "eslint" 17 | - "prettier" 18 | - package-ecosystem: github-actions 19 | directory: / 20 | schedule: 21 | interval: daily 22 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### :nut_and_bolt: What code changed, and why? 2 | 3 | ### :+1: Definition of done 4 | 5 | ### :athletic_shoe: How to test 6 | 7 | ### :chains: Related Resources 8 | 9 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, 4 | # surfacing known-vulnerable versions of the packages declared or updated in the PR. 5 | # Once installed, if the workflow run is marked as required, 6 | # PRs introducing known-vulnerable packages will be blocked from merging. 7 | # 8 | # Source repository: https://github.com/actions/dependency-review-action 9 | name: "Dependency Review" 10 | on: [pull_request] 11 | 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 14 | cancel-in-progress: true 15 | 16 | permissions: 17 | contents: read 18 | 19 | jobs: 20 | init: 21 | name: Prereqs 22 | runs-on: ubuntu-24.04 23 | steps: 24 | - uses: StyraInc/styra-init-action@main # ratchet:exclude 25 | 26 | dependency-review: 27 | runs-on: ubuntu-latest 28 | needs: init 29 | steps: 30 | - name: "Checkout Repository" 31 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 32 | - name: "Dependency Review" 33 | uses: actions/dependency-review-action@ce3cf9537a52e8119d91fd484ab5b8a807627bf8 # v4.6.0 34 | -------------------------------------------------------------------------------- /.github/workflows/docs_manual.yaml: -------------------------------------------------------------------------------- 1 | name: Docs 2 | 3 | on: 4 | workflow_dispatch: {} 5 | 6 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 7 | permissions: 8 | actions: read 9 | pages: write 10 | id-token: write 11 | 12 | concurrency: ${{ github.workflow }}-${{ github.ref }} 13 | 14 | jobs: 15 | init: 16 | name: Prereqs 17 | runs-on: ubuntu-24.04 18 | steps: 19 | - uses: StyraInc/styra-init-action@main # ratchet:exclude 20 | 21 | docs: 22 | name: Docs (manual) 23 | needs: init 24 | environment: 25 | name: github-pages 26 | url: ${{ steps.deployment.outputs.page_url }} 27 | runs-on: ubuntu-24.04 28 | steps: 29 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 30 | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 31 | with: 32 | node-version: 22 33 | - name: Install and build dependencies 34 | run: | 35 | npm ci 36 | npm run build --ws 37 | - name: Generate docs 38 | run: npm run docs 39 | - name: Upload artifact 40 | uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 41 | with: 42 | # Upload entire repository 43 | path: docs/ 44 | - name: Deploy to GitHub Pages 45 | id: deployment 46 | uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 47 | -------------------------------------------------------------------------------- /.github/workflows/jsr_manual.yaml: -------------------------------------------------------------------------------- 1 | name: JSR (Manual) 2 | 3 | on: 4 | workflow_dispatch: {} 5 | 6 | concurrency: ${{ github.workflow }}-${{ github.ref }} 7 | 8 | jobs: 9 | init: 10 | name: Prereqs 11 | runs-on: ubuntu-24.04 12 | steps: 13 | - uses: StyraInc/styra-init-action@main # ratchet:exclude 14 | 15 | jsr: 16 | name: Publish @styra/opa to JSR 17 | runs-on: ubuntu-24.04 18 | needs: init 19 | permissions: 20 | contents: read 21 | id-token: write # OIDC ID token for authentication with JSR 22 | steps: 23 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 24 | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 25 | with: 26 | node-version: 22 27 | - name: build and publish @styra/opa to JSR 28 | run: | 29 | npm ci 30 | npm run build --ws 31 | npx -w packages/opa jsr publish 32 | -------------------------------------------------------------------------------- /.github/workflows/pull-request.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | workflow_dispatch: {} 5 | pull_request: {} 6 | push: 7 | branches: 8 | - main 9 | 10 | # When a new revision is pushed to a PR, cancel all in-progress CI runs for that 11 | # PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 14 | cancel-in-progress: true 15 | 16 | jobs: 17 | prereqs: 18 | name: Prereqs 19 | runs-on: ubuntu-24.04 20 | steps: 21 | - uses: StyraInc/styra-init-action@main # ratchet:exclude 22 | 23 | init: 24 | runs-on: ubuntu-22.04 25 | needs: prereqs 26 | outputs: 27 | packages: ${{ steps.workspaces.outputs.packages }} 28 | steps: 29 | - name: Check out code 30 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 31 | with: 32 | fetch-depth: 0 33 | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 34 | with: 35 | node-version: 22 36 | - id: workspaces 37 | run: | 38 | npm ci 39 | echo packages=$(npm query .workspace | jq -c '[.[].location]') >> $GITHUB_OUTPUT 40 | 41 | packages: 42 | name: test packages 43 | runs-on: ubuntu-22.04 44 | needs: 45 | - init 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | pkg: ${{ fromJSON(needs.init.outputs.packages) }} 50 | steps: 51 | - name: Check out code 52 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 53 | with: 54 | fetch-depth: 0 55 | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 56 | with: 57 | node-version: 22 58 | - name: setup and build 59 | # https://github.com/npm/cli/issues/3034#issuecomment-885211061 60 | run: | 61 | npm ci 62 | npm run build --ws 63 | - name: test 64 | run: npx -w ${{ matrix.pkg }} tsx --test ./tests/**/*.ts 65 | env: 66 | EOPA_LICENSE_KEY: ${{ secrets.EOPA_LICENSE_KEY }} # @styra/opa needs this 67 | if: matrix.pkg == 'packages/opa' 68 | - name: test 69 | run: npm run -w ${{ matrix.pkg }} --if-present test 70 | - name: docs 71 | run: npx -w ${{ matrix.pkg }} typedoc 72 | - name: are the types wrong? 73 | run: npx -w ${{ matrix.pkg }} attw --pack 74 | if: matrix.pkg != 'packages/opa' 75 | - name: are the types wrong? (opa) 76 | run: npx -w ${{ matrix.pkg }} attw --pack --profile node16 77 | if: matrix.pkg == 'packages/opa' 78 | - name: jsr publish dry-run 79 | run: npx -w ${{ matrix.pkg }} jsr publish --dry-run 80 | if: matrix.pkg == 'packages/opa' 81 | 82 | success: 83 | name: tests succeed 84 | runs-on: ubuntu-22.04 85 | needs: 86 | - packages 87 | steps: 88 | - run: echo yay 89 | -------------------------------------------------------------------------------- /.github/workflows/sdk_generation.yaml: -------------------------------------------------------------------------------- 1 | name: Generate 2 | permissions: 3 | checks: write 4 | contents: write 5 | pull-requests: write 6 | statuses: write 7 | "on": 8 | workflow_dispatch: 9 | inputs: 10 | force: 11 | description: Force generation of SDKs 12 | type: boolean 13 | default: false 14 | schedule: 15 | - cron: 0 0 * * 0 16 | 17 | jobs: 18 | init: 19 | name: Prereqs 20 | runs-on: ubuntu-24.04 21 | steps: 22 | - uses: StyraInc/styra-init-action@main # ratchet:exclude 23 | 24 | generate: 25 | needs: init 26 | uses: speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@fb0db5083e6432c59c9be2d311ec82590720672a # ratchet:speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@v15 27 | with: 28 | force: ${{ github.event.inputs.force }} 29 | mode: pr 30 | speakeasy_version: latest 31 | secrets: 32 | github_access_token: ${{ secrets.GITHUB_TOKEN }} 33 | npm_token: ${{ secrets.NPM_TOKEN }} 34 | speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }} 35 | slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /packages/*/dist/ 2 | node_modules/ 3 | /docs/ 4 | /packages/opa-react/docs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 22 2 | -------------------------------------------------------------------------------- /.speakeasy/gen.yaml: -------------------------------------------------------------------------------- 1 | configVersion: 2.0.0 2 | generation: 3 | sdkClassName: opaApiClient 4 | maintainOpenAPIOrder: true 5 | usageSnippets: 6 | optionalPropertyRendering: withExample 7 | useClassNamesForArrayFields: true 8 | fixes: 9 | nameResolutionDec2023: true 10 | nameResolutionFeb2025: false 11 | parameterOrderingFeb2024: true 12 | requestResponseComponentNamesFeb2024: true 13 | securityFeb2025: false 14 | auth: 15 | oAuth2ClientCredentialsEnabled: false 16 | oAuth2PasswordEnabled: false 17 | typescript: 18 | version: 1.7.10 19 | additionalDependencies: 20 | dependencies: 21 | '@styra/ucast-prisma': ^0.1.3 22 | devDependencies: 23 | '@types/node': ^22.13.14 24 | testcontainers: ^10.23.0 25 | tsx: ^4.19.3 26 | typedoc: ^0.26.5 27 | typedoc-plugin-extras: ^3.1.0 28 | typedoc-plugin-replace-text: ^4.0.0 29 | peerDependencies: {} 30 | additionalPackageJSON: 31 | keywords: 32 | - OPA 33 | - Open Policy Agent 34 | - authorization 35 | - policy 36 | - permissions 37 | - rbac 38 | - role based access control 39 | license: Apache-2.0 40 | publishConfig: 41 | access: public 42 | author: Styra 43 | clientServerStatusCodesAsErrors: true 44 | compileCommand: 45 | - bash 46 | - -c 47 | - ../../build/compile-opa.sh 48 | defaultErrorName: SDKError 49 | enableCustomCodeRegions: false 50 | enableMCPServer: true 51 | enableReactQuery: false 52 | enumFormat: enum 53 | flattenGlobalSecurity: true 54 | flatteningOrder: parameters-first 55 | imports: 56 | option: openapi 57 | paths: 58 | callbacks: sdk/models/callbacks 59 | errors: sdk/models/errors 60 | operations: sdk/models/operations 61 | shared: sdk/models/components 62 | webhooks: sdk/models/webhooks 63 | inputModelSuffix: input 64 | jsonpath: legacy 65 | maxMethodParams: 4 66 | methodArguments: require-security-and-request 67 | moduleFormat: dual 68 | outputModelSuffix: output 69 | packageName: '@styra/opa' 70 | responseFormat: envelope-http 71 | templateVersion: v2 72 | useIndexModules: true 73 | -------------------------------------------------------------------------------- /.speakeasy/overlay.yaml: -------------------------------------------------------------------------------- 1 | overlay: 1.0.0 2 | info: 3 | title: Overlay to patch the CompileOptions' payloads 4 | version: 0.0.1 5 | actions: 6 | - target: "$.components..CompileOptions.additionalProperties" 7 | description: remove additional properties from the top-level request payload 8 | remove: true 9 | -------------------------------------------------------------------------------- /.speakeasy/workflow.lock: -------------------------------------------------------------------------------- 1 | speakeasyVersion: 1.533.0 2 | sources: 3 | openapi: 4 | sourceNamespace: openapi 5 | sourceRevisionDigest: sha256:c2448c44bc294da72bcfe707ff27429e1fc9996ba62aaa39664b41cbe9ae01d9 6 | sourceBlobDigest: sha256:3688645679b8687bb499064801c3f4e42f0383cafb08095f5d5bd9b341c28c92 7 | tags: 8 | - latest 9 | - speakeasy-sdk-regen-1744763210 10 | - 0.2.0 11 | targets: 12 | first-target: 13 | source: openapi 14 | sourceNamespace: openapi 15 | sourceRevisionDigest: sha256:c2448c44bc294da72bcfe707ff27429e1fc9996ba62aaa39664b41cbe9ae01d9 16 | sourceBlobDigest: sha256:3688645679b8687bb499064801c3f4e42f0383cafb08095f5d5bd9b341c28c92 17 | codeSamplesNamespace: openapi-typescript-code-samples 18 | codeSamplesRevisionDigest: sha256:41097a438038c847f3ed4991c7b9779e7e773941bdf860a34fab64fdde20567c 19 | workflow: 20 | workflowVersion: 1.0.0 21 | speakeasyVersion: latest 22 | sources: 23 | openapi: 24 | inputs: 25 | - location: https://raw.githubusercontent.com/StyraInc/enterprise-opa/main/openapi/openapi.yaml 26 | overlays: 27 | - location: ./.speakeasy/overlay.yaml 28 | registry: 29 | location: registry.speakeasyapi.dev/styra/styra/openapi 30 | targets: 31 | first-target: 32 | target: typescript 33 | source: openapi 34 | output: packages/opa 35 | codeSamples: 36 | registry: 37 | location: registry.speakeasyapi.dev/styra/styra/openapi-typescript-code-samples 38 | labelOverride: 39 | fixedValue: Typescript (SDK) 40 | blocking: false 41 | -------------------------------------------------------------------------------- /.speakeasy/workflow.yaml: -------------------------------------------------------------------------------- 1 | workflowVersion: 1.0.0 2 | speakeasyVersion: latest 3 | sources: 4 | openapi: 5 | inputs: 6 | - location: https://raw.githubusercontent.com/StyraInc/enterprise-opa/main/openapi/openapi.yaml 7 | overlays: 8 | - location: ./.speakeasy/overlay.yaml 9 | registry: 10 | location: registry.speakeasyapi.dev/styra/styra/openapi 11 | targets: 12 | first-target: 13 | target: typescript 14 | source: openapi 15 | output: packages/opa 16 | codeSamples: 17 | registry: 18 | location: registry.speakeasyapi.dev/styra/styra/openapi-typescript-code-samples 19 | labelOverride: 20 | fixedValue: Typescript (SDK) 21 | blocking: false 22 | -------------------------------------------------------------------------------- /.typedoc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StyraInc/opa-typescript/e68c278a3125872486c7f42ae5db3fdef42c14ff/.typedoc/favicon.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Styra TypeScript packages 2 | 3 | [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | 5 | This repository contains Styra-supported Open Source TypeScript packages for use with the [Styra](https://styra.com) products, and [Open Policy Agent (OPA)](https://www.openpolicyagent.org/). 6 | 7 | ## [@styra/opa](https://www.npmjs.com/package/@styra/opa) 8 | 9 | The Styra-supported driver to connect to Open Policy Agent (OPA) and Enterprise OPA deployments. 10 | 11 | 12 | ## [@styra/opa-react](https://www.npmjs.com/package/@styra/opa-react) 13 | 14 | Utilities for using [@styra/opa](https://www.npmjs.com/package/@styra/opa) from React. 15 | 16 | 17 | ## [@styra/ucast-prisma](https://www.npmjs.com/package/@styra/ucast-prisma) 18 | 19 | Utilities for using [@styra/opa](https://www.npmjs.com/package/@styra/opa) and 20 | [Enterprise OPA's Compile API](https://docs.styra.com/enterprise-opa/reference/api-reference/partial-evaluation-api) with Prisma. 21 | 22 | 23 | ## Community 24 | 25 | For questions, discussions and announcements related to Styra products, services and open-source projects, please join 26 | the Styra community on [Slack](https://communityinviter.com/apps/styracommunity/signup)! 27 | -------------------------------------------------------------------------------- /build/compile-opa.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | pushd ../../ 6 | npm install # 'npm ci' fails with engine mismatch in SE workflow run 7 | npm run build --workspaces 8 | -------------------------------------------------------------------------------- /build/opa-release-notes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This takes the last block (by record separator "\n## ") and removes the first line (timestamp) 4 | awk 'BEGIN { RS="\n## "} END { print $0 }' packages/opa/RELEASES.md | \ 5 | tail +2 6 | 7 | envsubst '$VERSION' <=22", 17 | "npm": ">=8" 18 | }, 19 | "devDependencies": { 20 | "@arethetypeswrong/cli": "^0.17.4", 21 | "@changesets/cli": "^2.28.1", 22 | "esbuild": "^0.25.2", 23 | "jsr": "^0.13.4", 24 | "typedoc": "^0.26.5", 25 | "vite": "^6.3.5", 26 | "vitest": "^3.1.1" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/opa-react/.gitignore: -------------------------------------------------------------------------------- 1 | /.tshy 2 | /.tshy-* 3 | /src/package.json 4 | -------------------------------------------------------------------------------- /packages/opa-react/.npmignore: -------------------------------------------------------------------------------- 1 | /* 2 | !/**/*.ts* 3 | !/**/*.js* 4 | !/**/*.map 5 | /tests/**/*.ts* 6 | -------------------------------------------------------------------------------- /packages/opa-react/README.md: -------------------------------------------------------------------------------- 1 | # @styra/opa-react 2 | 3 | [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | [![NPM Version](https://img.shields.io/npm/v/%40styra%2Fopa-react?style=flat&color=%2324b6e0)](https://www.npmjs.com/package/@styra/opa-react) 5 | 6 | This package contains helpers for using [@styra/opa](https://www.npmjs.com/package/@styra/opa) from React. 7 | 8 | ## Features 9 | 10 | * High-level, declarative components for embedding authorization decisions in your frontend code. 11 | * Built-in caching, deduplication, and state management based on `@tanstack/react-query`. 12 | * Optional **request batching** for backends that support it (Enterprise OPA, or your own implementation of the Batch API). 13 | 14 | ## Details 15 | 16 | The package provides an `useAuthz` hook and a high-level `` component. 17 | 18 | They are enabled by wrapping your App into ``: 19 | 20 | ```tsx 21 | 22 |