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

bx24-api

v1.4.1

Published

Interface for using official Bitrix JavaScript library

Downloads

34

Readme

bx24-api

This library is an improved interface for working with the official Bitrix JavaScript library.

The library cannot be used for external applications and webhooks.

Advantage:

  • [x] Promise is used instead of callback in functions.
  • [x] Auto loading and initialize the official Bitrix library when calling any function.

Это библиотека представляет собой улучшений интерфейс для работы с официальной JavaScript библитекой Bitrix.

Для внешних приложений и вебхуков библиотека использоваться не может.

Плюсы:

  • [x] Использование Promise вместо callback в функциях.
  • [x] Автоматическая загрузка и инициализация официальной библиотеки Bitrix при вызове любой функции

Installation / Установка

npm install bx24-api

Use / Использование

import BX24 from 'bx24-api'

let leads = [];
BX24.callMethod('crm.lead.get').then(data => {
    leads = data.answer.result
})

You don't need to call init() before using any functions, because init() is always called at the beginning of these functions, except install()

All function from official library duplicate for this library interface.


Вам не нужно постоянно вызывать функцию init() перед использованием любой функции, так как init() вызывается автоматически при вызове функции, исключение функция install().

Все функции официальной библиотеки дублированы под интерфейс данной библиотеки.

Additions / Дополнения

Request next data chunk / Запрос следующей страницы данных

ajaxResult.next() will return Promise like callMethod


ajaxResult.next() будет возращать Promise, как callMethod

let lastCall = null
let users = []
callMethod('user.get').then(result => {
  lastCall = result.more()? result: null
  users.push(...result.data())
})

function nextPage() {
  if(lastCall) {
    lastCall.next().then(result => {
      lastCall = result.more()? result: null
      users.push(...result.data())
    })
  }
}

Import Large Data Batches / Выгрузка больших объемов данных

Additional function callMethodAll(method, params) is designed to import large amounts of data. Based on advice in the documentation.

Supports only methods for calling the list of entities that have an ID parameter in their structure and support query parameters: filter, order and select


Дополнительная функция callMethodAll(method, params) разработана для загрузки больших объемов данных. Основана на примере с документации.

Поддерживает только методы вызова списка сущностей которые имеют в своей структуре параметр ID и поддерживают параметры запроса: filter, order, select

BX24.callMethodAll('crm.lead.get').then(result => {
  // ...
})

Throw exception mode / Режим генерации ошибок

By default, if the functions callMethod, callBatch, callBind and callUnBind response returns with errors, then an error will be thrown.

You can turn off throw errors BX24.throwOn(false).


По дефолду если запросы функций callMethod, callBatch, callBind and callUnBind возвращают ответ с ошибкой будет вызываться throw.

Вы можете выключить вызов ошибки BX24.throwOn(false).

// When throw on
BX24.callMethod('crm.lead.get').then(result => {
    leads = result.data()
}).catch(error => {
    // ...
})