Amee 类型脚本 SDKs
此repo发布两个来自npm工作空间的ESM TypeScript SDK包.
软件包
@aimee.shop/sdk
公共SDK用于商店前端和商家安全的商业API.
npm install @aimee.shop/sdk
import { AimeeSDK } from '@aimee.shop/sdk';
const sdk = new AimeeSDK({
apiKey: process.env.AIMEE_API_KEY,
tenantId: 'tenant-uuid',
});
const products = await sdk.products.list({ limit: 20 });
const checkout = await sdk.checkout.create({ cartId: 'cart-uuid' });
浏览器用法 :
import { aimee, browserAuth } from '@aimee.shop/sdk/browser';
await browserAuth.signIn('[email protected]', 'password');
const products = await aimee.products.list();
@aimee.shop/sdk-platform
内部/管理员SDK用于平台操作. 它包括公共SDK表面外加RBAC,支付管理员,工作流程,通知,租户,用户/管理员,API密钥,UCP/admin,沙盒促销,以及内容副本.
npm install @aimee.shop/sdk @aimee.shop/sdk-platform
import { AimeePlatformSDK } from '@aimee.shop/sdk-platform';
const sdk = new AimeePlatformSDK({
apiKey: process.env.AIMEE_API_KEY,
tenantId: 'tenant-uuid',
});
const roles = await sdk.rbac.roles.list();
const tenants = await sdk.tenants.list();
发展
npm install
npm run build
npm run typecheck
npm test
npm run status
npm run pack:dry-run
质量规则:
npm run status必须在承诺前通过.- 没有
any, (中文(简体) ),as any,或@ts-ignore。 。 。 . - 公共软件包不得包括平台服务文件.
- 平台软件包是唯一暴露内部/管理员客户端的软件包.
认证
支持的认证模式 :
- 为服务器侧消费者提供的 API 密钥 .
getAccessToken用于浏览器/框架管理的会议.- 用于服务类认证的可识别电子邮件/密码字 .
- 地方发展的交互式授权.
const sdk = new AimeeSDK({
getAccessToken: () => authContext.getToken(),
tenantId: 'tenant-uuid',
});
多十年背景
const tenantSdk = sdk.withTenant('other-tenant');
const storeSdk = sdk.withStore('store-uuid');
范围化实例共享认证, 但获得自己的 HTTP 客户端, 因此租户/ 仓库头被隔离 .
通知配置( 服务器 /) sk_ 仅限)
列出存储和点火测试发送的交易定义
没有下命令 需要密钥 API (sk_)或管理JWT
notification-config:read 编号 : notification-config:trigger,加上存储上下文.
可出版(pk_)键返回 403。 这不是在上 @aimee.shop/sdk/storefront。 。 。 .
管理模板/提供者工作继续 @aimee.shop/sdk-platform (单位:千美元)sdk.notifications) (中文(简体) ).
sdk.setStore(storeId);
const { items } = await sdk.notificationConfig.list();
await sdk.notificationConfig.testSend({
eventName: 'order.created',
to: '[email protected]',
});
现场订单确认活动是 order.created (无) order.confirmed) (中文(简体) ).
CSV出口(服务器 / sk_ 仅限)
创建 Async CSV 导出任务, 民调直到 completed,然后打开
预签名下载 URL。 要求数 {entity}:export (单位:千美元)orders:export, (中文(简体) ),
products:export, (中文(简体) ), customers:export+ 存储范围
实体。 可出版(pk_)键返回 403。 这不是在上
@aimee.shop/sdk/storefront。 。 。 .
sdk.setStore(storeId);
const { jobId } = await sdk.exports.create(
{ entity: 'orders', filters: { status: 'PAID' }, columnSet: 'summary' },
{ idempotencyKey: crypto.randomUUID() },
);
const job = await sdk.exports.get(jobId);
if (job.status === 'completed') {
const { downloadUrl } = await sdk.exports.getDownloadUrl(jobId);
}
软件包边界
使用 @aimee.shop/sdk 用于店面,公共开发商工具,以及商家安全整合.
使用 @aimee.shop/sdk-platform 用于管理员UI,内部服务和需要平台操作的工具.
@aimee.shop/sdk-platform 对等依赖 @aimee.shop/sdk 并扩展其公共SDK类. 平台消费者应当从 @aimee.shop/sdk-platform 当他们需要 公共加平台组合表面.