@devrev/typescript-sdk

中文文档
1.1.79发布于 2026/10/10MITTypeScriptCommonJS近 30 天下载 1.8万

SDK Generation

原始使用文档
文档目录7 节
  1. Basic Setup
  2. Core Features
  3. 1. User Management
  4. 2. File Management
  5. Error Handling
  6. TypeScript Support
  7. How to Contribute?

Authorization

Setup an env variable DEVREV_TOKEN It will be used as an auth token by default, You can also pass in the url and token in client.setup() as a param (see below). It is also required to run tests.

Installation

npm install @devrev/typescript-sdk

The version can be found in package.json. The SDK is currently beta. Make sure that your project's package.json contains "type":"module" setting.

Example Usage of the Beta SDK

import {client, betaSDK} from "@devrev/typescript-sdk";

const devrevBetaSDK = client.setupBeta({ endpoint: "https://api.devrev.ai",
token: process.env.DEVREV_TOKEN });

async function test(){
    const response = await devrevBetaSDK.worksCreate({title:"New work item!",
    applies_to_part: "PROD-1",
    owned_by:["DEVU-1"],
    type: betaSDK.WorkType.Issue})
    console.log(response)
}

test()

Example Usage of the Public SDK

import {client, publicSDK} from "@devrev/typescript-sdk";

const devrevSDK = client.setup({ endpoint: "https://api.devrev.ai", token: process.env.DEVREV_TOKEN });

async function test(){
    const response = await devrevSDK.worksCreate({title:"New work item!", applies_to_part: "PROD-1", owned_by:["DEVU-16"], type: publicSDK.WorkType.Issue})
    console.log(response.status)
}

test()

Execute tests in the repo

npm test

Devrev SDK Utils Guide

Basic Setup

First, initialize the SDK with your DevRev credentials:

import { client } from '@devrev/typescript-sdk';
import { BetaSdkUtil } from '@devrev/sdk-utils';

// Initialize the DevRev SDK
const devrevSDK = new client.setupBeta({
  // Your DevRev credentials
  endpoint: "https://api.devrev.ai",
  token: "YOUR_TOKEN"
});

// Initialize the utils SDK
const sdkUtil = new BetaSdkUtil(devrevSDK);

Core Features

1. User Management

Fetch all Rev users associated with an account:

const accountId = "ACC-12345";
const revUsers = await sdkUtil.getAllRevUsersFromAccount(accountId);
// Returns array of RevUser objects

2. File Management

Upload Files

import { FileTypes } from '@devrev/sdk-utils';

// Prepare file object
const fileObject = {
  file_name: "example.txt",
  file_type: FileTypes.OTHERS,
  file: Buffer.from("Hello World"),
  custom_file_type: "text/plain" // Required when file_type is OTHERS
};

// Upload file
const artifactId = await sdkUtil.uploadFileToArtifact(fileObject);

Retrieve File Content

const artifactId = "ART-12345";
const fileContent = await sdkUtil.getFileContentFromArtifact(artifactId);

Error Handling

The SDK includes built-in API error handling that provides detailed error information:

try {
  await sdkUtil.uploadFileToArtifact(fileObject);
} catch (error) {
  // Error will be automatically handled with detailed logging:
  // === Error Details ===
  // Service: [function name]
  // API: [API endpoint]
  // Error Type: [error type]
  // Status Code: [status code]
  // Message: [error message]
}

TypeScript Support

The SDK is written in TypeScript and provides comprehensive type definitions for:

  • File management operations
  • User management
  • API Error handling

How to Contribute?

  1. Create a New Branch

    • Start by creating a separate branch for your feature or bug fix.
  2. Follow Best Coding Practices

    • Ensure your code adheres to the following guidelines:
      • Handle potential errors using try-catch blocks.
      • Use TypeScript types/interfaces from the SDK for type safety.
      • Check file type requirements before uploading.
      • Utilize built-in API error handling for consistent logging.
  3. Enhance BetaSDKUtil

    • Modify the BetaSDKUtil class to add new utilities.
    • Write comprehensive test cases to ensure functionality.
  4. Run Tests

    • Execute tests using:
      npm test
      
  5. Submit a Pull Request

    • Open a pull request with a clear and detailed description of your changes.

版本与发布记录

@devrev/typescript-sdk 共发布 79 个版本,首次发布于 2023/04/29;过去 12 个月发布了 9 个版本。

版本发布日期距今
1.1.79latest2026/10/101 个月前
1.1.782026/06/154 个月前
1.1.772026/06/105 个月前
1.1.762026/06/015 个月前
1.1.752026/05/235 个月前
1.1.742026/05/056 个月前

关于 @devrev/typescript-sdk 的常见问题

@devrev/typescript-sdk 是什么?

SDK Generation

如何安装 @devrev/typescript-sdk?

在项目目录运行 npm install @devrev/typescript-sdk,或使用 pnpm add / yarn add / bun add。

@devrev/typescript-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devrev/typescript-sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@devrev/typescript-sdk 可以商用吗?

@devrev/typescript-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@devrev/typescript-sdk 的下载量有多少?

根据 npm 官方下载统计,@devrev/typescript-sdk 在 2026/10/12 – 2026/11/10 这 30 天内被下载 17,899 次,日均约 597 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devrev/typescript-sdk 还在维护吗?

最新版本 1.1.79 发布于 2026/10/10(1 个月前);至今共发布 79 个版本,其中过去 12 个月发布了 9 个;首次发布于 2023/04/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。