Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@qn-pandora/app-sdk

Package Overview
Dependencies
Maintainers
2
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qn-pandora/app-sdk

Pandora APP 核心渲染逻辑 SDK

  • 1.2.11-alpha.0
  • canary
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-73.91%
Maintainers
2
Weekly downloads
 
Created
Source

@qn-pandora/app-sdk

Manager

SearchManager

对 Pandora 平台搜索相关 API 进行封装

使用姿势
  • 创建 SearchManager 传递参数
import { SearchManager } from '@qn-pandora/app-sdk'

const searchCondition = {
  queryString: 'repo="testjwzfr"',
  time: {
    start: 0,
    end: 1589770122581,
  },
}
const option = {
  task: {
    event: true,
    summary: true,
    timeline: true,
    result: true,
  },
}
const searchManager = new SearchManager({
  searchCondition: searchCondition,
  option: option,
})
searchManager.on('done', (data) => {
  console.log('data', data)
})
searchManager.search()
  • 调用 search 方法时传递参数
import { SearchManager } from '@qn-pandora/app-sdk'

const searchCondition = {
  queryString: 'repo="testjwzfr"',
  time: {
    start: 0,
    end: 1589770122581,
  },
}
const option = {
  task: {
    event: true,
    summary: true,
    timeline: true,
    result: true,
  },
}
const searchManager = new SearchManager({
  option: option,
})
searchManager.on('done', (data) => {
  console.log('data', data)
})
searchManager.search(searchCondition)
  • 通过 jobId 获取数据
import { SearchManager } from '@qn-pandora/app-sdk'

const searchCondition = {
  queryString: 'repo="testjwzfr"',
  time: {
    start: 0,
    end: 1589770122581,
  },
}
const option = {
  task: {
    event: true,
    summary: true,
    timeline: true,
    result: true,
  },
}
const searchManager = new SearchManager({
  option: option,
})
const jobId = await searchManager.search(searchCondition)
searchManager.on('done', (data) => {
  const event = searchMangeer.getEvent(jobId)
  console.log('event', event)
})
参数介绍
  • searchCondition
  1. queryString: 搜索条件
  2. time: 搜索时间范围
    • start 搜索开始时间,时间戳
    • end 搜索结束时间,时间戳
  3. preview: 可选,是否预览数据,默认值为 true
  4. mode: 可选,搜索模式 "fast" | "smart" | "detailed", 默认值为"smart"
  • option
    • task,任务选项,根据需要开启特定任务进行计算
      1. event: 事件信息
      2. timeline: 时间柱
      3. summary: 字段汇总统计
      4. result: 聚合计算结果
方法
  • search() 开启搜索任务,参数为 searchCondition,是可选项,不填则使用创建 searchManager 时的 searchCondition。该函数是个 Promise 函数,返回创建好任务的 jobId。
  • getEvent(jobId) 获取事件信息结果
  • getTimeline(jobId) 获取时间柱结果
  • getSummary(jobId) 获取字段汇总统计结果
  • getResult(jobID) 获取聚合计算结果
  • stop() 停止当前任务
事件

可通过 on 函数注册监听事件回调函数

  • data 每一次轮训数据结束触发,当开启 preview 时,可获取到中间结果
  • done 轮训结束后触发,当搜索结果全部返回后触发回调,可直接在回调函数中获取完整搜索结果
  • error 轮训发生错误时触发,可获取到错误信息

LoginManager

对 Pandora 平台登录相关 API 进行封装

使用姿势
  • pandora 登录
import { LoginManager, ELoginType } from '@qn-pandora/app-sdk'

const loginManager = new LoginManager(ELoginType.PANDORA)
loginManager.login({
  username: 'admin',
  password: 'admin',
})
  • SSO 登录
import { LoginManager, ELoginType } from '@qn-pandora/app-sdk'

const loginManager = new LoginManager(ELoginType.SSO)
loginManager.login({
  token:
    'MjNGNDEweHdnQ2pOWVpuNFpINkkzUVJQZ0I0MnBab2RNTGt6UGcya0h0aUFpVVNGOjcxNzdmNjRhN2RmZDdjN2UxMGQ1MmRiNmQxYmZkNGU0NjJlNzU3NDdhNjU1NGMyNzJlMzMwODgyNzFiY2IzODMyZGJiZTA1YTM4OWI3NDIyOTgxODkwZGYzYjMxYWI2NTk2OTY0MmI1NDZjMjMxZDRiZjNlZGE3YWMyYjc4MzFj',
})
支持方法

方法返回都为 Promise

  • login 登录
  • logout 登出
  • getUserInfo 获取用户信息

FAQs

Package last updated on 22 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc