v2.1.0

OptionsManager

Typed access to app.option.get / user.option.get, plus a save() that batches *.option.set with an optional Pull notification.

OptionsManager is created twice — once for app.option.get and once for user.option.get. Reachable through B24HelperManager.appOptions and B24HelperManager.userOptions. It treats option values as raw strings server-side and converts on read.

Usage

import { useB24Helper, LoadDataType } from '@bitrix24/b24jssdk'

const { initB24Helper, getB24Helper } = useB24Helper()
await initB24Helper($b24, [LoadDataType.AppOptions, LoadDataType.UserOptions])

const helper = getB24Helper()

// Read with a default
const filters = helper.userOptions.getJsonObject('listFilters', {})
const itemsPerPage = helper.userOptions.getInteger('itemsPerPage', 20)

// Persist
await helper.appOptions.save(
  { theme: 'dark' },
  { moduleId: 'main', command: 'optionsChanged', params: { theme: 'dark' } }
)

Typed Getters

MethodReturnsDefaultNotes
getJsonArray(key, def?)any[][]Parses JSON, also accepts JSON objects (returns Object.values).
getJsonObject(key, def?)object{}Parses JSON, falls back to def on failure.
getFloat(key, def?)number0.0Uses Text.toNumber.
getInteger(key, def?)number0Uses Text.toInteger.
getBoolYN(key, def?)booleantrue'Y'true, 'N'false.
getBoolNY(key, def?)booleanfalseSame conversion as getBoolYN, different default.
getString(key, def?)string''Calls .toString().
getDate(key, def?)null | DateTimenullUses Text.toDateTime (Luxon).

Static Helpers

OptionsManager.getSupportTypes(): TypeOption[]
OptionsManager.prepareArrayList(list: any): any[]

TypeOption enumerates the supported value shapes (NotSet / JsonArray / JsonObject / FloatVal / IntegerVal / BoolYN / StringVal).

Cache Methods

get data(): Map<string, any>
reset(): void

data is the raw key→string map. reset() clears the in-memory cache without touching the server.

Save

save(
  options: Record<string, any>,
  optionsPull?: { moduleId: string, command: string, params: any },
  requestId?: string
): Promise<Result>

Issues a single batched call:

  1. app.option.set for appOptions / user.option.set for userOptions, with the supplied options payload.
  2. Optionally pull.application.event.add so other clients are notified about the change.

Both calls share isHaltOnError: true. Returns the wrapping Result.

save() does not update the local cache. Call getB24Helper().loadData([LoadDataType.AppOptions]) (or rerun initB24Helper) if you need the new state to be visible to subsequent getX() reads.

Encoding Helpers

encode(value: any): string  // JSON.stringify wrapper
decode(data: string, defaultValue: any): any  // JSON.parse with logged failure

Convenience wrappers around JSON.stringify / JSON.parse that log parse failures through the manager's logger.