Skip to content

Commit

Permalink
Release 0.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Oct 17, 2023
1 parent 678e962 commit 062930a
Show file tree
Hide file tree
Showing 42 changed files with 517 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fern-api/node-sdk",
"version": "0.0.2",
"version": "0.0.12",
"private": false,
"repository": "https://github.com/fern-api/node-sdk",
"main": "./index.js",
Expand Down
204 changes: 193 additions & 11 deletions src/api/resources/snippets/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ export class Snippets {

/**
* Get snippet by endpoint method and path
* @throws {@link Fern.snippets.UnauthorizedError}
* @throws {@link Fern.snippets.UserNotInOrgError}
* @throws {@link Fern.snippets.UnavailableError}
* @throws {@link Fern.snippets.ApiIdRequiredError}
* @throws {@link Fern.snippets.OrgIdRequiredError}
* @throws {@link Fern.snippets.OrgIdAndApiIdNotFound}
* @throws {@link Fern.snippets.OrgIdNotFound}
* @throws {@link Fern.snippets.ApiIdNotFound}
* @throws {@link Fern.snippets.EndpointNotFound}
* @throws {@link Fern.snippets.SdkNotFound}
* @throws {@link Fern.snippets.ApiIdNotFound}
*/
public async get(
request: Fern.snippets.GetSnippetRequest,
Expand All @@ -44,7 +51,7 @@ export class Snippets {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@fern-api/node-sdk",
"X-Fern-SDK-Version": "0.0.2",
"X-Fern-SDK-Version": "0.0.12",
},
contentType: "application/json",
body: await serializers.snippets.GetSnippetRequest.jsonOrThrow(request, {
Expand All @@ -63,12 +70,89 @@ export class Snippets {

if (_response.error.reason === "status-code") {
switch ((_response.error.body as any)?.["error"]) {
case "UnauthorizedError":
throw new Fern.snippets.UnauthorizedError(
await serializers.snippets.UnauthorizedError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "UserNotInOrgError":
throw new Fern.snippets.UserNotInOrgError();
case "UnavailableError":
throw new Fern.snippets.UnavailableError(
await serializers.snippets.UnavailableError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "ApiIdRequiredError":
throw new Fern.snippets.ApiIdRequiredError(
await serializers.snippets.ApiIdRequiredError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "OrgIdRequiredError":
throw new Fern.snippets.OrgIdRequiredError(
await serializers.snippets.OrgIdRequiredError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "OrgIdAndApiIdNotFound":
throw new Fern.snippets.OrgIdAndApiIdNotFound(
await serializers.snippets.OrgIdAndApiIdNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "OrgIdNotFound":
throw new Fern.snippets.OrgIdNotFound(
await serializers.snippets.OrgIdNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "ApiIdNotFound":
throw new Fern.snippets.ApiIdNotFound(
await serializers.snippets.ApiIdNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "EndpointNotFound":
throw new Fern.snippets.EndpointNotFound();
throw new Fern.snippets.EndpointNotFound(
await serializers.snippets.EndpointNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "SDKNotFound":
throw new Fern.snippets.SdkNotFound();
case "ApiIdNotFound":
throw new Fern.snippets.ApiIdNotFound();
throw new Fern.snippets.SdkNotFound(
await serializers.snippets.SdkNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
default:
throw new errors.FernError({
statusCode: _response.error.statusCode,
Expand All @@ -92,6 +176,18 @@ export class Snippets {
}
}

/**
* @throws {@link Fern.snippets.UnauthorizedError}
* @throws {@link Fern.snippets.UserNotInOrgError}
* @throws {@link Fern.snippets.UnavailableError}
* @throws {@link Fern.snippets.InvalidPageError}
* @throws {@link Fern.snippets.ApiIdRequiredError}
* @throws {@link Fern.snippets.OrgIdRequiredError}
* @throws {@link Fern.snippets.OrgIdAndApiIdNotFound}
* @throws {@link Fern.snippets.OrgIdNotFound}
* @throws {@link Fern.snippets.ApiIdNotFound}
* @throws {@link Fern.snippets.SdkNotFound}
*/
public async load(
request: Fern.snippets.ListSnippetsRequest = {},
requestOptions?: Snippets.RequestOptions
Expand All @@ -112,7 +208,7 @@ export class Snippets {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@fern-api/node-sdk",
"X-Fern-SDK-Version": "0.0.2",
"X-Fern-SDK-Version": "0.0.12",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand All @@ -131,10 +227,96 @@ export class Snippets {
}

if (_response.error.reason === "status-code") {
throw new errors.FernError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
switch ((_response.error.body as any)?.["error"]) {
case "UnauthorizedError":
throw new Fern.snippets.UnauthorizedError(
await serializers.snippets.UnauthorizedError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "UserNotInOrgError":
throw new Fern.snippets.UserNotInOrgError();
case "UnavailableError":
throw new Fern.snippets.UnavailableError(
await serializers.snippets.UnavailableError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "InvalidPageError":
throw new Fern.snippets.InvalidPageError(
await serializers.snippets.InvalidPageError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "ApiIdRequiredError":
throw new Fern.snippets.ApiIdRequiredError(
await serializers.snippets.ApiIdRequiredError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "OrgIdRequiredError":
throw new Fern.snippets.OrgIdRequiredError(
await serializers.snippets.OrgIdRequiredError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "OrgIdAndApiIdNotFound":
throw new Fern.snippets.OrgIdAndApiIdNotFound(
await serializers.snippets.OrgIdAndApiIdNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "OrgIdNotFound":
throw new Fern.snippets.OrgIdNotFound(
await serializers.snippets.OrgIdNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "ApiIdNotFound":
throw new Fern.snippets.ApiIdNotFound(
await serializers.snippets.ApiIdNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case "SDKNotFound":
throw new Fern.snippets.SdkNotFound(
await serializers.snippets.SdkNotFound.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
default:
throw new errors.FernError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

switch (_response.error.reason) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import * as Fern from "../../../..";

export interface GetSnippetRequest {
/**
* If the same API is defined across multiple organization,
* you must specify an organization ID.
*
*/
orgId?: Fern.snippets.OrgId;
/**
* If you have more than one API, you must specify its ID.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import * as Fern from "../../../..";

export interface ListSnippetsRequest {
page?: number;
/**
* If the same API is defined across multiple organization,
* you must specify an organization ID.
*
*/
orgId?: Fern.snippets.OrgId;
/**
* If you have more than one API, you must specify its ID.
*
Expand Down
3 changes: 2 additions & 1 deletion src/api/resources/snippets/errors/ApiIdNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import * as errors from "../../../../errors";

export class ApiIdNotFound extends errors.FernError {
constructor() {
constructor(body: string) {
super({
statusCode: 404,
body: body,
});
Object.setPrototypeOf(this, ApiIdNotFound.prototype);
}
Expand Down
15 changes: 15 additions & 0 deletions src/api/resources/snippets/errors/ApiIdRequiredError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class ApiIdRequiredError extends errors.FernError {
constructor(body: string) {
super({
statusCode: 400,
body: body,
});
Object.setPrototypeOf(this, ApiIdRequiredError.prototype);
}
}
3 changes: 2 additions & 1 deletion src/api/resources/snippets/errors/EndpointNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import * as errors from "../../../../errors";

export class EndpointNotFound extends errors.FernError {
constructor() {
constructor(body: string) {
super({
statusCode: 404,
body: body,
});
Object.setPrototypeOf(this, EndpointNotFound.prototype);
}
Expand Down
15 changes: 15 additions & 0 deletions src/api/resources/snippets/errors/InvalidPageError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class InvalidPageError extends errors.FernError {
constructor(body: string) {
super({
statusCode: 400,
body: body,
});
Object.setPrototypeOf(this, InvalidPageError.prototype);
}
}
15 changes: 15 additions & 0 deletions src/api/resources/snippets/errors/OrgIdAndApiIdNotFound.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class OrgIdAndApiIdNotFound extends errors.FernError {
constructor(body: string) {
super({
statusCode: 400,
body: body,
});
Object.setPrototypeOf(this, OrgIdAndApiIdNotFound.prototype);
}
}
15 changes: 15 additions & 0 deletions src/api/resources/snippets/errors/OrgIdNotFound.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class OrgIdNotFound extends errors.FernError {
constructor(body: string) {
super({
statusCode: 404,
body: body,
});
Object.setPrototypeOf(this, OrgIdNotFound.prototype);
}
}
15 changes: 15 additions & 0 deletions src/api/resources/snippets/errors/OrgIdRequiredError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class OrgIdRequiredError extends errors.FernError {
constructor(body: string) {
super({
statusCode: 400,
body: body,
});
Object.setPrototypeOf(this, OrgIdRequiredError.prototype);
}
}
3 changes: 2 additions & 1 deletion src/api/resources/snippets/errors/SdkNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import * as errors from "../../../../errors";

export class SdkNotFound extends errors.FernError {
constructor() {
constructor(body: string) {
super({
statusCode: 404,
body: body,
});
Object.setPrototypeOf(this, SdkNotFound.prototype);
}
Expand Down
Loading

0 comments on commit 062930a

Please sign in to comment.