Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-ollama-crontab/llms.txt
Use this file to discover all available pages before exploring further.
ParserService is the generic field-extraction engine at the heart of the pipeline’s ingestion layer. It receives raw ScraperMessage objects — plain text scraped from a Telegram channel — together with a typed FieldMapping that describes how each field should be extracted, transformed, and validated using regular expressions. The result is a ParserMessageBase array where each entry either carries a fully structured data object or null when the message did not match the expected signal format. Because ParserService is format-agnostic, the same engine powers every channel-specific screen service; CryptoYodaScreenService passes its own SIGNAL_FORMAT map while future channels need only supply a different format object.
ParserService
ParserService is registered under TYPES.parserService in the DI container.
Methods
parseDay
Processes a list of scraped messages against a field-mapping format and returns augmented message objects.
Raw messages from
ScraperService.scrapeDay. Each item must provide:id: number— Telegram message IDchannel: string— source channel identifiercontent: string— raw message text to parsedate: Date— original publication timestamp
A
FieldMapping record mapping field names to either a bare RegExp or a
full ExtractConfig<T> descriptor. Every key in format becomes a key in
the returned data object. See FieldMapping and ExtractConfig below.One entry per input message. Each entry extends
ScraperMessage with an
additional data field:data: ExtractedData<M>— all fields successfully extracteddata: null— at least one required field failed to match or validate
Normalize the spec
Each
format entry is coerced from RegExp | ExtractConfig to a full
ExtractConfig object via the internal TO_CONFIG_FN helper. A bare
RegExp becomes { pattern } with all other options defaulting.Extract each field
EXTRACT_DATA_FN(msg.content, format) is called. For each key in
format:- Single field (
multiabsent orfalse): runstext.match(cfg.pattern), readsmatch[cfg.group ?? 1], appliestransform, checksvalidate. Returnsnullfor the whole message if the match fails andoptionalis not set. - Multi field (
multi: true, pattern must be global): runstext.matchAll(cfg.pattern), maps each match throughtransform, validates every value. Returnsnullif no matches andoptionalis not set. - Optional field (
optional: true): if no match is found the key is simply omitted from the result object instead of aborting.
Log the preview
Each message content is truncated to 64 characters, newlines replaced with
spaces, and logged alongside the extracted result for debugging.
Type Reference
ExtractConfig<T>
Defined in model/ParseFormat.model.ts. Describes how a single field is extracted from raw text.
The regular expression to match against the message text. Must include the
g flag when multi: true.Capture group index to read from the match array. Defaults to
1. Use 0
to read the full match string.Optional mapping function applied to the raw captured string before
validation and storage. Receives both the raw string and the full match
array so complex shapes (e.g.
{ from, to } objects) can be constructed
from multiple groups.Optional predicate run after
transform. Returning false causes the
entire message to parse as null (unless optional: true).When
true, text.matchAll(pattern) is used instead of text.match. The
field value becomes an array of transformed matches. The pattern must
have the g flag; the parser throws otherwise.When
true, a missing match does not abort extraction. The key is omitted
from the result object rather than returning null for the whole message.FieldMapping
RegExp (equivalent to { pattern: rx }) or a full ExtractConfig.
ParseFormat<T>
A stricter variant of FieldMapping that binds each key’s config type to the corresponding value type in T. Used when you want TypeScript to enforce that your ExtractConfig transforms produce the right output type.
ExtractedData<M>
The mapped output type inferred from a FieldMapping. multi: true fields become arrays.
ScraperMessage
Defined in model/ScraperMessage.model.ts. The raw input type for parseDay.
ParserMessageBase<M>
Defined in model/ParserMessage.model.ts. The output type of parseDay.
ParserMessage<M, T> variant additionally carries a type: T discriminant string, used by channel screen services to tag messages with their source channel:
Practical Example: Defining a Format for a New Channel
Below is a self-contained example showing how to define aParseFormat for a hypothetical new signal channel, mirroring the structure used by CryptoYodaScreenService’s SIGNAL_FORMAT.
Error Handling
EXTRACT_DATA_FN returns null — not throws — when a required field fails to match or validate. The parseDay wrapper catches no errors; any exception propagates up. The only explicit throw in the parser is the multi + non-global pattern guard.
CrawlerService
Orchestrates
screenDay calls and upserts parsed messages to
parser-items.SignalJobService
Consumes
parser-items rows and pipes them through the LLM risk outline.