@aws-appsync/utils

中文文档
2.1.1发布于 2026/02/26Apache-2.0TypeScriptCommonJS零依赖近 30 天下载 40.4万

This project contains type definitions for AppSync resolver types.

原始使用文档

Type definition for @aws-appsync/utils

This project contains utility function definitions and type definitions for working with AWS AppSync Resolvers written in JavaScript using the APPSYNC_JS runtime. This includes the util and extensions utilities. For more information on these utilities, see the AppSync documentation.

Usage

Install the type definition by running

npm install @aws-appsync/utils

In your AppSync function code definition:

import { util } from '@aws-appsync/utils';
import * as ddb from '@aws-appsync/utils/dynamodb';

/**
 * Creates a new item in a DynamoDB table
 * @param ctx contextual information about the request
 */
export function request(ctx) {
  const item = ctx.arguments.input;
  return ddb.put({ key: { id: util.autoId() }, item });
}

/**
 * Returns the result
 * @param ctx contextual information about the request
 */
export function response(ctx) {
  const { error, result } = ctx;
  if (error) {
    return util.appendError(error.message, error.type, result);
  }
  return ctx.result;
}

版本与发布记录

@aws-appsync/utils 共发布 23 个版本,首次发布于 2022/11/17;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.1.1latest2026/02/268 个月前
2.0.32025/04/301.5 年前
1.12.02024/12/181.9 年前
1.11.02024/11/222 年前
1.10.12024/11/012 年前
1.10.02024/10/312 年前

关于 @aws-appsync/utils 的常见问题

@aws-appsync/utils 是什么?

This project contains type definitions for AppSync resolver types.

如何安装 @aws-appsync/utils?

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

@aws-appsync/utils 支持 TypeScript 吗?

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

@aws-appsync/utils 支持 ESM 还是 CommonJS?

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

@aws-appsync/utils 可以商用吗?

@aws-appsync/utils 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aws-appsync/utils 的下载量有多少?

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

@aws-appsync/utils 还在维护吗?

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