@esposter/azure

中文文档
4.10.1发布于 2026/11/14Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2035

The Azure wire conventions Esposter's clients and its mocks both speak — OData filter clauses, entity key casing, and service limits.

原始使用文档
文档目录9 节
  1. Table of Contents
  2. 🚀 Getting Started
  3. 🧩 Key Exports
  4. Clauses
  5. Values
  6. Filters
  7. Keys
  8. Limits
  9. ⚖️ License

@esposter/azure

Apache-2.0 licensed NPM version NPM downloads NPM Unpacked Size (with version)

It holds the Azure wire conventions that a real client and a fake client must both follow. They are the OData filter clause vocabulary shared by Table Storage and Search, the entity key casing convention and the service limits.

Design notes live in the specs.

Table of Contents


🚀 Getting Started

Install the package:

pnpm add @esposter/azure

🧩 Key Exports

ExportKindPurpose
AZURE_MAX_PAGE_SIZEconstLargest page size the service returns in one call
BinaryOperatorenumComparison operators Table Storage understands
ClausetypeA filter condition on one property, the unit OData strings are built from
CompositeKeyclassThe partitionKey and rowKey pair every Table entity carries
CompositeKeyPropertyNamesconstThe CompositeKey property names, so callers never restate the strings
deserializeClausefunctionParses a serialized filter clause back into a Clause, throwing on no match
escapeValuefunctionQuotes a string as an OData literal, doubling embedded single quotes
getPartitionKeyFilterfunctionThe filter selecting everything under one partition key
getTableNullClausefunctionThe Table Storage "is null" clause, a negated NaN comparison
SearchOperatorenumCollection predicates only Azure Search supports
serializeClausesfunctionSerializes clauses into a Table Storage OData filter string
serializeValuefunctionRenders one SerializableValue as a literal for Table or Search

Clauses

A Clause<T> is a filter condition on a property of T. The OData string is built from clauses. Do not assemble the string by hand.

  • BinaryOperator holds the comparisons that Table Storage understands.
  • SearchOperator holds the collection predicates that only Azure Search supports.
  • UnaryOperator combines clauses.
import type { Clause } from "@esposter/azure";

import { BinaryOperator } from "@esposter/azure";

const clause: Clause<{ createdAt: Date }> = { key: "createdAt", operator: BinaryOperator.Ge, value: new Date(0) };

Values

serializeValue renders a SerializableValue in the format that the target service expects. isTableFilter selects the format.

  • Table Storage: a Date renders as a datetime'<iso>' literal.
  • Search: a Date renders as the bare ISO string.

Strings go through escapeValue. It doubles each embedded single quote, so a value cannot close its own literal or add filter syntax of its own.

import { escapeValue, serializeValue } from "@esposter/azure";

Filters

serializeClauses turns a clause array into a Table Storage filter string. serializeSearchClauses turns a clause array into a Search filter string. The two differ only in how a Date renders.

Clauses on the same key are grouped:

  • A range pair is joined with and.
  • Any other group is joined with or.

Do not assemble the boolean structure by hand. deserializeClause is the inverse.

import { BinaryOperator, CompositeKeyPropertyNames, getTableNullClause, serializeClauses } from "@esposter/azure";

const roomId = crypto.randomUUID();
const filter = serializeClauses([
  { key: CompositeKeyPropertyNames.partitionKey, operator: BinaryOperator.Eq, value: roomId },
  getTableNullClause("deletedAt"),
]);

The two services handle null differently. The helpers handle the difference.

  • getTableNullClause expresses "is null" for Table Storage.
  • Search supports null directly, through getSearchNullClause / getSearchNonNullClause.

getPartitionKeyFilter builds the one-clause filter that selects everything under one partition key. A read, a count and a purge of the same entity must all start from this filter.

Keys

CompositeKey is the partitionKey/rowKey pair that every Table entity carries. Refer to these names through CompositeKeyPropertyNames. Do not restate the strings. serializeKey and deserializeKey convert keys at the boundary.

import { CompositeKey, CompositeKeyPropertyNames, serializeKey } from "@esposter/azure";

Limits

These constants hold the maximum values that the service allows: AZURE_MAX_BATCH_SIZE, AZURE_MAX_PAGE_SIZE and AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS. Use them when you paginate, batch or enqueue. Do not hard-code these values.

⚖️ License

This project is licensed under the Apache-2.0 license.

版本与发布记录

@esposter/azure 共发布 28 个版本,首次发布于 2026/08/23;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.10.1latest2026/11/14今天
4.10.02026/11/131 天前
4.9.02026/11/122 天前
4.8.02026/11/104 天前
4.7.02026/11/095 天前
4.6.02026/11/077 天前

关于 @esposter/azure 的常见问题

@esposter/azure 是什么?

The Azure wire conventions Esposter's clients and its mocks both speak — OData filter clauses, entity key casing, and service limits.

如何安装 @esposter/azure?

在项目目录运行 npm install @esposter/azure,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:zod(^4.6.7)、@azure/data-tables(^13.3.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@esposter/azure 支持 TypeScript 吗?

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

@esposter/azure 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@esposter/azure 可以商用吗?

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

@esposter/azure 的下载量有多少?

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

@esposter/azure 还在维护吗?

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