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 🙏

© 2026 – Pkg Stats / Ryan Hefner

deepflow-sdk-js

v0.0.13

Published

Yunshan Querier JS SDK

Readme

deepflow-sdk-js

用于提供 deepflow querier 的 js sdk, 构造用于请求 querier 的 sql

API

由于向 querier 查询可用字段、待选项等会非常频繁,因此可能需要 API 支持 cancel 的能力。由于 querier.js 用于给不同项目使用,因此内置了一个 api 能力,但每个项目应根据自己情况,使用自己的 api 接口

使用外部 api:

import { setCreateReqFunc } from 'deepflow-sdk-js'
import dfApiCreator from 'my-api-creator'

setCreateReqFunc(dfApiCreator)

注意,setCreateReqFunc 接受的是一个函数,该函数的参数为:

  • method
  • url
  • params
  • headers 返回值为一个函数,执行该函数即发起查询。 返回的函数可以提供一个 cancel 方法,用于 cancel 该请求
let func = createCancelAbleFunc(url, method, params, headers)
func() //实际发起请求
func.cancel() //cancel该请求

绑定后端 querier 地址

import { setQuerierBaseUrl } from 'deepflow-sdk-js'
setQuerierBaseUrl('http://deepflow-querier:8080')

使用 dfQuery 来构造一个完整的搜索 sql

TODO

querier feature

  1. 查询到的 tag 结构,在 deepflow-sdk-js 内部会将resource类型的字段补上${resource}_id的字段,用于后续的转换
  2. 对 resource 类型的 select,自动添加对应的${resource}_id的 select,如 select vm 会变成 select vm, vm_id, groupBy 也同样会拼接
  3. 对于 resource 类型的 where 条件,当是 =, !=, IN, NOT IN 时,会自动转换为 resource_id
  4. 会将 groupBy 中第一个资源类型的分组条件,附加上 node_type(${resource})icon_id(${resource})的 select 内容,服务端和客户端会单独计算
  5. groupBy 的字段会自动加入到 select 中(groupBy 会自动检查字段是否在最终的 select 中)(group by enum 类型的会自动加上 enum(tag), bit_enum 除外)
  6. groupBy/orderBy 会自动查找 select 中是否有用过且有 as 的项,有的话直接复用 as 后的名称, 若存在多个匹配项, 使用第一个 有 as 的
  7. 有 groupBy 情况下,会检查 orderBy 中所有项,要求在 select 中出现。
  8. 没有 groupBy 情况下,having 条件应拼到 where 中。(6.3.5 后废弃)
  9. external 类型资源组,会额外增加:将其他所有资源组中资源类型的条件取反 not 资源组A中的资源查询条件 and not B and not C,...))
  10. metric function 使用 类 percentile 时, 参数 百分比 转为 小数
  11. 当参数里有any 时,资源类型 key 会转换为resource_id=0resource_id!=0,注意只有资源类型支持any,且需要是正向或者反向 op
  12. 当参数里有__disabled 时,会忽略该条件
  13. resource 类型的资源集会自动加上 is_internet=false,该条件在另一端为 internet 时失效。同时,资源外取反也不对该条件取反。
  14. 当 metric (如 byte > 100, sum(byte)> 100)在条件中出现时,如果是裸的 metric 条件,那么会拼接到 where 里。如果是聚合的 metric 条件,那么会拼接到 having 里
  15. 资源集在设置 uid 时,下发的 QUERY_ID 会按照 uid 进行下发