@basenative/integrations

中文文档
3.3.0发布于 2026/11/03Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 1934

BaseNative 应用程序的无头第三方集成包

中文使用文档
文档目录10 节
  1. 安装
  2. 快速启动
  3. 平板链接( 客户端)
  4. 平板账户+转账(服务器侧)
  5. Yield 优化( 纯函数, 无网络调用)
  6. API 密码
  7. @basenative/integrations/plaid
  8. @basenative/integrations/yield
  9. 测试
  10. 许可证

@ asinative/ 整合

BaseNative apps的无头第三方集成包件——平板链接+账户/传输,和纯浮产优化数学

部分 基础 生态系统——一个基于信号的网络运行时间超过本土的HTML.

安装

npm install @basenative/integrations

每个子路径是一个单独的切入点——只导入您需要的东西:

import { createPlaidLink, createPlaidClient } from '@basenative/integrations/plaid';
import { findBestYieldAccount, optimizeFloatAllocation } from '@basenative/integrations/yield';

快速启动

import { createPlaidLink } from '@basenative/integrations/plaid';
import { signal } from '@basenative/runtime';

const { linkStatus, open, destroy } = await createPlaidLink({
  token: linkToken, // from createLinkToken() below, fetched from your server
  onSuccess: (publicToken, metadata) => {
    // send publicToken to your server to exchange it
  },
  signals: { signal },
});

open(); // launches the Plaid Link UI; linkStatus updates as the user completes it

平板账户+转账(服务器侧)

import { createLinkToken, exchangePublicToken, createPlaidClient } from '@basenative/integrations/plaid';

const credentials = { clientId: process.env.PLAID_CLIENT_ID, secret: process.env.PLAID_SECRET, env: 'sandbox' };

const { linkToken } = await createLinkToken({ userId: 'user_123' }, credentials);
const { accessToken } = await exchangePublicToken(publicTokenFromClient, credentials);

const plaid = createPlaidClient({ clientId: credentials.clientId, secret: credentials.secret, environment: credentials.env });
const { accounts } = await plaid.getAccounts(accessToken);

Yield 优化( 纯函数, 无网络调用)

import { findBestYieldAccount, optimizeFloatAllocation } from '@basenative/integrations/yield';

const best = findBestYieldAccount([
  { id: 'a1', name: 'Checking', balance: 5000, apy: 0.005 },
  { id: 'a2', name: 'High-yield savings', balance: 20000, apy: 0.045 },
]);
// { accountId: 'a2', accountName: 'High-yield savings', apy: 0.045, expectedMonthlyYield: 75 }

API 密码

@basenative/integrations/plaid

客户端( 需要浏览器 ):

  • loadPlaidScript() ——装入平板链接滴入脚本一次;准备时解决.
  • createPlaidLink(config) ——以信号为主的链接处理器. config数字 : token, (中文(简体) ), onSuccess(publicToken, metadata), (中文(简体) ), onExit?, (中文(简体) ), onEvent?, (中文(简体) ), signals (物体曝光) signal(),比如说. @basenative/runtime) (中文(简体) ). 回返 { linkToken, linkStatus, open(), destroy() } —— 说 linkToken编号 :linkStatus 是信号,当 signals.signal 提供, null 否则.
  • openPlaidLink(options) 低级 没有信号的链接处理器 . options数字 : token, (中文(简体) ), onSuccess, (中文(简体) ), onExit?, (中文(简体) ), onEvent?. 回归 { open(), destroy() }。 。 。 .

服务器侧面(节点或Cloudflare工人-使用) fetch没有SDK:

  • createPlaidClient(config) - 工厂将证书捆绑在一起 exchangePublicToken, (中文(简体) ), getAccounts, (中文(简体) ), getBalance, (中文(简体) ), createTransfer, (中文(简体) ), getTransferStatus。 。 。 . config数字 : clientId, (中文(简体) ), secret, (中文(简体) ), environment? (单位:千美元)'sandbox' | 'development' | 'production'默认值 'sandbox') (中文(简体) ).
  • createLinkToken(options, credentials) ——创建链接符. options数字 : userId, (中文(简体) ), clientName?, (中文(简体) ), products? (默认) ['transactions'], (中文(简体) ), countryCodes? (默认) ['US'], (中文(简体) ), language?. 回归 { linkToken, expiration, requestId }。 。 。 .
  • exchangePublicToken(publicToken, credentials) - 交换链接 onSuccess 公共信使是访问信使 回返 { accessToken, itemId, requestId }。 。 。 .
  • getAccounts(accessToken, credentials) ——取出无余额的关联账户.
  • getBalances(accessToken, credentials) 编号 : getBalance(accessToken, credentials) - 以余额获取账户(getBalance 是一个别名).
  • createTransfer(params, credentials) 启动平板传输. params数字 : accessToken, (中文(简体) ), accountId, (中文(简体) ), type (单位:千美元)'debit' | 'credit', (中文(简体) ), amount (分数), description, (中文(简体) ), network? (单位:千美元)'rtp' 对于RTP/FedNow,在失败时回到ACH, user? (单位:千美元){ name, email }) (中文(简体) ). 回返 { transferId, status, network }。 。 。 .
  • getTransferStatus(transferId, credentials) - 回返 { transferId, status, amount, network }。 。 。 .

credentials 总是 { clientId, secret, env? }。所有服务器函数直接通过 Plaid REST API 调用 fetch 没有 plaid npm SDK依赖.

@basenative/integrations/yield

纯函数——无外部 API 调用,无 I/O :

  • findBestYieldAccount(accounts) - 从APY账户中选择最高的账户 [{ id, name, balance, apy }]. 回归 { accountId, accountName, apy, expectedMonthlyYield }。 。 。 .
  • optimizeFloatAllocation(accounts, totalFloat) - 贪婪地分配 totalFloat 跨账户(最高APY第一,尊重每个账户的可选性) maxBalance) (中文(简体) ). 回返 [{ accountId, accountName, allocation, expectedYield }]。 。 。 .
  • calculateOptimalTransferTiming(liabilities, accounts) ——构建一个转移调度表,将最高收益账户中浮动到每个负债到期日前2天. 回返 [{ transferDate, fromAccountId, amount, reason }]。 。 。 .
  • calculateBreakEven(amount, fromApy, toApy, transferCostCents?, daysFloat?) ——确定是否移动 amount 从一个APY到一个更高的PY(分)值 固定转帐成本超过 daysFloat 几天时间 回返 { profitable, yieldGain, breakEvenDays }。 。 。 .

测试

cd packages/integrations && node --test

许可证

阿帕奇 - 2.0

版本与发布记录

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

版本发布日期距今
3.3.0latest2026/11/035 天前
3.2.02026/11/035 天前
3.1.02026/11/017 天前
3.0.02026/10/317 天前
2.4.02026/10/2613 天前
2.3.22026/10/2217 天前

关于 @basenative/integrations 的常见问题

@basenative/integrations 是什么?

BaseNative 应用程序的无头第三方集成包

如何安装 @basenative/integrations?

在项目目录运行 npm install @basenative/integrations,或使用 pnpm add / yarn add / bun add。

@basenative/integrations 支持 TypeScript 吗?

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

@basenative/integrations 支持 ESM 还是 CommonJS?

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

@basenative/integrations 可以商用吗?

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

@basenative/integrations 的下载量有多少?

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

@basenative/integrations 还在维护吗?

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