npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fibona_sdk

v1.0.4

Published

Fibona服务SDK,用于集成Fibona应用和使用相关服务

Downloads

11

Readme

Fibona SDK 说明文档

目录

介绍

用于接入Fibona相关服务

安装

使用 npm 安装

npm install fibona_sdk --save

使用 yarn 安装

yarn add fibona_sdk

(非npm项目请联系Fibona团队获取SDK物料包)

快速开始

  • 第一步:向Fibona申请应用集成服务

​ 启动并运行您的项目后,到 https://fibona.woa.com/#/app/index 检查验证应用集成状态,若集成成功,则显示【已集成】,否则【未集成】

import fibona from 'fibona_sdk'
// app_id 从 Fibona管理平台-应用管理 创建应用获取或联系Fibona团队
fibona.start({ app_id: 'your app_id' }, (err) => {
  if (err) { // 如果失败,报错信息将在err中返回
    console.log('fibona sdk集成失败', err)
    return
  }
  console.log('fibona sdk集成成功')
})
  • 第二步:快速接入Fibona能力

您可以通过此接口为您的平台配置默认使用示例的数据源(即快速开始能力)

数据源可更新,若在多处调用fibona.quickUse,则数据源以最新一次调用触发为准

// 同步
fibona.quickUse(() => {
  return {
    data: JSON.stringify({ data: 'date_example' })
  }
})
// or 异步
const getData = (): Promise<any> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({ data: 'date_example_sync' })
    }, 1000)
  })
}
fibona.quickUse(async() => {
  return { data: JSON.stringify(await getData()) }
})

配置完成并安装插件后,可通过网页左下角悬浮的Fibona气泡助手点击【快速使用】,体验一触即达的响应能力,

自定义配置

  • 数据流转/导入

    将数据导出至Fibona插件, 并启用插件。


import fibona, { DataConfig } from 'fibona_sdk'

fibona.send(
  {
    data: 'date_example',
    format: DataConfig.FORMAT.TEXT,
    consumer: DataConfig.CONSUMER.BUGFIX
  },
  (err) => {
    if (err) {
      console.log('发送失败', err)
      return
    }
    console.log('发送成功')
  }
)
  • 数据与提示词的触发绑定

    当您的团队拥有提示词后,可通过该接口为平台用户提供一键分析数据等能力。

    与【数据流转/导入】的区别:通过该接口绑定的数据源,Fibona插件只显示绑定的提示词。

    如何获取 trigger_id?查看:https://iwiki.woa.com/p/4010004569

import fibona, { DataConfig } from 'fibona_sdk'

const trigger_id: number = 123456
fibona.send(
  {
    data: 'date_example',
    format: DataConfig.FORMAT.TEXT,
    consumer: DataConfig.CONSUMER.BUGFIX,
    trigger_id: trigger_id
  },
  (err) => {
    if (err) {
      console.log('发送失败', err)
      return
    }
    console.log('发送成功')
  }
)

API 参考

导入

import fibona from 'fibona_sdk'

可调用方法

  • checkFibonaExist - 检查 Fibona 插件是否已经安装。
  • send - 配合 Fibona 插件实现 数据流转、提示词绑定。
  • start - 启动 Fibona 服务。
  • quickUse - 绑定默认数据源并启用 Fibona【快速使用】功能

方法说明

  • send(data: DataType, calllback?: (error: ErrorType | undefined) => void): void;

    • 参数一:data - 要发送的数据。
    • 参数二:calllback - 可选的回调函数,在数据发送成功或失败后调用。
  • start(config: Config, calllback?: (error: ErrorType | undefined) => void): void;

    • 参数一:config - Fibona 服务的配置信息。
    • 参数二:calllback - 可选的回调函数,在 Fibona 服务启动成功或失败后调用。
  • `quickUse((data?: any) => QuickUseReturnType | Promise

    • 参数一:接收一个返回字符串类型数据的 同步/异步 函数
  • checkFibonaExist(): boolean;

参数说明

  • Config
    • app_id - Fibona 服务的应用 ID。
  • ErrorType
    • code - 错误代码。
    • message - 错误消息。
  • DataType
    • data - 数据内容(字符串)。
    • consumer - 数据消费者。必需。限制:目前仅支持传入 "bugfix" | "input",具体呈现方式请下载Fibona插件测试。
    • format - 数据格式。必需。限制:若传入 "csv" 请参考 注意事项 使用。
    • tags - 数据标签(可选)。
    • description - 数据描述(可选)。
    • trigger_id - 提示词触发ID,详情到 Fibona web 进行配置(可选)。
  • QuickUseReturnType
    • data - 数据(字符串)

TS类型

支持导出TS类型,如

import { DataType, ErrorType } from 'fibona/types'

具体说明

| 所属接口/类型 | 属性 | 说明 | 类型 | | ------------- | ------------------ | ---------------- | -------- | | FibonaType | send | 数据流转 | function | | FibonaType | checkFibonaExist | 检查插件是否安装 | function | | FibonaType | start | 验证应用接入 | function | | Config | app_id | 应用ID | string | | ErrorType | code | 错误码 | number | | ErrorType | message | 错误信息 | string | | DataType | data | 数据源 | string | | DataType | consumer | 数据源参数 | string | | DataType | format | 数据源参数 | string | | DataType | trigger_id | 触发配置参数 | number |

注意事项

  • 数据源格式标准

    当数据源 format 为 csv 时,数据将被渲染为表格形式,请确保csv数据符合以下格式:

  • 兼容性

    若出现兼容性问题,请联系Fibona团队。

  • 提升用户体验

    建议在调用与Fibona插件产生交互的接口前(如fibona.send),先使用checkFibonaExist检查插件是否已安装,以免出现意料之外的行为。