Skip to content

Commit

Permalink
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.369.0 (#197)
Browse files Browse the repository at this point in the history
Co-authored-by: speakeasybot <[email protected]>
  • Loading branch information
github-actions[bot] and speakeasybot committed Aug 15, 2024
1 parent 67ae3ae commit 1547f18
Show file tree
Hide file tree
Showing 49 changed files with 759 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: false
typescript:
version: 1.4.0
version: 1.4.1
additionalDependencies:
dependencies: {}
devDependencies:
Expand Down
14 changes: 6 additions & 8 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions packages/opa/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -35,6 +35,7 @@ generatedFiles:
- src/funcs/health.ts
- src/sdk/sdk.ts
- .eslintrc.cjs
- FUNCTIONS.md
- RUNTIMES.md
- jsr.json
- package.json
Expand Down Expand Up @@ -134,4 +135,3 @@ generatedFiles:
- src/hooks/hooks.ts
- src/hooks/types.ts
- src/hooks/index.ts
- CONTRIBUTING.md
102 changes: 102 additions & 0 deletions packages/opa/FUNCTIONS.md
Original file line number Diff line number Diff line change
@@ -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<Value, Error>` 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 "<sdk-package-name>";
import { fetchSomething } from "<sdk-package-name>/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).
25 changes: 25 additions & 0 deletions packages/opa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,31 @@ const sdk = new OpaApiClient({ debugLogger: console });
```
<!-- End Debugging [debug] -->

<!-- Start Standalone functions [standalone-funcs] -->
## 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).

<details>

<summary>Available standalone functions</summary>

- [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)


</details>
<!-- End Standalone functions [standalone-funcs] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

## Community
Expand Down
10 changes: 9 additions & 1 deletion packages/opa/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- [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
14 changes: 14 additions & 0 deletions packages/opa/docs/sdk/models/components/batchmixedresults.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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: ["<value>"],
},
},
},
};
```

## Fields

Expand Down
10 changes: 10 additions & 0 deletions packages/opa/docs/sdk/models/components/errors.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Errors

## Example Usage

```typescript
import { Errors } from "@styra/opa/sdk/models/components";

let value: Errors = {
code: "<value>",
message: "<value>",
};
```

## Fields

Expand Down
7 changes: 7 additions & 0 deletions packages/opa/docs/sdk/models/components/explain.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Explain

## Example Usage

```typescript
import { Explain } from "@styra/opa/sdk/models/components";

let value: Explain = Explain.Fails;
```

## Values

Expand Down
7 changes: 7 additions & 0 deletions packages/opa/docs/sdk/models/components/gzipacceptencoding.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# GzipAcceptEncoding

## Example Usage

```typescript
import { GzipAcceptEncoding } from "@styra/opa/sdk/models/components";

let value: GzipAcceptEncoding = GzipAcceptEncoding.Gzip;
```

## Values

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# GzipContentEncoding

## Example Usage

```typescript
import { GzipContentEncoding } from "@styra/opa/sdk/models/components";

let value: GzipContentEncoding = GzipContentEncoding.Gzip;
```

## Values

Expand Down
7 changes: 7 additions & 0 deletions packages/opa/docs/sdk/models/components/healthyserver.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# HealthyServer

## Example Usage

```typescript
import { HealthyServer } from "@styra/opa/sdk/models/components";

let value: HealthyServer = {};
```

## Fields

Expand Down
12 changes: 12 additions & 0 deletions packages/opa/docs/sdk/models/components/httpmetadata.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 12 additions & 0 deletions packages/opa/docs/sdk/models/components/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 1547f18

Please sign in to comment.