@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
1 lines • 3.47 kB
Source Map (JSON)
{"version":3,"file":"abstract-action.mjs","sources":["../../../../src/core/actions/abstract-action.ts"],"sourcesContent":["import type { TypeB24 } from '../../types/b24'\nimport type { LoggerInterface } from '../../types/logger'\n\n/**\n * Abstract Class for working with actions\n */\n\nexport type ActionOptions = {\n [key: string]: any\n}\n\nexport abstract class AbstractAction {\n protected _b24: TypeB24\n protected _logger: LoggerInterface\n\n constructor(b24: TypeB24, logger: LoggerInterface) {\n this._b24 = b24\n this._logger = logger\n }\n\n /**\n * Warns when an option that belongs inside a nested bag was passed at the top\n * level, where it is read by nobody.\n *\n * The action option types no longer carry an index signature, so a TypeScript\n * caller writing an object literal gets a compile error instead. This covers\n * everyone else: JavaScript callers, a literal widened through a variable, and\n * anything crossing a `JSON.parse` boundary. Without it the call simply\n * behaves as though the flag were never set — and a dropped\n * `returnAjaxResult` turns a batch where every command succeeded into one that\n * reads as wholly failed, because `isSuccess` on a raw payload is `undefined`\n * (#426).\n *\n * @param options the argument as received\n * @param nestedKeys names that belong in the nested bag\n * @param nestedName the bag they belong in, for the message\n */\n protected _warnMisplacedOptions(\n options: object | undefined,\n nestedKeys: readonly string[],\n nestedName: string\n ): void {\n if (!options) return\n\n const misplaced = nestedKeys.filter(key => Object.hasOwn(options, key))\n if (misplaced.length === 0) return\n\n // `.catch(() => {})`, not `void`: an unawaited rejected logger promise is an\n // unhandled rejection, which Node terminates the process on by default, and\n // a custom `LoggerInterface` doing real I/O is exactly what rejects (#346).\n // `local/require-catch-on-logger-call` does not see through a `void`, so it\n // would not have caught this.\n this._logger.warning(\n `[b24jssdk] ${misplaced.join(', ')} passed at the top level `\n + `${misplaced.length === 1 ? 'is' : 'are'} ignored — `\n + `${misplaced.length === 1 ? 'it belongs' : 'they belong'} in \\`${nestedName}\\`. `\n + `Write \\`${nestedName}: { ${misplaced.join(', ')} }\\`.`\n ).catch(() => {})\n }\n\n public abstract make(options?: ActionOptions): AsyncGenerator | Promise<unknown>\n}\n"],"names":[],"mappings":";;;;;;;;;;AAWO,MAAe,cAAA,CAAe;AAAA,EAXrC;AAWqC,IAAA,MAAA,CAAA,IAAA,EAAA,gBAAA,CAAA;AAAA;AAAA,EACzB,IAAA;AAAA,EACA,OAAA;AAAA,EAEV,WAAA,CAAY,KAAc,MAAA,EAAyB;AACjD,IAAA,IAAA,CAAK,IAAA,GAAO,GAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBU,qBAAA,CACR,OAAA,EACA,UAAA,EACA,UAAA,EACM;AACN,IAAA,IAAI,CAAC,OAAA,EAAS;AAEd,IAAA,MAAM,SAAA,GAAY,WAAW,MAAA,CAAO,CAAA,GAAA,KAAO,OAAO,MAAA,CAAO,OAAA,EAAS,GAAG,CAAC,CAAA;AACtE,IAAA,IAAI,SAAA,CAAU,WAAW,CAAA,EAAG;AAO5B,IAAA,IAAA,CAAK,OAAA,CAAQ,OAAA;AAAA,MACX,CAAA,WAAA,EAAc,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,4BAC7B,SAAA,CAAU,MAAA,KAAW,CAAA,GAAI,IAAA,GAAO,KAAK,CAAA,gBAAA,EACrC,UAAU,MAAA,KAAW,CAAA,GAAI,YAAA,GAAe,aAAa,CAAA,MAAA,EAAS,UAAU,CAAA,YAAA,EAChE,UAAU,CAAA,IAAA,EAAO,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,CAAA,KAAA;AAAA,KACpD,CAAE,MAAM,MAAM;AAAA,IAAC,CAAC,CAAA;AAAA,EAClB;AAGF;;;;"}