Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.277.1 (#58)
Browse files Browse the repository at this point in the history
Co-authored-by: speakeasybot <bot@speakeasyapi.dev>
  • Loading branch information
github-actions[bot] and speakeasybot authored Apr 30, 2024
1 parent c4e5b4e commit 387fe71
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 36 deletions.
10 changes: 5 additions & 5 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ id: 2f8b2839-3001-46b4-b5e0-cec0aad583ed
management:
docChecksum: 2422daf10293e923232daf08349ae0ae
docVersion: 0.2.0
speakeasyVersion: 1.276.0
generationVersion: 2.314.0
releaseVersion: 0.4.1
configChecksum: 02bbee7871c8eb9f1e6449a9a884ae2e
speakeasyVersion: 1.277.1
generationVersion: 2.317.0
releaseVersion: 0.4.2
configChecksum: 79144134c7663495fdf07e9a4393b783
repoURL: https://github.com/StyraInc/opa-typescript.git
installationURL: https://github.com/StyraInc/opa-typescript
published: true
features:
typescript:
constsAndDefaults: 0.1.5
core: 3.9.0
core: 3.9.2
examples: 2.81.3
flattening: 2.81.1
globalServerURLs: 2.82.4
Expand Down
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: 0.4.1
version: 0.4.2
additionalDependencies:
dependencies: {}
devDependencies:
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speakeasyVersion: 1.276.0
speakeasyVersion: 1.277.1
sources:
openapi: {}
targets:
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,14 @@ Based on:
### Generated
- [typescript v0.4.1] .
### Releases
- [NPM v0.4.1] https://www.npmjs.com/package/@styra/opa/v/0.4.1 - .
- [NPM v0.4.1] https://www.npmjs.com/package/@styra/opa/v/0.4.1 - .

## 2024-04-30 08:48:47
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.277.1 (2.317.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.4.2] .
### Releases
- [NPM v0.4.2] https://www.npmjs.com/package/@styra/opa/v/0.4.2 - .
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.1",
"version": "0.4.2",
"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.1",
"version": "0.4.2",
"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.1",
genVersion: "2.314.0",
userAgent: "speakeasy-sdk/typescript 0.4.1 2.314.0 0.2.0 @styra/opa",
sdkVersion: "0.4.2",
genVersion: "2.317.0",
userAgent: "speakeasy-sdk/typescript 0.4.2 2.317.0 0.2.0 @styra/opa",
} as const;
57 changes: 42 additions & 15 deletions src/lib/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,29 +141,56 @@ export class HTTPClient {
}
}

export function matchContentType(response: Response, pattern: string): boolean {
if (pattern === "*" || pattern === "*/*") {
// A semicolon surrounded by optional whitespace characters is used to separate
// segments in a media type string.
const mediaParamSeparator = /\s*;\s*/g;

function matchContentType(response: Response, pattern: string): boolean {
// `*` is a special case which means anything is acceptable.
if (pattern === "*") {
return true;
}

const contentType =
response.headers.get("content-type") ?? "application/octet-stream";
let contentType =
response.headers.get("content-type")?.trim() || "application/octet-stream";
contentType = contentType.toLowerCase();

const idx = contentType.split(";").findIndex((raw) => {
const ctype = raw.trim();
if (ctype === pattern) {
return true;
}
const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator);
const [wantType = "", ...wantParams] = wantParts;

if (wantType.split("/").length !== 2) {
return false;
}

const gotParts = contentType.split(mediaParamSeparator);
const [gotType = "", ...gotParams] = gotParts;

const [type = "", subtype = ""] = gotType.split("/");
if (!type || !subtype) {
return false;
}

const parts = ctype.split("/");
if (parts.length !== 2) {
if (
wantType !== "*/*" &&
gotType !== wantType &&
`${type}/*` !== wantType &&
`*/${subtype}` !== wantType
) {
return false;
}

if (gotParams.length < wantParams.length) {
return false;
}

const params = new Set(gotParams);
for (const wantParam of wantParams) {
if (!params.has(wantParam)) {
return false;
}
}

return `${parts[0]}/*` === pattern || `*/${parts[1]}` === pattern;
});

return idx >= 0;
return true;
}

const codeRangeRE = new RegExp("^[0-9]xx$", "i");
Expand Down
5 changes: 3 additions & 2 deletions src/lib/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ type SecurityInputOAuth2 = {

type SecurityInputOAuth2ClientCredentials = {
type: "oauth2:client_credentials";
value: string | null | undefined;
fieldName: "clientID" | "clientSecret";
value: { clientID?: string | undefined; clientSecret?: string | undefined } | null | undefined;
};

export type SecurityInput =
Expand All @@ -91,6 +90,8 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState |
return false;
} else if (o.type === "http:basic") {
return o.value.username != null || o.value.password != null;
} else if (o.type === "oauth2:client_credentials") {
return o.value.clientID != null || o.value.clientSecret != null;
} else if (typeof o.value === "string") {
return !!o.value;
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/sdk/models/errors/sdkerror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export class SDKError extends Error {
request: Request;
}
) {
super(`${message}: Status ${httpMeta.response.status}`);
super(
`${message}: Status ${httpMeta.response.status} Content-Type ${
httpMeta.response.headers.get("content-type") || ""
}`
);

this.name = "SDKError";
}
Expand Down
15 changes: 12 additions & 3 deletions src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ export class OpaApiClient extends ClientSDK {
);
throw result;
} else {
throw new errors.SDKError("Unexpected API response", { response, request });
throw new errors.SDKError("Unexpected API response status or content-type", {
response,
request,
});
}
}

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

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

0 comments on commit 387fe71

Please sign in to comment.