Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ id: 2f8b2839-3001-46b4-b5e0-cec0aad583ed
management:
docChecksum: 2422daf10293e923232daf08349ae0ae
docVersion: 0.2.0
speakeasyVersion: 1.277.1
generationVersion: 2.317.0
releaseVersion: 0.4.2
configChecksum: 79144134c7663495fdf07e9a4393b783
speakeasyVersion: 1.286.0
generationVersion: 2.326.3
releaseVersion: 0.5.0
configChecksum: 12a2529c34d131d1a3a61086b3fd32dc
repoURL: https://github.com/StyraInc/opa-typescript.git
installationURL: https://github.com/StyraInc/opa-typescript
published: true
features:
typescript:
additionalDependencies: 0.1.0
constsAndDefaults: 0.1.5
core: 3.9.2
examples: 2.81.3
core: 3.9.3
examples: 2.81.4
flattening: 2.81.1
globalSecurityCallbacks: 0.1.0
globalServerURLs: 2.82.4
responseFormat: 0.2.3
unions: 2.85.3
sdkHooks: 0.1.0
unions: 2.85.4
generatedFiles:
- src/sdk/sdk.ts
- RUNTIMES.md
Expand Down
3 changes: 2 additions & 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: 0.4.2
version: 0.5.0
additionalDependencies:
dependencies: {}
devDependencies:
Expand All @@ -39,6 +39,7 @@ typescript:
webhooks: sdk/models/webhooks
inputModelSuffix: input
maxMethodParams: 4
methodArguments: require-security-and-request
outputModelSuffix: output
packageName: '@styra/opa'
responseFormat: envelope-http
Expand Down
15 changes: 13 additions & 2 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
speakeasyVersion: 1.277.1
speakeasyVersion: 1.286.0
sources:
openapi: {}
openapi:
sourceNamespace: openapi
sourceRevisionDigest: sha256:a533ab22170eaa56a25bda5a6ea2b4ce81e458a192b449c4f2d3b2e0041b19ac
sourceBlobDigest: sha256:2e4510c88bf40f5ebe1982d8a370214696a9eaa4b11a656b904a93c3e4788325
tags:
- latest
- main
targets:
first-target:
source: openapi
sourceNamespace: openapi
sourceRevisionDigest: sha256:a533ab22170eaa56a25bda5a6ea2b4ce81e458a192b449c4f2d3b2e0041b19ac
sourceBlobDigest: sha256:2e4510c88bf40f5ebe1982d8a370214696a9eaa4b11a656b904a93c3e4788325
outLocation: /github/workspace/repo
workflow:
workflowVersion: 1.0.0
Expand All @@ -12,6 +21,8 @@ workflow:
openapi:
inputs:
- location: https://raw.githubusercontent.com/StyraInc/enterprise-opa/main/openapi/openapi.yaml
registry:
location: registry.speakeasyapi.dev/styra/styra/openapi
targets:
first-target:
target: typescript
Expand Down
2 changes: 2 additions & 0 deletions .speakeasy/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ sources:
openapi:
inputs:
- location: https://raw.githubusercontent.com/StyraInc/enterprise-opa/main/openapi/openapi.yaml
registry:
location: registry.speakeasyapi.dev/styra/styra/openapi
targets:
first-target:
target: typescript
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,14 @@ Based on:
### Generated
- [typescript v0.4.2] .
### Releases
- [NPM v0.4.2] https://www.npmjs.com/package/@styra/opa/v/0.4.2 - .
- [NPM v0.4.2] https://www.npmjs.com/package/@styra/opa/v/0.4.2 - .

## 2024-05-13 00:15:08
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.286.0 (2.326.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.5.0] .
### Releases
- [NPM v0.5.0] https://www.npmjs.com/package/@styra/opa/v/0.5.0 - .
8 changes: 2 additions & 6 deletions docs/sdks/opaapiclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,9 @@ import { OpaApiClient } from "@styra/opa";
const opaApiClient = new OpaApiClient();

async function run() {
const bundles = false;
const plugins = false;
const excludePlugin = [
const result = await opaApiClient.health(false, false, [
"<value>",
];

const result = await opaApiClient.health(bundles, plugins, excludePlugin);
]);

// Handle the result
console.log(result)
Expand Down
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "@styra/opa",
"version": "0.4.2",
"version": "0.5.0",
"exports": {
".": "./src/index.ts",
"./sdk/models/errors": "./src/sdk/models/errors/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@styra/opa",
"version": "0.4.2",
"version": "0.5.0",
"author": "Styra",
"main": "./index.js",
"sideEffects": false,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
export const SDK_METADATA = {
language: "typescript",
openapiDocVersion: "0.2.0",
sdkVersion: "0.4.2",
genVersion: "2.317.0",
userAgent: "speakeasy-sdk/typescript 0.4.2 2.317.0 0.2.0 @styra/opa",
sdkVersion: "0.5.0",
genVersion: "2.326.3",
userAgent: "speakeasy-sdk/typescript 0.5.0 2.326.3 0.2.0 @styra/opa",
} as const;
12 changes: 11 additions & 1 deletion src/lib/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ export type Fetcher = (

export type Awaitable<T> = T | Promise<T>;

const DEFAULT_FETCHER: Fetcher = (input, init) => fetch(input, init);
const DEFAULT_FETCHER: Fetcher = (input, init) => {
// If input is a Request and init is undefined, Bun will discard the method,
// headers, body and other options that were set on the request object.
// Node.js and browers would ignore an undefined init value. This check is
// therefore needed for interop with Bun.
if (init == null) {
return fetch(input);
} else {
return fetch(input, init);
}
};

export type RequestInput = {
/**
Expand Down
34 changes: 18 additions & 16 deletions src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ export class OpaApiClient extends ClientSDK {
* Execute a policy
*/
async executePolicy(
input: operations.ExecutePolicyRequest,
request: operations.ExecutePolicyRequest,
options?: RequestOptions
): Promise<operations.ExecutePolicyResponse> {
const input$ = request;
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
headers$.set("Accept", "application/json");

const payload$ = schemas$.parse(
input,
input$,
(value$) => operations.ExecutePolicyRequest$.outboundSchema.parse(value$),
"Input validation failed"
);
Expand Down Expand Up @@ -100,18 +101,18 @@ export class OpaApiClient extends ClientSDK {
const context = { operationID: "executePolicy", oAuth2Scopes: [], securitySource: null };

const doOptions = { context, errorCodes: ["400", "4XX", "500", "5XX"] };
const request = this.createRequest$(
const request$ = this.createRequest$(
context,
{ method: "GET", path: path$, headers: headers$, query: query$, body: body$ },
options
);

const response = await this.do$(request, doOptions);
const response = await this.do$(request$, doOptions);

const responseFields$ = {
HttpMeta: {
Response: response,
Request: request,
Request: request$,
},
};

Expand Down Expand Up @@ -158,7 +159,7 @@ export class OpaApiClient extends ClientSDK {
} else {
throw new errors.SDKError("Unexpected API response status or content-type", {
response,
request,
request: request$,
});
}
}
Expand All @@ -167,16 +168,17 @@ export class OpaApiClient extends ClientSDK {
* Execute a policy given an input
*/
async executePolicyWithInput(
input: operations.ExecutePolicyWithInputRequest,
request: operations.ExecutePolicyWithInputRequest,
options?: RequestOptions
): Promise<operations.ExecutePolicyWithInputResponse> {
const input$ = request;
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
headers$.set("Content-Type", "application/json");
headers$.set("Accept", "application/json");

const payload$ = schemas$.parse(
input,
input$,
(value$) => operations.ExecutePolicyWithInputRequest$.outboundSchema.parse(value$),
"Input validation failed"
);
Expand Down Expand Up @@ -237,18 +239,18 @@ export class OpaApiClient extends ClientSDK {
};

const doOptions = { context, errorCodes: ["400", "4XX", "500", "5XX"] };
const request = this.createRequest$(
const request$ = this.createRequest$(
context,
{ method: "POST", path: path$, headers: headers$, query: query$, body: body$ },
options
);

const response = await this.do$(request, doOptions);
const response = await this.do$(request$, doOptions);

const responseFields$ = {
HttpMeta: {
Response: response,
Request: request,
Request: request$,
},
};

Expand Down Expand Up @@ -295,7 +297,7 @@ export class OpaApiClient extends ClientSDK {
} else {
throw new errors.SDKError("Unexpected API response status or content-type", {
response,
request,
request: request$,
});
}
}
Expand Down Expand Up @@ -350,18 +352,18 @@ export class OpaApiClient extends ClientSDK {
const context = { operationID: "health", oAuth2Scopes: [], securitySource: null };

const doOptions = { context, errorCodes: ["4XX", "500", "5XX"] };
const request = this.createRequest$(
const request$ = this.createRequest$(
context,
{ method: "GET", path: path$, headers: headers$, query: query$, body: body$ },
options
);

const response = await this.do$(request, doOptions);
const response = await this.do$(request$, doOptions);

const responseFields$ = {
HttpMeta: {
Response: response,
Request: request,
Request: request$,
},
};

Expand Down Expand Up @@ -394,7 +396,7 @@ export class OpaApiClient extends ClientSDK {
} else {
throw new errors.SDKError("Unexpected API response status or content-type", {
response,
request,
request: request$,
});
}
}
Expand Down