UNPKG

@accounter/server

Version:
35 lines (34 loc) 2.42 kB
import type { PoalimForeignTransactionInput, PoalimIlsTransactionInput, PoalimSecurityInput, PoalimSecurityTransactionInput, PoalimSwiftTransactionInput, ScraperUploadResult } from '../../../__generated__/types.js'; import { TenantAwareDBClient } from '../../app-providers/tenant-db-client.js'; import { AuthContextProvider } from '../../auth/providers/auth-context.provider.js'; import { SecurityBusinessesProvider } from '../../foreign-securities/providers/security-businesses.provider.js'; export declare class PoalimScraperIngestionProvider { private db; private authContextProvider; private securityBusinessesProvider; private businessIdCache; constructor(db: TenantAwareDBClient, authContextProvider: AuthContextProvider, securityBusinessesProvider: SecurityBusinessesProvider); /** * Give every security in the payload a business of its own, and record the Poalim key it is * known by here. * * Driven off the whole validated payload rather than only the newly inserted rows: a * re-scrape inserts nothing, but a security whose business was never created (ingested * before this existed, or created while an earlier scrape failed here) still needs one. * Both steps are idempotent, and `ensureSecurityBusinesses` settles the whole payload with a * single lookup, so a repeat scrape costs one query rather than one per security. * * Rows with no ISIN are skipped: the ISIN is the identity, and one cannot be invented from * the Poalim key alone. Those securities stay unlinked and are assigned by hand. * * Failures are logged rather than thrown: the executions are already stored, and reporting * the upload as failed would be a lie. The next scrape repairs the gap. */ private ensureSecurityBusinesses; private getBusinessId; uploadPoalimIlsTransactions(transactions: readonly PoalimIlsTransactionInput[]): Promise<ScraperUploadResult>; uploadPoalimForeignTransactions(transactions: readonly PoalimForeignTransactionInput[]): Promise<ScraperUploadResult>; uploadPoalimSwiftTransactions(swifts: readonly PoalimSwiftTransactionInput[]): Promise<ScraperUploadResult>; uploadPoalimSecurities(securities: readonly PoalimSecurityInput[]): Promise<ScraperUploadResult>; uploadPoalimSecuritiesTransactions(transactions: readonly PoalimSecurityTransactionInput[]): Promise<ScraperUploadResult>; }