@bitrix24/b24jssdk
Version:
Bitrix24 REST API JS SDK
1 lines • 1.11 MB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../src/logger/browser.ts","../../src/types/common.ts","../../src/tools/type.ts","../../src/tools/index.ts","../../src/tools/uuidv7.ts","../../src/tools/text.ts","../../src/tools/browser.ts","../../src/types/http.ts","../../src/types/crm/entity-type.ts","../../src/types/crm/productrow.ts","../../src/types/catalog/index.ts","../../src/types/bizproc/index.ts","../../src/types/b24-helper.ts","../../src/types/pull.ts","../../src/core/result.ts","../../src/core/http/ajax-error.ts","../../src/core/http/ajax-result.ts","../../src/core/http/restriction-manager.ts","../../src/core/http/request-id-generator.ts","../../src/core/http/controller.ts","../../src/core/abstract-b24.ts","../../src/core/language/list.ts","../../src/tools/scroll-size.ts","../../src/tools/formatters/numbers.ts","../../src/tools/formatters/iban.ts","../../src/tools/use-formatters.ts","../../src/hook/auth.ts","../../src/hook/controller.ts","../../src/frame/message/commands.ts","../../src/frame/message/controller.ts","../../src/frame/frame.ts","../../src/frame/auth.ts","../../src/frame/parent.ts","../../src/frame/options.ts","../../src/frame/dialog.ts","../../src/frame/slider.ts","../../src/frame/placement.ts","../../src/frame/controller.ts","../../src/oauth/refresh-token-error.ts","../../src/oauth/auth.ts","../../src/oauth/controller.ts","../../src/helper/abstract-helper.ts","../../src/helper/profile-manager.ts","../../src/helper/app-manager.ts","../../src/helper/payment-manager.ts","../../src/helper/license-manager.ts","../../src/helper/currency-manager.ts","../../src/helper/options-manager.ts","../../src/pullClient/storage-manager.ts","../../src/pullClient/errors.ts","../../src/pullClient/json-rpc.ts","../../src/pullClient/shared-config.ts","../../src/pullClient/channel-manager.ts","../../src/pullClient/protobuf/protobuf.js","../../src/pullClient/protobuf/model.js","../../src/pullClient/protobuf/index.ts","../../src/pullClient/abstract-connector.ts","../../src/pullClient/web-socket-connector.ts","../../src/pullClient/long-polling-connector.ts","../../src/pullClient/client.ts","../../src/helper/helper-manager.ts","../../src/helper/use-b24-helper.ts","../../src/loader-b24frame.ts"],"sourcesContent":["export enum LoggerType {\n\tdesktop = 'desktop',\n\tlog = 'log',\n\tinfo = 'info',\n\twarn = 'warn',\n\terror = 'error',\n\ttrace = 'trace',\n}\n\ninterface LoggerTypes {\n\tdesktop: boolean\n\tlog: boolean\n\tinfo: boolean\n\twarn: boolean\n\terror: boolean\n\ttrace: boolean\n}\n\n// region StyleCollection ////\nconst styleCollection: Map<string, string[]> = new Map()\n\nstyleCollection.set('title', [\n\t'%c#title#',\n\t'color: #959ca4; font-style: italic; padding: 0 6px; border-top: 1px solid #ccc; border-left: 1px solid #ccc; border-bottom: 1px solid #ccc',\n])\n\nstyleCollection.set(LoggerType.desktop, [\n\t`%cDESKTOP`,\n\t'color: white; font-style: italic; background-color: #29619b; padding: 0 6px; border: 1px solid #29619b',\n])\n\nstyleCollection.set(LoggerType.log, [\n\t`%cLOG`,\n\t'color: #2a323b; font-style: italic; background-color: #ccc; padding: 0 6px; border: 1px solid #ccc',\n])\n\nstyleCollection.set(LoggerType.info, [\n\t`%cINFO`,\n\t'color: #fff; font-style: italic; background-color: #6b7f96; padding: 0 6px; border: 1px solid #6b7f96',\n])\n\nstyleCollection.set(LoggerType.warn, [\n\t`%cWARNING`,\n\t'color: #f0a74f; font-style: italic; padding: 0 6px; border: 1px solid #f0a74f',\n])\n\nstyleCollection.set(LoggerType.error, [\n\t`%cERROR`,\n\t'color: white; font-style: italic; background-color: #8a3232; padding: 0 6px; border: 1px solid #8a3232',\n])\n\nstyleCollection.set(LoggerType.trace, [\n\t`%cTRACE`,\n\t'color: #2a323b; font-style: italic; background-color: #ccc; padding: 0 6px; border: 1px solid #ccc',\n])\n// endregion ////\n\nexport class LoggerBrowser {\n\treadonly #title: string\n\t#types: LoggerTypes = {\n\t\tdesktop: true,\n\t\tlog: false,\n\t\tinfo: false,\n\t\twarn: false,\n\t\terror: true,\n\t\ttrace: true,\n\t}\n\n\tstatic build(title: string, isDevelopment: boolean = false): LoggerBrowser {\n\t\tconst logger = new LoggerBrowser(title)\n\n\t\tif (isDevelopment) {\n\t\t\tlogger.enable(LoggerType.log)\n\t\t\tlogger.enable(LoggerType.info)\n\t\t\tlogger.enable(LoggerType.warn)\n\t\t}\n\n\t\treturn logger\n\t}\n\n\tprivate constructor(title: string) {\n\t\tthis.#title = title\n\t}\n\n\t// region Styles ////\n\t#getStyle(type: LoggerType): string[] {\n\t\tconst resultText: string[] = []\n\t\tconst resultStyle: string[] = []\n\n\t\tif (styleCollection.has('title')) {\n\t\t\tconst styleTitle = styleCollection.get('title') as string[]\n\t\t\tif (styleTitle[0]) {\n\t\t\t\tresultText.push(styleTitle[0].replace('#title#', this.#title))\n\t\t\t\tresultStyle.push(styleTitle[1] || '')\n\t\t\t}\n\t\t}\n\n\t\tif (styleCollection.has(type)) {\n\t\t\tconst styleBadge = styleCollection.get(type) as string[]\n\t\t\tif (styleBadge[0]) {\n\t\t\t\tresultText.push(styleBadge[0])\n\t\t\t\tresultStyle.push(styleBadge[1] || '')\n\t\t\t}\n\t\t}\n\n\t\treturn [resultText.join(''), ...resultStyle]\n\t}\n\t// endregion ////\n\n\t// region Config ////\n\tsetConfig(types: Record<string | LoggerType, boolean>): void {\n\t\tfor (const type in types) {\n\t\t\tthis.#types[type as LoggerType] = types[type] as boolean\n\t\t}\n\t}\n\n\tenable(type: LoggerType): boolean {\n\t\tif (typeof this.#types[type] === 'undefined') {\n\t\t\treturn false\n\t\t}\n\n\t\tthis.#types[type] = true\n\n\t\treturn true\n\t}\n\n\tdisable(type: LoggerType): boolean {\n\t\tif (typeof this.#types[type] === 'undefined') {\n\t\t\treturn false\n\t\t}\n\n\t\tthis.#types[type] = false\n\n\t\treturn true\n\t}\n\n\tisEnabled(type: LoggerType): boolean {\n\t\treturn this.#types[type]\n\t}\n\t// endregion ////\n\n\t// region Functions ////\n\tdesktop(...params: any[]): void {\n\t\tif (this.isEnabled(LoggerType.desktop)) {\n\t\t\tconsole.log(...this.#getStyle(LoggerType.desktop), ...params)\n\t\t}\n\t}\n\n\tlog(...params: any[]): void {\n\t\tif (this.isEnabled(LoggerType.log)) {\n\t\t\tconsole.log(...this.#getStyle(LoggerType.log), ...params)\n\t\t}\n\t}\n\n\tinfo(...params: any[]): void {\n\t\tif (this.isEnabled(LoggerType.info)) {\n\t\t\tconsole.info(...this.#getStyle(LoggerType.info), ...params)\n\t\t}\n\t}\n\n\twarn(...params: any[]): void {\n\t\tif (this.isEnabled(LoggerType.warn)) {\n\t\t\tconsole.warn(...this.#getStyle(LoggerType.warn), ...params)\n\t\t}\n\t}\n\n\terror(...params: any[]): void {\n\t\tif (this.isEnabled(LoggerType.error)) {\n\t\t\tconsole.error(...this.#getStyle(LoggerType.error), ...params)\n\t\t}\n\t}\n\n\ttrace(...params: any[]): void {\n\t\tif (this.isEnabled(LoggerType.trace)) {\n\t\t\tconsole.trace(...this.#getStyle(LoggerType.trace), ...params)\n\t\t}\n\t}\n\t// endregion ////\n}\n","/**\n * String which is actually a number, like `'20.23'`\n */\nexport type NumberString = string\n\n/**\n * Like `'2018-06-07T03:00:00+03:00'`\n */\nexport type ISODate = string\nexport type BoolString = 'Y' | 'N'\nexport type GenderString = 'M' | 'F' | ''\n\nexport type PlacementViewMode = 'view' | 'edit'\nexport type TextType = 'text' | 'html'\n\nexport type Fields = {\n\treadonly [key: string]: {\n\t\treadonly type: string\n\t\treadonly isRequired: boolean\n\t\treadonly isReadOnly: boolean\n\t\treadonly isImmutable: boolean\n\t\treadonly isMultiple: boolean\n\t\treadonly isDynamic: boolean\n\t\treadonly title: string\n\t\treadonly upperName?: string\n\t}\n}\n\nexport type MultiField = {\n\treadonly ID: NumberString\n\treadonly VALUE_TYPE: string\n\treadonly VALUE: string\n\treadonly TYPE_ID: string\n}\n\nexport type MultiFieldArray = ReadonlyArray<\n\tPick<MultiField, 'VALUE' | 'VALUE_TYPE'>\n>\n\n/**\n * Describes the inline settings in UF\n */\nexport type UserFieldType = {\n\tUSER_TYPE_ID: string\n\tHANDLER: string\n\tTITLE: string\n\tDESCRIPTION: string\n\tOPTIONS?: {\n\t\theight: number\n\t}\n}\n\n/**\n * Data types\n * @link https://apidocs.bitrix24.ru/api-reference/data-types.html\n * @link https://dev.1c-bitrix.ru/rest_help/crm/dynamic/methodscrmitem/crm_item_fields.php\n */\nexport enum DataType {\n\tundefined = 'undefined',\n\tany = 'any',\n\tinteger = 'integer',\n\tboolean = 'boolean',\n\tdouble = 'double',\n\tdate = 'date',\n\tdatetime = 'datetime',\n\tstring = 'string',\n\ttext = 'text',\n\tfile = 'file',\n\tarray = 'array',\n\tobject = 'object',\n\tuser = 'user',\n\tlocation = 'location',\n\tcrmCategory = 'crm_category',\n\tcrmStatus = 'crm_status',\n\tcrmCurrency = 'crm_currency',\n}\n","const OBJECT_CONSTRUCTOR_STRING = Function.prototype.toString.call(Object)\n\ninterface BlobLike {\n readonly size: number\n readonly type: string\n slice(start?: number, end?: number, contentType?: string): Blob\n}\n\ninterface FileLike extends BlobLike {\n name: string;\n lastModified?: number;\n lastModifiedDate?: object;\n}\n\n/**\n * The `Type` class is designed to check and determine data types\n *\n * @see bitrix/js/main/core/src/lib/type.js\n */\nclass TypeManager {\n getTag(value: any): string {\n return Object.prototype.toString.call(value)\n }\n\n /**\n * Checks that value is string\n * @param value\n * @return {boolean}\n *\n * @memo get from pull.client.Utils\n */\n isString(value: any): value is string {\n // eslint-disable-next-line unicorn/no-instanceof-builtins\n return typeof value === 'string' || value instanceof String\n }\n\n /**\n * Returns true if a value is not an empty string\n * @param value\n * @returns {boolean}\n */\n isStringFilled(value: any): value is string {\n return this.isString(value) && value !== ''\n }\n\n /**\n * Checks that value is function\n * @param value\n * @return {boolean}\n *\n * @memo get from pull.client.Utils\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n isFunction(value: any): value is Function {\n return value === null\n ? false\n : // eslint-disable-next-line unicorn/no-instanceof-builtins\n typeof value === 'function' || value instanceof Function\n }\n\n /**\n * Checks that value is an object\n * @param value\n * @return {boolean}\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n isObject(value: any): value is object | Function {\n return !!value && (typeof value === 'object' || typeof value === 'function')\n }\n\n /**\n * Checks that value is object like\n * @param value\n * @return {boolean}\n */\n isObjectLike<T>(value: any): value is T {\n return !!value && typeof value === 'object'\n }\n\n /**\n * Checks that value is plain object\n * @param value\n * @return {boolean}\n */\n isPlainObject(value: any): value is Record<string | number, any> {\n if (!this.isObjectLike(value) || this.getTag(value) !== '[object Object]') {\n return false\n }\n\n const proto = Object.getPrototypeOf(value)\n if (proto === null) {\n return true\n }\n\n const ctor = proto.hasOwnProperty('constructor') && proto.constructor\n\n return (\n typeof ctor === 'function' &&\n Function.prototype.toString.call(ctor) === OBJECT_CONSTRUCTOR_STRING\n )\n }\n\n isJsonRpcRequest(value: any): boolean {\n return (\n typeof value === 'object' &&\n value &&\n 'jsonrpc' in value &&\n this.isStringFilled(value.jsonrpc) &&\n 'method' in value &&\n this.isStringFilled(value.method)\n )\n }\n\n isJsonRpcResponse(value: any): boolean {\n return (\n typeof value === 'object' &&\n value &&\n 'jsonrpc' in value &&\n this.isStringFilled(value.jsonrpc) &&\n 'id' in value &&\n ('result' in value || 'error' in value)\n )\n }\n\n /**\n * Checks that value is boolean\n * @param value\n * @return {boolean}\n */\n isBoolean(value: any): value is boolean {\n return value === true || value === false\n }\n\n /**\n * Checks that value is number\n * @param value\n * @return {boolean}\n */\n isNumber(value: any): value is number {\n return typeof value === 'number' && !Number.isNaN(value)\n }\n\n /**\n * Checks that value is integer\n * @param value\n * @return {boolean}\n */\n isInteger(value: any): value is number {\n return Number.isInteger(value)\n }\n\n /**\n * Checks that value is float\n * @param value\n * @return {boolean}\n */\n isFloat(value: any): value is number {\n return this.isNumber(value) && !this.isInteger(value)\n }\n\n /**\n * Checks that value is nil\n * @param value\n * @return {boolean}\n */\n isNil(value: any): value is null | undefined {\n return value === null || value === undefined\n }\n\n /**\n * Checks that value is an array\n * @param value\n * @return {boolean}\n */\n isArray(value: any): value is any[] {\n return !this.isNil(value) && Array.isArray(value)\n }\n\n /**\n * Returns true if a value is an array, and it has at least one element\n * @param value\n * @returns {boolean}\n */\n isArrayFilled(value: any): value is any[] {\n return this.isArray(value) && value.length > 0\n }\n\n /**\n * Checks that value is array like\n * @param value\n * @return {boolean}\n */\n isArrayLike(value: any): value is ArrayLike<any> {\n return (\n !this.isNil(value)\n && !this.isFunction(value)\n && value.length > -1\n && value.length <= Number.MAX_SAFE_INTEGER\n )\n }\n\n /**\n * Checks that value is Date\n * @param value\n * @return {boolean}\n */\n isDate(value: any): value is Date {\n return value instanceof Date\n }\n\n /**\n * Checks that is a DOM node\n * @param value\n * @return {boolean}\n */\n isDomNode(value: any): value is Node {\n return (\n this.isObjectLike<{\n nodeType?: any\n }>(value)\n && !this.isPlainObject(value)\n && 'nodeType' in value\n )\n }\n\n /**\n * Checks that value is element node\n * @param value\n * @return {boolean}\n */\n isElementNode(value: any): value is HTMLElement {\n return this.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE\n }\n\n /**\n * Checks that value is a text node\n * @param value\n * @return {boolean}\n */\n isTextNode(value: any): value is Text {\n return this.isDomNode(value) && value.nodeType === Node.TEXT_NODE\n }\n\n /**\n * Checks that value is Map\n * @param value\n * @return {boolean}\n */\n isMap(value: any): value is Map<unknown, unknown> {\n return this.isObjectLike(value) && this.getTag(value) === '[object Map]'\n }\n\n /**\n * Checks that value is Set\n * @param value\n * @return {boolean}\n */\n isSet(value: any): value is Set<unknown> {\n return this.isObjectLike(value) && this.getTag(value) === '[object Set]'\n }\n\n /**\n * Checks that value is WeakMap\n * @param value\n * @return {boolean}\n */\n isWeakMap(value: any): value is WeakMap<object, unknown> {\n return this.isObjectLike(value) && this.getTag(value) === '[object WeakMap]'\n }\n\n /**\n * Checks that value is WeakSet\n * @param value\n * @return {boolean}\n */\n isWeakSet(value: any): value is WeakSet<object> {\n return this.isObjectLike(value) && this.getTag(value) === '[object WeakSet]'\n }\n\n /**\n * Checks that value is prototype\n * @param value\n * @return {boolean}\n */\n isPrototype(value: any): value is object {\n return (\n (\n (\n typeof (value && value.constructor) === 'function'\n && value.constructor.prototype\n ) || Object.prototype\n ) === value\n )\n }\n\n /**\n * Checks that value is regexp\n * @param value\n * @return {boolean}\n */\n isRegExp(value: any): value is RegExp {\n return this.isObjectLike(value) && this.getTag(value) === '[object RegExp]'\n }\n\n /**\n * Checks that value is null\n * @param value\n * @return {boolean}\n */\n isNull(value: any): value is null {\n return value === null\n }\n\n /**\n * Checks that value is undefined\n * @param value\n * @return {boolean}\n */\n isUndefined(value: any): value is undefined {\n return typeof value === 'undefined'\n }\n\n /**\n * Checks that value is ArrayBuffer\n * @param value\n * @return {boolean}\n */\n isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n this.isObjectLike(value) && this.getTag(value) === '[object ArrayBuffer]'\n )\n }\n\n /**\n * Checks that value is typed array\n * @param value\n * @return {boolean}\n */\n isTypedArray(value: any): value is\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Float32Array\n | Float64Array\n {\n const regExpTypedTag =\n /^\\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/\n return this.isObjectLike(value) && regExpTypedTag.test(this.getTag(value))\n }\n\n /**\n * Checks that value is Blob\n * @param value\n * @return {boolean}\n */\n isBlob(value: any): value is BlobLike {\n return (\n this.isObjectLike(value) &&\n this.isNumber((value as BlobLike).size) &&\n this.isString((value as BlobLike).type) &&\n this.isFunction((value as BlobLike).slice)\n )\n }\n\n /**\n * Checks that value is File\n * @param value\n * @return {boolean}\n */\n isFile(value: any): value is FileLike {\n return (\n this.isBlob(value) &&\n this.isString((value as FileLike).name) &&\n (this.isNumber((value as FileLike).lastModified) || this.isObjectLike((value as FileLike).lastModifiedDate))\n )\n }\n\n /**\n * Checks that value is FormData\n * @param value\n * @return {boolean}\n */\n isFormData(value: any): value is FormData {\n if (typeof FormData !== 'undefined' && value instanceof FormData) {\n return true\n }\n\n return this.isObjectLike(value) && this.getTag(value) === '[object FormData]'\n }\n\n clone(obj: any, bCopyObj: boolean = true): any {\n let _obj, i, l\n\n if (this.isNil(obj) || typeof obj !== 'object') {\n return obj\n }\n\n if (this.isDomNode(obj)) {\n _obj = obj.cloneNode(bCopyObj)\n } else if (typeof obj == 'object') {\n if (this.isArray(obj)) {\n _obj = []\n for (i = 0, l = obj.length; i < l; i++) {\n if (typeof obj[i] == 'object' && bCopyObj) {\n _obj[i] = this.clone(obj[i], bCopyObj)\n } else {\n _obj[i] = obj[i]\n }\n }\n } else {\n _obj = {}\n if (obj.constructor) {\n if (this.isDate(obj)) {\n _obj = new Date(obj)\n } else {\n _obj = new obj.constructor()\n }\n }\n\n for (i in obj) {\n if (!obj.hasOwnProperty(i)) {\n continue\n }\n if (typeof obj[i] === 'object' && bCopyObj) {\n _obj[i] = this.clone(obj[i], bCopyObj)\n } else {\n _obj[i] = obj[i]\n }\n }\n }\n } else {\n _obj = obj\n }\n\n return _obj\n }\n}\n\nconst Type = new TypeManager()\n\nexport default Type\n","/**\n * @todo add docs\n */\nexport function pick<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Pick<Data, Keys> {\n const result = {} as Pick<Data, Keys>\n\n for (const key of keys) {\n result[key] = data[key]\n }\n\n return result\n}\n\n/**\n * @todo add docs\n */\nexport function omit<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Omit<Data, Keys> {\n const result = { ...data }\n\n for (const key of keys) {\n\n delete result[key]\n }\n\n return result as Omit<Data, Keys>\n}\n\n/**\n * @todo add docs\n */\nexport function isArrayOfArray<A>(item: A[] | A[][]): item is A[][] {\n return Array.isArray(item[0])\n}\n\n/**\n * @todo add docs\n *\n * @example\n * const result = getEnumValue(EnumBizprocDocumentType, 'CCrmDocumentSmartOrder')\n */\nexport function getEnumValue<T extends Record<string, string | number>>(\n enumObj: T,\n value: string | number\n): T[keyof T] | undefined {\n return (Object.values(enumObj) as (string | number)[]).includes(value)\n ? value as T[keyof T]\n : undefined\n}\n","/**\n * uuid v7\n */\nconst byteToHex: string[] = []\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1))\n}\n\nfunction sfc32(a: number, b: number, c: number, d: number) {\n return () => {\n // eslint-disable-next-line\n a |= 0; b |= 0; c |= 0; d |= 0;\n // eslint-disable-next-line\n const t = (a + b | 0) + d | 0;\n // eslint-disable-next-line\n d = d + 1 | 0;\n a = b ^ b >>> 9;\n // eslint-disable-next-line\n b = c + (c << 3) | 0;\n // eslint-disable-next-line\n c = (c << 21 | c >>> 11) + t | 0;\n return t >>> 0;\n };\n}\n\nexport default function uuidv7(): string {\n const bytes = new Uint8Array(16)\n const timestamp = BigInt(Date.now());\n const perf = BigInt(Math.floor(performance.now() * 1000) % 0xffff);\n const combinedTime = (timestamp << 16n) | perf;\n\n bytes[0] = Number((combinedTime >> 40n) & 0xffn)\n bytes[1] = Number((combinedTime >> 32n) & 0xffn)\n bytes[2] = Number((combinedTime >> 24n) & 0xffn)\n bytes[3] = Number((combinedTime >> 16n) & 0xffn)\n bytes[4] = Number((combinedTime >> 8n) & 0xffn)\n bytes[5] = Number(combinedTime & 0xffn)\n\n const seed = (Math.random() * 0xffffffff ^ Date.now() ^ performance.now()) >>> 0\n const rand = sfc32(0x9E3779B9, 0x243F6A88, 0xB7E15162, seed)\n const randView = new DataView(bytes.buffer)\n\n randView.setUint32(6, rand());\n randView.setUint32(10, rand());\n randView.setUint16(14, rand());\n\n bytes[6] = 0x70 | (bytes[6] & 0x0f)\n bytes[8] = 0x80 | (bytes[8] & 0x3f)\n\n return (\n byteToHex[bytes[0]] +\n byteToHex[bytes[1]] +\n byteToHex[bytes[2]] +\n byteToHex[bytes[3]] +\n '-' +\n byteToHex[bytes[4]] +\n byteToHex[bytes[5]] +\n '-' +\n byteToHex[bytes[6]] +\n byteToHex[bytes[7]] +\n '-' +\n byteToHex[bytes[8]] +\n byteToHex[bytes[9]] +\n '-' +\n byteToHex[bytes[10]] +\n byteToHex[bytes[11]] +\n byteToHex[bytes[12]] +\n byteToHex[bytes[13]] +\n byteToHex[bytes[14]] +\n byteToHex[bytes[15]]\n ).toLowerCase()\n}\n","import { DateTime, type DateTimeOptions } from 'luxon'\nimport uuidv7 from './uuidv7'\nimport Type from './type'\n\nconst reEscape = /[&<>'\"]/g\nconst reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34)/g\n\nconst escapeEntities: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n \"'\": ''',\n '\"': '"',\n}\n\nconst unescapeEntities: Record<string, string> = {\n '&': '&',\n '&': '&',\n '<': '<',\n '<': '<',\n '>': '>',\n '>': '>',\n '&apos': \"'\",\n ''': \"'\",\n '"': '\"',\n '"': '\"',\n}\n\n/**\n * The `Text` class provides a set of utility methods for working with text data.\n * It includes functions for encoding and decoding HTML entities, generating random strings,\n * converting values to different data types, and changing the case and format of strings\n *\n * @see bitrix/js/main/core/src/lib/text.js\n */\nclass TextManager {\n getRandom(length = 8): string {\n // eslint-disable-next-line\n return [...Array(length)]\n .map(() => Math.trunc(Math.random() * 36).toString(36))\n .join('')\n }\n\n /**\n * Generates UUID\n */\n getUniqId(): string {\n return 'xxxxxxxx-xlsx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.trunc(Math.random() * 16)\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n }\n\n /**\n * Generate uuid v7\n * @return {string}\n */\n getUuidRfc4122(): string {\n return uuidv7()\n }\n\n /**\n * Encodes all unsafe entities\n * @param {string} value\n * @return {string}\n */\n encode(value: string): string {\n if (Type.isString(value)) {\n return value.replace(reEscape, (item) => escapeEntities[item])\n }\n\n return value\n }\n\n /**\n * Decodes all encoded entities\n * @param {string} value\n * @return {string}\n */\n decode(value: string): string {\n if (Type.isString(value)) {\n return value.replace(reUnescape, (item) => unescapeEntities[item])\n }\n\n return value\n }\n\n toNumber(value: any): number {\n const parsedValue = Number.parseFloat(value)\n\n if (Type.isNumber(parsedValue)) {\n return parsedValue\n }\n\n return 0.0\n }\n\n toInteger(value: any): number {\n return this.toNumber(Number.parseInt(value, 10))\n }\n\n toBoolean(value: any, trueValues: string[] = []): boolean {\n const transformedValue = Type.isString(value) ? value.toLowerCase() : value\n return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue)\n }\n\n toCamelCase(str: string): string {\n if (!Type.isStringFilled(str)) {\n return str\n }\n\n const regex = /[-_\\s]+(.)?/g\n if (!regex.test(str)) {\n // eslint-disable-next-line\n return str.match(/^[A-Z]+$/)\n ? str.toLowerCase()\n : str[0].toLowerCase() + str.slice(1)\n }\n\n str = str.toLowerCase()\n str = str.replace(regex, (_match: string, letter) =>\n letter ? letter.toUpperCase() : ''\n )\n\n // eslint-disable-next-line\n return str[0].toLowerCase() + str.substring(1)\n }\n\n toPascalCase(str: string): string {\n if (!Type.isStringFilled(str)) {\n return str\n }\n\n return this.capitalize(this.toCamelCase(str))\n }\n\n toKebabCase(str: string): string {\n if (!Type.isStringFilled(str)) {\n return str\n }\n\n const matches = str.match(\n /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g\n )\n if (!matches) {\n return str\n }\n\n return matches.map((x) => x.toLowerCase()).join('-')\n }\n\n capitalize(str: string): string {\n if (!Type.isStringFilled(str)) {\n return str\n }\n\n // eslint-disable-next-line\n return str[0].toUpperCase() + str.substring(1)\n }\n\n numberFormat(\n number: number,\n decimals: number = 0,\n decPoint: string = '.',\n thousandsSep: string = ','\n ): string {\n // eslint-disable-next-line\n const n = !Number.isFinite(number) ? 0 : number\n // eslint-disable-next-line\n const fractionDigits = !Number.isFinite(decimals) ? 0 : Math.abs(decimals)\n\n const toFixedFix = (n: number, fractionDigits: number): number => {\n const k = Math.pow(10, fractionDigits)\n return Math.round(n * k) / k\n }\n\n const s = (fractionDigits ? toFixedFix(n, fractionDigits) : Math.round(n))\n .toString()\n .split('.')\n\n if (s[0].length > 3) {\n s[0] = s[0].replace(/\\B(?=(?:\\d{3})+(?!\\d))/g, thousandsSep)\n }\n\n if ((s[1] || '').length < fractionDigits) {\n s[1] = s[1] || ''\n // eslint-disable-next-line\n s[1] += new Array(fractionDigits - s[1].length + 1).join('0')\n }\n\n return s.join(decPoint)\n }\n\n /**\n * Convert string to DateTime from ISO 8601 or self template\n *\n * @param {string} dateString\n * @param {string} template\n * @param opts\n * @returns {DateTime}\n *\n * @link https://moment.github.io/luxon/#/parsing?id=parsing-technical-formats\n */\n toDateTime(\n dateString: string,\n template?: string,\n opts?: DateTimeOptions\n ): DateTime {\n if (!(typeof template === 'undefined') && Type.isStringFilled(template)) {\n return DateTime.fromFormat(dateString, template, opts)\n }\n\n return DateTime.fromISO(dateString, opts)\n }\n\n getDateForLog(): string {\n const now = DateTime.now()\n return now.toFormat('y-MM-dd HH:mm:ss')\n }\n\n buildQueryString(params: any): string {\n let result = ''\n for (const key in params) {\n if (!params.hasOwnProperty(key)) {\n continue\n }\n\n const value = params[key]\n if (Type.isArray(value)) {\n // eslint-disable-next-line\n value.forEach((valueElement: any, index: any) => {\n result +=\n encodeURIComponent(key + '[' + index + ']') +\n '=' +\n encodeURIComponent(valueElement) +\n '&'\n })\n } else {\n result +=\n encodeURIComponent(key) + '=' + encodeURIComponent(value) + '&'\n }\n }\n\n if (result.length > 0) {\n // eslint-disable-next-line\n result = result.substring(0, result.length - 1)\n }\n\n return result\n }\n}\n\nconst Text = new TextManager()\n\nexport default Text\n","import Type from './type'\n\nlet UA: string = ''\ntry {\n UA = navigator?.userAgent.toLowerCase()\n} catch {\n UA = '?'\n}\n\n/**\n * @see bitrix/js/main/core/src/lib/browser.js\n */\nclass BrowserManager {\n isOpera(): boolean {\n return UA.includes('opera')\n }\n\n isIE(): boolean {\n return 'attachEvent' in document && !this.isOpera()\n }\n\n isIE6(): boolean {\n return UA.includes('msie 6')\n }\n\n isIE7(): boolean {\n return UA.includes('msie 7')\n }\n\n isIE8(): boolean {\n return UA.includes('msie 8')\n }\n\n isIE9(): boolean {\n // @ts-ignore ////\n return 'documentMode' in document && document.documentMode >= 9\n }\n\n isIE10(): boolean {\n // @ts-ignore ////\n return 'documentMode' in document && document.documentMode >= 10\n }\n\n isSafari(): boolean {\n return UA.includes('safari') && !UA.includes('chrome')\n }\n\n isFirefox() {\n return UA.includes('firefox')\n }\n\n isChrome() {\n return UA.includes('chrome')\n }\n\n detectIEVersion() {\n if (\n this.isOpera() ||\n this.isSafari() ||\n this.isFirefox() ||\n this.isChrome()\n ) {\n return -1\n }\n\n let rv = -1\n\n if (\n // @ts-ignore ////\n !!window.MSStream &&\n // @ts-ignore ////\n !window.ActiveXObject &&\n 'ActiveXObject' in window\n ) {\n rv = 11\n } else if (this.isIE10()) {\n rv = 10\n } else if (this.isIE9()) {\n rv = 9\n } else if (this.isIE()) {\n rv = 8\n }\n\n if (rv === -1 || rv === 8) {\n // @ts-ignore ////\n if (navigator.appName === 'Microsoft Internet Explorer') {\n const re = new RegExp('MSIE ([0-9]+[.0-9]*)')\n const res = navigator.userAgent.match(re)\n\n // @ts-ignore ////\n if (Type.isArrayLike(res) && res.length > 0) {\n // @ts-ignore ////\n rv = Number.parseFloat(res[1])\n }\n }\n\n // @ts-ignore ////\n if (navigator.appName === 'Netscape') {\n // Alternative check for IE 11\n rv = 11\n const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)')\n\n if (re.exec(navigator.userAgent) != null) {\n const res = navigator.userAgent.match(re)\n\n // @ts-ignore ////\n if (Type.isArrayLike(res) && res.length > 0) {\n // @ts-ignore ////\n rv = Number.parseFloat(res[1])\n }\n }\n }\n }\n\n return rv\n }\n\n isIE11(): boolean {\n return this.detectIEVersion() >= 11\n }\n\n isMac(): boolean {\n return UA.includes('macintosh')\n }\n\n isWin(): boolean {\n return UA.includes('windows')\n }\n\n isLinux(): boolean {\n return UA.includes('linux') && !this.isAndroid()\n }\n\n isAndroid(): boolean {\n return UA.includes('android')\n }\n\n isIPad(): boolean {\n return UA.includes('ipad;') || (this.isMac() && this.isTouchDevice())\n }\n\n isIPhone(): boolean {\n return UA.includes('iphone;')\n }\n\n isIOS(): boolean {\n return this.isIPad() || this.isIPhone()\n }\n\n isMobile(): boolean {\n return (\n this.isIPhone() ||\n this.isIPad() ||\n this.isAndroid() ||\n UA.includes('mobile') ||\n UA.includes('touch')\n )\n }\n\n isRetina(): boolean {\n return (window.devicePixelRatio && window.devicePixelRatio >= 2) === true\n }\n\n isTouchDevice(): boolean {\n return (\n 'ontouchstart' in window ||\n navigator.maxTouchPoints > 0 ||\n // @ts-ignore ////\n navigator.msMaxTouchPoints > 0\n )\n }\n\n isDoctype(target: any): boolean {\n const doc = target || document\n\n if (doc.compatMode) {\n return doc.compatMode === 'CSS1Compat'\n }\n\n return doc.documentElement && doc.documentElement.clientHeight\n }\n\n isLocalStorageSupported(): boolean {\n try {\n localStorage.setItem('test', 'test')\n localStorage.removeItem('test')\n return true\n } catch {\n return false\n }\n }\n\n detectAndroidVersion(): number {\n const re = new RegExp('Android ([0-9]+[.0-9]*)')\n\n if (re.exec(navigator.userAgent) != null) {\n const res = navigator.userAgent.match(re)\n\n // @ts-ignore ////\n if (Type.isArrayLike(res) && res.length > 0) {\n // @ts-ignore ////\n return Number.parseFloat(res[1])\n }\n }\n\n return 0\n }\n}\n\nconst Browser = new BrowserManager()\n\nexport default Browser\n","import { LoggerBrowser } from '../logger/browser'\nimport { Result } from '../core/result'\nimport { AjaxResult } from '../core/http/ajax-result'\n\nexport type TypeHttp = {\n\tsetLogger(logger: LoggerBrowser): void\n\tgetLogger(): LoggerBrowser\n\n\tbatch(calls: any[] | object, isHaltOnError: boolean, returnAjaxResult: boolean): Promise<Result>\n\n\tcall(method: string, params: object, start: number): Promise<AjaxResult>\n\n\tsetRestrictionManagerParams(params: TypeRestrictionManagerParams): void\n\n\tgetRestrictionManagerParams(): TypeRestrictionManagerParams\n\n\tsetLogTag(logTag?: string): void\n\tclearLogTag(): void\n\n\t/**\n\t * On|Off warning about client-side query execution\n\t * @param {boolean} value\n\t * @param {string} message\n\t */\n\tsetClientSideWarning(value: boolean, message: string): void\n}\n\nexport interface IRequestIdGenerator {\n\tgetRequestId(): string\n\tgetHeaderFieldName(): string\n\tgetQueryStringParameterName(): string\n\tgetQueryStringSdkParameterName(): string\n}\n\nexport type TypeRestrictionManagerParams = {\n\tsleep: number\n\tspeed: number\n\tamount: number\n}\n\nexport const RestrictionManagerParamsBase = {\n\tsleep: 1_000,\n\tspeed: 0.001,\n\tamount: 30,\n} as TypeRestrictionManagerParams\n\n/**\n * @todo Need test\n */\nexport const RestrictionManagerParamsForEnterprise = {\n\tsleep: 600,\n\tspeed: 0.01,\n\tamount: 30 * 5,\n} as TypeRestrictionManagerParams\n","/**\n * CRM Entity Types\n * @link https://dev.1c-bitrix.ru/rest_help/crm/constants.php\n */\nexport enum EnumCrmEntityType {\n\tundefined = 'UNDEFINED',\n\tlead = 'CRM_LEAD',\n\tdeal = 'CRM_DEAL',\n\tcontact = 'CRM_CONTACT',\n\tcompany = 'CRM_COMPANY',\n\toldInvoice = 'CRM_INVOICE',\n\tinvoice = 'CRM_SMART_INVOICE',\n\tquote = 'CRM_QUOTE',\n\trequisite = 'CRM_REQUISITE',\n order = 'ORDER'\n}\n\nexport enum EnumCrmEntityTypeId {\n\tundefined = 0,\n\tlead = 1,\n\tdeal = 2,\n\tcontact = 3,\n\tcompany = 4,\n\toldInvoice = 5,\n\tinvoice = 31,\n\tquote = 7,\n\trequisite = 8,\n order = 14\n}\n\nexport enum EnumCrmEntityTypeShort {\n undefined = '?',\n lead = 'L',\n deal = 'D',\n contact = 'C',\n company = 'CO',\n oldInvoice = 'I',\n invoice = 'SI',\n quote = 'Q',\n requisite = 'RQ',\n order = 'O'\n}\n\n/**\n * @todo add docs\n */\nexport function getEnumCrmEntityTypeShort(id: EnumCrmEntityTypeId): EnumCrmEntityTypeShort {\n const key = EnumCrmEntityTypeId[id] as keyof typeof EnumCrmEntityTypeShort\n return EnumCrmEntityTypeShort[key] || EnumCrmEntityTypeShort.undefined\n}\n","import type { BoolString } from '../common'\nimport { EnumCrmEntityTypeShort } from './entity-type'\nimport { CatalogProductType } from '../catalog'\n\nexport enum ProductRowDiscountTypeId {\n undefined = 0,\n absolute = 1,\n percentage = 2\n}\n\nexport interface CrmItemProductRow {\n id: number\n ownerId: number\n ownerType: typeof EnumCrmEntityTypeShort[keyof typeof EnumCrmEntityTypeShort]\n productId: number\n productName: string\n sort: number\n price: number\n priceAccount: number\n priceExclusive: number\n priceNetto: number\n priceBrutto: number\n customized: BoolString\n quantity: number\n measureCode: string\n measureName: string\n taxRate: number | null\n taxIncluded: BoolString\n discountRate: number\n discountSum: number\n discountTypeId: typeof ProductRowDiscountTypeId[keyof typeof ProductRowDiscountTypeId]\n xmlId: string\n type: typeof CatalogProductType[keyof typeof CatalogProductType]\n storeId: number\n}\n","import type { BoolString, ISODate, TextType } from '../common'\n\n/**\n * Data Types and Object Structure in the REST API Catalog\n * @link https://apidocs.bitrix24.com/api-reference/catalog/data-types.html\n */\n\n\nexport enum CatalogProductType {\n undefined = 0,\n product = 1,\n service = 7,\n sku = 3,\n skuEmpty = 6,\n offer = 4,\n offerEmpty = 5\n}\n\nexport enum CatalogProductImageType {\n undefined = 'UNDEFINED',\n detail = 'DETAIL_PICTURE',\n preview = 'PREVIEW_PICTURE',\n morePhoto = 'MORE_PHOTO'\n}\n\nexport enum CatalogRoundingRuleType {\n undefined = 0,\n mathematical = 1,\n roundingUp = 2,\n roundingDown = 4\n}\n\nexport interface CatalogCatalog {\n id: number\n iblockId: number\n iblockTypeId: string | 'CRM_PRODUCT_CATALOG'\n lid: string\n name: string\n productIblockId?: number\n skuPropertyId?: number\n subscription?: BoolString\n vatId: number\n}\n\ninterface BaseProduct {\n id: number\n iblockId: number\n sort: number\n name: string\n active: BoolString\n available: BoolString\n code: string\n xmlId: string\n barcodeMulti: BoolString\n bundle: BoolString\n canBuyZero?: BoolString\n type: number\n vatId: number\n vatIncluded: BoolString\n weight?: number\n height?: number\n length?: number\n width?: number\n createdBy: number\n modifiedBy: number\n dateActiveFrom?: ISODate\n dateActiveTo?: ISODate\n dateCreate: ISODate\n timestampX: ISODate\n iblockSectionId?: number\n measure?: number\n previewText?: string\n previewTextType?: TextType\n detailText?: string\n detailTextType?: TextType\n previewPicture?: object\n detailPicture?: object\n subscribe: 'Y' | 'N' | 'D'\n quantityTrace: 'Y' | 'N' | 'D'\n purchasingCurrency: string\n purchasingPrice: number\n quantity: number\n quantityReserved: number\n [key: string]: any\n}\n\nexport interface CatalogProduct extends BaseProduct {\n type: CatalogProductType.product\n}\n\nexport interface CatalogProductSku extends BaseProduct {\n type: CatalogProductType.sku | CatalogProductType.skuEmpty\n}\n\nexport interface CatalogProductOffer extends BaseProduct {\n type: CatalogProductType.offer | CatalogProductType.offerEmpty\n}\n\nexport interface CatalogProductService extends Omit<BaseProduct, 'quantityReserved' | 'quantity' | 'purchasingPrice' | 'purchasingCurrency' | 'quantityTrace' | 'subscribe' | 'weight' | 'height' | 'length' | 'width' | 'canBuyZero' | 'barcodeMulti'> {\n type: CatalogProductType.service\n}\n\nexport interface CatalogSection {\n id: number\n xmlId: string\n code: string\n iblockId: number\n sort: number\n iblockSectionId: number\n name: string\n active: BoolString\n description: string\n descriptionType: TextType\n}\n\nexport interface CatalogProductImage {\n id: number\n name: string\n productId: number\n type: typeof CatalogProductImageType[keyof typeof CatalogProductImageType]\n createTime?: ISODate\n downloadUrl?: string\n detailUrl?: string\n}\n\nexport interface CatalogStore {\n id: number\n code: string\n xmlId: string\n sort: number\n address: string\n title: string\n active: BoolString\n description?: string\n gpsN: number\n gpsS: number\n imageId: object\n dateModify: ISODate\n dateCreate: ISODate\n userId: number\n modifiedBy: number\n phone: string\n email: string\n schedule: string\n issuingCenter: BoolString\n}\n\nexport interface CatalogMeasure {\n id: number\n code: string\n isDefault: BoolString\n measureTitle: string\n symbol: string\n symbolIntl: string\n symbolLetterIntl: string\n}\n\nexport interface CatalogRatio {\n id: number\n productId: number\n ratio: number\n isDefault: BoolString\n}\n\nexport interface CatalogPriceType {\n id: number\n xmlId: string\n sort: number\n name: string\n base: BoolString\n createdBy: number\n modifiedBy: number\n dateCreate: ISODate\n timestampX: ISODate\n}\n\nexport interface CatalogVat {\n id: number\n name: string\n active: BoolString\n rate: number\n sort: number\n timestampX: ISODate\n}\n\nexport interface CatalogPriceTypeLang {\n id: number\n catalogGroupId: number\n name: string\n lang: string\n}\n\nexport interface CatalogLanguage {\n lid: string\n name: string\n active: BoolString\n}\n\nexport interface CatalogRoundingRule {\n id: number\n catalogGroupId: number\n price: number\n roundType: typeof CatalogRoundingRuleType[keyof typeof CatalogRoundingRuleType]\n roundPrecision: number\n createdBy: number\n modifiedBy: number\n dateCreate: ISODate\n dateModify: ISODate\n}\n\nexport interface CatalogExtra {\n id: number\n name: string\n percentage: number\n}\n","/**\n * Data Types and Object Structure in the REST API bizproc\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/bizproc-activity-add.html\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-robot/bizproc-robot-add.html\n * @todo add docs\n */\nimport { EnumCrmEntityTypeId } from '../crm'\n\n/**\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/bizproc-activity-add.html\n */\nexport enum EnumBitrix24Edition {\n undefined = 'undefined',\n b24 = 'b24',\n box = 'box'\n}\n\nexport enum EnumBizprocBaseType {\n undefined = 'undefined',\n crm = 'crm',\n disk = 'disk',\n lists = 'lists'\n}\n\n/**\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-workflow-start.html\n */\nexport enum EnumBizprocDocumentType {\n undefined = 'undefined',\n lead = 'CCrmDocumentLead',\n company = 'CCrmDocumentCompany',\n contact = 'CCrmDocumentContact',\n deal = 'CCrmDocumentDeal',\n invoice = 'Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\SmartInvoice',\n quote = 'Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\Quote',\n order = 'Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\Order',\n dynamic = 'Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\Dynamic',\n disk = 'Bitrix\\\\Disk\\\\BizProcDocument',\n lists = 'BizprocDocument',\n listsList = 'Bitrix\\\\Lists\\\\BizprocDocumentLists'\n}\n\nexport function convertBizprocDocumentTypeToCrmEntityTypeId(\n documentType: EnumBizprocDocumentType\n): EnumCrmEntityTypeId {\n switch (documentType) {\n case EnumBizprocDocumentType.lead:\n return EnumCrmEntityTypeId.lead\n case EnumBizprocDocumentType.company:\n return EnumCrmEntityTypeId.company\n case EnumBizprocDocumentType.contact:\n return EnumCrmEntityTypeId.contact\n case EnumBizprocDocumentType.deal:\n return EnumCrmEntityTypeId.deal\n case EnumBizprocDocumentType.invoice:\n return EnumCrmEntityTypeId.invoice\n case EnumBizprocDocumentType.quote:\n return EnumCrmEntityTypeId.quote\n case EnumBizprocDocumentType.order:\n return EnumCrmEntityTypeId.order\n }\n\n return EnumCrmEntityTypeId.undefined\n}\n\n/**\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-activity/bizproc-activity-add.html\n */\nexport function getDocumentType(\n documentType: EnumBizprocDocumentType,\n entityId?: number\n): string[] {\n let entityIdFormatted = ''\n let base: EnumBizprocBaseType = EnumBizprocBaseType.undefined\n switch (documentType) {\n case EnumBizprocDocumentType.lead: base = EnumBizprocBaseType.crm; entityIdFormatted = 'LEAD'; break;\n case EnumBizprocDocumentType.company: base = EnumBizprocBaseType.crm; entityIdFormatted = 'COMPANY'; break;\n case EnumBizprocDocumentType.contact: base = EnumBizprocBaseType.crm; entityIdFormatted = 'CONTACT'; break;\n case EnumBizprocDocumentType.deal: base = EnumBizprocBaseType.crm; entityIdFormatted = 'DEAL'; break;\n case EnumBizprocDocumentType.invoice: base = EnumBizprocBaseType.crm; entityIdFormatted = 'SMART_INVOICE'; break;\n case EnumBizprocDocumentType.quote: base = EnumBizprocBaseType.crm; entityIdFormatted = 'QUOTE'; break;\n case EnumBizprocDocumentType.order: base = EnumBizprocBaseType.crm; entityIdFormatted = 'ORDER'; break;\n case EnumBizprocDocumentType.dynamic: base = EnumBizprocBaseType.crm; entityIdFormatted = `DYNAMIC_${entityId || 0}`; if ((entityId || 0) < 1) { throw new Error('Need set entityId'); } break;\n case EnumBizprocDocumentType.disk: base = EnumBizprocBaseType.disk; entityIdFormatted = `STORAGE_${entityId || 0}`; if ((entityId || 0) < 1) { throw new Error('Need set entityId'); } break;\n case EnumBizprocDocumentType.lists: base = EnumBizprocBaseType.lists; entityIdFormatted = `iblock_${entityId || 0}`; if ((entityId || 0) < 1) { throw new Error('Need set entityId'); } break;\n case EnumBizprocDocumentType.listsList: base = EnumBizprocBaseType.lists; entityIdFormatted = `iblock_${entityId || 0}`; if ((entityId || 0) < 1) { throw new Error('Need set entityId'); } break;\n }\n\n return [\n base,\n documentType,\n entityIdFormatted\n ]\n}\n\n/**\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-workflow-start.html\n */\nexport function getDocumentId(\n documentType: EnumBizprocDocumentType,\n id: number,\n dynamicId?: number\n): string[] {\n let entityIdFormatted = ''\n const tmp = getDocumentType(documentType, 1)\n switch (documentType) {\n case EnumBizprocDocumentType.lead: entityIdFormatted = `LEAD_${id}`; break;\n case EnumBizprocDocumentType.company: entityIdFormatted = `COMPANY_${id}`; break;\n case EnumBizprocDocumentType.contact: entityIdFormatted = `CONTACT_${id}`; break;\n case EnumBizprocDocumentType.deal: entityIdFormatted = `DEAL_${id}`; break;\n case EnumBizprocDocumentType.invoice: entityIdFormatted = `SMART_INVOICE_${id}`; break;\n case EnumBizprocDocumentType.quote: entityIdFormatted = `QUOTE_${id}`; break;\n case EnumBizprocDocumentType.order: entityIdFormatted = `ORDER_${id}`; break;\n case EnumBizprocDocumentType.dynamic: entityIdFormatted = `DYNAMIC_${dynamicId || 0}_${id}`; if ((dynamicId || 0) < 1) { throw new Error('Need set dynamicId'); } break;\n case EnumBizprocDocumentType.disk: entityIdFormatted = `${id}`; break;\n case EnumBizprocDocumentType.lists: entityIdFormatted = `${id}`; break;\n case EnumBizprocDocumentType.listsList: entityIdFormatted = `${id}`; break;\n }\n\n return [\n tmp[0],\n tmp[1],\n entityIdFormatted\n ]\n}\n\n/**\n * @link https://apidocs.bitrix24.com/api-reference/bizproc/bizproc-workflow-start.html\n */\nexport function getDocumentTypeForFilter(\n documentType: EnumBizprocDocumentType\n): string[] {\n const result = getDocumentType(documentType, 1)\n\n return [\n result[0],\n result[1]\n ]\n}\n","import { DateTime } from 'luxon'\n\nimport type { BoolString, GenderString } from './common'\n\nexport enum LoadDataType {\n App = 'app',\n Profile = 'profile',\n Currency = 'currency',\n AppOptions = 'appOptions',\n UserOptions = 'userOptions',\n}\n\nexport type TypeUser = {\n readonly isAdmin: boolean\n\n readonly id: null | number\n readonly lastName: null | string\n readonly name: null | string\n\n readonly gender: GenderString\n\n readonly photo: null | string\n\n readonly TimeZone: null | string\n readonly TimeZoneOffset: null | number\n}\n\nexport const EnumAppStatus = {\n // free ////\n Free: 'F',\n\n // demo version ////\n Demo: 'D',\n\n // trial version (limited time) ////\n Trial: 'T',\n\n // paid application ////\n Paid: 'P',\n\n // local application ////\n Local: 'L',\n\n // subscription application ////\n Subscription: 'S',\n} as const\n\nexport const StatusDescriptions: Record<(typeof EnumAppStatus)[keyof typeof EnumAppStatus], string> = {\n [EnumAppStatus.Free]: 'Free',\n [EnumAppStatus.Demo]: 'Demo',\n [EnumAppStatus.Trial]: 'Trial',\n [EnumAppStatus.Paid]: 'Paid',\n [EnumAppStatus.Local]: 'Local',\n [EnumAppStatus.Subscription]: 'Subscription',\n}\n\nexport type TypeEnumAppStatus = keyof typeof EnumAppStatus\n\n/**\n * @link https://dev.1c-bitrix.ru/rest_help/general/app_info.php\n */\nexport type TypeApp = {\n /**\n * Local application identifier on the portal\n */\n readonly id: number\n\n /**\n * application code\n */\n readonly code: string\n\n /**\n * installed version of the application\n */\n readonly version: number\n\n /**\n * application status\n */\n readonly status: TypeEnumAppStatus\n\n /**\n * application installed flag\n */\n readonly isInstalled: boolean\n}\n\n/**\n * @link https://dev.1c-bitrix.ru/rest_help/general/app_info.php\n */\nexport type TypePayment = {\n /**\n * flag indicating whether the paid period or trial period has expired\n */\n readonly isExpired: boolean\n\n /**\n * number of days remaining until the end of the paid period or trial period\n */\n readonly days: number\n}\n\n/**\n * @link https://dev.1c-bitrix.ru/rest_help/general/app_info.php\n */\nexport type TypeLicense = {\n /**\n * language code designation\n */\n readonly languageId: null | string\n /**\n * tariff designation with indication of the region as a prefix\n */\n readonly license: null | string\n\n /**\n * internal tariff designation without indication of region\n */\n readonly licenseType: null | string\n\n /**\n * past meaning of license\n */\n readonly licensePrevious: null | string\n\n /**\n * Tariff designation without specifying the region.\n */\n readonly licenseFamily: null | string\n\n /**\n * flag indicat