From 1547f181f57408d1175f143b3a9ed1177b7a4f16 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:01:38 +0200 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.369.0 (#197) Co-authored-by: speakeasybot --- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 14 +- package-lock.json | 2 +- packages/opa/.speakeasy/gen.lock | 16 +- packages/opa/FUNCTIONS.md | 102 +++++++++++ packages/opa/README.md | 25 +++ packages/opa/RELEASES.md | 10 +- .../models/components/batchmixedresults.md | 14 ++ .../batchsuccessfulpolicyevaluation.md | 18 ++ .../opa/docs/sdk/models/components/errors.md | 10 ++ .../opa/docs/sdk/models/components/explain.md | 7 + .../models/components/gzipacceptencoding.md | 7 + .../models/components/gzipcontentencoding.md | 7 + .../sdk/models/components/healthyserver.md | 7 + .../sdk/models/components/httpmetadata.md | 12 ++ .../opa/docs/sdk/models/components/input.md | 12 ++ .../docs/sdk/models/components/location.md | 11 ++ .../docs/sdk/models/components/provenance.md | 7 + .../docs/sdk/models/components/responses.md | 12 ++ .../responsessuccessfulpolicyresponse.md | 14 ++ .../opa/docs/sdk/models/components/result.md | 7 + .../docs/sdk/models/components/revision.md | 9 + .../docs/sdk/models/components/security.md | 7 + .../docs/sdk/models/components/servererror.md | 12 ++ .../components/successfulpolicyresponse.md | 9 + .../sdk/models/errors/batchservererror.md | 7 + .../opa/docs/sdk/models/errors/clienterror.md | 7 + packages/opa/docs/sdk/models/errors/errors.md | 10 ++ .../opa/docs/sdk/models/errors/location.md | 11 ++ .../opa/docs/sdk/models/errors/servererror.md | 7 + .../sdk/models/errors/servererrorerrors.md | 10 ++ .../sdk/models/errors/servererrorlocation.md | 11 ++ .../docs/sdk/models/errors/unhealthyserver.md | 7 + .../executebatchpolicywithinputrequest.md | 14 ++ .../executebatchpolicywithinputrequestbody.md | 11 ++ .../executebatchpolicywithinputresponse.md | 35 ++++ .../executedefaultpolicywithinputrequest.md | 9 + .../executedefaultpolicywithinputresponse.md | 22 +++ .../models/operations/executepolicyrequest.md | 9 + .../operations/executepolicyresponse.md | 20 +++ .../executepolicywithinputrequest.md | 12 ++ .../executepolicywithinputrequestbody.md | 14 ++ .../executepolicywithinputresponse.md | 20 +++ .../sdk/models/operations/healthrequest.md | 7 + .../sdk/models/operations/healthresponse.md | 14 ++ packages/opa/docs/sdks/opaapiclient/README.md | 159 ++++++++++++++++++ packages/opa/jsr.json | 2 +- packages/opa/package.json | 10 +- packages/opa/src/lib/config.ts | 6 +- 49 files changed, 759 insertions(+), 28 deletions(-) create mode 100644 packages/opa/FUNCTIONS.md diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index bb993bc..0bdaced 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 1.4.0 + version: 1.4.1 additionalDependencies: dependencies: {} devDependencies: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index cf1f65d..2038593 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,18 +1,18 @@ -speakeasyVersion: 1.361.1 +speakeasyVersion: 1.369.0 sources: openapi: sourceNamespace: openapi - sourceRevisionDigest: sha256:041a9c6f5a9a2ad11fb0ecb4c958ee21331d4c1df411241715405a481a0842f4 - sourceBlobDigest: sha256:1278b402479d50883b21bc284419cdd247db61f17087a97dd47531b54f0c326c + sourceRevisionDigest: sha256:9b23164c63cb86b765915fb16fe576a049193d891ad7187b8b07933709cce52d + sourceBlobDigest: sha256:7a77d65d39072fc44b01f8f6d61e871955a17efd6f9ea7b21114566ae9199507 tags: - latest - - dependabot-npm_and_yarn-multi-875484771a + - main targets: first-target: source: openapi sourceNamespace: openapi - sourceRevisionDigest: sha256:041a9c6f5a9a2ad11fb0ecb4c958ee21331d4c1df411241715405a481a0842f4 - sourceBlobDigest: sha256:1278b402479d50883b21bc284419cdd247db61f17087a97dd47531b54f0c326c + sourceRevisionDigest: sha256:9b23164c63cb86b765915fb16fe576a049193d891ad7187b8b07933709cce52d + sourceBlobDigest: sha256:7a77d65d39072fc44b01f8f6d61e871955a17efd6f9ea7b21114566ae9199507 outLocation: packages/opa workflow: workflowVersion: 1.0.0 @@ -21,8 +21,6 @@ workflow: openapi: inputs: - location: https://raw.githubusercontent.com/StyraInc/enterprise-opa/main/openapi/openapi.yaml - overlays: - - location: ./.speakeasy/overlay.yaml registry: location: registry.speakeasyapi.dev/styra/styra/openapi targets: diff --git a/package-lock.json b/package-lock.json index bfc4ee5..0052462 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9881,7 +9881,7 @@ }, "packages/opa": { "name": "@styra/opa", - "version": "1.4.0", + "version": "1.4.1", "license": "Apache-2.0", "devDependencies": { "@types/node": "^20.14.9", diff --git a/packages/opa/.speakeasy/gen.lock b/packages/opa/.speakeasy/gen.lock index c3a50a4..6656750 100755 --- a/packages/opa/.speakeasy/gen.lock +++ b/packages/opa/.speakeasy/gen.lock @@ -1,20 +1,20 @@ lockVersion: 2.0.0 id: 078615ff-ff96-44f8-8aca-2f4d3e687bf0 management: - docChecksum: 553ed43ff98c81b3e770c34850f0b5f5 + docChecksum: 899b27d9399190d5ff40fc3e7c07c252 docVersion: 0.2.0 - speakeasyVersion: 1.361.1 - generationVersion: 2.393.4 - releaseVersion: 1.4.0 - configChecksum: 931fe09dabde06c0b0a9d81cf9c8e1da + speakeasyVersion: 1.369.0 + generationVersion: 2.399.0 + releaseVersion: 1.4.1 + configChecksum: c714d6cd61c0b03af384266ab1d93b6b repoURL: https://github.com/StyraInc/opa-typescript.git repoSubDirectory: packages/opa installationURL: https://gitpkg.now.sh/StyraInc/opa-typescript/packages/opa features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.7 - core: 3.13.1 + constsAndDefaults: 0.1.8 + core: 3.13.2 defaultEnabledRetries: 0.1.0 envVarSecurityUsage: 0.1.1 examples: 2.81.4 @@ -35,6 +35,7 @@ generatedFiles: - src/funcs/health.ts - src/sdk/sdk.ts - .eslintrc.cjs + - FUNCTIONS.md - RUNTIMES.md - jsr.json - package.json @@ -134,4 +135,3 @@ generatedFiles: - src/hooks/hooks.ts - src/hooks/types.ts - src/hooks/index.ts - - CONTRIBUTING.md diff --git a/packages/opa/FUNCTIONS.md b/packages/opa/FUNCTIONS.md new file mode 100644 index 0000000..f547862 --- /dev/null +++ b/packages/opa/FUNCTIONS.md @@ -0,0 +1,102 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { OpaApiClientCore } from "@styra/opa/core.js"; +import { executeDefaultPolicyWithInput } from "@styra/opa/funcs/executeDefaultPolicyWithInput.js"; +import { SDKValidationError } from "@styra/opa/sdk/models/errors/sdkvalidationerror.js"; + +// Use `OpaApiClientCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const opaApiClient = new OpaApiClientCore(); + +async function run() { + const res = await executeDefaultPolicyWithInput(opaApiClient, 5928.45); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/packages/opa/README.md b/packages/opa/README.md index b338537..f4cacab 100644 --- a/packages/opa/README.md +++ b/packages/opa/README.md @@ -401,6 +401,31 @@ const sdk = new OpaApiClient({ debugLogger: console }); ``` + +## Standalone functions + +All the methods listed above are available as standalone functions. These +functions are ideal for use in applications running in the browser, serverless +runtimes or other environments where application bundle size is a primary +concern. When using a bundler to build your application, all unused +functionality will be either excluded from the final bundle or tree-shaken away. + +To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +
+ +Available standalone functions + +- [executeBatchPolicyWithInput](docs/sdks/opaapiclient/README.md#executebatchpolicywithinput) +- [executeDefaultPolicyWithInput](docs/sdks/opaapiclient/README.md#executedefaultpolicywithinput) +- [executePolicyWithInput](docs/sdks/opaapiclient/README.md#executepolicywithinput) +- [executePolicy](docs/sdks/opaapiclient/README.md#executepolicy) +- [health](docs/sdks/opaapiclient/README.md#health) + + +
+ + ## Community diff --git a/packages/opa/RELEASES.md b/packages/opa/RELEASES.md index 76f8c4c..a7e384d 100644 --- a/packages/opa/RELEASES.md +++ b/packages/opa/RELEASES.md @@ -405,4 +405,12 @@ Based on: - OpenAPI Doc - Speakeasy CLI 1.361.1 (2.393.4) https://github.com/speakeasy-api/speakeasy ### Generated -- [typescript v1.4.0] packages/opa \ No newline at end of file +- [typescript v1.4.0] packages/opa + +## 2024-08-15 11:53:35 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.369.0 (2.399.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.4.1] packages/opa \ No newline at end of file diff --git a/packages/opa/docs/sdk/models/components/batchmixedresults.md b/packages/opa/docs/sdk/models/components/batchmixedresults.md index d85c670..4009dbe 100644 --- a/packages/opa/docs/sdk/models/components/batchmixedresults.md +++ b/packages/opa/docs/sdk/models/components/batchmixedresults.md @@ -1,5 +1,19 @@ # BatchMixedResults +## Example Usage + +```typescript +import { BatchMixedResults } from "@styra/opa/sdk/models/components"; + +let value: BatchMixedResults = { + responses: { + key: { + result: 3927.85, + httpStatusCode: "200", + }, + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/batchsuccessfulpolicyevaluation.md b/packages/opa/docs/sdk/models/components/batchsuccessfulpolicyevaluation.md index 0dc6cab..1e68c60 100644 --- a/packages/opa/docs/sdk/models/components/batchsuccessfulpolicyevaluation.md +++ b/packages/opa/docs/sdk/models/components/batchsuccessfulpolicyevaluation.md @@ -1,5 +1,23 @@ # BatchSuccessfulPolicyEvaluation +## Example Usage + +```typescript +import { BatchSuccessfulPolicyEvaluation } from "@styra/opa/sdk/models/components"; + +let value: BatchSuccessfulPolicyEvaluation = { + batchDecisionId: "1bef6b7d-cd13-4890-bfe1-fd2e8de32189", + responses: { + key: { + result: { + allow: true, + user_is_admin: true, + user_is_granted: [""], + }, + }, + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/errors.md b/packages/opa/docs/sdk/models/components/errors.md index 18c46f1..cef2e2b 100644 --- a/packages/opa/docs/sdk/models/components/errors.md +++ b/packages/opa/docs/sdk/models/components/errors.md @@ -1,5 +1,15 @@ # Errors +## Example Usage + +```typescript +import { Errors } from "@styra/opa/sdk/models/components"; + +let value: Errors = { + code: "", + message: "", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/explain.md b/packages/opa/docs/sdk/models/components/explain.md index f66494a..134d9b8 100644 --- a/packages/opa/docs/sdk/models/components/explain.md +++ b/packages/opa/docs/sdk/models/components/explain.md @@ -1,5 +1,12 @@ # Explain +## Example Usage + +```typescript +import { Explain } from "@styra/opa/sdk/models/components"; + +let value: Explain = Explain.Fails; +``` ## Values diff --git a/packages/opa/docs/sdk/models/components/gzipacceptencoding.md b/packages/opa/docs/sdk/models/components/gzipacceptencoding.md index dded017..9d8e035 100644 --- a/packages/opa/docs/sdk/models/components/gzipacceptencoding.md +++ b/packages/opa/docs/sdk/models/components/gzipacceptencoding.md @@ -1,5 +1,12 @@ # GzipAcceptEncoding +## Example Usage + +```typescript +import { GzipAcceptEncoding } from "@styra/opa/sdk/models/components"; + +let value: GzipAcceptEncoding = GzipAcceptEncoding.Gzip; +``` ## Values diff --git a/packages/opa/docs/sdk/models/components/gzipcontentencoding.md b/packages/opa/docs/sdk/models/components/gzipcontentencoding.md index 59fdb98..d011126 100644 --- a/packages/opa/docs/sdk/models/components/gzipcontentencoding.md +++ b/packages/opa/docs/sdk/models/components/gzipcontentencoding.md @@ -1,5 +1,12 @@ # GzipContentEncoding +## Example Usage + +```typescript +import { GzipContentEncoding } from "@styra/opa/sdk/models/components"; + +let value: GzipContentEncoding = GzipContentEncoding.Gzip; +``` ## Values diff --git a/packages/opa/docs/sdk/models/components/healthyserver.md b/packages/opa/docs/sdk/models/components/healthyserver.md index 1579a46..ee52ae5 100644 --- a/packages/opa/docs/sdk/models/components/healthyserver.md +++ b/packages/opa/docs/sdk/models/components/healthyserver.md @@ -1,5 +1,12 @@ # HealthyServer +## Example Usage + +```typescript +import { HealthyServer } from "@styra/opa/sdk/models/components"; + +let value: HealthyServer = {}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/httpmetadata.md b/packages/opa/docs/sdk/models/components/httpmetadata.md index 8ce9328..0ce96cd 100644 --- a/packages/opa/docs/sdk/models/components/httpmetadata.md +++ b/packages/opa/docs/sdk/models/components/httpmetadata.md @@ -1,5 +1,17 @@ # HTTPMetadata +## Example Usage + +```typescript +import { HTTPMetadata } from "@styra/opa/sdk/models/components"; + +let value: HTTPMetadata = { + response: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/input.md b/packages/opa/docs/sdk/models/components/input.md index b1bd5e2..70a85e5 100644 --- a/packages/opa/docs/sdk/models/components/input.md +++ b/packages/opa/docs/sdk/models/components/input.md @@ -2,6 +2,18 @@ Arbitrary JSON used within your policies by accessing `input` +## Example Usage + +```typescript +import { Input } from "@styra/opa/sdk/models/components"; + +let value: Input = { + user: "alice", + action: "read", + object: "id123", + type: "dog", +}; +``` ## Supported Types diff --git a/packages/opa/docs/sdk/models/components/location.md b/packages/opa/docs/sdk/models/components/location.md index eec2dae..0ab075b 100644 --- a/packages/opa/docs/sdk/models/components/location.md +++ b/packages/opa/docs/sdk/models/components/location.md @@ -1,5 +1,16 @@ # Location +## Example Usage + +```typescript +import { Location } from "@styra/opa/sdk/models/components"; + +let value: Location = { + file: "", + row: 477665, + col: 791725, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/provenance.md b/packages/opa/docs/sdk/models/components/provenance.md index c79c51a..70617f9 100644 --- a/packages/opa/docs/sdk/models/components/provenance.md +++ b/packages/opa/docs/sdk/models/components/provenance.md @@ -2,6 +2,13 @@ Provenance information can be requested on individual API calls and are returned inline with the API response. To obtain provenance information on an API call, specify the `provenance=true` query parameter when executing the API call. +## Example Usage + +```typescript +import { Provenance } from "@styra/opa/sdk/models/components"; + +let value: Provenance = {}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/responses.md b/packages/opa/docs/sdk/models/components/responses.md index 2bc85fa..28b9525 100644 --- a/packages/opa/docs/sdk/models/components/responses.md +++ b/packages/opa/docs/sdk/models/components/responses.md @@ -1,5 +1,17 @@ # Responses +## Example Usage + +```typescript +import { Responses } from "@styra/opa/sdk/models/components"; + +let value: Responses = { + code: "", + message: "", + decisionId: "b84cf736-213c-4932-a8e4-bb5c648f1b4d", + httpStatusCode: "200", +}; +``` ## Supported Types diff --git a/packages/opa/docs/sdk/models/components/responsessuccessfulpolicyresponse.md b/packages/opa/docs/sdk/models/components/responsessuccessfulpolicyresponse.md index 34fbb63..11f6863 100644 --- a/packages/opa/docs/sdk/models/components/responsessuccessfulpolicyresponse.md +++ b/packages/opa/docs/sdk/models/components/responsessuccessfulpolicyresponse.md @@ -1,5 +1,19 @@ # ResponsesSuccessfulPolicyResponse +## Example Usage + +```typescript +import { ResponsesSuccessfulPolicyResponse } from "@styra/opa/sdk/models/components"; + +let value: ResponsesSuccessfulPolicyResponse = { + result: { + allow: true, + user_is_admin: true, + user_is_granted: [""], + }, + httpStatusCode: "200", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/result.md b/packages/opa/docs/sdk/models/components/result.md index 1471d37..0b847ed 100644 --- a/packages/opa/docs/sdk/models/components/result.md +++ b/packages/opa/docs/sdk/models/components/result.md @@ -2,6 +2,13 @@ The base or virtual document referred to by the URL path. If the path is undefined, this key will be omitted. +## Example Usage + +```typescript +import { Result } from "@styra/opa/sdk/models/components"; + +let value: Result = false; +``` ## Supported Types diff --git a/packages/opa/docs/sdk/models/components/revision.md b/packages/opa/docs/sdk/models/components/revision.md index 2c3bce5..6da4661 100644 --- a/packages/opa/docs/sdk/models/components/revision.md +++ b/packages/opa/docs/sdk/models/components/revision.md @@ -1,5 +1,14 @@ # Revision +## Example Usage + +```typescript +import { Revision } from "@styra/opa/sdk/models/components"; + +let value: Revision = { + revision: "", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/security.md b/packages/opa/docs/sdk/models/components/security.md index 4576e99..eb0a4cc 100644 --- a/packages/opa/docs/sdk/models/components/security.md +++ b/packages/opa/docs/sdk/models/components/security.md @@ -1,5 +1,12 @@ # Security +## Example Usage + +```typescript +import { Security } from "@styra/opa/sdk/models/components"; + +let value: Security = {}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/servererror.md b/packages/opa/docs/sdk/models/components/servererror.md index b9c980e..db1fc44 100644 --- a/packages/opa/docs/sdk/models/components/servererror.md +++ b/packages/opa/docs/sdk/models/components/servererror.md @@ -1,5 +1,17 @@ # ServerError +## Example Usage + +```typescript +import { ServerError } from "@styra/opa/sdk/models/components"; + +let value: ServerError = { + code: "", + message: "", + decisionId: "b84cf736-213c-4932-a8e4-bb5c648f1b4d", + httpStatusCode: "200", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/components/successfulpolicyresponse.md b/packages/opa/docs/sdk/models/components/successfulpolicyresponse.md index ae8c5dd..733b66e 100644 --- a/packages/opa/docs/sdk/models/components/successfulpolicyresponse.md +++ b/packages/opa/docs/sdk/models/components/successfulpolicyresponse.md @@ -1,5 +1,14 @@ # SuccessfulPolicyResponse +## Example Usage + +```typescript +import { SuccessfulPolicyResponse } from "@styra/opa/sdk/models/components"; + +let value: SuccessfulPolicyResponse = { + result: "", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/batchservererror.md b/packages/opa/docs/sdk/models/errors/batchservererror.md index e849178..9eee011 100644 --- a/packages/opa/docs/sdk/models/errors/batchservererror.md +++ b/packages/opa/docs/sdk/models/errors/batchservererror.md @@ -1,5 +1,12 @@ # BatchServerError +## Example Usage + +```typescript +import { BatchServerError } from "@styra/opa/sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/clienterror.md b/packages/opa/docs/sdk/models/errors/clienterror.md index e82f1ef..8c63682 100644 --- a/packages/opa/docs/sdk/models/errors/clienterror.md +++ b/packages/opa/docs/sdk/models/errors/clienterror.md @@ -2,6 +2,13 @@ Bad Request +## Example Usage + +```typescript +import { ClientError } from "@styra/opa/sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/errors.md b/packages/opa/docs/sdk/models/errors/errors.md index 47c51d0..2bed06c 100644 --- a/packages/opa/docs/sdk/models/errors/errors.md +++ b/packages/opa/docs/sdk/models/errors/errors.md @@ -1,5 +1,15 @@ # Errors +## Example Usage + +```typescript +import { Errors } from "@styra/opa/sdk/models/errors"; + +let value: Errors = { + code: "", + message: "", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/location.md b/packages/opa/docs/sdk/models/errors/location.md index eec2dae..e2003e7 100644 --- a/packages/opa/docs/sdk/models/errors/location.md +++ b/packages/opa/docs/sdk/models/errors/location.md @@ -1,5 +1,16 @@ # Location +## Example Usage + +```typescript +import { Location } from "@styra/opa/sdk/models/errors"; + +let value: Location = { + file: "", + row: 836079, + col: 71036, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/servererror.md b/packages/opa/docs/sdk/models/errors/servererror.md index 29f61be..40e227b 100644 --- a/packages/opa/docs/sdk/models/errors/servererror.md +++ b/packages/opa/docs/sdk/models/errors/servererror.md @@ -2,6 +2,13 @@ Server Error +## Example Usage + +```typescript +import { ServerError } from "@styra/opa/sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/servererrorerrors.md b/packages/opa/docs/sdk/models/errors/servererrorerrors.md index 14d2cdf..396aad8 100644 --- a/packages/opa/docs/sdk/models/errors/servererrorerrors.md +++ b/packages/opa/docs/sdk/models/errors/servererrorerrors.md @@ -1,5 +1,15 @@ # ServerErrorErrors +## Example Usage + +```typescript +import { ServerErrorErrors } from "@styra/opa/sdk/models/errors"; + +let value: ServerErrorErrors = { + code: "", + message: "", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/servererrorlocation.md b/packages/opa/docs/sdk/models/errors/servererrorlocation.md index 3871c9b..97f1e34 100644 --- a/packages/opa/docs/sdk/models/errors/servererrorlocation.md +++ b/packages/opa/docs/sdk/models/errors/servererrorlocation.md @@ -1,5 +1,16 @@ # ServerErrorLocation +## Example Usage + +```typescript +import { ServerErrorLocation } from "@styra/opa/sdk/models/errors"; + +let value: ServerErrorLocation = { + file: "", + row: 337396, + col: 87129, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/errors/unhealthyserver.md b/packages/opa/docs/sdk/models/errors/unhealthyserver.md index b2aadc7..adf48e8 100644 --- a/packages/opa/docs/sdk/models/errors/unhealthyserver.md +++ b/packages/opa/docs/sdk/models/errors/unhealthyserver.md @@ -1,5 +1,12 @@ # UnhealthyServer +## Example Usage + +```typescript +import { UnhealthyServer } from "@styra/opa/sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequest.md b/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequest.md index 1da183b..ce553b3 100644 --- a/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequest.md +++ b/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequest.md @@ -1,5 +1,19 @@ # ExecuteBatchPolicyWithInputRequest +## Example Usage + +```typescript +import { ExecuteBatchPolicyWithInputRequest } from "@styra/opa/sdk/models/operations"; + +let value: ExecuteBatchPolicyWithInputRequest = { + path: "app/rbac", + requestBody: { + inputs: { + key: "", + }, + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequestbody.md b/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequestbody.md index 03edef2..f1bf4ad 100644 --- a/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequestbody.md +++ b/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputrequestbody.md @@ -2,6 +2,17 @@ The batch of inputs +## Example Usage + +```typescript +import { ExecuteBatchPolicyWithInputRequestBody } from "@styra/opa/sdk/models/operations"; + +let value: ExecuteBatchPolicyWithInputRequestBody = { + inputs: { + key: [""], + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputresponse.md b/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputresponse.md index fb6b6bb..9d5c253 100644 --- a/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputresponse.md +++ b/packages/opa/docs/sdk/models/operations/executebatchpolicywithinputresponse.md @@ -1,5 +1,40 @@ # ExecuteBatchPolicyWithInputResponse +## Example Usage + +```typescript +import { ExecuteBatchPolicyWithInputResponse } from "@styra/opa/sdk/models/operations"; + +let value: ExecuteBatchPolicyWithInputResponse = { + httpMeta: { + response: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + batchSuccessfulPolicyEvaluation: { + batchDecisionId: "1bef6b7d-cd13-4890-bfe1-fd2e8de32189", + responses: { + key: { + result: 2975.34, + }, + }, + }, + batchMixedResults: { + responses: { + key: { + code: "", + message: "", + decisionId: "b84cf736-213c-4932-a8e4-bb5c648f1b4d", + httpStatusCode: "200", + }, + }, + }, + headers: { + key: [""], + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputrequest.md b/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputrequest.md index 2502003..93107bb 100644 --- a/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputrequest.md +++ b/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputrequest.md @@ -1,5 +1,14 @@ # ExecuteDefaultPolicyWithInputRequest +## Example Usage + +```typescript +import { ExecuteDefaultPolicyWithInputRequest } from "@styra/opa/sdk/models/operations"; + +let value: ExecuteDefaultPolicyWithInputRequest = { + input: [""], +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputresponse.md b/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputresponse.md index b4a2e33..efe4c55 100644 --- a/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputresponse.md +++ b/packages/opa/docs/sdk/models/operations/executedefaultpolicywithinputresponse.md @@ -1,5 +1,27 @@ # ExecuteDefaultPolicyWithInputResponse +## Example Usage + +```typescript +import { ExecuteDefaultPolicyWithInputResponse } from "@styra/opa/sdk/models/operations"; + +let value: ExecuteDefaultPolicyWithInputResponse = { + httpMeta: { + response: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + result: { + allow: true, + user_is_admin: true, + user_is_granted: [""], + }, + headers: { + key: [""], + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executepolicyrequest.md b/packages/opa/docs/sdk/models/operations/executepolicyrequest.md index b64419e..255408a 100644 --- a/packages/opa/docs/sdk/models/operations/executepolicyrequest.md +++ b/packages/opa/docs/sdk/models/operations/executepolicyrequest.md @@ -1,5 +1,14 @@ # ExecutePolicyRequest +## Example Usage + +```typescript +import { ExecutePolicyRequest } from "@styra/opa/sdk/models/operations"; + +let value: ExecutePolicyRequest = { + path: "app/rbac", +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executepolicyresponse.md b/packages/opa/docs/sdk/models/operations/executepolicyresponse.md index 0a580a4..5d6de3d 100644 --- a/packages/opa/docs/sdk/models/operations/executepolicyresponse.md +++ b/packages/opa/docs/sdk/models/operations/executepolicyresponse.md @@ -1,5 +1,25 @@ # ExecutePolicyResponse +## Example Usage + +```typescript +import { ExecutePolicyResponse } from "@styra/opa/sdk/models/operations"; + +let value: ExecutePolicyResponse = { + httpMeta: { + response: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + successfulPolicyResponse: { + result: [""], + }, + headers: { + key: [""], + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executepolicywithinputrequest.md b/packages/opa/docs/sdk/models/operations/executepolicywithinputrequest.md index 0a5e582..c694515 100644 --- a/packages/opa/docs/sdk/models/operations/executepolicywithinputrequest.md +++ b/packages/opa/docs/sdk/models/operations/executepolicywithinputrequest.md @@ -1,5 +1,17 @@ # ExecutePolicyWithInputRequest +## Example Usage + +```typescript +import { ExecutePolicyWithInputRequest } from "@styra/opa/sdk/models/operations"; + +let value: ExecutePolicyWithInputRequest = { + path: "app/rbac", + requestBody: { + input: 8472.52, + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executepolicywithinputrequestbody.md b/packages/opa/docs/sdk/models/operations/executepolicywithinputrequestbody.md index 3c460cd..de5ed6e 100644 --- a/packages/opa/docs/sdk/models/operations/executepolicywithinputrequestbody.md +++ b/packages/opa/docs/sdk/models/operations/executepolicywithinputrequestbody.md @@ -2,6 +2,20 @@ The input document +## Example Usage + +```typescript +import { ExecutePolicyWithInputRequestBody } from "@styra/opa/sdk/models/operations"; + +let value: ExecutePolicyWithInputRequestBody = { + input: { + user: "alice", + action: "read", + object: "id123", + type: "dog", + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/executepolicywithinputresponse.md b/packages/opa/docs/sdk/models/operations/executepolicywithinputresponse.md index 817b25b..0b23b32 100644 --- a/packages/opa/docs/sdk/models/operations/executepolicywithinputresponse.md +++ b/packages/opa/docs/sdk/models/operations/executepolicywithinputresponse.md @@ -1,5 +1,25 @@ # ExecutePolicyWithInputResponse +## Example Usage + +```typescript +import { ExecutePolicyWithInputResponse } from "@styra/opa/sdk/models/operations"; + +let value: ExecutePolicyWithInputResponse = { + httpMeta: { + response: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + successfulPolicyResponse: { + result: 6235.64, + }, + headers: { + key: [""], + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/healthrequest.md b/packages/opa/docs/sdk/models/operations/healthrequest.md index cd17544..4a5feb8 100644 --- a/packages/opa/docs/sdk/models/operations/healthrequest.md +++ b/packages/opa/docs/sdk/models/operations/healthrequest.md @@ -1,5 +1,12 @@ # HealthRequest +## Example Usage + +```typescript +import { HealthRequest } from "@styra/opa/sdk/models/operations"; + +let value: HealthRequest = {}; +``` ## Fields diff --git a/packages/opa/docs/sdk/models/operations/healthresponse.md b/packages/opa/docs/sdk/models/operations/healthresponse.md index 780b4ee..3948f0d 100644 --- a/packages/opa/docs/sdk/models/operations/healthresponse.md +++ b/packages/opa/docs/sdk/models/operations/healthresponse.md @@ -1,5 +1,19 @@ # HealthResponse +## Example Usage + +```typescript +import { HealthResponse } from "@styra/opa/sdk/models/operations"; + +let value: HealthResponse = { + httpMeta: { + response: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, +}; +``` ## Fields diff --git a/packages/opa/docs/sdks/opaapiclient/README.md b/packages/opa/docs/sdks/opaapiclient/README.md index 10ba838..1d61161 100644 --- a/packages/opa/docs/sdks/opaapiclient/README.md +++ b/packages/opa/docs/sdks/opaapiclient/README.md @@ -34,6 +34,35 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpaApiClientCore } from "@styra/opa/core.js"; +import { executeDefaultPolicyWithInput } from "@styra/opa/funcs/executeDefaultPolicyWithInput.js"; + +// Use `OpaApiClientCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const opaApiClient = new OpaApiClientCore(); + +async function run() { + const res = await executeDefaultPolicyWithInput(opaApiClient, ""); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -80,6 +109,37 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpaApiClientCore } from "@styra/opa/core.js"; +import { executePolicy } from "@styra/opa/funcs/executePolicy.js"; + +// Use `OpaApiClientCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const opaApiClient = new OpaApiClientCore(); + +async function run() { + const res = await executePolicy(opaApiClient, { + path: "app/rbac", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -127,6 +187,40 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpaApiClientCore } from "@styra/opa/core.js"; +import { executePolicyWithInput } from "@styra/opa/funcs/executePolicyWithInput.js"; + +// Use `OpaApiClientCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const opaApiClient = new OpaApiClientCore(); + +async function run() { + const res = await executePolicyWithInput(opaApiClient, { + path: "app/rbac", + requestBody: { + input: "", + }, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -176,6 +270,42 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpaApiClientCore } from "@styra/opa/core.js"; +import { executeBatchPolicyWithInput } from "@styra/opa/funcs/executeBatchPolicyWithInput.js"; + +// Use `OpaApiClientCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const opaApiClient = new OpaApiClientCore(); + +async function run() { + const res = await executeBatchPolicyWithInput(opaApiClient, { + path: "app/rbac", + requestBody: { + inputs: { + "key": 9561.78, + }, + }, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | @@ -218,6 +348,35 @@ async function run() { run(); ``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpaApiClientCore } from "@styra/opa/core.js"; +import { health } from "@styra/opa/funcs/health.js"; + +// Use `OpaApiClientCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const opaApiClient = new OpaApiClientCore(); + +async function run() { + const res = await health(opaApiClient); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + ### Parameters | Parameter | Type | Required | Description | diff --git a/packages/opa/jsr.json b/packages/opa/jsr.json index ec2c10d..b603788 100644 --- a/packages/opa/jsr.json +++ b/packages/opa/jsr.json @@ -2,7 +2,7 @@ { "name": "@styra/opa", - "version": "1.4.0", + "version": "1.4.1", "exports": { ".": "./src/index.ts", "./sdk/models/errors": "./src/sdk/models/errors/index.ts", diff --git a/packages/opa/package.json b/packages/opa/package.json index 0851a7d..1222e20 100644 --- a/packages/opa/package.json +++ b/packages/opa/package.json @@ -1,11 +1,7 @@ { "name": "@styra/opa", - "version": "1.4.0", + "version": "1.4.1", "author": "Styra", - "license": "Apache-2.0", - "publishConfig": { - "access": "public" - }, "keywords": [ "OPA", "Open Policy Agent", @@ -15,6 +11,10 @@ "rbac", "role based access control" ], + "license": "Apache-2.0", + "publishConfig": { + "access": "public" + }, "tshy": { "exports": { ".": "./src/index.ts", diff --git a/packages/opa/src/lib/config.ts b/packages/opa/src/lib/config.ts index 224bf5b..f3bbd0d 100644 --- a/packages/opa/src/lib/config.ts +++ b/packages/opa/src/lib/config.ts @@ -57,7 +57,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.2.0", - sdkVersion: "1.4.0", - genVersion: "2.393.4", - userAgent: "speakeasy-sdk/typescript 1.4.0 2.393.4 0.2.0 @styra/opa", + sdkVersion: "1.4.1", + genVersion: "2.399.0", + userAgent: "speakeasy-sdk/typescript 1.4.1 2.399.0 0.2.0 @styra/opa", } as const;