diff --git a/.gitignore b/.gitignore index 0126dadc99ae1..35fb5a98b2393 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ docs/.vuepress/dist ./package-lock.json components/**/package-lock.json +/packages/evals/ +/packages/sdk/examples/.next/ diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index cc96845275bc7..5fb32ca01f23c 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,12 +1,21 @@ # Changelog +## [1.0.5] - 2024-11-18 + +### Changed + +- The backend client used to default to `production` if the environment was not +specified. Now `environment` is a required argument for `createBackendClient` +and must be one of `production` or `development`. + ## [1.0.4] - 2024-11-15 ### Changed - Improved the docs of the `getAccountById` method in the backend client to clarify the behavior of the new argument. + - Fixed the exported `HTTPAuthType` enum so that it can be used by the consumers of the SDK. diff --git a/packages/sdk/package-lock.json b/packages/sdk/package-lock.json index 38bb8b1cd0052..c46ed631dd510 100644 --- a/packages/sdk/package-lock.json +++ b/packages/sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pipedream/sdk", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pipedream/sdk", - "version": "1.0.4", + "version": "1.0.5", "license": "SEE LICENSE IN LICENSE", "dependencies": { "simple-oauth2": "^5.1.0" diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 1f16f9048ebe4..e0c33dd299616 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/sdk", - "version": "1.0.4", + "version": "1.0.5", "description": "Pipedream SDK", "main": "dist/server/index.js", "module": "dist/server/index.js", diff --git a/packages/sdk/src/server/__tests__/server.test.ts b/packages/sdk/src/server/__tests__/server.test.ts index 9aa9c1081032f..0356686a3c3af 100644 --- a/packages/sdk/src/server/__tests__/server.test.ts +++ b/packages/sdk/src/server/__tests__/server.test.ts @@ -10,6 +10,7 @@ import { const projectId = "proj_abc123"; const clientParams: BackendClientOpts = { + environment: "production", credentials: { clientId: "test-client-id", clientSecret: "test-client-secret", @@ -175,6 +176,7 @@ describe("BackendClient", () => { clientId: "test-client-id", clientSecret: "test-client-secret", }, + environment: "production", projectId, }, ); @@ -677,6 +679,7 @@ describe("BackendClient", () => { clientId: "test-client-id", clientSecret: "test-client-secret", }, + environment: "production", projectId: "proj_abc123", }, ); diff --git a/packages/sdk/src/server/index.ts b/packages/sdk/src/server/index.ts index e27aa70035729..10590b5424632 100644 --- a/packages/sdk/src/server/index.ts +++ b/packages/sdk/src/server/index.ts @@ -16,6 +16,11 @@ export type OAuthCredentials = { clientSecret: string; }; +/** + * The environment in which the server client is running. + */ +export type ProjectEnvironment = "development" | "production"; + /** * Options for creating a server-side client. * This is used to configure the BackendClient instance. @@ -25,7 +30,7 @@ export type BackendClientOpts = { * The environment in which the server client is running (e.g., "production", * "development"). */ - environment?: string; + environment?: ProjectEnvironment; /** * The credentials to use for authentication against the Pipedream API. @@ -353,7 +358,8 @@ export class BackendClient { * @param opts - The options for configuring the server client. */ constructor(opts: BackendClientOpts) { - this.environment = opts.environment ?? "production"; + this.ensureValidEnvironment(opts.environment); + this.environment = opts.environment!; this.projectId = opts.projectId; if (!this.projectId) { @@ -370,6 +376,15 @@ export class BackendClient { this.oauthClient = this.newOauthClient(opts.credentials, this.baseApiUrl); } + private ensureValidEnvironment(environment?: string) { + if (!environment || ![ + "development", + "production", + ].includes(environment)) { + throw new Error("Project environment is required. Supported environments are development and production."); + } + } + private newOauthClient( { clientId,