open-index/open-npm huggingface dataset:
npm package: @magic-number/cli
Description: 魔数命令行工具
Author: hao
Latest version: 0.0.23

# 关于魔数
魔数旨在帮助开发人员更为高效的管理测试用例和测试场景，并提供开发环境、单元测试、集成测试等不同阶段的数据接入方案和自动化测试方案。

# @magic-number/cli
本项目为一个魔数的命令行工具，可以全局安装，直接执行magic --help查看更多帮助说明，或者在项目目录中安装，执行node_modules/.bin/magic --help

Options:

  -h, --help      output usage information

Commands:

  rpc <uri> 创建rpc接口

  rule      创建数据规则

  tc        创建测试场景TestSuite

  ts <name> 创建测试用例TestCase

  list <type>  列出当前工作目录下的数据，例如magic list api会列出目前已经创建好的api
  
  http [options] 启动魔数http服务器，支持三个额外参数，控制服务器的工作目录、绑定的端口和ip，更多详情请查看magic http --help
npm package: @magic-number/client
Description: 魔数客户端(node执行环境)
Author: hao
Latest version: 0.0.17

# 关于魔数
魔数旨在帮助开发人员更为高效的管理测试用例和测试场景，并提供开发环境、单元测试、集成测试等不同阶段的数据接入方案和自动化测试方案。

# @magic-number/client
本项目为魔数在node环境下的客户端。

LocalClient用于直接从文件系统的数据访问，不建议直接在项目中使用。

优先使用@magic-number/core中提供的HttpClient访问魔数远程服务器获取数据，HttpClient支持node和浏览器环境，node环境中使用时，传入node-fetch作为其远程数据获取的方法即可；浏览器中可以直接使用window.fetch.bind(window)。

AlipayClient是魔数提供的一个访问支付宝钱包容器的工具类，方便开发者在集成测试阶段控制支付宝钱包。
npm package: @magic-number/core
Description: 魔数核心类
Author: hao
Latest version: 0.0.6

# 关于魔数
魔数旨在帮助开发人员更为高效的管理测试用例和测试场景，并提供开发环境、单元测试、集成测试等不同阶段的数据接入方案和自动化测试方案。

# @magic-number/core
本项目中包含魔数项目中所有的核心类和接口定义，关于它们的使用说明，请在浏览器中打开[./docs/index.html](./docs/index.html)查看
npm package: @magic-number/server
Description: 魔数服务器
Author: hao
Latest version: 0.0.12

# 关于魔数
魔数旨在帮助开发人员更为高效的管理测试用例和测试场景，并提供开发环境、单元测试、集成测试等不同阶段的数据接入方案和自动化测试方案。

# @magic-number/server
本项目中包含魔数数据服务端的实现。包含了魔数本地文件服务和魔数http服务。
更多类的说明，请在浏览器中打开[./docs/index.html](./docs/index.html)查看
npm package: @magic-rpc/client
Description: Magic RPC client for type-safe RPC calls
Latest version: 1.3.0

# @magic-rpc/client

Type-safe client for making Magic RPC calls with support for field selection and automatic batching.

## Installation

```bash
npm install @magic-rpc/client
```

## Usage

### Basic Client

```typescript
import { RpcClient } from "@magic-rpc/client";

const client = new RpcClient({
  baseUrl: "http://localhost:3000/json-rpc",
  timeout: 5000,
  headers: {
    Authorization: "Bearer token",
  },
});

// Make RPC calls
const user = await client.call({
  method: "getUser",
  input: { userId: "123" },
  mappings: {
    avatar: 1,
    posts: { comments: 1 },
  },
});

// Batch multiple calls
const results = await client.batch([
  { method: "getUser", input: { userId: "1" } },
  { method: "getUser", input: { userId: "2" } },
]);
```

### Type-Safe Client

```typescript
import { createTypedClient } from "@magic-rpc/client";

// Define your schema (shared with server)
const schema = {
  getUser: [GetUserInputSchema, GetUserOutputSchema],
  getUserPosts: [GetPostsInputSchema, GetPostsOutputSchema],
};

const client = createTypedClient(schema, {
  baseUrl: "http://localhost:3000/json-rpc",
});

// Fully typed method calls
const user = await client.getUser(
  { userId: "123" }, // Typed input
  { avatar: 1, posts: 1 } // Optional field mappings
);
```

## Features

- **Type Safety**: Full TypeScript support with inferred types
- **Field Selection**: Specify which nested fields to resolve
- **Automatic Batching**: Batch multiple requests efficiently
- **Error Handling**: Proper error propagation from server
- **Timeout Support**: Configurable request timeouts
- **Custom Headers**: Support for authentication and custom headers

## API Reference

### RpcClient

```typescript
class RpcClient {
  constructor(config: RpcClientConfig);
  call<T>(request: RpcRequest): Promise<T>;
  batch<T>(requests: RpcRequest[]): Promise<T[]>;
}
```

### createTypedClient

```typescript
function createTypedClient<TSchema>(
  schema: TSchema,
  config: RpcClientConfig
): TypedRpcClient<TSchema>;
```

### Types

```typescript
interface RpcClientConfig {
  baseUrl: string;
  timeout?: number;
  headers?: Record<string, string>;
}

interface RpcRequest {
  method: string;
  input: any;
  mappings?: Record<string, any>;
}
```
npm package: @magic-rpc/server
Description: Magic RPC server with GraphQL-like resolver mechanism
Latest version: 1.3.0

# @magic-rpc/server

Server-side Magic RPC handler with GraphQL-like resolver mechanism for efficient data fetching and field resolution.

## Installation

```bash
npm install @magic-rpc/server
```

## Usage

```typescript
import { RpcHandler } from '@magic-rpc/server';
import DataLoader from 'dataloader';

// Define your RPC methods
const schema = {
  getUser: [GetUserInputSchema, GetUserOutputSchema],
  getUserPosts: [GetPostsInputSchema, GetPostsOutputSchema],
};

// Create efficient data loaders
function createLoaders() {
  return {
    User: new DataLoader(async (ids) => {
      return ids.map((id) => db.users.get(id));
    }),
  };
}

// Define resolvers for nested fields
const resolvers = {
  User: {
    avatar: {
      type: "Asset",
      resolve: async (user, context) => {
        return context.loaders.Asset.load(user.avatarId);
      },
    },
  },
};

// Create RPC handler
const rpc = new RpcHandler({
  schema,
  handlers: {
    getUser: async ({ input }) => {
      return db.users.get(input.userId);
    },
  },
  types: { User: UserSchema },
  resolvers,
  createLoaders,
});

// Handle requests
const result = await rpc.handle({
  method: "getUser",
  input: { userId: "123" },
  mappings: { avatar: 1 }
}, context);
```

## Features

- **RPC Method Handling**: Define methods with input/output validation using Hyperstruct schemas
- **GraphQL-like Resolvers**: Resolve nested fields on-demand based on client mappings
- **DataLoader Integration**: Automatic batching and caching for efficient data fetching
- **Type Safety**: Full TypeScript support with inferred types
- **Flexible Architecture**: Pluggable loaders and custom resolvers

## API Reference

See the [main README](../../README.md) for detailed API documentation.
npm package: @magic-script/cli
Description: Magic Script CLI Tools
Author: Tim Caswell
Latest version: 0.0.0
Deprecated: this package has been moved to 'magic-script-cli'

magic-script-cli
================

Magic Script CLI Tools

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/magic-script-cli.svg)](https://npmjs.org/package/magic-script-cli)
[![CircleCI](https://circleci.com/gh/magic-script/magic-script-cli/tree/master.svg?style=shield)](https://circleci.com/gh/magic-script/magic-script-cli/tree/master)
[![Downloads/week](https://img.shields.io/npm/dw/magic-script-cli.svg)](https://npmjs.org/package/magic-script-cli)
[![License](https://img.shields.io/npm/l/magic-script-cli.svg)](https://github.com/magic-script/magic-script-cli/blob/master/package.json)

<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g @magic-script/cli
$ magic-script COMMAND
running command...
$ magic-script (-v|--version|version)
@magic-script/cli/0.0.0 linux-x64 node-v10.12.0
$ magic-script --help [COMMAND]
USAGE
  $ magic-script COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`magic-script hello [FILE]`](#magic-script-hello-file)
* [`magic-script help [COMMAND]`](#magic-script-help-command)

## `magic-script hello [FILE]`

describe the command here

```
USAGE
  $ magic-script hello [FILE]

OPTIONS
  -f, --force
  -h, --help       show CLI help
  -n, --name=name  name to print

EXAMPLE
  $ magic-script hello
  hello world from ./src/hello.ts!
```

_See code: [src/commands/hello.ts](https://github.com/magic-script/magic-script-cli/blob/v0.0.0/src/commands/hello.ts)_

## `magic-script help [COMMAND]`

display help for magic-script

```
USAGE
  $ magic-script help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.1.3/src/commands/help.ts)_
<!-- commandsstop -->