@arrirpc/codegen-utils

中文文档
0.85.0发布于 2026/10/03MITTypeScriptESM + CJS近 30 天下载 4638

This library contains a number of utilities that to assist in creating generators for Arri RPC. To See more complete usage example checkout one of the official arri client generators.

原始使用文档
文档目录5 节
  1. Creating a Generator Plugin
  2. Other Utilities
  3. Development
  4. Building
  5. Running unit tests

@arrirpc/codegen-utils

This library contains a number of utilities that to assist in creating generators for Arri RPC. To See more complete usage example checkout one of the official arri client generators.

Creating a Generator Plugin

import { defineGeneratorPlugin } from "@arrirpc/codegen-utils";

// add any options needed for your plugin here
export interface MyPluginOptions {
    a: string;
    b: string;
}

export default defineGeneratorPlugin((options: MyPluginOptions) => {
    return {
        options,
        run: async (appDef, isDevServer) => {
            // generate something using the app definition and the specified options
        },
    };
});

Other Utilities

// type guards
isAppDefinition(input);
isRpcDefinition(input);
isServiceDefinition(input);
isSchema(input);
isSchemaFormEmpty(input);
isSchemaFormType(input);
isSchemaFormEnum(input);
isSchemaFormElements(inputs);
isSchemaFormProperties(input);
isSchemaFormValues(input);
isSchemaFormDiscriminator(input);
isSchemaFormRef(input);

unflattenProcedures({
    "v1.users.getUser": {
        transport: "http",
        path: "/v1/users/get-user",
        method: "get",
    },
    "v1.users.createUser": {
        transport: "http",
        path: "/v1/users/create-user",
        method: "post",
    },
});
/**
 * outputs the following
 * {
 *   v1: {
 *     users: {
 *       getUser: {
 *         transport: "http",
 *         path: "/v1/users/get-user",
 *         method: "get",
 *       },
 *       createUser: {
 *          transport: "http",
 *          path: "/v1/users/create-user",
 *          method: "post",
 *       }
 *     }
 *   }
 * }
 */

removeDisallowedChars(input, disallowedChars);
camelCase(input, opts);
kebabCase(input);
pascalCase(input, opts);
snakeCase(input, opts);
titleCase(input, opts);
flatCase(input, opts);
upperFirst(input);
lowerFirst(input);
isUppercase(input);

Development

Building

Run pnpm nx build codegen-utils to build the library.

Running unit tests

Run pnpm nx test codegen-utils to execute the unit tests via Vitest.

版本与发布记录

@arrirpc/codegen-utils 共发布 91 个版本,首次发布于 2024/05/14;过去 12 个月发布了 11 个版本。

版本发布日期距今
0.85.0latest2026/10/031 个月前
0.84.12026/08/043 个月前
0.84.02026/08/043 个月前
0.83.12026/07/143 个月前
0.83.02026/07/143 个月前
0.82.02026/05/225 个月前

其他发布通道:beta → 0.76.3-beta.0。

关于 @arrirpc/codegen-utils 的常见问题

@arrirpc/codegen-utils 是什么?

This library contains a number of utilities that to assist in creating generators for Arri RPC. To See more complete usage example checkout one of the official arri client generators.

如何安装 @arrirpc/codegen-utils?

在项目目录运行 npm install @arrirpc/codegen-utils,或使用 pnpm add / yarn add / bun add。

@arrirpc/codegen-utils 支持 TypeScript 吗?

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

@arrirpc/codegen-utils 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@arrirpc/codegen-utils 可以商用吗?

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

@arrirpc/codegen-utils 的下载量有多少?

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

@arrirpc/codegen-utils 还在维护吗?

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