0.63.2 • Published 8 months ago

@arrirpc/codegen-utils v0.63.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@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,
        generator: 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.

0.63.2

8 months ago

0.63.0

8 months ago

0.62.0

8 months ago

0.63.1

8 months ago

0.61.1

9 months ago

0.60.3

10 months ago

0.60.2

10 months ago

0.61.0

10 months ago

0.60.1

10 months ago

0.60.0

10 months ago

0.57.4

11 months ago

0.57.5

11 months ago

0.59.0

10 months ago

0.58.1

10 months ago

0.57.2

11 months ago

0.57.3

11 months ago

0.57.0

11 months ago

0.58.0

10 months ago

0.55.0

11 months ago

0.53.2

12 months ago

0.57.8

11 months ago

0.57.6

11 months ago

0.53.0

12 months ago

0.51.2

12 months ago

0.54.0

12 months ago

0.53.1

12 months ago

0.51.0

1 year ago

0.52.0

12 months ago

0.51.1

12 months ago

0.50.0

1 year ago

0.49.1

1 year ago

0.48.2

1 year ago

0.45.6

1 year ago

0.48.0

1 year ago

0.49.0

1 year ago

0.48.1

1 year ago

0.46.0

1 year ago

0.47.0

1 year ago

0.45.7

1 year ago

0.45.5

1 year ago

0.45.3

1 year ago

0.45.4

1 year ago

0.45.2

1 year ago

0.45.1

1 year ago

0.45.0

1 year ago