@bitrix24/b24jssdk
Version:
Bitrix24 REST API JS SDK
1,815 lines (1,785 loc) • 106 kB
text/typescript
import { DateTimeOptions, DateTime } from 'luxon';
declare enum LoggerType {
desktop = "desktop",
log = "log",
info = "info",
warn = "warn",
error = "error",
trace = "trace"
}
declare class LoggerBrowser {
#private;
static build(title: string, isDevelopment?: boolean): LoggerBrowser;
private constructor();
setConfig(types: Record<string | LoggerType, boolean>): void;
enable(type: LoggerType): boolean;
disable(type: LoggerType): boolean;
isEnabled(type: LoggerType): boolean;
desktop(...params: any[]): void;
log(...params: any[]): void;
info(...params: any[]): void;
warn(...params: any[]): void;
error(...params: any[]): void;
trace(...params: any[]): void;
}
/**
* String which is actually a number, like `'20.23'`
*/
type NumberString = string;
/**
* Like `'2018-06-07T03:00:00+03:00'`
*/
type ISODate = string;
type BoolString = 'Y' | 'N';
type GenderString = 'M' | 'F' | '';
type PlacementViewMode = 'view' | 'edit';
type TextType = 'text' | 'html';
type Fields = {
readonly [key: string]: {
readonly type: string;
readonly isRequired: boolean;
readonly isReadOnly: boolean;
readonly isImmutable: boolean;
readonly isMultiple: boolean;
readonly isDynamic: boolean;
readonly title: string;
readonly upperName?: string;
};
};
type MultiField = {
readonly ID: NumberString;
readonly VALUE_TYPE: string;
readonly VALUE: string;
readonly TYPE_ID: string;
};
type MultiFieldArray = ReadonlyArray<Pick<MultiField, 'VALUE' | 'VALUE_TYPE'>>;
/**
* Describes the inline settings in UF
*/
type UserFieldType = {
USER_TYPE_ID: string;
HANDLER: string;
TITLE: string;
DESCRIPTION: string;
OPTIONS?: {
height: number;
};
};
/**
* Data types
* @link https://apidocs.bitrix24.ru/api-reference/data-types.html
* @link https://dev.1c-bitrix.ru/rest_help/crm/dynamic/methodscrmitem/crm_item_fields.php
*/
declare enum DataType {
undefined = "undefined",
any = "any",
integer = "integer",
boolean = "boolean",
double = "double",
date = "date",
datetime = "datetime",
string = "string",
text = "text",
file = "file",
array = "array",
object = "object",
user = "user",
location = "location",
crmCategory = "crm_category",
crmStatus = "crm_status",
crmCurrency = "crm_currency"
}
interface BlobLike {
readonly size: number;
readonly type: string;
slice(start?: number, end?: number, contentType?: string): Blob;
}
interface FileLike extends BlobLike {
name: string;
lastModified?: number;
lastModifiedDate?: object;
}
/**
* The `Type` class is designed to check and determine data types
*
* @see bitrix/js/main/core/src/lib/type.js
*/
declare class TypeManager {
getTag(value: any): string;
/**
* Checks that value is string
* @param value
* @return {boolean}
*
* @memo get from pull.client.Utils
*/
isString(value: any): value is string;
/**
* Returns true if a value is not an empty string
* @param value
* @returns {boolean}
*/
isStringFilled(value: any): value is string;
/**
* Checks that value is function
* @param value
* @return {boolean}
*
* @memo get from pull.client.Utils
*/
isFunction(value: any): value is Function;
/**
* Checks that value is an object
* @param value
* @return {boolean}
*/
isObject(value: any): value is object | Function;
/**
* Checks that value is object like
* @param value
* @return {boolean}
*/
isObjectLike<T>(value: any): value is T;
/**
* Checks that value is plain object
* @param value
* @return {boolean}
*/
isPlainObject(value: any): value is Record<string | number, any>;
isJsonRpcRequest(value: any): boolean;
isJsonRpcResponse(value: any): boolean;
/**
* Checks that value is boolean
* @param value
* @return {boolean}
*/
isBoolean(value: any): value is boolean;
/**
* Checks that value is number
* @param value
* @return {boolean}
*/
isNumber(value: any): value is number;
/**
* Checks that value is integer
* @param value
* @return {boolean}
*/
isInteger(value: any): value is number;
/**
* Checks that value is float
* @param value
* @return {boolean}
*/
isFloat(value: any): value is number;
/**
* Checks that value is nil
* @param value
* @return {boolean}
*/
isNil(value: any): value is null | undefined;
/**
* Checks that value is an array
* @param value
* @return {boolean}
*/
isArray(value: any): value is any[];
/**
* Returns true if a value is an array, and it has at least one element
* @param value
* @returns {boolean}
*/
isArrayFilled(value: any): value is any[];
/**
* Checks that value is array like
* @param value
* @return {boolean}
*/
isArrayLike(value: any): value is ArrayLike<any>;
/**
* Checks that value is Date
* @param value
* @return {boolean}
*/
isDate(value: any): value is Date;
/**
* Checks that is a DOM node
* @param value
* @return {boolean}
*/
isDomNode(value: any): value is Node;
/**
* Checks that value is element node
* @param value
* @return {boolean}
*/
isElementNode(value: any): value is HTMLElement;
/**
* Checks that value is a text node
* @param value
* @return {boolean}
*/
isTextNode(value: any): value is Text;
/**
* Checks that value is Map
* @param value
* @return {boolean}
*/
isMap(value: any): value is Map<unknown, unknown>;
/**
* Checks that value is Set
* @param value
* @return {boolean}
*/
isSet(value: any): value is Set<unknown>;
/**
* Checks that value is WeakMap
* @param value
* @return {boolean}
*/
isWeakMap(value: any): value is WeakMap<object, unknown>;
/**
* Checks that value is WeakSet
* @param value
* @return {boolean}
*/
isWeakSet(value: any): value is WeakSet<object>;
/**
* Checks that value is prototype
* @param value
* @return {boolean}
*/
isPrototype(value: any): value is object;
/**
* Checks that value is regexp
* @param value
* @return {boolean}
*/
isRegExp(value: any): value is RegExp;
/**
* Checks that value is null
* @param value
* @return {boolean}
*/
isNull(value: any): value is null;
/**
* Checks that value is undefined
* @param value
* @return {boolean}
*/
isUndefined(value: any): value is undefined;
/**
* Checks that value is ArrayBuffer
* @param value
* @return {boolean}
*/
isArrayBuffer(value: any): value is ArrayBuffer;
/**
* Checks that value is typed array
* @param value
* @return {boolean}
*/
isTypedArray(value: any): value is Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
/**
* Checks that value is Blob
* @param value
* @return {boolean}
*/
isBlob(value: any): value is BlobLike;
/**
* Checks that value is File
* @param value
* @return {boolean}
*/
isFile(value: any): value is FileLike;
/**
* Checks that value is FormData
* @param value
* @return {boolean}
*/
isFormData(value: any): value is FormData;
clone(obj: any, bCopyObj?: boolean): any;
}
declare const Type: TypeManager;
/**
* @todo add docs
*/
declare function pick<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Pick<Data, Keys>;
/**
* @todo add docs
*/
declare function omit<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Omit<Data, Keys>;
/**
* @todo add docs
*/
declare function isArrayOfArray<A>(item: A[] | A[][]): item is A[][];
/**
* @todo add docs
*
* @example
* const result = getEnumValue(EnumBizprocDocumentType, 'CCrmDocumentSmartOrder')
*/
declare function getEnumValue<T extends Record<string, string | number>>(enumObj: T, value: string | number): T[keyof T] | undefined;
/**
* The `Text` class provides a set of utility methods for working with text data.
* It includes functions for encoding and decoding HTML entities, generating random strings,
* converting values to different data types, and changing the case and format of strings
*
* @see bitrix/js/main/core/src/lib/text.js
*/
declare class TextManager {
getRandom(length?: number): string;
/**
* Generates UUID
*/
getUniqId(): string;
/**
* Generate uuid v7
* @return {string}
*/
getUuidRfc4122(): string;
/**
* Encodes all unsafe entities
* @param {string} value
* @return {string}
*/
encode(value: string): string;
/**
* Decodes all encoded entities
* @param {string} value
* @return {string}
*/
decode(value: string): string;
toNumber(value: any): number;
toInteger(value: any): number;
toBoolean(value: any, trueValues?: string[]): boolean;
toCamelCase(str: string): string;
toPascalCase(str: string): string;
toKebabCase(str: string): string;
capitalize(str: string): string;
numberFormat(number: number, decimals?: number, decPoint?: string, thousandsSep?: string): string;
/**
* Convert string to DateTime from ISO 8601 or self template
*
* @param {string} dateString
* @param {string} template
* @param opts
* @returns {DateTime}
*
* @link https://moment.github.io/luxon/#/parsing?id=parsing-technical-formats
*/
toDateTime(dateString: string, template?: string, opts?: DateTimeOptions): DateTime;
getDateForLog(): string;
buildQueryString(params: any): string;
}
declare const Text$1: TextManager;
/**
* @see bitrix/js/main/core/src/lib/browser.js
*/
declare class BrowserManager {
isOpera(): boolean;
isIE(): boolean;
isIE6(): boolean;
isIE7(): boolean;
isIE8(): boolean;
isIE9(): boolean;
isIE10(): boolean;
isSafari(): boolean;
isFirefox(): boolean;
isChrome(): boolean;
detectIEVersion(): number;
isIE11(): boolean;
isMac(): boolean;
isWin(): boolean;
isLinux(): boolean;
isAndroid(): boolean;
isIPad(): boolean;
isIPhone(): boolean;
isIOS(): boolean;
isMobile(): boolean;
isRetina(): boolean;
isTouchDevice(): boolean;
isDoctype(target: any): boolean;
isLocalStorageSupported(): boolean;
detectAndroidVersion(): number;
}
declare const Browser: BrowserManager;
/**
* Interface defining the structure and methods of a Result object.
*/
interface IResult<T = any> {
/**
* Indicates whether the operation resulted in success (no errors).
*/
readonly isSuccess: boolean;
/**
* Collection of errors
*/
readonly errors: Map<string, Error>;
/**
* Sets the data associated with the result.
*
* @param data The data to be stored in the result.
* @returns The current Result object for chaining methods.
*/
setData: (data: T) => IResult<T>;
/**
* Retrieves the data associated with the result.
*
* @returns The data stored in the result, if any.
*/
getData: () => T | null;
/**
* Adds an error message or Error object to the result.
* @param error The error message or Error object to be added.
* @param key Error key. You can leave it blank. Then it will be generated automatically.
* @returns {IResult} The current Result object for chaining methods.
*/
addError: (error: Error | string, key?: string) => IResult;
/**
* Adds multiple errors to the result in a single call.
*
* @param errors An array of errors or strings that will be converted to errors.
* @returns {IResult} The current Result object for chaining methods.
*/
addErrors: (errors: (Error | string)[]) => IResult;
/**
* Retrieves an iterator for the errors collected in the result.
*
* @returns {IterableIterator<Error>} An iterator over the stored Error objects.
*/
getErrors: () => IterableIterator<Error>;
/**
* Retrieves an array of error messages from the collected errors.
*
* @returns {string[]} An array of strings representing the error messages.
*/
getErrorMessages: () => string[];
/**
* Checks for an error in a collection by key
* @param key - Error key
*/
hasError(key: string): boolean;
/**
* Converts the Result object to a string.
*
* @returns {string} Returns a string representation of the result operation
*/
toString: () => string;
}
/**
* A class representing an operation result with success/failure status, data, and errors.
* Similar to \Bitrix\Main\Result from Bitrix Framework.
* @link https://dev.1c-bitrix.ru/api_d7/bitrix/main/result/index.php
*/
declare class Result<T = any> implements IResult<T> {
protected _errors: Map<string, Error>;
protected _data: T | null;
constructor(data?: T);
get isSuccess(): boolean;
get errors(): Map<string, Error>;
setData(data: T | null): Result<T>;
getData(): T | null;
addError(error: Error | string, key?: string): Result<T>;
addErrors(errors: (Error | string)[]): Result<T>;
getErrors(): IterableIterator<Error>;
hasError(key: string): boolean;
/**
* Retrieves an array of error messages from the collected errors.
*
* @returns An array of strings representing the error messages. Each string
* contains the message of a corresponding error object.
*/
getErrorMessages(): string[];
/**
* Converts the Result object to a string.
*
* @returns {string} Returns a string representation of the result operation
*/
toString(): string;
private safeStringify;
private replacer;
static ok<U>(data?: U): Result<U>;
static fail<U>(error: Error | string, key?: string): Result<U>;
}
type PayloadTime = {
readonly start: number;
readonly finish: number;
readonly duration: number;
readonly processing: number;
readonly date_start: string;
readonly date_finish: string;
};
type GetPayload<P> = {
readonly result: P;
readonly time: PayloadTime;
};
type ListPayload<P> = {
readonly result: any | P[];
readonly error?: string;
readonly total: number;
readonly next?: number;
readonly time: PayloadTime;
};
type BatchPayload<C> = {
readonly result: {
readonly result: {
readonly [P in keyof C]?: C[P];
} | ReadonlyArray<C[keyof C]>;
readonly result_error: {
readonly [P in keyof C]?: string;
} | readonly string[];
readonly result_total: {
readonly [P in keyof C]?: number;
} | readonly number[];
readonly result_next: {
readonly [P in keyof C]?: number;
} | readonly number[];
readonly result_time: {
readonly [P in keyof C]?: PayloadTime;
} | readonly PayloadTime[];
};
readonly time: PayloadTime;
};
type Payload<P> = GetPayload<P> | ListPayload<P> | BatchPayload<P>;
type AjaxQuery = Readonly<{
method: string;
params: Readonly<object>;
start: number;
}>;
type AjaxResultParams<T = unknown> = Readonly<{
error?: string | {
error: string;
error_description?: string;
};
error_description?: string;
result: T;
next?: NumberString;
total?: NumberString;
time: PayloadTime;
}>;
type AjaxResultOptions<T> = Readonly<{
answer: AjaxResultParams<T>;
query: AjaxQuery;
status: number;
}>;
/**
* Result of request to Rest Api
*/
declare class AjaxResult<T = unknown> extends Result<Payload<T>> implements IResult<Payload<T>> {
#private;
private readonly _status;
private readonly _query;
protected _data: AjaxResultParams<T>;
constructor(options: AjaxResultOptions<T>);
getData(): Payload<T>;
/**
* Alias for isMore
*/
hasMore(): boolean;
isMore(): boolean;
getTotal(): number;
getStatus(): number;
getQuery(): Readonly<AjaxQuery>;
/**
* Alias for getNext
* @param http
*/
fetchNext(http: TypeHttp): Promise<AjaxResult<T> | null>;
getNext(http: TypeHttp): Promise<AjaxResult<T> | false>;
setData(): never;
}
type TypeHttp = {
setLogger(logger: LoggerBrowser): void;
getLogger(): LoggerBrowser;
batch(calls: any[] | object, isHaltOnError: boolean, returnAjaxResult: boolean): Promise<Result>;
call(method: string, params: object, start: number): Promise<AjaxResult>;
setRestrictionManagerParams(params: TypeRestrictionManagerParams): void;
getRestrictionManagerParams(): TypeRestrictionManagerParams;
setLogTag(logTag?: string): void;
clearLogTag(): void;
/**
* On|Off warning about client-side query execution
* @param {boolean} value
* @param {string} message
*/
setClientSideWarning(value: boolean, message: string): void;
};
interface IRequestIdGenerator {
getRequestId(): string;
getHeaderFieldName(): string;
getQueryStringParameterName(): string;
getQueryStringSdkParameterName(): string;
}
type TypeRestrictionManagerParams = {
sleep: number;
speed: number;
amount: number;
};
declare const RestrictionManagerParamsBase: TypeRestrictionManagerParams;
/**
* @todo Need test
*/
declare const RestrictionManagerParamsForEnterprise: TypeRestrictionManagerParams;
/**
* Special cases of data passed to handlers
* @todo add docs
*/
interface HandlerAuthParams {
access_token: string;
expires: string;
expires_in: string;
scope: string;
domain: string;
server_endpoint: string;
status: string;
client_endpoint: string;
member_id: string;
user_id: string;
refresh_token: string;
application_token: string;
}
type PayloadOAuthToken = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'status' | 'user_id'>;
declare enum LoadDataType {
App = "app",
Profile = "profile",
Currency = "currency",
AppOptions = "appOptions",
UserOptions = "userOptions"
}
type TypeUser = {
readonly isAdmin: boolean;
readonly id: null | number;
readonly lastName: null | string;
readonly name: null | string;
readonly gender: GenderString;
readonly photo: null | string;
readonly TimeZone: null | string;
readonly TimeZoneOffset: null | number;
};
declare const EnumAppStatus: {
readonly Free: "F";
readonly Demo: "D";
readonly Trial: "T";
readonly Paid: "P";
readonly Local: "L";
readonly Subscription: "S";
};
declare const StatusDescriptions: Record<(typeof EnumAppStatus)[keyof typeof EnumAppStatus], string>;
type TypeEnumAppStatus = keyof typeof EnumAppStatus;
/**
* @link https://dev.1c-bitrix.ru/rest_help/general/app_info.php
*/
type TypeApp = {
/**
* Local application identifier on the portal
*/
readonly id: number;
/**
* application code
*/
readonly code: string;
/**
* installed version of the application
*/
readonly version: number;
/**
* application status
*/
readonly status: TypeEnumAppStatus;
/**
* application installed flag
*/
readonly isInstalled: boolean;
};
/**
* @link https://dev.1c-bitrix.ru/rest_help/general/app_info.php
*/
type TypePayment = {
/**
* flag indicating whether the paid period or trial period has expired
*/
readonly isExpired: boolean;
/**
* number of days remaining until the end of the paid period or trial period
*/
readonly days: number;
};
/**
* @link https://dev.1c-bitrix.ru/rest_help/general/app_info.php
*/
type TypeLicense = {
/**
* language code designation
*/
readonly languageId: null | string;
/**
* tariff designation with indication of the region as a prefix
*/
readonly license: null | string;
/**
* internal tariff designation without indication of region
*/
readonly licenseType: null | string;
/**
* past meaning of license
*/
readonly licensePrevious: null | string;
/**
* Tariff designation without specifying the region.
*/
readonly licenseFamily: null | string;
/**
* flag indicating whether it is a box (true) or a cloud (false)
*/
readonly isSelfHosted: boolean;
};
declare const TypeSpecificUrl: {
readonly MainSettings: "MainSettings";
readonly UfList: "UfList";
readonly UfPage: "UfPage";
};
type TypeB24Form = {
readonly app_code: string;
readonly app_status: string;
readonly payment_expired: BoolString;
readonly days: number;
/**
* B24 tariff plan identifier (if cloud)
*/
readonly b24_plan: string;
readonly c_name: string;
readonly c_last_name: string;
readonly hostname: string;
};
type CurrencyFormat = {
decimals: number;
decPoint: string;
formatString: string;
fullName: string;
isHideZero: boolean;
thousandsSep?: string;
thousandsVariant?: 'N' | 'D' | 'C' | 'S' | 'B' | 'OWN' | string;
};
type Currency = {
amount: number;
amountCnt: number;
isBase: boolean;
currencyCode: string;
dateUpdate: DateTime;
decimals: number;
decPoint: string;
formatString: string;
fullName: string;
lid: string;
sort: number;
thousandsSep?: string;
lang: Record<string, CurrencyFormat>;
};
declare enum TypeOption {
NotSet = "notSet",
JsonArray = "jsonArray",
JsonObject = "jsonObject",
FloatVal = "float",
IntegerVal = "integer",
BoolYN = "boolYN",
StringVal = "string"
}
type TypeDescriptionError = {
readonly error: 'invalid_token' | 'expired_token' | string;
readonly error_description: string;
};
/**
* Parameters for hook
*/
type B24HookParams = {
/**
* https://your-bitrix-portal.bitrix24.com
*/
b24Url: string;
userId: number;
secret: string;
};
/**
* Parameters passed in the GET request from the B24 parent window to the application
*/
type B24FrameQueryParams = {
DOMAIN: string | null | undefined;
PROTOCOL: boolean | null | undefined;
LANG: string | null | undefined;
APP_SID: string | null | undefined;
};
/**
* Parameters for application for OAuth
*/
type B24OAuthSecret = {
clientId: string;
clientSecret: string;
};
/**
* Parameters for OAuth
* @memo We get from b24 event this data
*/
interface B24OAuthParams {
/**
* @example '1xxxxx1694'
*/
applicationToken: string;
/**
* @example 1
*/
userId: number;
/**
* @example '3xx2030386cyy1b'
*/
memberId: string;
/**
* @example '1xxxxx1694'
*/
accessToken: string;
/**
* @example '0xxxx4e000011e700000001000000260dc83b47c40e9b5fd501093674c4f5'
*/
refreshToken: string;
/**
* @example 1745997853
*/
expires: number;
/**
* @example 3600
*/
expiresIn: number;
/**
* @example 'crm,catalog,bizproc,placement,user_brief'
*/
scope: string;
/**
* @example 'xxx.bitrix24.com'
*/
domain: string;
/**
* @example 'https://xxx.bitrix24.com/rest/'
*/
clientEndpoint: string;
/**
* @example 'https://oauth.bitrix.info/rest/'
*/
serverEndpoint: string;
/**
* @example 'L'
*/
status: typeof EnumAppStatus[keyof typeof EnumAppStatus];
issuer?: 'request' | 'store' | string;
}
type HandlerRefreshAuth = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'scope' | 'status' | 'domain'>;
/**
* Callback called when OAuth authorization is updated
*/
type CallbackRefreshAuth = (params: {
authData: AuthData;
b24OAuthParams: B24OAuthParams;
}) => Promise<void>;
/**
* Use for custom get new refresh token for OAuth
*/
type CustomRefreshAuth = () => Promise<HandlerRefreshAuth>;
/**
* Parameters passed from the parent window when calling refreshAuth
*/
type RefreshAuthData = {
AUTH_ID: string;
REFRESH_ID: string;
AUTH_EXPIRES: NumberString;
};
/**
* Parameters passed from the parent window when calling getInitData
*/
type MessageInitData = RefreshAuthData & {
DOMAIN: string;
PROTOCOL: string;
PATH: string;
LANG: string;
MEMBER_ID: string;
IS_ADMIN: boolean;
APP_OPTIONS: Record<string, any>;
USER_OPTIONS: Record<string, any>;
PLACEMENT: string;
PLACEMENT_OPTIONS: Record<string, any>;
INSTALL: boolean;
FIRST_RUN: boolean;
};
/**
* Parameters for OAuth authorization
*/
type AuthData = {
access_token: string;
refresh_token: string;
expires: number;
expires_in: number;
domain: string;
member_id: string;
};
/**
* Interface for updating authorization
*/
interface AuthActions {
getAuthData: () => false | AuthData;
refreshAuth: () => Promise<AuthData>;
getUniq: (prefix: string) => string;
isAdmin: boolean;
}
type TypeB24 = {
/**
* @link https://apidocs.bitrix24.com/api-reference/bx24-js-sdk/system-functions/bx24-init.html
*/
readonly isInit: boolean;
init(): Promise<void>;
destroy(): void;
getLogger(): LoggerBrowser;
setLogger(logger: LoggerBrowser): void;
get auth(): AuthActions;
/**
* Get the account address BX24 ( https://name.bitrix24.com )
*/
getTargetOrigin(): string;
/**
* Get the account address BX24 ( https://name.bitrix24.com/rest )
*/
getTargetOriginWithPath(): string;
/**
* Calls a REST service method with the specified parameters
*
* @param {string} method
* @param {object} params
* @param {number} start
*
* @return {Promise}
*
* @link https://apidocs.bitrix24.com/api-reference/bx24-js-sdk/how-to-call-rest-methods/bx24-call-method.html
*/
callMethod(method: string, params?: object, start?: number): Promise<AjaxResult>;
/**
* Calls a REST service list method with the specified parameters
*
* @param {string} method Query method
* @param {object} params Request parameters
* @param {null|((progress: number) => void)} progress Processing steps
* @param {string} customKeyForResult Custom field indicating that the result will be a grouping key
* @return {Promise}
*/
callListMethod(method: string, params?: object, progress?: null | ((progress: number) => void), customKeyForResult?: string | null): Promise<Result>;
/**
* Calls a REST service list method with the specified parameters and returns a generator object.
* Implements the fast algorithm described in {@see https://apidocs.bitrix24.com/api-reference/performance/huge-data.html}
*
* @param {string} method Query method
* @param {object} params Request parameters
* @param {string} idKey Entity ID field name ('ID' || 'id')
* @param {string} customKeyForResult Custom field indicating that the result will be a grouping key
*
* @return {AsyncGenerator} Generator
*/
fetchListMethod(method: string, params?: any, idKey?: string, customKeyForResult?: string | null): AsyncGenerator<any[]>;
/**
* Calls a batch request with a maximum number of commands of no more than 50
*
* @param {array|object} calls Request packet
* calls = [[method,params],[method,params]]
* calls = [{method:method,params:params},[method,params]]
* calls = {call_id:[method,params],...}
* @param {boolean} isHaltOnError Abort package execution when an error occurs
* @param {boolean} returnAjaxResult Return `Record<string | number, AjaxResult> | AjaxResult[]` in response
*
* @return {Promise} Promise
*
* @see https://apidocs.bitrix24.com/api-reference/bx24-js-sdk/how-to-call-rest-methods/bx24-call-batch.html
*/
callBatch(calls: Array<any> | object, isHaltOnError?: boolean, returnAjaxResult?: boolean): Promise<Result>;
/**
* Calls a batch request with any number of commands
*
* @param {array} calls Request packet
* calls = [[method,params],[method,params]]
* @param {boolean} isHaltOnError Abort package execution when an error occurs
*
* @return {Promise} Promise
*
* @see https://apidocs.bitrix24.com/api-reference/bx24-js-sdk/how-to-call-rest-methods/bx24-call-batch.html
*/
callBatchByChunk(calls: Array<any>, isHaltOnError: boolean): Promise<Result>;
/**
* Returns Http client for requests
*/
getHttpClient(): TypeHttp;
};
/**
* User fields for scope:user_brief
* @link https://dev.1c-bitrix.ru/rest_help/users/index.php
*/
type UserBrief = {
readonly [key: string]: string | boolean | null | readonly number[];
readonly ID: NumberString;
readonly XML_ID: string | null;
readonly ACTIVE: boolean;
readonly NAME: string | null;
readonly LAST_NAME: string | null;
readonly SECOND_NAME: string | null;
readonly TITLE: string | null;
readonly IS_ONLINE: BoolString;
readonly TIME_ZONE: string | null;
readonly TIME_ZONE_OFFSET: NumberString | null;
readonly TIMESTAMP_X: string;
readonly DATE_REGISTER: ISODate;
readonly PERSONAL_PROFESSION: string | null;
readonly PERSONAL_GENDER: GenderString;
readonly PERSONAL_BIRTHDAY: string | null;
readonly PERSONAL_PHOTO: string | null;
readonly PERSONAL_CITY: string | null;
readonly PERSONAL_STATE: string | null;
readonly PERSONAL_COUNTRY: string | null;
readonly WORK_POSITION: string | null;
readonly WORK_CITY: string | null;
readonly WORK_STATE: string | null;
readonly WORK_COUNTRY: string | null;
readonly LAST_ACTIVITY_DATE: string;
readonly UF_EMPLOYMENT_DATE: ISODate | string;
readonly UF_TIMEMAN: string | null;
readonly UF_SKILLS: string | null;
readonly UF_INTERESTS: string | null;
readonly UF_DEPARTMENT: readonly number[];
readonly UF_PHONE_INNER: NumberString | null;
};
/**
* User fields for scope:user_basic
*/
type UserBasic = UserBrief & {
readonly EMAIL: string | null;
readonly PERSONAL_WWW: string | null;
readonly PERSONAL_ICQ: string | null;
readonly PERSONAL_PHONE: string | null;
readonly PERSONAL_FAX: string | null;
readonly PERSONAL_MOBILE: string | null;
readonly PERSONAL_PAGER: string | null;
readonly PERSONAL_STREET: string | null;
readonly PERSONAL_ZIP: string | null;
readonly WORK_COMPANY: string | null;
readonly WORK_PHONE: string | null;
readonly UF_SKILLS: string | null;
readonly UF_WEB_SITES: string | null;
readonly UF_XING: string | null;
readonly UF_LINKEDIN: string | null;
readonly UF_FACEBOOK: string | null;
readonly UF_TWITTER: string | null;
readonly UF_SKYPE: string | null;
readonly UF_DISTRICT: string | null;
readonly USER_TYPE: 'employee';
};
type StatusClose = {
isOpenAtNewWindow: boolean;
isClose: boolean;
};
/**
* CRM Entity Types
* @link https://dev.1c-bitrix.ru/rest_help/crm/constants.php
*/
declare enum EnumCrmEntityType {
undefined = "UNDEFINED",
lead = "CRM_LEAD",
deal = "CRM_DEAL",
contact = "CRM_CONTACT",
company = "CRM_COMPANY",
oldInvoice = "CRM_INVOICE",
invoice = "CRM_SMART_INVOICE",
quote = "CRM_QUOTE",
requisite = "CRM_REQUISITE",
order = "ORDER"
}
declare enum EnumCrmEntityTypeId {
undefined = 0,
lead = 1,
deal = 2,
contact = 3,
company = 4,
oldInvoice = 5,
invoice = 31,
quote = 7,
requisite = 8,
order = 14
}
declare enum EnumCrmEntityTypeShort {
undefined = "?",
lead = "L",
deal = "D",
contact = "C",
company = "CO",
oldInvoice = "I",
invoice = "SI",
quote = "Q",
requisite = "RQ",
order = "O"
}
/**
* @todo add docs
*/
declare function getEnumCrmEntityTypeShort(id: EnumCrmEntityTypeId): EnumCrmEntityTypeShort;
/**
* Data Types and Object Structure in the REST API Catalog
* @link https://apidocs.bitrix24.com/api-reference/catalog/data-types.html
*/
declare enum CatalogProductType {
undefined = 0,
product = 1,
service = 7,
sku = 3,
skuEmpty = 6,
offer = 4,
offerEmpty = 5
}
declare enum CatalogProductImageType {
undefined = "UNDEFINED",
detail = "DETAIL_PICTURE",
preview = "PREVIEW_PICTURE",
morePhoto = "MORE_PHOTO"
}
declare enum CatalogRoundingRuleType {
undefined = 0,
mathematical = 1,
roundingUp = 2,
roundingDown = 4
}
interface CatalogCatalog {
id: number;
iblockId: number;
iblockTypeId: string | 'CRM_PRODUCT_CATALOG';
lid: string;
name: string;
productIblockId?: number;
skuPropertyId?: number;
subscription?: BoolString;
vatId: number;
}
interface BaseProduct {
id: number;
iblockId: number;
sort: number;
name: string;
active: BoolString;
available: BoolString;
code: string;
xmlId: string;
barcodeMulti: BoolString;
bundle: BoolString;
canBuyZero?: BoolString;
type: number;
vatId: number;
vatIncluded: BoolString;
weight?: number;
height?: number;
length?: number;
width?: number;
createdBy: number;
modifiedBy: number;
dateActiveFrom?: ISODate;
dateActiveTo?: ISODate;
dateCreate: ISODate;
timestampX: ISODate;
iblockSectionId?: number;
measure?: number;
previewText?: string;
previewTextType?: TextType;
detailText?: string;
detailTextType?: TextType;
previewPicture?: object;
detailPicture?: object;
subscribe: 'Y' | 'N' | 'D';
quantityTrace: 'Y' | 'N' | 'D';
purchasingCurrency: string;
purchasingPrice: number;
quantity: number;
quantityReserved: number;
[key: string]: any;
}
interface CatalogProduct extends BaseProduct {
type: CatalogProductType.product;
}
interface CatalogProductSku extends BaseProduct {
type: CatalogProductType.sku | CatalogProductType.skuEmpty;
}
interface CatalogProductOffer extends BaseProduct {
type: CatalogProductType.offer | CatalogProductType.offerEmpty;
}
interface CatalogProductService extends Omit<BaseProduct, 'quantityReserved' | 'quantity' | 'purchasingPrice' | 'purchasingCurrency' | 'quantityTrace' | 'subscribe' | 'weight' | 'height' | 'length' | 'width' | 'canBuyZero' | 'barcodeMulti'> {
type: CatalogProductType.service;
}
interface CatalogSection {
id: number;
xmlId: string;
code: string;
iblockId: number;
sort: number;
iblockSectionId: number;
name: string;
active: BoolString;
description: string;
descriptionType: TextType;
}
interface CatalogProductImage {
id: number;
name: string;
productId: number;
type: typeof CatalogProductImageType[keyof typeof CatalogProductImageType];
createTime?: ISODate;
downloadUrl?: string;
detailUrl?: string;
}
interface CatalogStore {
id: number;
code: string;
xmlId: string;
sort: number;
address: string;
title: string;
active: BoolString;
description?: string;
gpsN: number;
gpsS: number;
imageId: object;
dateModify: ISODate;
dateCreate: ISODate;
userId: number;
modifiedBy: number;
phone: string;
email: string;
schedule: string;
issuingCenter: BoolString;
}
interface CatalogMeasure {
id: number;
code: string;
isDefault: BoolString;
measureTitle: string;
symbol: string;
symbolIntl: string;
symbolLetterIntl: string;
}
interface CatalogRatio {
id: number;
productId: number;
ratio: number;
isDefault: BoolString;
}
interface CatalogPriceType {
id: number;
xmlId: string;
sort: number;
name: string;
base: BoolString;
createdBy: number;
modifiedBy: number;
dateCreate: ISODate;
timestampX: ISODate;
}
interface CatalogVat {
id: number;
name: string;
active: BoolString;
rate: number;
sort: number;
timestampX: ISODate;
}
interface CatalogPriceTypeLang {
id: number;
catalogGroupId: number;
name: string;
lang: string;
}
interface CatalogLanguage {
lid: string;
name: string;
active: BoolString;
}
interface CatalogRoundingRule {
id: number;
catalogGroupId: number;
price: number;
roundType: typeof CatalogRoundingRuleType[keyof typeof CatalogRoundingRuleType];
roundPrecision: number;
createdBy: number;
modifiedBy: number;
dateCreate: ISODate;
dateModify: ISODate;
}
interface CatalogExtra {
id: number;
name: string;
percentage: number;
}
declare enum ProductRowDiscountTypeId {
undefined = 0,
absolute = 1,
percentage = 2
}
interface CrmItemProductRow {
id: number;
ownerId: number;
ownerType: typeof EnumCrmEntityTypeShort[keyof typeof EnumCrmEntityTypeShort];
productId: number;
productName: string;
sort: number;
price: number;
priceAccount: number;
priceExclusive: number;
priceNetto: number;
priceBrutto: number;
customized: BoolString;
quantity: number;
measureCode: string;
measureName: string;
taxRate: number | null;
taxIncluded: BoolString;
discountRate: number;
discountSum: number;
discountTypeId: typeof ProductRowDiscountTypeId[keyof typeof ProductRowDiscountTypeId];
xmlId: string;
type: typeof CatalogProductType[keyof typeof CatalogProductType];
storeId: number;
}
interface CrmItemDelivery {
id: number;
accountNumber: string;
deducted: BoolString;
dateDeducted?: ISODate;
deliveryId: number;
deliveryName: string;
priceDelivery: number;
}
interface CrmItemPayment {
id: number;
accountNumber: string;
paid: BoolString;
datePaid?: ISODate;
empPaidId?: number;
sum: number;
currency: string;
paySystemId: number;
paySystemName: string;
}
/**
* UF embedding properties interface
*
* @link https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=99&LESSON_ID=8633
*/
interface IPlacementUF {
/**
* UF ID
*/
FIELD_NAME: string;
/**
* The identifier of the entity to which the field is bound
*/
ENTITY_ID: EnumCrmEntityType;
/**
* The identifier of the entity element whose field value is being edited
*/
ENTITY_VALUE_ID: NumberString;
/**
* The mode in which the field is called
*/
MODE: PlacementViewMode;
/**
* Field Requirement Flag
*/
MANDATORY: BoolString;
/**
* Field multiplicity flag
*/
MULTIPLE: BoolString;
/**
* Current value of the field. For a multiple field, an array of values.
*/
VALUE: any;
/**
* External field code
*/
XML_ID: string;
}
/**
* List of supported languages in B24.Cloud
*
* It is worth remembering that there will be 1-2 languages for the B24.Box
*/
declare enum B24LangList {
en = "en",
de = "de",
la = "la",
br = "br",
fr = "fr",
it = "it",
pl = "pl",
ru = "ru",
ua = "ua",
tr = "tr",
sc = "sc",
tc = "tc",
ja = "ja",
vn = "vn",
id = "id",
ms = "ms",
th = "th",
ar = "ar"
}
/**
* @todo add docs
*/
declare const B24LocaleMap: Record<B24LangList, string>;
/**
* Data Types and Object Structure in the REST API bizproc activity and robot
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/index.html
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-robot/index.html
*
* @todo add docs
*/
interface ActivityHandlerParams {
event_token: string;
workflow_id: string;
code: string;
document_id: string[];
document_type: string[];
properties?: Record<string, string>;
use_subscription: BoolString;
timeout_duration: string;
ts: string;
[key: string]: any;
auth: HandlerAuthParams;
}
type ActivityPropertyType = 'bool' | 'date' | 'datetime' | 'double' | 'int' | 'select' | 'string' | 'text' | 'user';
interface ActivityProperty {
Name: string | Partial<Record<B24LangList, string>>;
Description?: string | Record<string, string>;
Type: ActivityPropertyType;
Options?: Record<string | number, string>;
Required?: BoolString;
Multiple?: BoolString;
Default?: any;
}
interface ActivityConfig {
CODE: string;
HANDLER: string;
NAME: string | Partial<Record<B24LangList, string>>;
DESCRIPTION?: string | Partial<Record<B24LangList, string>>;
DOCUMENT_TYPE?: [string, string, string];
PROPERTIES?: Record<string, ActivityProperty>;
RETURN_PROPERTIES?: Record<string, ActivityProperty>;
FILTER?: {
INCLUDE?: Array<string | string[]>;
EXCLUDE?: Array<string | string[]>;
};
USE_PLACEMENT?: BoolString;
PLACEMENT_HANDLER?: string;
USE_SUBSCRIPTION?: BoolString;
AUTH_USER_ID?: number;
}
interface ActivityOrRobotConfig extends Omit<ActivityConfig, 'HANDLER' | 'PLACEMENT_HANDLER' | 'NAME'> {
type: 'activity' | 'robot';
NAME?: ActivityConfig['NAME'];
HANDLER?: ActivityConfig['HANDLER'];
PLACEMENT_HANDLER?: ActivityConfig['PLACEMENT_HANDLER'];
}
/**
* Data Types and Object Structure in the REST API bizproc
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/bizproc-activity-add.html
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-robot/bizproc-robot-add.html
* @todo add docs
*/
/**
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/bizproc-activity-add.html
*/
declare enum EnumBitrix24Edition {
undefined = "undefined",
b24 = "b24",
box = "box"
}
declare enum EnumBizprocBaseType {
undefined = "undefined",
crm = "crm",
disk = "disk",
lists = "lists"
}
/**
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-workflow-start.html
*/
declare enum EnumBizprocDocumentType {
undefined = "undefined",
lead = "CCrmDocumentLead",
company = "CCrmDocumentCompany",
contact = "CCrmDocumentContact",
deal = "CCrmDocumentDeal",
invoice = "Bitrix\\Crm\\Integration\\BizProc\\Document\\SmartInvoice",
quote = "Bitrix\\Crm\\Integration\\BizProc\\Document\\Quote",
order = "Bitrix\\Crm\\Integration\\BizProc\\Document\\Order",
dynamic = "Bitrix\\Crm\\Integration\\BizProc\\Document\\Dynamic",
disk = "Bitrix\\Disk\\BizProcDocument",
lists = "BizprocDocument",
listsList = "Bitrix\\Lists\\BizprocDocumentLists"
}
declare function convertBizprocDocumentTypeToCrmEntityTypeId(documentType: EnumBizprocDocumentType): EnumCrmEntityTypeId;
/**
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/bizproc-activity-add.html
*/
declare function getDocumentType(documentType: EnumBizprocDocumentType, entityId?: number): string[];
/**
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-workflow-start.html
*/
declare function getDocumentId(documentType: EnumBizprocDocumentType, id: number, dynamicId?: number): string[];
/**
* @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-workflow-start.html
*/
declare function getDocumentTypeForFilter(documentType: EnumBizprocDocumentType): string[];
/**
* Data Types and Object Structure in the REST API event handler
* @link https://apidocs.bitrix24.com/api-reference/events/index.html
* @todo add docs
*/
interface EventHandlerParams {
event: string;
event_handler_id: string;
ts: string;
[key: string]: any;
auth?: HandlerAuthParams;
}
interface EventOnAppInstallHandlerParams extends EventHandlerParams {
data: {
VERSION: string;
ACTIVE: BoolString;
INSTALLED: BoolString;
LANGUAGE_ID: string;
};
auth: HandlerAuthParams;
}
/**
* @todo fix this application_token
* @see https://apidocs.bitrix24.com/api-reference/events/safe-event-handlers.html
*/
interface EventOnAppUnInstallHandlerParams {
event: string;
event_handler_id: string;
ts: string;
[key: string]: any;
auth: {
domain: string;
client_endpoint: string;
server_endpoint: string;
member_id: string;
application_token: string;
};
}
type TypePullMessage = {
command: string;
params: Record<string, any>;
extra: Record<string, any>;
};
type TypePullClientMessageBody = {
module_id: string;
command: string;
params: any;
extra?: {
revision_web?: number;
sender?: {
type: SenderType;
};
server_time_unix?: number;
server_time_ago?: number;
};
};
declare enum ConnectionType {
Undefined = "undefined",
WebSocket = "webSocket",
LongPolling = "longPolling"
}
type TypeConnector = {
setLogger(logger: LoggerBrowser): void;
destroy(): void;
connect(): void;
disconnect(code: number, reason: string): void;
send(buffer: ArrayBuffer | string): boolean;
connected: boolean;
connectionPath: string;
};
type ConnectorParent = {
session: TypePullClientSession;
getConnectionPath(connectionType: ConnectionType): string;
getPublicationPath(): string;
setLastMessageId(lastMessageId: string): void;
isProtobufSupported(): boolean;
isJsonRpc(): boolean;
};
type ConnectorCallbacks = {
onOpen: () => void;
onDisconnect: (response: {
code: number;
reason: string;
}) => void;
onError: (error: Error) => void;
onMessage: (response: string | ArrayBuffer) => void;
};
type ConnectorConfig = {
parent: ConnectorParent;
onOpen?: () => void;
onDisconnect?: (response: {
code: number;
reason: string;
}) => void;
onError?: (error: Error) => void;
onMessage?: (response: string | ArrayBuffer) => void;
};
type StorageManagerParams = {
userId?: number;
siteId?: string;
};
type TypeStorageManager = {
setLogger(logger: LoggerBrowser): void;
getLogger(): LoggerBrowser;
set(name: string, value: any): void;
get(name: string, defaultValue: any): any;
remove(name: string): void;
compareKey(eventKey: string, userKey: string): boolean;
};
declare enum LsKeys {
PullConfig = "bx-pull-config",
WebsocketBlocked = "bx-pull-websocket-blocked",
LongPollingBlocked = "bx-pull-longpolling-blocked",
LoggingEnabled = "bx-pull-logging-enabled"
}
type SharedConfigCallbacks = {
onWebSocketBlockChanged: (response: {
isWebSocketBlocked: boolean;
}) => void;
};
type SharedConfigParams = {
storage?: TypeStorageManager;
onWebSocketBlockChanged?: (response: {
isWebSocketBlocked: boolean;
}) => void;
};
declare enum PullStatus {
Online = "online",
Offline = "offline",
Connecting = "connect"
}
declare enum SenderType {
Unknown = 0,
Client = 1,
Backend = 2
}
declare enum SubscriptionType {
Server = "server",
Client = "client",
Online = "online",
Status = "status",
Revision = "revision"
}
type TypeSubscriptionOptions = {
/**
* Subscription type
*/
type?: SubscriptionType;
/**
* Name of the module
*/
moduleId?: string;
/**
* Name of the command
*/
command?: null | string;
/**
* Function, that will be called for incoming messages
*/
callback: Function;
};
interface UserStatusCallback {
(params: {
userId: number;
isOnline: boolean;
}): void;
}
interface CommandHandlerFunctionV1 {
(data: Record<string, any>, info?: {
type: SubscriptionType;
moduleId?: string;
}): void;
}
interface CommandHandlerFunctionV2 {
(params: Record<string, any>, extra: Record<string, any>, command: string, info?: {
type: SubscriptionType;
moduleId: string;
}): void;
}
interface TypeSubscriptionCommandHandler {
getModuleId: () => string;
getSubscriptionType?: () => SubscriptionType;
getMap?: () => Record<string, CommandHandlerFunctionV2>;
[key: string]: CommandHandlerFunctionV2 | undefined;
}
type TypePullClientEmitConfig = {
type: SubscriptionType;
moduleId?: string;
data?: Record<string, any>;
};
declare enum CloseReasons {
NORMAL_CLOSURE = 1000,
SERVER_DIE = 1001,
CONFIG_REPLACED = 3000,
CHANNEL_EXPIRED = 3001,
SERVER_RESTARTED = 3002,
CONFIG_EXPIRED = 3003,
MANUAL = 3004,
STUCK = 3005,
WRONG_CHANNEL_ID = 4010
}
declare enum SystemCommands {
CHANNEL_EXPIRE = "CHANNEL_EXPIRE",
CONFIG_EXPIRE = "CONFIG_EXPIRE",
SERVER_RESTART = "SERVER_RESTART"
}
declare enum ServerMode {
Shared = "shared",
Personal = "personal"
}
type RpcError = {
code: number;
message: string;
};
declare const ListRpcError: {
readonly Parse: RpcError;
readonly InvalidRequest: RpcError;
readonly MethodNotFound: RpcError;
readonly InvalidParams: RpcError;
readonly Internal: RpcError;
};
type JsonRpcRequest = {
method: string;
params: any;
id: number;
};
type RpcCommand = {
jsonrpc: string;
method: string;
params: any;
id: number;
};
type RpcRequest = RpcCommand & {};
type RpcCommandResult = {
jsonrpc?: string;
id?: number;
/**
* @fix this TypeRpcResponseAwaiters.resolve(response)
*/
result?: any;
error?: RpcError;
};
declare enum RpcMethod {
Publish = "publish",
GetUsersLastSeen = "getUsersLastSeen",
Ping = "ping",
ListChannels = "listChannels",
SubscribeStatusChange = "subscribeSt