v2.1.0

TypeB24

Public contract implemented by every entry-point class (B24Frame, B24Hook, B24OAuth). Single source of truth for the SDK surface.

TypeB24 is the unified type implemented by B24Frame, B24Hook, and B24OAuth. Use it as a parameter type when your code shouldn't care which transport it talks to.

import type { TypeB24 } from '@bitrix24/b24jssdk'

async function listAdminTasks($b24: TypeB24): Promise<unknown[]> {
  const response = await $b24.actions.v2.callList.make<{ id: number, title: string }>({
    method: 'tasks.task.list',
    params: { filter: { '!=STATUS': '5' }, select: ['ID', 'TITLE'] },
    idKey: 'id', // tasks return lowercase id
    cursorIdKey: 'ID', // ...but sort / filter by uppercase ID
    customKeyForResult: 'tasks',
    requestId: 'admin-tasks'
  })
  return response.isSuccess ? response.getData()! : []
}

Shape

type TypeB24 = {
  readonly isInit: boolean
  init(): Promise<void>
  destroy(): void

  getLogger(): LoggerInterface
  setLogger(logger: LoggerInterface): void

  get auth(): AuthActions
  get actions(): ActionsManager
  get tools(): ToolsManager

  setRestrictionManagerParams(params: RestrictionParams): Promise<void>

  getTargetOrigin(): string
  getTargetOriginWithPath(): Map<ApiVersion, string>

  getHttpClient(version: ApiVersion): TypeHttp
  setHttpClient(version: ApiVersion, client: TypeHttp): void

  // @deprecated — use actions.v2.* / actions.v3.* instead.
  // Removed in 3.0.0:
  callMethod(method: string, params?: object, start?: number): Promise<AjaxResult>
  callListMethod(method: string, params?: object, progress?: null | ((p: number) => void), customKeyForResult?: string | null): Promise<Result>
  fetchListMethod(method: string, params?: any, idKey?: string, customKeyForResult?: string | null): AsyncGenerator<any[]>
  callBatch(calls: any[] | object, isHaltOnError?: boolean, returnAjaxResult?: boolean): Promise<Result>
  callBatchByChunk(calls: any[], isHaltOnError: boolean): Promise<Result>
}
callMethod / callListMethod / fetchListMethod / callBatch / callBatchByChunk will be removed in 3.0.0. Migrate to actions.v{2,3}.{call,callList,fetchList,batch,batchByChunk}.make(options).