@adobe/aio-lib-templates

中文文档
3.0.4发布于 2025/11/12Apache-2.0CommonJS近 30 天下载 2.5万

A library to communicate with Adobe App Builder Template Registry.

原始使用文档
文档目录6 节
  1. Adobe App Builder Templates Library
  2. Installing
  3. Usage
  4. Explore
  5. Contributing
  6. Licensing

Adobe App Builder Templates Library

This is a helper library that is to be used in the Adobe I/O CLI and SDKs to communicate with Adobe App Builder Template Registry through its REST APIs.

Installing

$ npm install @adobe/aio-lib-templates

Usage

Search Adobe App Builder templates

Search Adobe App Builder templates in Adobe App Builder Template Registry and paginate through results.

const sdk = require('@adobe/aio-lib-templates');

async function sdkTest() {
    const templateRegistryClient = sdk.init();
    // an optional Search Criteria object
    // without Search Criteria the following code will paginate through all Adobe App Builder templates
    const searchCriteria = {
        [sdk.SEARCH_CRITERIA_CATEGORIES]: ['action', sdk.SEARCH_CRITERIA_FILTER_NOT + 'ui', sdk.SEARCH_CRITERIA_FILTER_OR + 'runtime'],
        [sdk.SEARCH_CRITERIA_STATUSES]: [sdk.TEMPLATE_STATUS_APPROVED],
        [sdk.SEARCH_CRITERIA_ADOBE_RECOMMENDED]: true
    };
    // an optional OrderBy Criteria object
    const orderByCriteria = {
        [sdk.ORDER_BY_CRITERIA_NAMES]: sdk.ORDER_BY_CRITERIA_SORT_DESC
    };
    for await (const templates of templateRegistryClient.getTemplates(searchCriteria, orderByCriteria)) {
        for (const template of templates) {
            console.log(template);
        }
    }
}
Supported Search Criteria properties
KeyValueSDK ConstantDescription
nameslist of stringsSEARCH_CRITERIA_NAMESFilter by template names.
categorieslist of stringsSEARCH_CRITERIA_CATEGORIESFilter by template categories.
statuseslist of stringsSEARCH_CRITERIA_STATUSESFilter by template statuses (TEMPLATE_STATUS_IN_VERIFICATION, TEMPLATE_STATUS_APPROVED, TEMPLATE_STATUS_REJECTED).
apislist of stringsSEARCH_CRITERIA_APISFilter by template APIs. Supports EMPTY and ANY filters.
extensionslist of stringsSEARCH_CRITERIA_EXTENSIONSFilter by template extension points. Supports EMPTY and ANY filters.
eventsEMPTY and ANY filters onlySEARCH_CRITERIA_EVENTSFilter by template events. For now supports EMPTY and ANY filters only.
runtimebooleanSEARCH_CRITERIA_RUNTIMEIs Adobe I/O Runtime required or not? Supports EMPTY and ANY filters.
adobeRecommendedbooleanSEARCH_CRITERIA_ADOBE_RECOMMENDEDIndicates templates featured by Adobe.
Filter Operators
Filter TypeValueSDK ConstantDescription
EMPTY (NONE)'', an empty stringSEARCH_CRITERIA_FILTER_NONEReturns all templates that don't have a property set.
ANY*, an asterisk symbolSEARCH_CRITERIA_FILTER_ANYReturns all templates that have a property set.
NOT!, an exclamation point symbolSEARCH_CRITERIA_FILTER_NOTExcludes all templates which contain the negated query parameter value.
OR|, a pipe symbolSEARCH_CRITERIA_FILTER_ORArray filters, e.g.: categories, default to returning the intersection (AND) of all matching templates. This filter operator adds the ability to specify a logical "OR" for individual values.
Supported OrderBy Criteria properties
KeyValueSDK ConstantDescription
namesstring, desc or ascORDER_BY_CRITERIA_NAMESSort by template names.
statusesstring, desc or ascORDER_BY_CRITERIA_STATUSESSort by template statuses.
adobeRecommendedstring, desc or ascORDER_BY_CRITERIA_ADOBE_RECOMMENDEDSort by the "Adobe Recommended" flag.
publishDatestring, desc or ascORDER_BY_CRITERIA_PUBLISH_DATESort by a publish date.

Get a template from Adobe App Builder Template Registry

Get a template from Adobe App Builder Template Registry.

const sdk = require('@adobe/aio-lib-templates');

async function sdkTest() {
    const templateRegistryClient = sdk.init();
    const templateName = '@author/app-builder-template';
    try {
        const template = await templateRegistryClient.getTemplate(templateName);
        console.log(template);
    } catch (error) {
        console.log(error.toString());
    }
}

Add a new template to Adobe App Builder Template Registry

Add a new template to Adobe App Builder Template Registry.

const sdk = require('@adobe/aio-lib-templates');

async function sdkTest() {
    const templateRegistryClient = sdk.init({
        'auth': {
            'token': '<IMS_ACCESS_TOKEN>'
        }
    });
    const templateName = '@author/app-builder-template';
    const githubRepoUrl = 'https://github.com/author/app-builder-template';
    try {
        const template = await templateRegistryClient.addTemplate(templateName, githubRepoUrl);
        console.log(`A new template "${template.name}" has been successfully added to Adobe App Builder Template Registry.`);
        console.log(`Its status is "${sdk.TEMPLATE_STATUS_IN_VERIFICATION}". Please use the "${template.reviewLink}" link to check the verification status.`);
    } catch (error) {
        console.log(error.toString());
    }
}

Updates a template to Adobe App Builder Template Registry

Updates a template to Adobe App Builder Template Registry.

Note: It's only accessible with an IMS service token

const sdk = require('@adobe/aio-lib-templates');

async function sdkTest() {
    const templateRegistryClient = sdk.init({
        'auth': {
            'token': '<IMS_ACCESS_TOKEN>'
        }
    });
    const templateId = '66431bb2f682a35bf4b1b002';
    const githubRepoUrl = 'https://github.com/author/app-builder-template';
    try {
        const template = await templateRegistryClient.updateTemplate(templateId, githubRepoUrl);
        console.log(`template with Id "${template.templateId}" has been successfully updated to Adobe App Builder Template Registry.`);
    } catch (error) {
        console.log(error.toString());
    }
}

Delete a template from Adobe App Builder Template Registry

Delete a template from Adobe App Builder Template Registry.

const sdk = require('@adobe/aio-lib-templates');

async function sdkTest() {
    const templateRegistryClient = sdk.init({
        'auth': {
            'token': '<IMS_ACCESS_TOKEN>'
        }
    });
    const templateName = '@author/app-builder-template';
    try {
        await templateRegistryClient.deleteTemplate(templateName);
        console.log(`"${templateName}" has been successfully deleted from Adobe App Builder Template Registry.`);
    } catch (error) {
        console.log(error.toString());
    }
}

Install a template

Install a template from Developer Console

Note: It's only accessible with an IMS service token

const sdk = require('@adobe/aio-lib-templates');

async function sdkTest() {
    const templateRegistryClient = sdk.init({
        'auth': {
            'token': '<IMS_ACCESS_TOKEN>'
        }
    });
    const templateId = '<valid templateId>';
    const templateInstallRequestBody = {
        orgId: '<valid orgId>',
        projectName: '<projectName>',
        description: '<description>',
        metadata: {
            domain : '<domain>',
            defaultRedirectUri: '<defaultRedirectUri>'
        },
        apis: [
            {
                code: 'SDKCode',
                credentialType: 'valid credentialType',
                flowType: 'valid flowType',
                licenseConfigs: [
                    {
                        id: 'valid id',
                        productId: 'valid productId',
                        op: 'valid op',
                    }
                ]
            }
        ]
    }
    try {
        await templateRegistryClient.installTemplate(templateId, templateInstallRequestBody);
        console.log(`Template with id "${templateId}" has been successfully installed.`);
    } catch (error) {
        console.log(error.toString());
    }
}

Explore

goto API

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

版本与发布记录

@adobe/aio-lib-templates 共发布 11 个版本,首次发布于 2022/06/10;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.0.4latest2025/11/1211 个月前
3.0.32025/01/211.8 年前
3.0.22024/02/082 年前
3.0.02024/01/112 年前
2.2.1-pre.2024-01-10.sha-d2ea121fnext2024/01/102 年前
2.2.12023/01/133 年前

关于 @adobe/aio-lib-templates 的常见问题

@adobe/aio-lib-templates 是什么?

A library to communicate with Adobe App Builder Template Registry.

如何安装 @adobe/aio-lib-templates?

在项目目录运行 npm install @adobe/aio-lib-templates,或使用 pnpm add / yarn add / bun add。

@adobe/aio-lib-templates 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adobe__aio-lib-templates 是否存在。

@adobe/aio-lib-templates 支持 ESM 还是 CommonJS?

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

@adobe/aio-lib-templates 需要什么版本的 Node.js?

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

@adobe/aio-lib-templates 可以商用吗?

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

@adobe/aio-lib-templates 的下载量有多少?

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

@adobe/aio-lib-templates 还在维护吗?

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