@databolsa/sdk 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CorporateEventsResponse, CryptoQuotesResponse, DividendsResponse, DocumentsResponse, EtfListResponse, EtfProfile, ExpectationsResponse, Fii, FiiDistributionsResponse, FiiIndicatorsResponse, FiiReportsResponse, FiiScreenResponse, FundHoldersResponse, FundHoldingsResponse, FundListResponse, FundProfile, FundQuotesResponse, FundScreenerResponse, HealthResponse, IngestHealthResponse, IndexCompositionResponse, IndexMeta, IndexQuotesResponse, IndicatorHistoryResponse, IntradaySeriesResponse, LiveQuotesResponse, BdrListResponse, BdrProfile, BdrQuotesResponse, InsiderResponse, InvestorFlowMonthlyResponse, InvestorFlowResponse, MacroGearsResponse, OfferingsResponse, OptionExpiriesResponse, OptionsChainResponse, OptionsQuotesResponse, Query, QuotesResponse, RangeParams, RegimeSnapshot, ScreenStocksResponse, SearchResult, SeriesResponse, Stock, StockIndicatorsResponse, TesouroBondsResponse, TradeStatsResponse, YieldCurveResponse } from "./types";
1
+ import type { CorporateEventsResponse, CryptoQuotesResponse, DividendsResponse, DocumentsResponse, EtfListResponse, EtfProfile, ExpectationsResponse, Fii, FiiDistributionsResponse, FiiIndicatorsResponse, FiiReportsResponse, FiiScreenResponse, FundHoldersResponse, FundHoldingsResponse, FundListResponse, FundProfile, FundQuotesResponse, FundScreenerResponse, HealthResponse, IngestHealthResponse, IndexCompositionResponse, IndexMeta, IndexQuotesResponse, IndicatorHistoryResponse, IntradaySeriesResponse, LiveQuotesResponse, BdrListResponse, BdrProfile, BdrQuotesResponse, InsiderResponse, InvestorFlowMonthlyResponse, InvestorFlowResponse, MacroGearsResponse, OfferingsResponse, OptionExpiriesResponse, OptionsChainResponse, OptionsQuotesResponse, DocumentSearchResponse, PortfolioResponse, Query, QuotesResponse, RangeParams, RegimeSnapshot, ScreenStocksResponse, SearchDocumentsParams, SearchResult, SeriesResponse, Stock, StockIndicatorsResponse, SuitabilityResponse, TesouroBondsResponse, TradeStatsResponse, YieldCurveResponse } from "./types";
2
2
  /** Filtros do screener de ações — derivados de `GET /v1/screener/stocks`. */
3
3
  export type ScreenStocksParams = Query<"screenStocks">;
4
4
  /**
@@ -187,6 +187,18 @@ export interface DataBolsaClient {
187
187
  search(q: string, params?: {
188
188
  limit?: number;
189
189
  }): Promise<SearchResult[]>;
190
+ /**
191
+ * Sua carteira consolidada: patrimônio, posições, preço médio, P&L, alocação.
192
+ * Escopada ao dono da chave de API (a mesma da conta) — passe sua chave por usuário.
193
+ */
194
+ getPortfolio(): Promise<PortfolioResponse>;
195
+ /** Seu perfil de investidor (suitability). `profile` é nulo se ainda não definido. */
196
+ getSuitability(): Promise<SuitabilityResponse>;
197
+ /**
198
+ * Busca semântica no texto de documentos CVM/B3 (fatos relevantes, releases,
199
+ * balanços, relatórios de FII, atas). Filtre por papel/categoria/ano quando souber.
200
+ */
201
+ searchDocuments(q: string, params?: SearchDocumentsParams): Promise<DocumentSearchResponse>;
190
202
  }
191
203
  export declare class NotInPreviewError extends Error {
192
204
  readonly entity: string;
@@ -1,5 +1,5 @@
1
1
  import { type DataBolsaClient, type LiveQuotesParams, type ScreenFiisParams, type ScreenFundsParams, type ScreenStocksParams } from "./client";
2
- import type { CorporateEventsResponse, CryptoQuotesResponse, DividendsResponse, DocumentsResponse, EtfListResponse, EtfProfile, ExpectationsResponse, Fii, FiiDistributionsResponse, FiiIndicatorsResponse, FiiReportsResponse, FiiScreenResponse, FundHoldersResponse, FundHoldingsResponse, FundListResponse, FundProfile, FundQuotesResponse, FundScreenerResponse, HealthResponse, IngestHealthResponse, IndexCompositionResponse, IndexMeta, IndexQuotesResponse, IndicatorHistoryResponse, IntradaySeriesResponse, LiveQuotesResponse, BdrListResponse, BdrProfile, BdrQuotesResponse, InsiderResponse, InvestorFlowMonthlyResponse, InvestorFlowResponse, MacroGearsResponse, OfferingsResponse, OptionExpiriesResponse, OptionsChainResponse, OptionsQuotesResponse, QuotesResponse, RangeParams, RegimeSnapshot, ScreenStocksResponse, SearchResult, SeriesResponse, Stock, StockIndicatorsResponse, TesouroBondsResponse, TradeStatsResponse, YieldCurveResponse } from "./types";
2
+ import type { CorporateEventsResponse, CryptoQuotesResponse, DividendsResponse, DocumentSearchResponse, DocumentsResponse, EtfListResponse, EtfProfile, ExpectationsResponse, Fii, FiiDistributionsResponse, FiiIndicatorsResponse, FiiReportsResponse, FiiScreenResponse, FundHoldersResponse, FundHoldingsResponse, FundListResponse, FundProfile, FundQuotesResponse, FundScreenerResponse, HealthResponse, IngestHealthResponse, IndexCompositionResponse, IndexMeta, IndexQuotesResponse, IndicatorHistoryResponse, IntradaySeriesResponse, LiveQuotesResponse, BdrListResponse, BdrProfile, BdrQuotesResponse, InsiderResponse, InvestorFlowMonthlyResponse, InvestorFlowResponse, MacroGearsResponse, OfferingsResponse, OptionExpiriesResponse, OptionsChainResponse, OptionsQuotesResponse, PortfolioResponse, QuotesResponse, RangeParams, RegimeSnapshot, ScreenStocksResponse, SearchDocumentsParams, SearchResult, SeriesResponse, Stock, StockIndicatorsResponse, SuitabilityResponse, TesouroBondsResponse, TradeStatsResponse, YieldCurveResponse } from "./types";
3
3
  /**
4
4
  * Cliente HTTP da Serving API do DataBolsa. Os métodos públicos espelham os
5
5
  * operationIds do OpenAPI e retornam tipos gerados.
@@ -161,4 +161,7 @@ export declare class HttpClient implements DataBolsaClient {
161
161
  search(q: string, params?: {
162
162
  limit?: number;
163
163
  }): Promise<SearchResult[]>;
164
+ getPortfolio(): Promise<PortfolioResponse>;
165
+ getSuitability(): Promise<SuitabilityResponse>;
166
+ searchDocuments(q: string, params?: SearchDocumentsParams): Promise<DocumentSearchResponse>;
164
167
  }
package/dist/index.js CHANGED
@@ -356,6 +356,22 @@ class HttpClient {
356
356
  search(q, params) {
357
357
  return this.request("/search", { q, limit: params?.limit });
358
358
  }
359
+ getPortfolio() {
360
+ return this.request("/portfolio");
361
+ }
362
+ getSuitability() {
363
+ return this.request("/suitability");
364
+ }
365
+ searchDocuments(q, params) {
366
+ return this.request("/documents/search", {
367
+ q,
368
+ tickers: Array.isArray(params?.tickers) ? params?.tickers.join(",") : params?.tickers,
369
+ category: params?.category,
370
+ year: params?.year,
371
+ tables_only: params?.tablesOnly === true ? "true" : undefined,
372
+ limit: params?.limit
373
+ });
374
+ }
359
375
  }
360
376
  function enc(segment) {
361
377
  return encodeURIComponent(segment);
package/dist/schema.d.ts CHANGED
@@ -947,6 +947,66 @@ export interface paths {
947
947
  patch?: never;
948
948
  trace?: never;
949
949
  };
950
+ "/v1/portfolio": {
951
+ parameters: {
952
+ query?: never;
953
+ header?: never;
954
+ path?: never;
955
+ cookie?: never;
956
+ };
957
+ /**
958
+ * Sua carteira (consolidada)
959
+ * @description Retorna a carteira consolidada do dono da chave de API: patrimônio, total investido, P&L realizado e não-realizado, variação do dia, composição por classe, maiores posições e quebra por carteira. Exige uma chave de API por usuário (crie em https://databolsa.com/conta).
960
+ */
961
+ get: operations["getPortfolio"];
962
+ put?: never;
963
+ post?: never;
964
+ delete?: never;
965
+ options?: never;
966
+ head?: never;
967
+ patch?: never;
968
+ trace?: never;
969
+ };
970
+ "/v1/suitability": {
971
+ parameters: {
972
+ query?: never;
973
+ header?: never;
974
+ path?: never;
975
+ cookie?: never;
976
+ };
977
+ /**
978
+ * Seu perfil de investidor
979
+ * @description Retorna o perfil de investidor (suitability) do dono da chave: nível (Conservador/Moderado/Arrojado), a posição na régua 0–100 (não é uma nota) e as respostas do questionário. `profile` é nulo se o usuário ainda não definiu o perfil.
980
+ */
981
+ get: operations["getSuitability"];
982
+ put?: never;
983
+ post?: never;
984
+ delete?: never;
985
+ options?: never;
986
+ head?: never;
987
+ patch?: never;
988
+ trace?: never;
989
+ };
990
+ "/v1/documents/search": {
991
+ parameters: {
992
+ query?: never;
993
+ header?: never;
994
+ path?: never;
995
+ cookie?: never;
996
+ };
997
+ /**
998
+ * Busca semântica em documentos
999
+ * @description Busca semântica no TEXTO de documentos CVM/B3 (fatos relevantes, releases de resultado, balanços, relatórios gerenciais de FII, atas de assembleia). Ideal para perguntas qualitativas que os dados estruturados não respondem. Filtre por papel, categoria e ano quando souber.
1000
+ */
1001
+ get: operations["searchDocuments"];
1002
+ put?: never;
1003
+ post?: never;
1004
+ delete?: never;
1005
+ options?: never;
1006
+ head?: never;
1007
+ patch?: never;
1008
+ trace?: never;
1009
+ };
950
1010
  }
951
1011
  export type webhooks = Record<string, never>;
952
1012
  export interface components {
@@ -1245,6 +1305,15 @@ export interface components {
1245
1305
  sell_rate: number | null;
1246
1306
  buy_price: number | null;
1247
1307
  sell_price: number | null;
1308
+ is_negotiable: boolean | null;
1309
+ /** @enum {string|null} */
1310
+ coupon: "unique" | "semiannual" | "monthly" | null;
1311
+ min_investment: number | null;
1312
+ live_buy_rate: number | null;
1313
+ live_sell_rate: number | null;
1314
+ live_buy_price: number | null;
1315
+ live_sell_price: number | null;
1316
+ priced_at: string | null;
1248
1317
  };
1249
1318
  IndexMeta: {
1250
1319
  code: string;
@@ -1521,6 +1590,72 @@ export interface components {
1521
1590
  rows: number;
1522
1591
  duration_s: number | null;
1523
1592
  };
1593
+ PortfolioHolding: {
1594
+ symbol: string;
1595
+ assetType: string;
1596
+ qty: number;
1597
+ weightPct?: number | null;
1598
+ marketValue?: number | null;
1599
+ unrealizedPct?: number | null;
1600
+ };
1601
+ PortfolioByCarteira: {
1602
+ name: string;
1603
+ patrimonio: number;
1604
+ unrealizedPct: number;
1605
+ assets: number;
1606
+ };
1607
+ /** @description Carteira consolidada do usuário (mesmo resumo que o agente de IA usa). */
1608
+ PortfolioContext: {
1609
+ hasPortfolio: boolean;
1610
+ carteiras: number;
1611
+ patrimonio: number;
1612
+ invested: number;
1613
+ unrealizedPL: number;
1614
+ unrealizedPct: number;
1615
+ realizedPL: number;
1616
+ dayChangeBrl: number;
1617
+ kindMix: string;
1618
+ anyUnpriced: boolean;
1619
+ topHoldings: components["schemas"]["PortfolioHolding"][];
1620
+ byCarteira: components["schemas"]["PortfolioByCarteira"][];
1621
+ };
1622
+ SuitabilityProfile: {
1623
+ /** @enum {string} */
1624
+ level: "Conservador" | "Moderado" | "Arrojado";
1625
+ /** @description Posição na régua 0–100 (Conservador→Arrojado), não uma nota. */
1626
+ score: number;
1627
+ answers: {
1628
+ q: string;
1629
+ a: string;
1630
+ }[];
1631
+ updatedAt: string;
1632
+ };
1633
+ SuitabilityEnvelope: {
1634
+ profile: components["schemas"]["SuitabilityProfile"] | null;
1635
+ };
1636
+ DocumentChunk: {
1637
+ text: string;
1638
+ /** @description Entorno costurado (context-expansion), quando disponível. */
1639
+ text_expanded?: string;
1640
+ ticker?: string | null;
1641
+ company_name?: string | null;
1642
+ doc_category?: string | null;
1643
+ doc_type?: string | null;
1644
+ reference_date?: string | null;
1645
+ page_start?: number | null;
1646
+ download_url?: string | null;
1647
+ heading_path?: string | null;
1648
+ is_table?: boolean | null;
1649
+ /** @description Similaridade (1 - distância cosseno). */
1650
+ score?: number;
1651
+ };
1652
+ DocumentSearchResponse: {
1653
+ query: string;
1654
+ count: number;
1655
+ chunks: components["schemas"]["DocumentChunk"][];
1656
+ /** @description Bloco pronto p/ prompt, com citação por trecho. */
1657
+ context: string;
1658
+ };
1524
1659
  };
1525
1660
  responses: never;
1526
1661
  parameters: never;
@@ -3523,4 +3658,104 @@ export interface operations {
3523
3658
  };
3524
3659
  };
3525
3660
  };
3661
+ getPortfolio: {
3662
+ parameters: {
3663
+ query?: never;
3664
+ header?: never;
3665
+ path?: never;
3666
+ cookie?: never;
3667
+ };
3668
+ requestBody?: never;
3669
+ responses: {
3670
+ /** @description Carteira consolidada do usuário. */
3671
+ 200: {
3672
+ headers: {
3673
+ [name: string]: unknown;
3674
+ };
3675
+ content: {
3676
+ "application/json": components["schemas"]["PortfolioContext"];
3677
+ };
3678
+ };
3679
+ /** @description Erro (RFC 9457 application/problem+json) */
3680
+ default: {
3681
+ headers: {
3682
+ [name: string]: unknown;
3683
+ };
3684
+ content: {
3685
+ "application/problem+json": Record<string, never>;
3686
+ };
3687
+ };
3688
+ };
3689
+ };
3690
+ getSuitability: {
3691
+ parameters: {
3692
+ query?: never;
3693
+ header?: never;
3694
+ path?: never;
3695
+ cookie?: never;
3696
+ };
3697
+ requestBody?: never;
3698
+ responses: {
3699
+ /** @description Perfil de investidor do usuário (ou nulo). */
3700
+ 200: {
3701
+ headers: {
3702
+ [name: string]: unknown;
3703
+ };
3704
+ content: {
3705
+ "application/json": components["schemas"]["SuitabilityEnvelope"];
3706
+ };
3707
+ };
3708
+ /** @description Erro (RFC 9457 application/problem+json) */
3709
+ default: {
3710
+ headers: {
3711
+ [name: string]: unknown;
3712
+ };
3713
+ content: {
3714
+ "application/problem+json": Record<string, never>;
3715
+ };
3716
+ };
3717
+ };
3718
+ };
3719
+ searchDocuments: {
3720
+ parameters: {
3721
+ query: {
3722
+ /** @description Termo/pergunta em linguagem natural. */
3723
+ q: string;
3724
+ /** @description Filtra por papéis (CSV), ex.: PETR4,PRIO3. */
3725
+ tickers?: string;
3726
+ /** @description Categoria do documento, ex.: Fato Relevante. */
3727
+ category?: string;
3728
+ /** @description Ano de referência do documento (AAAA). */
3729
+ year?: number;
3730
+ /** @description Restringe a trechos de tabela (fatos numéricos). */
3731
+ tables_only?: boolean;
3732
+ /** @description Máximo de trechos (1–25, default 8). */
3733
+ limit?: number;
3734
+ };
3735
+ header?: never;
3736
+ path?: never;
3737
+ cookie?: never;
3738
+ };
3739
+ requestBody?: never;
3740
+ responses: {
3741
+ /** @description Trechos relevantes + bloco de contexto com citação. */
3742
+ 200: {
3743
+ headers: {
3744
+ [name: string]: unknown;
3745
+ };
3746
+ content: {
3747
+ "application/json": components["schemas"]["DocumentSearchResponse"];
3748
+ };
3749
+ };
3750
+ /** @description Erro (RFC 9457 application/problem+json) */
3751
+ default: {
3752
+ headers: {
3753
+ [name: string]: unknown;
3754
+ };
3755
+ content: {
3756
+ "application/problem+json": Record<string, never>;
3757
+ };
3758
+ };
3759
+ };
3760
+ };
3526
3761
  }
package/dist/types.d.ts CHANGED
@@ -59,6 +59,10 @@ export type InvestorFlowMonthly = Schemas["InvestorFlowMonthly"];
59
59
  export type PublicOffering = Schemas["PublicOffering"];
60
60
  export type LiveQuote = Schemas["LiveQuote"];
61
61
  export type IntradayPoint = Schemas["IntradayPoint"];
62
+ export type PortfolioContext = Schemas["PortfolioContext"];
63
+ export type PortfolioHolding = Schemas["PortfolioHolding"];
64
+ export type SuitabilityProfile = Schemas["SuitabilityProfile"];
65
+ export type DocumentChunk = Schemas["DocumentChunk"];
62
66
  export type HealthResponse = Ok<"getHealth">;
63
67
  export type IngestHealthResponse = Ok<"getIngestHealth">;
64
68
  export type ScreenStocksResponse = Ok<"screenStocks">;
@@ -99,6 +103,22 @@ export type InvestorFlowMonthlyResponse = Ok<"listInvestorFlowMonthly">;
99
103
  export type OfferingsResponse = Ok<"listOfferings">;
100
104
  export type LiveQuotesResponse = Ok<"getLiveQuotes">;
101
105
  export type IntradaySeriesResponse = Ok<"getStockIntraday">;
106
+ export type PortfolioResponse = Ok<"getPortfolio">;
107
+ export type SuitabilityResponse = Ok<"getSuitability">;
108
+ export type DocumentSearchResponse = Ok<"searchDocuments">;
109
+ /** Filtros da busca semântica de documentos — `GET /v1/documents/search`. */
110
+ export interface SearchDocumentsParams {
111
+ /** Papéis a filtrar; array serializado em CSV pelo HttpClient. */
112
+ tickers?: string[] | string;
113
+ /** Categoria do documento, ex.: "Fato Relevante". */
114
+ category?: string;
115
+ /** Ano de referência (AAAA). */
116
+ year?: number;
117
+ /** Restringe a trechos de tabela (fatos numéricos). */
118
+ tablesOnly?: boolean;
119
+ /** Máximo de trechos (1–25, default 8). */
120
+ limit?: number;
121
+ }
102
122
  /**
103
123
  * Agrupamento client-side de `from`/`to` (datas ISO) — não é um schema do
104
124
  * contrato; os endpoints os recebem como query params soltos. Único tipo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databolsa/sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "SDK TypeScript tipado para a Serving API pública do DataBolsa, gerado a partir do contrato OpenAPI.",