@communities-webruntime/metadata-schema

中文文档
1.66.8发布于 2021/12/02MITTypeScriptES Module近 30 天下载 2965

UI metadata schema specs for Lightning Web Runtime

原始使用文档
文档目录4 节
  1. Overview
  2. Usage
  3. Definitions
  4. Contributing

UI Metadata Schema

Model the shape of your UI in JSON using a unified schema.

This project is currently only used by @communities-webruntime and its corresponding validators.

Overview

Metadata-schema validates the shape of different types of JSON metadata for a LWR project.

The current supported schemas include:

  • base (canonical metadata)
  • communities (declarative metadata)

The metadata types include:

  • branding
  • routes
  • theme
  • view

Usage

To validate against the schema, import the MetadataValidator:

import MetadataValidator from '@communities-webruntime/metadata-schema';

const schema = 'communities';   // name of the schema to validate against
const metadataType = 'routes';  // name of the metadata type
const data = ...;
new MetadataValidator(schema).validate(data, metadataType);

For an example, see metadata-validation.ts.

Definitions

NameDescription
ViewA view on a screen. Also known as a Page.
ComponentA reusable, composable fragment of UI. This is agnostic to technology, i.e. this could be a LWC component or a reusable HTML element.
RegionA part of the view which may contain one or more Components
BrandingPropertyA piece of data which stores visual information such as color or font. This is typically a key:value pair
RouteA route contains metadata about a URL scheme, or any location specifier
ThemeA theme is a complex type which contains metadata about your application's higher-level visuals
ThemeLayoutA theme layout is just another name for a view

For a more detailed rundown of the metadata pieces, see Anatomy of a Communities LWR Template.

Contributing

  1. Edit only the schema affected by your change. Know that any definition changes can affect all schemas. Ensure you are not breaking someone else by looking at the files in the /config folder and verifying the impact of your schema change.
  2. Further ensure you are not breaking someone else by running all tests.
  3. Add tests for your changes to make sure someone else does not break you.

版本与发布记录

@communities-webruntime/metadata-schema 共发布 359 个版本,首次发布于 2020/01/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.66.8latest2021/12/024 年前
1.66.3-236.12021/12/024 年前
1.66.72021/12/014 年前
1.66.62021/11/274 年前
1.66.52021/11/244 年前
1.66.3-236.02021/11/244 年前

其他发布通道:summer20 → 0.29.13-226.1,winter21 → 0.33.24-228.1,spring21 → 0.42.6-230.3,summer21 → 0.49.6-232.2,winter22 → 0.61.2-234.9,canary → 1.61.5-alpha.1720。

关于 @communities-webruntime/metadata-schema 的常见问题

@communities-webruntime/metadata-schema 是什么?

UI metadata schema specs for Lightning Web Runtime

如何安装 @communities-webruntime/metadata-schema?

在项目目录运行 npm install @communities-webruntime/metadata-schema,或使用 pnpm add / yarn add / bun add。

@communities-webruntime/metadata-schema 支持 TypeScript 吗?

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

@communities-webruntime/metadata-schema 支持 ESM 还是 CommonJS?

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

@communities-webruntime/metadata-schema 可以商用吗?

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

@communities-webruntime/metadata-schema 的下载量有多少?

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

@communities-webruntime/metadata-schema 还在维护吗?

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