diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d3e53744..3440ca236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed the deprecated public _Stripe_ key +### Fixed + +- Fixed the import of `jsonpath` to support REST APIs (`JSON`) via the scraper configuration + +## 2.226.0 - 2026-01-01 + +### Added + +- Extended the content of the _Self-Hosting_ section by information about additional data providers on the Frequently Asked Questions (FAQ) page + +### Changed + +- Upgraded `class-validator` from version `0.14.2` to `0.14.3` +- Upgraded `yahoo-finance2` from version `3.10.2` to `3.11.2` + ## 2.225.0 - 2025-12-31 ### Added diff --git a/README.md b/README.md index 822825b57..35276b232 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,7 @@ Deprecated: `GET http://localhost:3333/api/v1/auth/anonymous/ { + it('should get market price from stock API response', () => { + const object = { + currency: 'USD', + market: { + previousClose: 273.04, + price: 271.86 + }, + symbol: 'AAPL' + }; + + const result = query({ + object, + pathExpression: '$.market.price' + })[0]; + + expect(result).toBe(271.86); + }); +}); describe('redactAttributes', () => { it('should redact provided attributes', () => { diff --git a/apps/api/src/helper/object.helper.ts b/apps/api/src/helper/object.helper.ts index a5854e9d9..6bb6579d2 100644 --- a/apps/api/src/helper/object.helper.ts +++ b/apps/api/src/helper/object.helper.ts @@ -1,4 +1,5 @@ import { Big } from 'big.js'; +import jsonpath from 'jsonpath'; import { cloneDeep, isArray, isObject } from 'lodash'; export function hasNotDefinedValuesInObject(aObject: Object): boolean { @@ -31,6 +32,16 @@ export function nullifyValuesInObjects(aObjects: T[], keys: string[]): T[] { }); } +export function query({ + object, + pathExpression +}: { + object: object; + pathExpression: string; +}) { + return jsonpath.query(object, pathExpression); +} + export function redactAttributes({ isFirstRun = true, object, diff --git a/apps/api/src/services/data-provider/manual/manual.service.ts b/apps/api/src/services/data-provider/manual/manual.service.ts index f18da49ab..7392f0914 100644 --- a/apps/api/src/services/data-provider/manual/manual.service.ts +++ b/apps/api/src/services/data-provider/manual/manual.service.ts @@ -1,3 +1,4 @@ +import { query } from '@ghostfolio/api/helper/object.helper'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -26,7 +27,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; import * as cheerio from 'cheerio'; import { addDays, format, isBefore } from 'date-fns'; -import * as jsonpath from 'jsonpath'; @Injectable() export class ManualService implements DataProviderInterface { @@ -286,9 +286,14 @@ export class ManualService implements DataProviderInterface { let value: string; if (response.headers.get('content-type')?.includes('application/json')) { - const data = await response.json(); + const object = await response.json(); - value = String(jsonpath.query(data, scraperConfiguration.selector)[0]); + value = String( + query({ + object, + pathExpression: scraperConfiguration.selector + })[0] + ); } else { const $ = cheerio.load(await response.text()); diff --git a/apps/client/src/app/pages/faq/self-hosting/self-hosting-page.html b/apps/client/src/app/pages/faq/self-hosting/self-hosting-page.html index f44759124..42e810eb0 100644 --- a/apps/client/src/app/pages/faq/self-hosting/self-hosting-page.html +++ b/apps/client/src/app/pages/faq/self-hosting/self-hosting-page.html @@ -135,9 +135,17 @@ Which data providers are supported? COINGECKO, MANUAL and - YAHOO are officially supported while all other data - providers are considered experimental.COINGECKO, GHOSTFOLIO (available with + Ghostfolio Premium), MANUAL, and YAHOO are officially + supported while all other data providers are considered + experimental. @@ -147,7 +155,8 @@ > Yes, access to a professional data provider is included with a + >Yes, access to a professional data provider (GHOSTFOLIO) + is included with a