bharosa 0.5.0 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -1,8 +1,25 @@
1
- # 0.4.0 — unpublished release candidate
1
+ # Changelog
2
2
 
3
- Add account-scoped Growth scheme performance and category return statistics. Change the default origin from published 0.3.2’s app.bharosa.finance to api.bharosa.finance, preserving explicit overrides. The reviewed host-default delta is included directly; no intermediate 0.3.3 publication is required. No investor monetary-performance, fund-AUM or stated-TER methods. API deployment and SDK publication are separate.
3
+ ## 0.6.0
4
4
 
5
- # Changelog
5
+ Add `markets.schemes.search` and compatible `BharosaMarket.schemes.search` using the canonical account-independent search route. Keep private search and historical methods unchanged. Correct the getting-started example to use an API key without a required account ID.
6
+
7
+
8
+ ## 0.5.1
9
+
10
+ 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.
11
+
12
+ ## 0.5.0 — 31 October 2026
13
+
14
+ 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.
15
+
16
+ ## 0.4.0 — 30 October 2026
17
+
18
+ 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.
19
+
20
+ ## 0.3.3 — 30 October 2026
21
+
22
+ Change the default API origin to https://api.bharosa.finance. No analytics changes.
6
23
 
7
24
  ## 0.3.2 — 30 October 2026
8
25
 
@@ -23,11 +40,11 @@ Adds server-side BharosaMarket for four authenticated registered-app monthly mar
23
40
  - Clarify that monthly market reads require authenticated account-read access without a separate market-data approval.
24
41
  - 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
42
 
26
- The entries below retain historical preparation notes from the published 0.1.0 package. They are not additional changes in 0.2.0.
43
+ 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
44
 
28
- ## 0.1.0 — release candidate
45
+ ## 0.1.0 — published
29
46
 
30
- Prepared for the first npm release; publication is pending registry authentication and verification. API deployment and external consent activation are separate.
47
+ Initial npm release. API deployment and external consent activation are separate.
31
48
 
32
49
  - Typed Node.js client with ESM/CommonJS exports, account-scoped direct/delegated authentication, and 17 public resource operations.
33
50
  - 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 is an unpublished SDK under local preparation. 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.
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
 
@@ -0,0 +1 @@
1
+ 49577eff1da1c0b5badeb61136ee64f8ed35eab4e68f040d4341016475d4d646
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
- **Local release candidate (unpublished):** `bharosa@0.5.0`. 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.
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 reviewed local candidate in your backend application:
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 /absolute/path/to/bharosa-0.5.0.tgz --ignore-scripts
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 API key through your backend secret manager. In the local unified-key API candidate, every active key has baseline market access; private account calls require the optional account permissions. Then:
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";
@@ -116,11 +116,11 @@ The optional `bharosa/testing` entrypoint supplies fresh, deterministic syntheti
116
116
 
117
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.
118
118
 
119
- After installing the archive, 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
+ 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.
120
120
 
121
- ### Registered-app monthly data
121
+ ### Baseline market access
122
122
 
123
- Available in SDK 0.3.0 and activated at `https://api.bharosa.finance`. Server applications can use `new BharosaMarket({apiKey})` with an owner-issued `market_key` scoped only to `market:read`. `client.schemes.nav(id,{asOf:'2026-08-01'})`, `schemes.expenseRatio`, `funds.portfolio` and `funds.holdings` use account-independent monthly snapshot routes. These keys cannot read private accounts or portfolios and require no investor OAuth token. Keep secrets server-side; never bundle them into browser code. Existing account-key and delegated-user clients remain unchanged. The production control-plane environment is `production`. General third-party OAuth provisioning is separate and is not enabled by this feature.
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.
124
124
 
125
125
  ### Optional API origin override
126
126
 
@@ -128,10 +128,25 @@ Set `baseUrl` only for another deployment or tests. Omitted or `undefined` uses
128
128
 
129
129
  ## Growth performance and category returns
130
130
 
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 the SDK 0.4.0 methods are published; this unified-key SDK candidate is not yet published. `BharosaMarket` retains its four monthly operations and cannot call account analytics.
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
132
 
133
- ## Unified-key candidate
133
+ ## Unified API keys
134
134
 
135
- This local 0.5.0 candidate adds `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.
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
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 server changes are locally tested and pending coordinated activation; this archive alone does not activate permissions.
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.
138
+
139
+ ## Find a scheme with baseline market access
140
+
141
+ ```ts
142
+ const choices = await bharosa.markets.schemes.search({ query: "equity", limit: 5 });
143
+ const selected = choices.data[0];
144
+ if (selected) {
145
+ const nav = await bharosa.markets.schemes.nav(selected.scheme_id);
146
+ console.log(selected.plan_label, selected.option_label, nav.status);
147
+ }
148
+ ```
149
+
150
+ Choose the intended scheme and plan from the results. `query` must have 2–100 characters, with at least two after trimming; `limit` is 1–20 and defaults to 10. If `has_more` is true, refine the query; search has no cursor or historical date parameter. An empty `data` array is a valid result. Search returns scheme identities and latest NAV references, including freshness and data-mode information. It does not grant private account access. Existing `mutualFunds.search` remains account-scoped. `BharosaMarket` users can call `schemes.search` directly.
151
+
152
+ Available in SDK 0.6.0 and later, using the account-independent `/v1/market-data/schemes/search` route.
package/dist/index.cjs CHANGED
@@ -399,7 +399,7 @@ class Bharosa {
399
399
  }
400
400
  }
401
401
  exports.Bharosa = Bharosa;
402
- /** Server-only registered-app monthly market access. No account or user token. */
402
+ /** Server-only baseline market access. No account or user token. */
403
403
  class BharosaMarket {
404
404
  schemes;
405
405
  funds;
@@ -431,6 +431,11 @@ function baselineMarkets(call) {
431
431
  };
432
432
  };
433
433
  const schemes = {
434
+ search: async (p, o) => {
435
+ (0, transport_cjs_1.keys)(p, ["query", "limit"]);
436
+ (0, transport_cjs_1.check)(typeof p.query === "string" && p.query.trim().length >= 2 && p.query.length <= 100);
437
+ return call("searchMarketSchemes", p, undefined, o);
438
+ },
434
439
  nav: (id, q = {}, o) => {
435
440
  (0, transport_cjs_1.keys)(q, ["asOf"]);
436
441
  return call("monthly_nav", { id, ...(q.asOf === undefined ? {} : { as_of: q.asOf }) }, undefined, o);
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ export type * from "./analytics-types.cjs";
2
2
  import type { MonthlyMarketClient } from "./monthly-types.cjs";
3
3
  export type * from "./monthly-types.cjs";
4
4
  import type * as T from "./client-types.cjs";
5
+ import type * as M from "./models.cjs";
5
6
  import type * as D from "./market-types.cjs";
6
7
  export type * from "./client-types.cjs";
7
8
  export * from "./errors.cjs";
@@ -26,7 +27,7 @@ export interface BharosaMarketConfig {
26
27
  maxResponseBytes?: number;
27
28
  fetch?: typeof globalThis.fetch;
28
29
  }
29
- /** Server-only registered-app monthly market access. No account or user token. */
30
+ /** Server-only baseline market access. No account or user token. */
30
31
  export declare class BharosaMarket {
31
32
  readonly schemes: BaselineMarketClient["schemes"];
32
33
  readonly funds: MonthlyMarketClient["funds"];
@@ -34,6 +35,10 @@ export declare class BharosaMarket {
34
35
  }
35
36
  export interface BaselineMarketClient {
36
37
  readonly schemes: {
38
+ search(query: {
39
+ query: string;
40
+ limit?: number;
41
+ }, options?: T.RequestOptions): Promise<M.FundsList>;
37
42
  nav(id: string, selection?: {
38
43
  asOf?: string;
39
44
  }, options?: T.RequestOptions): ReturnType<MonthlyMarketClient["schemes"]["nav"]>;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export type * from "./analytics-types.js";
2
2
  import type { MonthlyMarketClient } from "./monthly-types.js";
3
3
  export type * from "./monthly-types.js";
4
4
  import type * as T from "./client-types.js";
5
+ import type * as M from "./models.js";
5
6
  import type * as D from "./market-types.js";
6
7
  export type * from "./client-types.js";
7
8
  export * from "./errors.js";
@@ -26,7 +27,7 @@ export interface BharosaMarketConfig {
26
27
  maxResponseBytes?: number;
27
28
  fetch?: typeof globalThis.fetch;
28
29
  }
29
- /** Server-only registered-app monthly market access. No account or user token. */
30
+ /** Server-only baseline market access. No account or user token. */
30
31
  export declare class BharosaMarket {
31
32
  readonly schemes: BaselineMarketClient["schemes"];
32
33
  readonly funds: MonthlyMarketClient["funds"];
@@ -34,6 +35,10 @@ export declare class BharosaMarket {
34
35
  }
35
36
  export interface BaselineMarketClient {
36
37
  readonly schemes: {
38
+ search(query: {
39
+ query: string;
40
+ limit?: number;
41
+ }, options?: T.RequestOptions): Promise<M.FundsList>;
37
42
  nav(id: string, selection?: {
38
43
  asOf?: string;
39
44
  }, options?: T.RequestOptions): ReturnType<MonthlyMarketClient["schemes"]["nav"]>;
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+ // Generated from the canonical market search contract; all references resolved locally.
3
+ module.exports = {
4
+ "operations": {
5
+ "searchMarketSchemes": {
6
+ "path": "/v1/market-data/schemes/search",
7
+ "method": "GET",
8
+ "status": 200,
9
+ "marketData": true,
10
+ "readOnly": true,
11
+ "parameters": [
12
+ {
13
+ "name": "query",
14
+ "in": "query",
15
+ "required": true,
16
+ "description": "2–100 characters. Case-insensitive label and identifier search; percent and underscore are literal.",
17
+ "schema": {
18
+ "type": "string",
19
+ "minLength": 2,
20
+ "maxLength": 100
21
+ }
22
+ },
23
+ {
24
+ "name": "limit",
25
+ "in": "query",
26
+ "required": false,
27
+ "description": "1–20; default 10. Search is a bounded result set, not cursor pagination.",
28
+ "schema": {
29
+ "type": "integer",
30
+ "minimum": 1,
31
+ "maximum": 20,
32
+ "default": 10
33
+ }
34
+ }
35
+ ],
36
+ "response": {
37
+ "type": "object",
38
+ "properties": {
39
+ "object": {
40
+ "const": "list"
41
+ },
42
+ "data": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "object",
46
+ "properties": {
47
+ "instrument": {
48
+ "type": "object",
49
+ "properties": {
50
+ "id": {
51
+ "type": "string",
52
+ "pattern": "^ins_[A-Za-z0-9_-]{1,150}$"
53
+ },
54
+ "object": {
55
+ "const": "instrument"
56
+ },
57
+ "created": {
58
+ "type": "integer",
59
+ "minimum": 0,
60
+ "maximum": 9007199254740991
61
+ },
62
+ "name": {
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "maxLength": 200,
66
+ "pattern": "\\S"
67
+ },
68
+ "identifiers": {
69
+ "type": "array",
70
+ "items": {
71
+ "type": "object",
72
+ "properties": {
73
+ "namespace": {
74
+ "type": "string"
75
+ },
76
+ "value": {
77
+ "type": "string"
78
+ }
79
+ },
80
+ "required": [
81
+ "namespace",
82
+ "value"
83
+ ],
84
+ "additionalProperties": true
85
+ }
86
+ },
87
+ "domicile_country": {
88
+ "anyOf": [
89
+ {
90
+ "type": "string"
91
+ },
92
+ {
93
+ "type": "null"
94
+ }
95
+ ]
96
+ },
97
+ "type": {
98
+ "const": "mutual_fund"
99
+ },
100
+ "mutual_fund": {
101
+ "type": "object",
102
+ "properties": {
103
+ "fund_name": {
104
+ "type": "string",
105
+ "minLength": 1,
106
+ "maxLength": 200,
107
+ "pattern": "\\S"
108
+ },
109
+ "share_class": {
110
+ "anyOf": [
111
+ {
112
+ "type": "string"
113
+ },
114
+ {
115
+ "type": "null"
116
+ }
117
+ ]
118
+ },
119
+ "class_currency": {
120
+ "anyOf": [
121
+ {
122
+ "type": "string"
123
+ },
124
+ {
125
+ "type": "null"
126
+ }
127
+ ]
128
+ },
129
+ "distribution_policy": {
130
+ "type": "string",
131
+ "x-known-values": [
132
+ "accumulating",
133
+ "distributing",
134
+ "unknown"
135
+ ],
136
+ "minLength": 1
137
+ }
138
+ },
139
+ "required": [
140
+ "fund_name",
141
+ "share_class",
142
+ "class_currency",
143
+ "distribution_policy"
144
+ ],
145
+ "additionalProperties": true
146
+ }
147
+ },
148
+ "required": [
149
+ "id",
150
+ "object",
151
+ "created",
152
+ "name",
153
+ "identifiers",
154
+ "domicile_country",
155
+ "type",
156
+ "mutual_fund"
157
+ ],
158
+ "additionalProperties": true
159
+ },
160
+ "market": {
161
+ "const": "IN"
162
+ },
163
+ "currency": {
164
+ "const": "INR"
165
+ },
166
+ "scheme_id": {
167
+ "type": "string",
168
+ "minLength": 1,
169
+ "description": "Opaque catalogue identifier; production bridge accepts validated positive decimal scheme IDs, fixture IDs are not DB IDs."
170
+ },
171
+ "plan_label": {
172
+ "type": "string"
173
+ },
174
+ "option_label": {
175
+ "type": "string"
176
+ },
177
+ "amfi_code": {
178
+ "anyOf": [
179
+ {
180
+ "type": "string"
181
+ },
182
+ {
183
+ "type": "null"
184
+ }
185
+ ]
186
+ },
187
+ "isin": {
188
+ "anyOf": [
189
+ {
190
+ "type": "string"
191
+ },
192
+ {
193
+ "type": "null"
194
+ }
195
+ ]
196
+ },
197
+ "identity_status": {
198
+ "type": "string",
199
+ "x-known-values": [
200
+ "resolved",
201
+ "conflict"
202
+ ],
203
+ "minLength": 1
204
+ },
205
+ "latest_nav": {
206
+ "anyOf": [
207
+ {
208
+ "type": "object",
209
+ "properties": {
210
+ "amount": {
211
+ "type": "string",
212
+ "pattern": "^(0|[1-9][0-9]{0,19})(\\.[0-9]{1,18})?$"
213
+ },
214
+ "currency": {
215
+ "const": "INR"
216
+ },
217
+ "date": {
218
+ "type": "string",
219
+ "format": "date",
220
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
221
+ "description": "Real calendar date, 1900-01-01 through today Asia/Kolkata; replacement cannot move backwards."
222
+ }
223
+ },
224
+ "required": [
225
+ "amount",
226
+ "currency",
227
+ "date"
228
+ ],
229
+ "additionalProperties": true
230
+ },
231
+ {
232
+ "type": "null"
233
+ }
234
+ ]
235
+ },
236
+ "data_mode": {
237
+ "type": "string",
238
+ "x-known-values": [
239
+ "live",
240
+ "fixture"
241
+ ],
242
+ "minLength": 1
243
+ },
244
+ "source": {
245
+ "type": "string"
246
+ },
247
+ "freshness": {
248
+ "type": "object",
249
+ "properties": {
250
+ "status": {
251
+ "type": "string",
252
+ "x-known-values": [
253
+ "recent",
254
+ "stale",
255
+ "missing",
256
+ "invalid",
257
+ "fixture"
258
+ ],
259
+ "minLength": 1
260
+ },
261
+ "checked_at": {
262
+ "type": "string",
263
+ "format": "date-time"
264
+ },
265
+ "as_of": {
266
+ "type": "string",
267
+ "format": "date",
268
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
269
+ "description": "Real calendar date, 1900-01-01 through today Asia/Kolkata; replacement cannot move backwards."
270
+ },
271
+ "time_zone": {
272
+ "const": "Asia/Kolkata"
273
+ },
274
+ "age_days": {
275
+ "anyOf": [
276
+ {
277
+ "type": "integer"
278
+ },
279
+ {
280
+ "type": "null"
281
+ }
282
+ ]
283
+ },
284
+ "recent_within_days": {
285
+ "const": 3
286
+ }
287
+ },
288
+ "required": [
289
+ "status",
290
+ "checked_at",
291
+ "as_of",
292
+ "time_zone",
293
+ "age_days",
294
+ "recent_within_days"
295
+ ],
296
+ "additionalProperties": true
297
+ }
298
+ },
299
+ "required": [
300
+ "instrument",
301
+ "market",
302
+ "currency",
303
+ "scheme_id",
304
+ "plan_label",
305
+ "option_label",
306
+ "amfi_code",
307
+ "isin",
308
+ "identity_status",
309
+ "latest_nav",
310
+ "data_mode",
311
+ "source",
312
+ "freshness"
313
+ ],
314
+ "additionalProperties": true
315
+ }
316
+ },
317
+ "has_more": {
318
+ "type": "boolean"
319
+ },
320
+ "url": {
321
+ "type": "string"
322
+ },
323
+ "market_data": {
324
+ "type": "object",
325
+ "properties": {
326
+ "mode": {
327
+ "type": "string",
328
+ "x-known-values": [
329
+ "live",
330
+ "fixture",
331
+ "unavailable"
332
+ ],
333
+ "minLength": 1
334
+ },
335
+ "notice": {
336
+ "type": "string"
337
+ }
338
+ },
339
+ "required": [
340
+ "mode",
341
+ "notice"
342
+ ],
343
+ "additionalProperties": true
344
+ }
345
+ },
346
+ "required": [
347
+ "object",
348
+ "data",
349
+ "has_more",
350
+ "url",
351
+ "market_data"
352
+ ],
353
+ "additionalProperties": true
354
+ }
355
+ }
356
+ }
357
+ };
@@ -0,0 +1,2 @@
1
+ import type { Operation } from "./schema.cjs";
2
+ export const operations: Readonly<Record<string, Operation>>;
@@ -0,0 +1,2 @@
1
+ import type { Operation } from "./schema.js";
2
+ export const operations: Readonly<Record<string, Operation>>;
@@ -5,6 +5,7 @@ import type * as D from "./market-types.cjs";
5
5
  import type { CurrentMixEvidence } from "./client-types.cjs";
6
6
  /** Each entry is the decoded response of the corresponding generated operation. */
7
7
  export interface OperationResults {
8
+ searchMarketSchemes: M.FundsList;
8
9
  analytics_scheme: A.SchemePerformance;
9
10
  analytics_category: A.CategoryStatistics;
10
11
  monthly_nav: S.MarketSnapshot<D.NavObservation>;
@@ -5,6 +5,7 @@ import type * as D from "./market-types.js";
5
5
  import type { CurrentMixEvidence } from "./client-types.js";
6
6
  /** Each entry is the decoded response of the corresponding generated operation. */
7
7
  export interface OperationResults {
8
+ searchMarketSchemes: M.FundsList;
8
9
  analytics_scheme: A.SchemePerformance;
9
10
  analytics_category: A.CategoryStatistics;
10
11
  monthly_nav: S.MarketSnapshot<D.NavObservation>;
@@ -55,6 +55,11 @@ function responseMatches(id, op, data, params, body, account) {
55
55
  (typeof params.limit === "number" && page.length > params.limit))
56
56
  return false;
57
57
  }
58
+ if (id === "searchMarketSchemes") {
59
+ const page = rows(d("data"));
60
+ if (d("url") !== op.path || page.length > (typeof params.limit === "number" ? params.limit : 10) || (d("has_more") === true && page.length === 0))
61
+ return false;
62
+ }
58
63
  if (op.marketData) {
59
64
  if (id.endsWith("_get") && d("id") !== params.id)
60
65
  return false;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.check = check;
4
4
  exports.keys = keys;
5
5
  exports.createTransport = createTransport;
6
+ const market_search_cjs_1 = require("./market-search.cjs");
6
7
  const analytics_contract_cjs_1 = require("./analytics-contract.cjs");
7
8
  const monthly_market_data_cjs_1 = require("./monthly-market-data.cjs");
8
9
  const contract_cjs_1 = require("./contract.cjs");
@@ -15,6 +16,7 @@ const operations = {
15
16
  ...market_data_cjs_1.operations,
16
17
  ...monthly_market_data_cjs_1.operations,
17
18
  ...analytics_contract_cjs_1.operations,
19
+ ...market_search_cjs_1.operations,
18
20
  };
19
21
  function assertServer() {
20
22
  if (typeof window !== "undefined" ||
@@ -209,7 +211,7 @@ function createTransport(input, marketOnly = false) {
209
211
  const call = async (id, params = {}, body, opts = {}) => {
210
212
  const op = operations[id];
211
213
  if (marketOnly &&
212
- !["monthly_nav", "monthly_expense", "monthly_portfolio", "monthly_holdings"].includes(id)) {
214
+ !["monthly_nav", "monthly_expense", "monthly_portfolio", "monthly_holdings", "searchMarketSchemes"].includes(id)) {
213
215
  throw Object.assign(new errors_cjs_1.ValidationError(), { code: "market_only_operation" });
214
216
  }
215
217
  let o, serialized, url;
package/docs/analytics.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Growth scheme performance and category returns
2
2
 
3
- The two analytics methods are deployed and published in SDK 0.4.0. This local unified-key successor preserves 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.
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";
@@ -4,18 +4,20 @@
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 your authorized account ID and account key. 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.
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 the unpublished 0.5.0 candidate
9
+ ## Install from npm
10
10
 
11
11
  ```sh
12
- npm install /absolute/path/to/bharosa-0.5.0.tgz --ignore-scripts
12
+ npm install bharosa
13
13
  ```
14
14
 
15
15
  Source contributors can build and pack a local archive as described in CONTRIBUTING.md.
16
16
 
17
17
  ## Read your account
18
18
 
19
+ This call requires the optional own-account read permission. An account ID is not a prerequisite: the API-key shorthand selects `me`. Use an explicit `account` only when needed; delegated access uses the server-authorized account.
20
+
19
21
  In an ESM application, save this as `account.mjs`:
20
22
 
21
23
  ```js
@@ -28,14 +30,13 @@ function required(name) {
28
30
  }
29
31
 
30
32
  const bharosa = new Bharosa({
31
- account: required("BHAROSA_ACCOUNT_ID"),
32
- auth: { type: "account_key", apiKey: required("BHAROSA_SECRET_KEY") },
33
+ apiKey: required("BHAROSA_SECRET_KEY"),
33
34
  });
34
35
  const account = await bharosa.accounts.retrieve();
35
36
  console.log(account.id);
36
37
  ```
37
38
 
38
- Supply those variables through your application's secret management, then run `node account.mjs`. Do not commit their values. For another deployment or tests, explicitly supply `baseUrl`. It must use HTTPS and contain no path, query, user information, or fragment; local HTTP additionally requires `allowLocalhostHttp: true`. Invalid explicit origins fail before sending a request.
39
+ Supply `BHAROSA_SECRET_KEY` through your application's secret management, then run `node account.mjs`. Do not commit their values. For another deployment or tests, explicitly supply `baseUrl`. It must use HTTPS and contain no path, query, user information, or fragment; local HTTP additionally requires `allowLocalhostHttp: true`. Invalid explicit origins fail before sending a request.
39
40
 
40
41
  CommonJS applications use `const { Bharosa } = require("bharosa")` inside an async function. TypeScript applications import types from the same root package; do not import files from `dist/`.
41
42
 
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. This SDK is not yet published on npm; install it from a local archive. Ask your service operator for API access separately.
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 locally and make your first request](getting-started.md).
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,19 @@
1
- # Monthly market snapshots
1
+ # Latest NAV and monthly market snapshots
2
2
 
3
- `client.mutualFundSchemes` and `client.mutualFunds.portfolios` provide month-start market history and current NAV valuation. Monthly market data requires no separate application approval. Use authenticated credentials with the required account-read scope; installing the SDK does not authenticate you or grant private account access. Availability still depends on the deployed service and source data.
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
+ SDK 0.6.0 adds baseline discovery through `client.markets.schemes.search({ query: "equity", limit: 5 })`, returning `data`, `has_more`, `url` and `market_data`. Use a returned `scheme_id` for NAV and expense methods. Choose among the plan/option labels; do not assume the first result is the intended investment. Refine the query when `has_more` is true; no cursor or historical selection is accepted. Search uses the account-independent `/v1/market-data/schemes/search` route.
15
+
16
+ The existing account-scoped discovery and analytics methods below retain their account permissions. Baseline access never grants private analytics.
4
17
 
5
18
  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
19
 
@@ -24,7 +37,7 @@ Replace the search term with a fund you intend to inspect and choose among the r
24
37
 
25
38
  Supported methods:
26
39
 
27
- - `mutualFundSchemes.navs.retrieve(schemeId, { asOf })`
40
+ - `mutualFundSchemes.navs.retrieve(schemeId)` for latest NAV, or pass `{ asOf }` for a monthly snapshot
28
41
  - `mutualFundSchemes.expenseRatios.retrieve(schemeId, { asOf })`
29
42
  - `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
43
  - `mutualFunds.portfolios.retrieve(fundOwnerId, { asOf })`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bharosa",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "description": "Typed Bharosa resource SDK with server credentials or caller-owned transport.",
6
6
  "license": "MIT",
@@ -45,7 +45,8 @@
45
45
  "CHANGELOG.md",
46
46
  "FIRST-PARTY-CONTRACT-SHA256",
47
47
  "MONTHLY-MARKET-CONTRACT-SHA256",
48
- "ANALYTICS-CONTRACT-SHA256"
48
+ "ANALYTICS-CONTRACT-SHA256",
49
+ "MARKET-SEARCH-CONTRACT-SHA256"
49
50
  ],
50
51
  "scripts": {
51
52
  "build": "node scripts/build.mjs",
@@ -61,7 +62,9 @@
61
62
  "generate:monthly": "node scripts/generate-monthly.mjs",
62
63
  "check:monthly": "node scripts/generate-monthly.mjs --check",
63
64
  "generate:analytics": "node scripts/generate-analytics.mjs",
64
- "check:analytics": "node scripts/generate-analytics.mjs --check"
65
+ "check:analytics": "node scripts/generate-analytics.mjs --check",
66
+ "generate:market-search": "node scripts/generate-market-search.mjs",
67
+ "check:market-search": "node scripts/generate-market-search.mjs --check"
65
68
  },
66
69
  "publishConfig": {
67
70
  "access": "public",