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

icafe-api

v1.3.0

Published

nodejs's sdk for icafe api

Downloads

8

Readme

icafe-api

NPM version Prettier Conventional Commits

nodejs's sdk for icafe api,对于 icafe 官方 web api 的封装

Installation

npm install icafe-api
# or use yarn
yarn add icafe-api

Usage

import { BatchCreate } from 'icafe-api'

BatchCreate.fetch({
  spaceId: 'icafe-api'
  username: '',
  password: '',
  issues: [
    {
      title: 'test', //主题
      detail: '我是新建的卡片<p>另起一段换行<br></p>', //内容
      type: 'Bug', //类型
      parent: 40, //上级卡片序号,成为父卡片的子卡片
      fields: {
        负责人: 'wudanping,guoxu07', //中文名或邮箱名
        流程状态: '新建', //流程状态名
        属性名: '属性值', //属性名对应属性值
        估算工时: '0.1' //(举例属性名对应属性值 )
      },
      notifyEmails: ['[email protected]', 'lihang11@baidu,com'], //要通知的邮件地址
      creator: '创建人的邮箱前缀,如不传则是当前api用户',
      comment: '评论' //需给卡片添加的评论内容
    },
    {
      title: '主题',
      detail: '内容',
      type: '类型',
      parent: 上级卡片序号,
      fields: {
        负责人: '中文名或邮箱名',
        流程状态: '流程状态名',
        属性名: '属性值'
      },
      notifyEmails: ['要通知的邮件地址', '要通知的邮件地址'],
      creator: '创建人的邮箱前缀,如不传则是当前api用户',
      comment: '评论'
    }
  ]
}).end((err, res) => {
  // res.body
})

BatchCreate.fetch(/* ... */)
  .then(res => {
    // res.body
  })

如何设置用户名、密码等默认参数

设置默认值在 环境变量 中或读取 git config username 或 package.json icafe 字段 (优先级逐渐升高) 中, 其中 icafe 用户名和密码, 在 http://icafe.baidu.com/users/virtual 中查看.

注意: 上述网站中的密码不能直接使用,需要经过 decodeURIComponent('password') 后, 才能赋值使用

如:

{
  "icafe": {
    "spaceId": "icafe-api",
    "username": "yucong02",
    "password": "..."
  }
}
{
  username: process.env.ICAFE_USERNAME,
  password: process.env.ICAFE_PASSWORD,
  spaceId: process.env.ICAFE_SPACE_ID
  ...fromPkg
}

或者直接修改

import { FetchAble } from 'icafe-api'

// 注意!这种方式会影响其他地方的 defaultData
FetchAble.defaultData = {
  // ...
}

因此,推荐创建独立环境来覆写 default Data

import { create } from 'icafe-api'

const { BatchCreate } = create({
  data: {
    //...
  }
})

BatchCreate.fetch() // ....

timeout

两种方式进行设置

  • 每个分别设置
BatchCreate.fetch(
  {
    // ...
    issues: []
  },
  {
    // mill second (default: 10000)
    timeout: 10000
  }
)
  • 全局设置
FetchAble.defaultOptions = {
  timeout: 10000
}

API

create

创建独立环境

Parameters

Returns {FetchAble: Function, BatchCreate: FetchAble, Card: FetchAble, CardUpdate: FetchAble, Comment: FetchAble, History: FetchAble, Plan: FetchAble, PlanCreate: FetchAble, Plans: FetchAble, PlanUpdateDate: FetchAble, ProcessStatus: FetchAble}

FetchAbleOptions

Type: {}

Parameters

  • data {object} (optional, default {})
  • context {string} (optional, default 'http://icafe.baidu.com/api')
  • options {object} (optional, default {})

BatchCreate

批量新建卡片

Examples

BatchCreate.fetch({ spaceId: 'icafe-api', username: 'abc', password: 'abc' })

Card

卡片相关 注意!链接中的 u 对应 username, pw 对应 password

Examples

Card.fetch({ spaceId: 'icafe-api', sequence: null, username: '', password: '' })

CardUpdate

修改单张卡片 注意!链接中的 u 对应 username, pw 对应 password

Examples

CardUpdate.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc',
  sequence: '106',
  fields: ['所属计划=12345', '估时=1']
})

Comment

获取卡片评论

Examples

Comment.fetch({ spaceId: 'icafe-api', username: 'abc', password: 'abc', sequence: '106' })

History

查询 Issue(卡片)历史

Examples

History.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc',
  sequences: ['106']
})

Plan

查询单个计划

Examples

Plan.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc'
  // ...
})

PlanCreate

新建单个计划

Examples

PlanCreate.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc'
  // ...
})

Plans

获取空间内所有计划

Examples

Plans.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc'
})

PlanUpdateDate

编辑计划的时间

Examples

PlanUpdateDate.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc',
  planBoxId: 'xx'
  // ...
})

ProcessStatus

查询 Issue(卡片)流程状态

Examples

ProcessStatus.fetch({
  spaceId: 'icafe-api',
  username: 'abc',
  password: 'abc',
  sequence: '106'
})

Development

Swagger

use test2doc for generating swagger after test.

npm test
http-server .
# visit `swagger-ui.html`

Authors

This library is written and maintained by imcuttle, [email protected].

License

MIT