@codaco/shared-consts

中文文档
6.3.0发布于 2026/10/21MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1.7万

Shared constants and typescript definitions for the Network Canvas project.

原始使用文档

@codaco/shared-consts

Shared constants, runtime schemas, and TypeScript types used across Network Canvas.

Sparse entity attributes

NcEntity, NcNode, NcEdge, NcEgo, and NcNetwork expose a strict output contract: every own property in an entity's attributes record contains a defined VariableValue. A missing property is the only representation of an unset variable.

VariableValueSchema and VariableValue support strings, booleans, numbers, arrays of primitive values, encrypted number arrays, and { x, y } layout coordinates. They do not accept null or undefined. Defined empty values are data, not absence, so writers and normalizers must preserve all of these:

{
  optedIn: false,
  count: 0,
  note: '',
  selections: [],
}

Do not create placeholder properties for unanswered variables:

// Correct: `nickname` is unset.
const attributes = {};

// Incorrect output: nullish values are not VariableValue values.
const attributes = { nickname: null };

Input compatibility and strict output

Use NcNetworkSchema.parse(input) at persistence, synchronization, and other untrusted-data boundaries. Its input accepts null and undefined attribute entries, then omits those properties from every ego, node, and edge attribute record. It preserves false, 0, '', [], and defined attributes not declared by the current codebook.

The distinction between input and output is intentional:

const network: NcNetwork = NcNetworkSchema.parse(storedValue);
// network attributes are now Record<string, VariableValue>

Code that already has an NcNetwork must not write nullish values. Code that accepts stored or external data must parse it before exposing the public output types. StageMetadataSchema applies the same sparse normalization to Family Pedigree edge attribute snapshots.

版本与发布记录

@codaco/shared-consts 共发布 25 个版本,首次发布于 2022/04/21;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.3.0latest2026/10/2119 天前
6.2.02026/10/1327 天前
6.1.02026/09/291 个月前
6.0.02026/08/312 个月前
5.6.12026/08/063 个月前
5.6.02026/07/313 个月前

其他发布通道:alpha → 3.0.0。

关于 @codaco/shared-consts 的常见问题

@codaco/shared-consts 是什么?

Shared constants and typescript definitions for the Network Canvas project.

如何安装 @codaco/shared-consts?

在项目目录运行 npm install @codaco/shared-consts,或使用 pnpm add / yarn add / bun add。

@codaco/shared-consts 支持 TypeScript 吗?

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

@codaco/shared-consts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@codaco/shared-consts 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codaco/shared-consts 可以商用吗?

@codaco/shared-consts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codaco/shared-consts 的下载量有多少?

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

@codaco/shared-consts 还在维护吗?

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