@ arrirpc/ codegen- utils
该图书馆载有一些公用事业,协助为Arri RPC创建发电机。 查看更完整的用法实例, 检查一个官方的 arri 客户端生成器 .
创建生成器插件
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
},
};
});
其他公用事业
// 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);
发展
大楼
运行 pnpm nx build codegen-utils 来建造图书馆.
运行单元测试
运行 pnpm nx test codegen-utils 通过 维特。 。 。 .