bharosa 0.4.0 → 0.5.1
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/ANALYTICS-CONTRACT-SHA256 +1 -1
- package/CHANGELOG.md +18 -6
- package/CONTRIBUTING.md +1 -1
- package/MONTHLY-MARKET-CONTRACT-SHA256 +1 -1
- package/README.md +18 -11
- package/dist/client-types.d.cts +12 -1
- package/dist/client-types.d.ts +12 -1
- package/dist/index.cjs +33 -19
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/monthly-market-data.cjs +3 -2
- package/dist/monthly-types.d.cts +1 -1
- package/dist/monthly-types.d.ts +1 -1
- package/dist/response-checks.cjs +1 -1
- package/dist/transport.cjs +12 -2
- package/dist/transport.d.cts +1 -1
- package/dist/transport.d.ts +1 -1
- package/docs/analytics.md +1 -1
- package/docs/getting-started.md +3 -3
- package/docs/index.md +2 -2
- package/docs/monthly-market-data.md +14 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1d2d37edf6ea65cdd3bac707119c6815ee73c89770a791d7dfdfadc9630b6f2b
|
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 0.5.1
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Documentation-only correction: use normal npm installation and released status, describe deployed unified-key/latest-NAV access, and remove stale preview wording. Runtime, public types, contracts and dependencies are unchanged from 0.5.0.
|
|
6
|
+
|
|
7
|
+
## 0.5.0 — 31 October 2026
|
|
8
|
+
|
|
9
|
+
Add `new Bharosa({ apiKey })` and `client.markets` for baseline market access. Support latest NAV by omitting the date on baseline and account-scoped NAV methods. Preserve existing auth forms, private authorization, production API origin and monthly limits on explicit historical dates.
|
|
10
|
+
|
|
11
|
+
## 0.4.0 — 30 October 2026
|
|
12
|
+
|
|
13
|
+
Add account-scoped Growth scheme performance and category return statistics. Preserve the api.bharosa.finance default introduced in 0.3.3 and explicit overrides. No investor monetary-performance, fund-AUM or stated-TER methods.
|
|
14
|
+
|
|
15
|
+
## 0.3.3 — 30 October 2026
|
|
16
|
+
|
|
17
|
+
Change the default API origin to https://api.bharosa.finance. No analytics changes.
|
|
6
18
|
|
|
7
19
|
## 0.3.2 — 30 October 2026
|
|
8
20
|
|
|
@@ -23,11 +35,11 @@ Adds server-side BharosaMarket for four authenticated registered-app monthly mar
|
|
|
23
35
|
- Clarify that monthly market reads require authenticated account-read access without a separate market-data approval.
|
|
24
36
|
- Preserve existing methods, exports, authentication, quantity precision, and analytics implementation. Requires a companion API with portfolio lifecycle support; package preparation does not establish production availability.
|
|
25
37
|
|
|
26
|
-
The entries below
|
|
38
|
+
The entries below are archived preparation notes retained for provenance, not current installation or release instructions. Their historical “unreleased” and “pending” labels describe preparation at that time.
|
|
27
39
|
|
|
28
|
-
## 0.1.0 —
|
|
40
|
+
## 0.1.0 — published
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
Initial npm release. API deployment and external consent activation are separate.
|
|
31
43
|
|
|
32
44
|
- Typed Node.js client with ESM/CommonJS exports, account-scoped direct/delegated authentication, and 17 public resource operations.
|
|
33
45
|
- Portfolio asset, sector, and issuer mix methods for saved and in-memory targets, with MutualFund conveniences delegated to their underlying Portfolio.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This repository contains the published Bharosa SDK. Keep changes limited to the client, public contracts, documentation, and synthetic tests. Do not copy API implementation, analytics code, provider data, credentials, or internal operational notes into this repository.
|
|
4
4
|
|
|
5
5
|
## Development
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ef53094920c324ab9d9fd31d8846b6f37da13b757301c6742461ee33b8fe49c4
|
package/README.md
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
A TypeScript client for Bharosa accounts, investors, portfolios, and mutual funds. Use one resource interface from TypeScript, ESM, or CommonJS, with no runtime dependencies.
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**Published on npm:** `bharosa`. Both clients use the production API at `https://api.bharosa.finance` by default. Account access and credentials are still required; installing the SDK does not grant access.
|
|
6
6
|
|
|
7
7
|
## Start here
|
|
8
8
|
|
|
9
|
-
Use Node.js 22.12+ in a supported LTS release. Install the
|
|
9
|
+
Use Node.js 22.12+ in a supported LTS release. Install the SDK in your backend application:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install
|
|
12
|
+
npm install bharosa
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Source contributors can build and pack a local archive using the commands in CONTRIBUTING.md.
|
|
16
16
|
|
|
17
|
-
Configure your
|
|
17
|
+
Configure your API key through your backend secret manager. Every active, unexpired API key has baseline market access; private account calls require the optional account permissions. Then:
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
import { Bharosa } from "bharosa";
|
|
@@ -25,10 +25,11 @@ function required(name: string): string {
|
|
|
25
25
|
return value;
|
|
26
26
|
}
|
|
27
27
|
const bharosa = new Bharosa({
|
|
28
|
-
|
|
29
|
-
auth: { type: "account_key", apiKey: required("BHAROSA_SECRET_KEY") },
|
|
28
|
+
apiKey: required("BHAROSA_SECRET_KEY"),
|
|
30
29
|
});
|
|
31
|
-
const
|
|
30
|
+
const latestNav = await bharosa.markets.schemes.nav("45139");
|
|
31
|
+
// Optional own-account permission is required for this call:
|
|
32
|
+
// const account = await bharosa.accounts.retrieve();
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
The startup check names missing environment variables without printing their values. See the [complete setup guide](docs/getting-started.md) for explicit checks and delegated authentication. CommonJS uses `const { Bharosa } = require("bharosa")`.
|
|
@@ -115,11 +116,11 @@ The optional `bharosa/testing` entrypoint supplies fresh, deterministic syntheti
|
|
|
115
116
|
|
|
116
117
|
Unit precision: supplied units accept at most four fractional digits; additional digits are rejected, never truncated. Dated amount conversion rounds once to four places using decimal half-even arithmetic; a positive amount rounding to zero returns `units_below_precision`. Currency and NAV precision are unchanged. Exact historical quantities and provenance remain in stored evidence and read responses; the web marks rounded displays with ≈, shows tiny positive values as <0.0001, and makes a rounded edit draft an explicit correction. Existing zero-unit closure remains supported; initial quantities must be positive. No portfolio reset or data rewrite is required.
|
|
117
118
|
|
|
118
|
-
After installing the
|
|
119
|
+
After installing the package, run `node node_modules/bharosa/examples/offline-smoke.mjs` for a credential-free synthetic read. This checks installed imports and the transport path without contacting Bharosa or creating data. It does not prove live access. Source-checkout verification commands require contributor files that are intentionally excluded from the runtime archive.
|
|
119
120
|
|
|
120
|
-
###
|
|
121
|
+
### Baseline market access
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
Use `new Bharosa({ apiKey })` and `client.markets` for account-independent latest NAV and monthly snapshots. Existing `new BharosaMarket({ apiKey })` clients remain compatible. Active, unexpired API keys have baseline market access without an investor OAuth token or a separate market-data approval. Legacy market-only keys still cannot access private accounts. Optional own-account permissions apply only to the key's authorized account; accessing another user's account still requires OAuth consent. Keep all secrets server-side.
|
|
123
124
|
|
|
124
125
|
### Optional API origin override
|
|
125
126
|
|
|
@@ -127,4 +128,10 @@ Set `baseUrl` only for another deployment or tests. Omitted or `undefined` uses
|
|
|
127
128
|
|
|
128
129
|
## Growth performance and category returns
|
|
129
130
|
|
|
130
|
-
Adds `mutualFundSchemes.performance.retrieve` and `fundCategories.statistics.retrieve` for authenticated account access. See [analytics methods, coverage and limitations](docs/analytics.md). These API routes
|
|
131
|
+
Adds `mutualFundSchemes.performance.retrieve` and `fundCategories.statistics.retrieve` for authenticated account access. See [analytics methods, coverage and limitations](docs/analytics.md). These API routes and SDK methods are published. `BharosaMarket` retains its four monthly operations and cannot call account analytics.
|
|
132
|
+
|
|
133
|
+
## Unified API keys
|
|
134
|
+
|
|
135
|
+
SDK 0.5.0 introduced `new Bharosa({ apiKey })` and `client.markets`, using the existing account-independent market routes. Omit the NAV selection for latest NAV, or pass `{ asOf: "2026-10-01" }` for a monthly snapshot. Missing observations return `status: "missing"` and `data: null`. Explicit dates must be month starts. The account-scoped NAV method also accepts omission, while keeping account authorization.
|
|
136
|
+
|
|
137
|
+
Existing `auth` configurations and `BharosaMarket` remain supported. Baseline calls use only the API key; delegated private calls still require user consent and a valid user token. The production origin remains `https://api.bharosa.finance`. Unified-key support is deployed. Private permissions remain optional and are enforced by the server; installing the SDK grants no additional access.
|
package/dist/client-types.d.cts
CHANGED
|
@@ -24,7 +24,7 @@ interface BharosaBaseConfig {
|
|
|
24
24
|
readonly allowLocalhostHttp?: boolean;
|
|
25
25
|
readonly maxResponseBytes?: number;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
type LegacyBharosaConfig = BharosaBaseConfig & ({
|
|
28
28
|
readonly auth: Auth;
|
|
29
29
|
readonly fetch?: typeof globalThis.fetch;
|
|
30
30
|
readonly transport?: never;
|
|
@@ -33,6 +33,17 @@ export type BharosaConfig = BharosaBaseConfig & ({
|
|
|
33
33
|
readonly auth?: never;
|
|
34
34
|
readonly fetch?: never;
|
|
35
35
|
});
|
|
36
|
+
/** Simple server-side API-key configuration. Account access remains server-authorized. */
|
|
37
|
+
export type BharosaConfig = LegacyBharosaConfig | {
|
|
38
|
+
readonly apiKey: string;
|
|
39
|
+
readonly account?: string;
|
|
40
|
+
readonly baseUrl?: string;
|
|
41
|
+
readonly allowLocalhostHttp?: boolean;
|
|
42
|
+
readonly maxResponseBytes?: number;
|
|
43
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
44
|
+
readonly auth?: never;
|
|
45
|
+
readonly transport?: never;
|
|
46
|
+
};
|
|
36
47
|
export interface RequestOptions {
|
|
37
48
|
idempotencyKey?: string;
|
|
38
49
|
signal?: AbortSignal;
|
package/dist/client-types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ interface BharosaBaseConfig {
|
|
|
24
24
|
readonly allowLocalhostHttp?: boolean;
|
|
25
25
|
readonly maxResponseBytes?: number;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
type LegacyBharosaConfig = BharosaBaseConfig & ({
|
|
28
28
|
readonly auth: Auth;
|
|
29
29
|
readonly fetch?: typeof globalThis.fetch;
|
|
30
30
|
readonly transport?: never;
|
|
@@ -33,6 +33,17 @@ export type BharosaConfig = BharosaBaseConfig & ({
|
|
|
33
33
|
readonly auth?: never;
|
|
34
34
|
readonly fetch?: never;
|
|
35
35
|
});
|
|
36
|
+
/** Simple server-side API-key configuration. Account access remains server-authorized. */
|
|
37
|
+
export type BharosaConfig = LegacyBharosaConfig | {
|
|
38
|
+
readonly apiKey: string;
|
|
39
|
+
readonly account?: string;
|
|
40
|
+
readonly baseUrl?: string;
|
|
41
|
+
readonly allowLocalhostHttp?: boolean;
|
|
42
|
+
readonly maxResponseBytes?: number;
|
|
43
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
44
|
+
readonly auth?: never;
|
|
45
|
+
readonly transport?: never;
|
|
46
|
+
};
|
|
36
47
|
export interface RequestOptions {
|
|
37
48
|
idempotencyKey?: string;
|
|
38
49
|
signal?: AbortSignal;
|
package/dist/index.cjs
CHANGED
|
@@ -45,9 +45,11 @@ class Bharosa {
|
|
|
45
45
|
fundCategories;
|
|
46
46
|
mutualFunds;
|
|
47
47
|
mutualFundSchemes;
|
|
48
|
+
markets;
|
|
48
49
|
marketSnapshots;
|
|
49
50
|
marketData;
|
|
50
51
|
constructor(config) {
|
|
52
|
+
this.markets = baselineMarkets((0, transport_cjs_1.createTransport)(config, true));
|
|
51
53
|
const call = (0, transport_cjs_1.createTransport)(config);
|
|
52
54
|
const analyticsQuery = (q, extra = []) => {
|
|
53
55
|
(0, transport_cjs_1.keys)(q, ["asOf", "periods", ...extra]);
|
|
@@ -314,7 +316,10 @@ class Bharosa {
|
|
|
314
316
|
};
|
|
315
317
|
this.marketSnapshots = {
|
|
316
318
|
schemes: {
|
|
317
|
-
nav: (id, q, o) =>
|
|
319
|
+
nav: (id, q = {}, o) => {
|
|
320
|
+
(0, transport_cjs_1.keys)(q, ["asOf"]);
|
|
321
|
+
return call("monthly_nav", { id, ...(q.asOf === undefined ? {} : { as_of: q.asOf }) }, undefined, o);
|
|
322
|
+
},
|
|
318
323
|
expenseRatio: (id, q, o) => call("monthly_expense", { id, ...monthlyQuery(q) }, undefined, o),
|
|
319
324
|
valuation: (id, input = {}, o) => {
|
|
320
325
|
(0, transport_cjs_1.keys)(input, ["units", "asOf", "positionDate", "observedValue"]);
|
|
@@ -408,24 +413,33 @@ class BharosaMarket {
|
|
|
408
413
|
]);
|
|
409
414
|
const { apiKey, ...rest } = config;
|
|
410
415
|
const call = (0, transport_cjs_1.createTransport)({ ...rest, account: "me", auth: { type: "account_key", apiKey } }, true);
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
as_of: q.asOf,
|
|
415
|
-
...(q.limit === undefined ? {} : { limit: q.limit }),
|
|
416
|
-
...(q.startingAfter === undefined
|
|
417
|
-
? {}
|
|
418
|
-
: { starting_after: q.startingAfter }),
|
|
419
|
-
};
|
|
420
|
-
};
|
|
421
|
-
this.schemes = {
|
|
422
|
-
nav: (id, q, o) => call("monthly_nav", { id, ...query(q) }, undefined, o),
|
|
423
|
-
expenseRatio: (id, q, o) => call("monthly_expense", { id, ...query(q) }, undefined, o),
|
|
424
|
-
};
|
|
425
|
-
this.funds = {
|
|
426
|
-
portfolio: (id, q, o) => call("monthly_portfolio", { id, ...query(q) }, undefined, o),
|
|
427
|
-
holdings: (id, q, o) => call("monthly_holdings", { id, ...query(q, true) }, undefined, o),
|
|
428
|
-
};
|
|
416
|
+
const resources = baselineMarkets(call);
|
|
417
|
+
this.schemes = resources.schemes;
|
|
418
|
+
this.funds = resources.funds;
|
|
429
419
|
}
|
|
430
420
|
}
|
|
431
421
|
exports.BharosaMarket = BharosaMarket;
|
|
422
|
+
function baselineMarkets(call) {
|
|
423
|
+
const query = (q, paging = false) => {
|
|
424
|
+
(0, transport_cjs_1.keys)(q, paging ? ["asOf", "limit", "startingAfter"] : ["asOf"]);
|
|
425
|
+
return {
|
|
426
|
+
as_of: q.asOf,
|
|
427
|
+
...(q.limit === undefined ? {} : { limit: q.limit }),
|
|
428
|
+
...(q.startingAfter === undefined
|
|
429
|
+
? {}
|
|
430
|
+
: { starting_after: q.startingAfter }),
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
const schemes = {
|
|
434
|
+
nav: (id, q = {}, o) => {
|
|
435
|
+
(0, transport_cjs_1.keys)(q, ["asOf"]);
|
|
436
|
+
return call("monthly_nav", { id, ...(q.asOf === undefined ? {} : { as_of: q.asOf }) }, undefined, o);
|
|
437
|
+
},
|
|
438
|
+
expenseRatio: (id, q, o) => call("monthly_expense", { id, ...query(q) }, undefined, o),
|
|
439
|
+
};
|
|
440
|
+
const funds = {
|
|
441
|
+
portfolio: (id, q, o) => call("monthly_portfolio", { id, ...query(q) }, undefined, o),
|
|
442
|
+
holdings: (id, q, o) => call("monthly_holdings", { id, ...query(q, true) }, undefined, o),
|
|
443
|
+
};
|
|
444
|
+
return Object.freeze({ schemes: Object.freeze(schemes), funds: Object.freeze(funds) });
|
|
445
|
+
}
|
package/dist/index.d.cts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class Bharosa implements T.ClientSurface {
|
|
|
13
13
|
readonly fundCategories: T.ClientSurface["fundCategories"];
|
|
14
14
|
readonly mutualFunds: T.ClientSurface["mutualFunds"];
|
|
15
15
|
readonly mutualFundSchemes: T.ClientSurface["mutualFundSchemes"];
|
|
16
|
+
readonly markets: BaselineMarketClient;
|
|
16
17
|
readonly marketSnapshots: MonthlyMarketClient;
|
|
17
18
|
readonly marketData: D.MarketDataClient;
|
|
18
19
|
constructor(config: T.BharosaConfig);
|
|
@@ -27,7 +28,16 @@ export interface BharosaMarketConfig {
|
|
|
27
28
|
}
|
|
28
29
|
/** Server-only registered-app monthly market access. No account or user token. */
|
|
29
30
|
export declare class BharosaMarket {
|
|
30
|
-
readonly schemes:
|
|
31
|
+
readonly schemes: BaselineMarketClient["schemes"];
|
|
31
32
|
readonly funds: MonthlyMarketClient["funds"];
|
|
32
33
|
constructor(config: BharosaMarketConfig);
|
|
33
34
|
}
|
|
35
|
+
export interface BaselineMarketClient {
|
|
36
|
+
readonly schemes: {
|
|
37
|
+
nav(id: string, selection?: {
|
|
38
|
+
asOf?: string;
|
|
39
|
+
}, options?: T.RequestOptions): ReturnType<MonthlyMarketClient["schemes"]["nav"]>;
|
|
40
|
+
expenseRatio: MonthlyMarketClient["schemes"]["expenseRatio"];
|
|
41
|
+
};
|
|
42
|
+
readonly funds: MonthlyMarketClient["funds"];
|
|
43
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class Bharosa implements T.ClientSurface {
|
|
|
13
13
|
readonly fundCategories: T.ClientSurface["fundCategories"];
|
|
14
14
|
readonly mutualFunds: T.ClientSurface["mutualFunds"];
|
|
15
15
|
readonly mutualFundSchemes: T.ClientSurface["mutualFundSchemes"];
|
|
16
|
+
readonly markets: BaselineMarketClient;
|
|
16
17
|
readonly marketSnapshots: MonthlyMarketClient;
|
|
17
18
|
readonly marketData: D.MarketDataClient;
|
|
18
19
|
constructor(config: T.BharosaConfig);
|
|
@@ -27,7 +28,16 @@ export interface BharosaMarketConfig {
|
|
|
27
28
|
}
|
|
28
29
|
/** Server-only registered-app monthly market access. No account or user token. */
|
|
29
30
|
export declare class BharosaMarket {
|
|
30
|
-
readonly schemes:
|
|
31
|
+
readonly schemes: BaselineMarketClient["schemes"];
|
|
31
32
|
readonly funds: MonthlyMarketClient["funds"];
|
|
32
33
|
constructor(config: BharosaMarketConfig);
|
|
33
34
|
}
|
|
35
|
+
export interface BaselineMarketClient {
|
|
36
|
+
readonly schemes: {
|
|
37
|
+
nav(id: string, selection?: {
|
|
38
|
+
asOf?: string;
|
|
39
|
+
}, options?: T.RequestOptions): ReturnType<MonthlyMarketClient["schemes"]["nav"]>;
|
|
40
|
+
expenseRatio: MonthlyMarketClient["schemes"]["expenseRatio"];
|
|
41
|
+
};
|
|
42
|
+
readonly funds: MonthlyMarketClient["funds"];
|
|
43
|
+
}
|
|
@@ -29,12 +29,13 @@ module.exports = {
|
|
|
29
29
|
{
|
|
30
30
|
"name": "as_of",
|
|
31
31
|
"in": "query",
|
|
32
|
-
"required":
|
|
32
|
+
"required": false,
|
|
33
33
|
"schema": {
|
|
34
34
|
"type": "string",
|
|
35
35
|
"format": "date",
|
|
36
36
|
"pattern": "^[0-9]{4}-[0-9]{2}-01$"
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"description": "Omit for latest NAV on or before today in Asia/Kolkata. When supplied, must be the first of a month and not in the future. Actual observation date is returned separately."
|
|
38
39
|
}
|
|
39
40
|
],
|
|
40
41
|
"response": {
|
package/dist/monthly-types.d.cts
CHANGED
|
@@ -21,7 +21,7 @@ export interface MonthSelection {
|
|
|
21
21
|
}
|
|
22
22
|
export interface MonthlyMarketClient {
|
|
23
23
|
schemes: {
|
|
24
|
-
nav(id: string, query
|
|
24
|
+
nav(id: string, query?: Partial<MonthSelection>, options?: RequestOptions): Promise<MarketSnapshot<D.NavObservation>>;
|
|
25
25
|
expenseRatio(id: string, query: MonthSelection, options?: RequestOptions): Promise<MarketSnapshot<D.ExpenseObservation>>;
|
|
26
26
|
valuation(id: string, input?: D.ValuationInput, options?: RequestOptions): Promise<D.LatestNavValuation>;
|
|
27
27
|
};
|
package/dist/monthly-types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface MonthSelection {
|
|
|
21
21
|
}
|
|
22
22
|
export interface MonthlyMarketClient {
|
|
23
23
|
schemes: {
|
|
24
|
-
nav(id: string, query
|
|
24
|
+
nav(id: string, query?: Partial<MonthSelection>, options?: RequestOptions): Promise<MarketSnapshot<D.NavObservation>>;
|
|
25
25
|
expenseRatio(id: string, query: MonthSelection, options?: RequestOptions): Promise<MarketSnapshot<D.ExpenseObservation>>;
|
|
26
26
|
valuation(id: string, input?: D.ValuationInput, options?: RequestOptions): Promise<D.LatestNavValuation>;
|
|
27
27
|
};
|
package/dist/response-checks.cjs
CHANGED
|
@@ -190,7 +190,7 @@ function responseMatches(id, op, data, params, body, account) {
|
|
|
190
190
|
}
|
|
191
191
|
if (id.startsWith("monthly_") && id !== "monthly_valuation") {
|
|
192
192
|
const observation = d("observation_date"), requested = d("requested_date"), data = d("data");
|
|
193
|
-
if (requested !== params.as_of)
|
|
193
|
+
if (!(id === "monthly_nav" && params.as_of === undefined) && requested !== params.as_of)
|
|
194
194
|
return false;
|
|
195
195
|
if (d("status") === "available") {
|
|
196
196
|
if (typeof observation !== "string" ||
|
package/dist/transport.cjs
CHANGED
|
@@ -143,7 +143,17 @@ async function read(response, max, signal) {
|
|
|
143
143
|
reader.releaseLock();
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
function createTransport(
|
|
146
|
+
function createTransport(input, marketOnly = false) {
|
|
147
|
+
let config;
|
|
148
|
+
if (input != null && typeof input === "object" && Object.hasOwn(input, "apiKey")) {
|
|
149
|
+
keys(input, ["apiKey", "account", "baseUrl", "allowLocalhostHttp", "maxResponseBytes", "fetch"]);
|
|
150
|
+
const simple = input;
|
|
151
|
+
const { apiKey, account, ...rest } = simple;
|
|
152
|
+
config = { ...rest, account: account === undefined ? "me" : account, auth: { type: "account_key", apiKey } };
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
config = input;
|
|
156
|
+
}
|
|
147
157
|
const customTransport = config?.transport !== undefined;
|
|
148
158
|
if (!customTransport)
|
|
149
159
|
assertServer();
|
|
@@ -177,7 +187,7 @@ function createTransport(config, marketOnly = false) {
|
|
|
177
187
|
(a.type === "delegated_application" && token(a.userAccessToken)));
|
|
178
188
|
headers = Object.freeze({
|
|
179
189
|
Authorization: "Bearer " + a.apiKey,
|
|
180
|
-
...(a.type === "delegated_application"
|
|
190
|
+
...(a.type === "delegated_application" && !marketOnly
|
|
181
191
|
? { "Bharosa-User-Authorization": "Bearer " + a.userAccessToken }
|
|
182
192
|
: {}),
|
|
183
193
|
Accept: "application/json",
|
package/dist/transport.d.cts
CHANGED
|
@@ -2,4 +2,4 @@ import type { OperationResults } from "./operation-types.cjs";
|
|
|
2
2
|
import type { BharosaConfig, RequestOptions } from "./client-types.cjs";
|
|
3
3
|
export declare function check(v: unknown): asserts v;
|
|
4
4
|
export declare function keys(v: unknown, allowed: readonly string[]): void;
|
|
5
|
-
export declare function createTransport(
|
|
5
|
+
export declare function createTransport(input: BharosaConfig, marketOnly?: boolean): <K extends keyof OperationResults>(id: K, params?: Record<string, unknown>, body?: unknown, opts?: RequestOptions) => Promise<OperationResults[K]>;
|
package/dist/transport.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { OperationResults } from "./operation-types.js";
|
|
|
2
2
|
import type { BharosaConfig, RequestOptions } from "./client-types.js";
|
|
3
3
|
export declare function check(v: unknown): asserts v;
|
|
4
4
|
export declare function keys(v: unknown, allowed: readonly string[]): void;
|
|
5
|
-
export declare function createTransport(
|
|
5
|
+
export declare function createTransport(input: BharosaConfig, marketOnly?: boolean): <K extends keyof OperationResults>(id: K, params?: Record<string, unknown>, body?: unknown, opts?: RequestOptions) => Promise<OperationResults[K]>;
|
package/docs/analytics.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Growth scheme performance and category returns
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The two analytics methods are deployed and published in SDK 0.4.0. SDK 0.5.0 and later preserve them. Default origin is https://api.bharosa.finance; explicit baseUrl overrides remain supported. Account authorization with accounts:read is required. BharosaMarket does not expose these methods.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { Bharosa } from "bharosa";
|
package/docs/getting-started.md
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
Use Node.js 22.12 or later in a supported LTS release. The SDK supports ESM and CommonJS. Key-based authentication is server-only; keep credentials in your backend or server that handles browser sessions. Browser applications can supply a generic transport whose private host implementation manages sessions, origin restrictions and CSRF. Bun and Deno are unsupported.
|
|
6
6
|
|
|
7
|
-
Obtain
|
|
7
|
+
Obtain an API key. For private account calls, enable the needed optional own-account permissions; the simple API-key configuration defaults to account selector `me`. Bharosa and BharosaMarket default to the production origin `https://api.bharosa.finance`; no API URL environment variable is required. The SDK neither provisions accounts nor runs an OAuth consent flow.
|
|
8
8
|
|
|
9
|
-
## Install
|
|
9
|
+
## Install from npm
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install
|
|
12
|
+
npm install bharosa
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Source contributors can build and pack a local archive as described in CONTRIBUTING.md.
|
package/docs/index.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Bharosa SDK guides
|
|
2
2
|
|
|
3
|
-
Build a Node.js integration with the Bharosa resource API.
|
|
3
|
+
Build a Node.js integration with the Bharosa resource API. Install the published SDK with `npm install bharosa`. Use an API key for baseline market data and optional authorized own-account access; other users' accounts require OAuth consent.
|
|
4
4
|
|
|
5
|
-
1. [Install
|
|
5
|
+
1. [Install and make your first request](getting-started.md).
|
|
6
6
|
2. [Work with portfolios and mixes](portfolios.md).
|
|
7
7
|
3. [Handle errors, cancellation, and retries](reliability.md).
|
|
8
8
|
4. [Use monthly market snapshots](monthly-market-data.md).
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Latest NAV and monthly market snapshots
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
Use `new Bharosa({ apiKey })` and `client.markets` for baseline market access with any active, unexpired API key. No account permission, investor token or separate market-data approval is required on these account-independent routes. Existing account-scoped methods retain account authorization; installing the SDK grants no private account access. Availability depends on source observations.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Bharosa } from "bharosa";
|
|
7
|
+
const client = new Bharosa({ apiKey: process.env.BHAROSA_SECRET_KEY! });
|
|
8
|
+
const latest = await client.markets.schemes.nav("45139");
|
|
9
|
+
const monthly = await client.markets.schemes.nav("45139", { asOf: "2026-10-01" });
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Baseline methods are `markets.schemes.nav`, `markets.schemes.expenseRatio`, `markets.funds.portfolio` and `markets.funds.holdings`. Omit the NAV selection for latest NAV; all explicit historical dates must be month starts. The remaining three methods require a monthly selection. `BharosaMarket` exposes the same baseline methods without the `markets` prefix.
|
|
13
|
+
|
|
14
|
+
The discovery and account-scoped methods below require their existing account permissions. A baseline-only key does not gain access to scheme search or private analytics.
|
|
4
15
|
|
|
5
16
|
Resolve an investible scheme through `client.mutualFunds.search()` and its returned `scheme_id`. Fund-owner IDs and scheme IDs are distinct: NAV and expense ratios belong to schemes; portfolio snapshots and holdings belong to fund owners. Do not use an AMC ID as a fund-owner ID.
|
|
6
17
|
|
|
@@ -24,7 +35,7 @@ Replace the search term with a fund you intend to inspect and choose among the r
|
|
|
24
35
|
|
|
25
36
|
Supported methods:
|
|
26
37
|
|
|
27
|
-
- `mutualFundSchemes.navs.retrieve(schemeId, { asOf }
|
|
38
|
+
- `mutualFundSchemes.navs.retrieve(schemeId)` for latest NAV, or pass `{ asOf }` for a monthly snapshot
|
|
28
39
|
- `mutualFundSchemes.expenseRatios.retrieve(schemeId, { asOf })`
|
|
29
40
|
- `mutualFundSchemes.valuation(schemeId, { units })` for current value using the latest eligible NAV. Supply a month-start `asOf` for historical valuation. Actual NAV date and freshness are returned; old NAVs are not labelled today's prices.
|
|
30
41
|
- `mutualFunds.portfolios.retrieve(fundOwnerId, { asOf })`
|