@mesadev/sdk
v0.1.7
Published
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *mesa* API.
Readme
mesa
Developer-friendly & type-safe Typescript SDK specifically catered to leverage mesa API.
[!IMPORTANT] This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Summary
Depot API: Depot HTTP API v1
Table of Contents
SDK Installation
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add @mesadev/sdkPNPM
pnpm add @mesadev/sdkBun
bun add @mesadev/sdkYarn
yarn add @mesadev/sdk[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
SDK Example Usage
Example
import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
const result = await mesa.admin.createApiKey({
org: "<value>",
});
console.log(result);
}
run();
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
| -------- | ---- | ----------- | -------------------- |
| apiKey | http | HTTP Bearer | MESA_API_KEY |
To authenticate with the API the apiKey parameter must be set when initializing the SDK client instance. For example:
import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
const result = await mesa.admin.createApiKey({
org: "<value>",
});
console.log(result);
}
run();
Available Resources and Operations
Admin
- createApiKey - Create API key
- listApiKeys - List API keys
- revokeApiKey - Revoke API key
AgentBlame
- getByOrgByRepoAgentblame - Get AI attribution data
- getByOrgByRepoAnalytics - Get repository analytics
- postByOrgByRepoAnalyticsRefresh - Refresh repository analytics
Branches
Commits
Content
- get - Get content
Diffs
- get - Get diff
Org
- get - Get organization
Repos
- create - Create repository
- list - List repositories
- get - Get repository
- delete - Delete repository
- update - Update repository
- getSyncStatus - Get sync status
- sync - Sync repository
Webhooks
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.
adminCreateApiKey- Create API keyadminListApiKeys- List API keysadminRevokeApiKey- Revoke API keyagentBlameGetByOrgByRepoAgentblame- Get AI attribution dataagentBlameGetByOrgByRepoAnalytics- Get repository analyticsagentBlamePostByOrgByRepoAnalyticsRefresh- Refresh repository analyticsbranchesCreate- Create branchbranchesDelete- Delete branchbranchesList- List branchescommitsCreate- Create commitcommitsGet- Get commitcommitsList- List commitscontentGet- Get contentdiffsGet- Get difforgGet- Get organizationreposCreate- Create repositoryreposDelete- Delete repositoryreposGet- Get repositoryreposGetSyncStatus- Get sync statusreposList- List repositoriesreposSync- Sync repositoryreposUpdate- Update repositorywebhooksCreate- Create webhookwebhooksDelete- Delete webhookwebhooksList- List webhooks
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you
make your SDK calls as usual, but the returned response object will also be an
async iterable that can be consumed using the for await...of
syntax.
Here's an example of one such pagination call:
import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
const result = await mesa.repos.list({
org: "<value>",
});
for await (const page of result) {
console.log(page);
}
}
run();
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
const result = await mesa.admin.createApiKey({
org: "<value>",
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
const result = await mesa.admin.createApiKey({
org: "<value>",
});
console.log(result);
}
run();
Error Handling
MesaError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |
| error.statusCode | number | HTTP response status code eg 404 |
| error.headers | Headers | HTTP response headers |
| error.body | string | HTTP body. Can be empty string if no body is returned. |
| error.rawResponse | Response | Raw HTTP response |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |
Example
import { Mesa } from "@mesadev/sdk";
import * as errors from "@mesadev/sdk/models/errors";
const mesa = new Mesa({
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
try {
const result = await mesa.admin.createApiKey({
org: "<value>",
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.MesaError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.PostByOrgApiKeysBadRequestError) {
console.log(error.data$.error); // operations.PostByOrgApiKeysBadRequestError
}
}
}
}
run();
Error Classes
Primary error:
MesaError: The base class for HTTP error responses.
Network errors:
ConnectionError: HTTP client was unable to make a request to a server.RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.RequestAbortedError: HTTP request was aborted by the client.InvalidRequestError: Any input used to create a request is invalid.UnexpectedClientError: Unrecognised or unexpected error.
Inherit from MesaError:
PostByOrgApiKeysBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgApiKeysBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgReposBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgReposBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PatchByOrgByRepoBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoContentBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*GetByOrgBadRequestError: Invalid request. Status code400. Applicable to 1 of 25 methods.*PostByOrgApiKeysUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgApiKeysUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgReposUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgReposUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*DeleteByOrgByRepoUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PatchByOrgByRepoUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoContentUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*GetByOrgUnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 25 methods.*PostByOrgApiKeysForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgApiKeysForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgReposForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgReposForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*DeleteByOrgByRepoForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PatchByOrgByRepoForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoContentForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*GetByOrgForbiddenError: Forbidden. Status code403. Applicable to 1 of 25 methods.*PostByOrgApiKeysNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgApiKeysNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgReposNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgReposNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*DeleteByOrgByRepoNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PatchByOrgByRepoNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoContentNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*GetByOrgNotFoundError: Not found. Status code404. Applicable to 1 of 25 methods.*PostByOrgApiKeysNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgApiKeysNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgReposNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgReposNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*DeleteByOrgByRepoNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PatchByOrgByRepoNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoContentNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*GetByOrgNotAcceptableError: Not acceptable. Status code406. Applicable to 1 of 25 methods.*PostByOrgApiKeysConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgApiKeysConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgReposConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgReposConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*DeleteByOrgByRepoConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PatchByOrgByRepoConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoContentConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*GetByOrgConflictError: Conflict. Status code409. Applicable to 1 of 25 methods.*PostByOrgApiKeysInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgApiKeysInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*DeleteByOrgApiKeysByIdInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PostByOrgReposInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgReposInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*DeleteByOrgByRepoInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PatchByOrgByRepoInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoSyncInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PostByOrgByRepoSyncInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoContentInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoBranchesInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PostByOrgByRepoBranchesInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*DeleteByOrgByRepoBranchesByBranchInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PostByOrgByRepoCommitsInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoCommitsByShaInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoDiffInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoAgentblameInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoAnalyticsInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PostByOrgByRepoAnalyticsRefreshInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgByRepoWebhooksInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*PostByOrgByRepoWebhooksInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*DeleteByOrgByRepoWebhooksByWebhookIdInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*GetByOrgInternalServerError: Internal error. Status code500. Applicable to 1 of 25 methods.*ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:
import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({
serverURL: "https://depot.mesa.dev/api/v1",
apiKey: process.env["MESA_API_KEY"] ?? "",
});
async function run() {
const result = await mesa.admin.createApiKey({
org: "<value>",
});
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:
import { Mesa } from "@mesadev/sdk";
import { HTTPClient } from "@mesadev/sdk/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new Mesa({ httpClient: httpClient });Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console's interface as an SDK option.
[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
import { Mesa } from "@mesadev/sdk";
const sdk = new Mesa({ debugLogger: console });You can also enable a default debug logger by setting an environment variable MESA_DEBUG to true.
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
