mattrguerra/meridian-ops-boardmainPrivate on GitHub, published here in full

index.ts

Language TypeScript1.4 KB45 lines

packages/bitrix-client/src/index.ts

  1. export {
  2. BitrixClient,
  3. BitrixError,
  4. BitrixRateLimitError,
  5. BitrixOperationTimeError,
  6. type BitrixOptions,
  7. type BitrixResponse,
  8. } from './http.js'
  9. export { LeadsResource, normalizeLead, isLikelyNoise, type Lead, type RawLead , type StageSemantic } from './leads.js'
  10. export {
  11. TasksResource,
  12. normalizeTask,
  13. isJunkTask,
  14. partitionTasks,
  15. type Task,
  16. type RawTask,
  17. } from './tasks.js'
  18. /**
  19. * Tariff limits, for reference. We throttle well below these.
  20. *
  21. * Standard: 2 req/sec drain, burst 50
  22. * Enterprise: 5 req/sec drain, burst 250
  23. *
  24. * Same-IP applications share the quota, so the cron and the MCP connector are
  25. * not independent even though their token buckets are.
  26. */
  27. export const BITRIX_TARIFF_LIMITS = {
  28. standard: { drainPerSecond: 2, burst: 50 },
  29. enterprise: { drainPerSecond: 5, burst: 250 },
  30. } as const
  31. export function clientFromEnv(env: Record<string, string | undefined>) {
  32. const url = env.BITRIX_WEBHOOK_URL
  33. if (!url) {
  34. throw new Error(
  35. 'BITRIX_WEBHOOK_URL is not set. Create an inbound webhook in Bitrix ' +
  36. '(Developer resources > Other > Inbound webhook) with crm read scope, and put the ' +
  37. 'full URL in your shell profile. This repo has no .env reader; see ' +
  38. 'credentials.example.sh. Grant read scope only: a read-only credential is a ' +
  39. 'stronger guarantee than read-only code.',
  40. )
  41. }
  42. return { url }
  43. }