diff --git a/package.json b/package.json index cf931b9..b55a5ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/sdk", - "version": "2.0.5", + "version": "2.0.6", "private": false, "repository": "github:PipedreamHQ/pipedream-sdk-typescript", "type": "commonjs", @@ -10,11 +10,6 @@ "exports": { ".": { "types": "./dist/cjs/index.d.ts", - "browser": { - "types": "./dist/esm/browser/index.d.mts", - "import": "./dist/esm/browser/index.mjs", - "default": "./dist/esm/browser/index.mjs" - }, "import": { "types": "./dist/esm/index.d.mts", "default": "./dist/esm/index.mjs" @@ -25,18 +20,6 @@ }, "default": "./dist/cjs/index.js" }, - "./browser": { - "types": "./dist/esm/browser/index.d.mts", - "import": { - "types": "./dist/esm/browser/index.d.mts", - "default": "./dist/esm/browser/index.mjs" - }, - "require": { - "types": "./dist/cjs/browser/index.d.ts", - "default": "./dist/cjs/browser/index.js" - }, - "default": "./dist/esm/browser/index.mjs" - }, "./serialization": { "types": "./dist/cjs/serialization/index.d.ts", "import": { @@ -49,18 +32,6 @@ }, "default": "./dist/cjs/serialization/index.js" }, - "./server": { - "types": "./dist/cjs/index.d.ts", - "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - }, - "default": "./dist/cjs/index.js" - }, "./package.json": "./package.json" }, "files": [ @@ -80,17 +51,17 @@ "test:wire": "jest --selectProjects wire" }, "devDependencies": { + "webpack": "^5.97.1", + "ts-loader": "^9.5.1", + "jest": "^29.7.0", "@jest/globals": "^29.7.0", "@types/jest": "^29.5.14", - "@types/node": "^18.19.70", - "jest": "^29.7.0", + "ts-jest": "^29.3.4", "jest-environment-jsdom": "^29.7.0", "msw": "^2.8.4", + "@types/node": "^18.19.70", "prettier": "^3.4.2", - "ts-jest": "^29.3.4", - "ts-loader": "^9.5.1", - "typescript": "~5.7.2", - "webpack": "^5.97.1" + "typescript": "~5.7.2" }, "browser": { "fs": false, diff --git a/src/api/resources/fileStash/client/Client.ts b/src/api/resources/fileStash/client/Client.ts new file mode 100644 index 0000000..2b6b503 --- /dev/null +++ b/src/api/resources/fileStash/client/Client.ts @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Pipedream from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as errors from "../../../../errors/index.js"; + +export declare namespace FileStash { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + projectId: string; + token?: core.Supplier; + /** Override the x-pd-environment header */ + projectEnvironment?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | null | undefined>; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-pd-environment header */ + projectEnvironment?: Pipedream.ProjectEnvironment | undefined; + /** Additional query string parameters to include in the request. */ + queryParams?: Record; + /** Additional headers to include in the request. */ + headers?: Record | null | undefined>; + } +} + +export class FileStash { + protected readonly _options: FileStash.Options; + + constructor(_options: FileStash.Options) { + this._options = _options; + } + + /** + * Download a file from File Stash + * + * @param {Pipedream.FileStashDownloadFileRequest} request + * @param {FileStash.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Pipedream.TooManyRequestsError} + * + * @example + * await client.fileStash.downloadFile({ + * s3Key: "s3_key" + * }) + */ + public downloadFile( + request: Pipedream.FileStashDownloadFileRequest, + requestOptions?: FileStash.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__downloadFile(request, requestOptions)); + } + + private async __downloadFile( + request: Pipedream.FileStashDownloadFileRequest, + requestOptions?: FileStash.RequestOptions, + ): Promise> { + const { s3Key } = request; + const _queryParams: Record = {}; + _queryParams["s3_key"] = s3Key; + let _headers: core.Fetcher.Args["headers"] = mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-pd-environment": requestOptions?.projectEnvironment ?? this._options?.projectEnvironment, + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.PipedreamEnvironment.Prod, + `v1/connect/${encodeURIComponent(this._options.projectId)}/file_stash/download`, + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 429: + throw new Pipedream.TooManyRequestsError(_response.error.body, _response.rawResponse); + default: + throw new errors.PipedreamError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.PipedreamError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.PipedreamTimeoutError( + "Timeout exceeded when calling GET /v1/connect/{project_id}/file_stash/download.", + ); + case "unknown": + throw new errors.PipedreamError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/fileStash/client/index.ts b/src/api/resources/fileStash/client/index.ts new file mode 100644 index 0000000..82648c6 --- /dev/null +++ b/src/api/resources/fileStash/client/index.ts @@ -0,0 +1,2 @@ +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/fileStash/client/requests/FileStashDownloadFileRequest.ts b/src/api/resources/fileStash/client/requests/FileStashDownloadFileRequest.ts new file mode 100644 index 0000000..88a7058 --- /dev/null +++ b/src/api/resources/fileStash/client/requests/FileStashDownloadFileRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * s3Key: "s3_key" + * } + */ +export interface FileStashDownloadFileRequest { + s3Key: string; +} diff --git a/src/api/resources/fileStash/client/requests/index.ts b/src/api/resources/fileStash/client/requests/index.ts new file mode 100644 index 0000000..269f696 --- /dev/null +++ b/src/api/resources/fileStash/client/requests/index.ts @@ -0,0 +1 @@ +export { type FileStashDownloadFileRequest } from "./FileStashDownloadFileRequest.js"; diff --git a/src/api/resources/fileStash/index.ts b/src/api/resources/fileStash/index.ts new file mode 100644 index 0000000..914b8c3 --- /dev/null +++ b/src/api/resources/fileStash/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/types/PropOption.ts b/src/api/types/PropOption.ts index 7299120..de78ba7 100644 --- a/src/api/types/PropOption.ts +++ b/src/api/types/PropOption.ts @@ -2,11 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Pipedream from "../index.js"; + /** * A configuration option for a component's prop */ export interface PropOption { /** The human-readable label for the option */ label: string; - value?: unknown; + value?: Pipedream.PropOptionValue; } diff --git a/src/api/types/PropOptionValue.ts b/src/api/types/PropOptionValue.ts new file mode 100644 index 0000000..a87d67d --- /dev/null +++ b/src/api/types/PropOptionValue.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The value of a prop option + */ +export type PropOptionValue = string | number | boolean; diff --git a/src/serialization/types/PropOption.ts b/src/serialization/types/PropOption.ts index 64241d2..7ad0407 100644 --- a/src/serialization/types/PropOption.ts +++ b/src/serialization/types/PropOption.ts @@ -5,16 +5,17 @@ import * as serializers from "../index.js"; import * as Pipedream from "../../api/index.js"; import * as core from "../../core/index.js"; +import { PropOptionValue } from "./PropOptionValue.js"; export const PropOption: core.serialization.ObjectSchema = core.serialization.object({ label: core.serialization.string(), - value: core.serialization.unknown(), + value: PropOptionValue.optional(), }); export declare namespace PropOption { export interface Raw { label: string; - value?: unknown; + value?: PropOptionValue.Raw | null; } } diff --git a/src/serialization/types/PropOptionValue.ts b/src/serialization/types/PropOptionValue.ts new file mode 100644 index 0000000..69991cf --- /dev/null +++ b/src/serialization/types/PropOptionValue.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../index.js"; +import * as Pipedream from "../../api/index.js"; +import * as core from "../../core/index.js"; + +export const PropOptionValue: core.serialization.Schema = + core.serialization.undiscriminatedUnion([ + core.serialization.string(), + core.serialization.number(), + core.serialization.boolean(), + ]); + +export declare namespace PropOptionValue { + export type Raw = string | number | boolean; +} diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts index 03a2afd..0b5f69e 100644 --- a/src/serialization/types/index.ts +++ b/src/serialization/types/index.ts @@ -84,6 +84,7 @@ export * from "./ProjectInfoResponse.js"; export * from "./ProjectInfoResponseApp.js"; export * from "./PropOption.js"; export * from "./PropOptionNested.js"; +export * from "./PropOptionValue.js"; export * from "./ProxyResponse.js"; export * from "./ReloadPropsOpts.js"; export * from "./ReloadPropsResponse.js"; diff --git a/src/version.ts b/src/version.ts index 2412826..f04d47f 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "2.0.5"; +export const SDK_VERSION = "2.0.6"; diff --git a/yarn.lock b/yarn.lock index 24884a5..d1a8e97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -733,16 +733,16 @@ integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== "@types/node@*": - version "24.4.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-24.4.0.tgz#4ca9168c016a55ab15b7765ad1674ab807489600" - integrity sha512-gUuVEAK4/u6F9wRLznPUU4WGUacSEBDPoC2TrBkw3GAnOLHBL45QdfHOXp1kJ4ypBGLxTOB+t7NJLpKoC3gznQ== + version "24.5.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-24.5.2.tgz#52ceb83f50fe0fcfdfbd2a9fab6db2e9e7ef6446" + integrity sha512-FYxk1I7wPv3K2XBaoyH2cTnocQEu8AOZ60hPbsyukMPLv5/5qr7V1i8PLHdl6Zf87I+xZXFvPCXYjiTFq+YSDQ== dependencies: - undici-types "~7.11.0" + undici-types "~7.12.0" "@types/node@^18.19.70": - version "18.19.124" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.124.tgz#6f49e4fab8274910691a900e8a14316cbf3c7a31" - integrity sha512-hY4YWZFLs3ku6D2Gqo3RchTd9VRCcrjqp/I0mmohYeUVA5Y8eCXKJEasHxLAJVZRJuQogfd1GiJ9lgogBgKeuQ== + version "18.19.127" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.127.tgz#7c2e47fa79ad7486134700514d4a975c4607f09d" + integrity sha512-gSjxjrnKXML/yo0BO099uPixMqfpJU0TKYjpfLU7TrtA2WWDki412Np/RSTPRil1saKBhvVVKzVx/p/6p94nVA== dependencies: undici-types "~5.26.4" @@ -1077,10 +1077,10 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -baseline-browser-mapping@^2.8.2: - version "2.8.4" - resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.8.4.tgz#e553e12272c4965682743705efd8b4b4cf0d709b" - integrity sha512-L+YvJwGAgwJBV1p6ffpSTa2KRc69EeeYGYjRVWKs0GKrK+LON0GC0gV+rKSNtALEDvMDqkvCFq9r1r94/Gjwxw== +baseline-browser-mapping@^2.8.3: + version "2.8.5" + resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.8.5.tgz#3147fe6b01a0c49ce1952daebcfc2057fc43fedb" + integrity sha512-TiU4qUT9jdCuh4aVOG7H1QozyeI2sZRqoRPdqBIaslfNt4WUSanRBueAwl2x5jt4rXBMim3lIN2x6yT8PDi24Q== brace-expansion@^1.1.7: version "1.1.12" @@ -1098,11 +1098,11 @@ braces@^3.0.3: fill-range "^7.1.1" browserslist@^4.24.0: - version "4.26.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.26.0.tgz#035ca84b4ff312a3c6a7014a77beb83456a882dd" - integrity sha512-P9go2WrP9FiPwLv3zqRD/Uoxo0RSHjzFCiQz7d4vbmwNqQFo9T9WCeP/Qn5EbcKQY6DBbkxEXNcpJOmncNrb7A== + version "4.26.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.26.2.tgz#7db3b3577ec97f1140a52db4936654911078cef3" + integrity sha512-ECFzp6uFOSB+dcZ5BK/IBaGWssbSYBHvuMeMt3MMFyhI0Z8SqGgEkBLARgpRH3hutIgPVsALcMwbDrJqPxQ65A== dependencies: - baseline-browser-mapping "^2.8.2" + baseline-browser-mapping "^2.8.3" caniuse-lite "^1.0.30001741" electron-to-chromium "^1.5.218" node-releases "^2.0.21" @@ -1151,9 +1151,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001741: - version "1.0.30001741" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001741.tgz#67fb92953edc536442f3c9da74320774aa523143" - integrity sha512-QGUGitqsc8ARjLdgAfxETDhRbJ0REsP6O3I96TAth/mVjh2cYzN2u+3AzPP3aVSm2FehEItaJw1xd+IGBXWeSw== + version "1.0.30001743" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001743.tgz#50ff91a991220a1ee2df5af00650dd5c308ea7cd" + integrity sha512-e6Ojr7RV14Un7dz6ASD0aZDmQPT/A+eZU+nuTNfjqmRrmkmQlnTNWH0SKmqagx9PeW87UVqapSurtAXifmtdmw== chalk@^4.0.0, chalk@^4.1.0: version "4.1.2" @@ -1348,9 +1348,9 @@ dunder-proto@^1.0.1: gopd "^1.2.0" electron-to-chromium@^1.5.218: - version "1.5.218" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.218.tgz#921042a011a98a4620853c9d391ab62bcc124400" - integrity sha512-uwwdN0TUHs8u6iRgN8vKeWZMRll4gBkz+QMqdS7DDe49uiK68/UX92lFb61oiFPrpYZNeZIqa4bA7O6Aiasnzg== + version "1.5.221" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.221.tgz#bd98014b2a247701c4ebd713080448d539545d79" + integrity sha512-/1hFJ39wkW01ogqSyYoA4goOXOtMRy6B+yvA1u42nnsEGtHzIzmk93aPISumVQeblj47JUHLC9coCjUxb1EvtQ== emittery@^0.13.1: version "0.13.1" @@ -2958,9 +2958,9 @@ tr46@^3.0.0: punycode "^2.1.1" ts-jest@^29.3.4: - version "29.4.2" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.4.2.tgz#095fe8770df81f2e39f2c34a6bcafac58b834423" - integrity sha512-pBNOkn4HtuLpNrXTMVRC9b642CBaDnKqWXny4OzuoULT9S7Kf8MMlaRe2veKax12rjf5WcpMBhVPbQurlWGNxA== + version "29.4.3" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.4.3.tgz#23264489bebb5b3e2c7966dbf6788e960f244f7c" + integrity sha512-KTWbK2Wot8VXargsLoxhSoEQ9OyMdzQXQoUDeIulWu2Tf7gghuBHeg+agZqVLdTOHhQHVKAaeuctBDRkhWE7hg== dependencies: bs-logger "^0.2.6" fast-json-stable-stringify "^2.1.0" @@ -3013,10 +3013,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici-types@~7.11.0: - version "7.11.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.11.0.tgz#075798115d0bbc4e4fc7c173f38727ca66bfb592" - integrity sha512-kt1ZriHTi7MU+Z/r9DOdAI3ONdaR3M3csEaRc6ewa4f4dTvX4cQCbJ4NkEn0ohE4hHtq85+PhPSTY+pO/1PwgA== +undici-types@~7.12.0: + version "7.12.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.12.0.tgz#15c5c7475c2a3ba30659529f5cdb4674b622fafb" + integrity sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ== universalify@^0.2.0: version "0.2.0"