@rundit-sdk/client 0.2.0 → 0.3.0-rc.13

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/index.js CHANGED
@@ -21,10 +21,35 @@ const routeManifest = {
21
21
  "path": "/companies",
22
22
  "summary": "List companies available to the SDK consumer",
23
23
  "description": null,
24
- "exampleCall": "client.companies.getAll()",
24
+ "exampleCall": "client.companies.getAll({ limit: 123 })",
25
25
  "responseType": "CompaniesGetAllResponse",
26
26
  "pathParams": [],
27
- "queryParams": []
27
+ "queryParams": [
28
+ {
29
+ "name": "limit",
30
+ "required": false,
31
+ "type": "number",
32
+ "description": "Maximum items per page. Currently accepted but not enforced; reserved for future pagination."
33
+ },
34
+ {
35
+ "name": "cursor",
36
+ "required": false,
37
+ "type": "string",
38
+ "description": "Opaque cursor from a previous response's meta.nextCursor. Currently accepted but ignored."
39
+ },
40
+ {
41
+ "name": "companyIds",
42
+ "required": false,
43
+ "type": "number[]",
44
+ "description": "Restrict results to these company identifiers"
45
+ },
46
+ {
47
+ "name": "companyGroupIds",
48
+ "required": false,
49
+ "type": "number[]",
50
+ "description": "Restrict results to companies that belong to any of these company groups"
51
+ }
52
+ ]
28
53
  }
29
54
  },
30
55
  "companyGroups": {
@@ -33,10 +58,29 @@ const routeManifest = {
33
58
  "path": "/company-groups",
34
59
  "summary": "List company groups available to the SDK consumer",
35
60
  "description": null,
36
- "exampleCall": "client.companyGroups.getAll()",
61
+ "exampleCall": "client.companyGroups.getAll({ limit: 123 })",
37
62
  "responseType": "CompanyGroupsGetAllResponse",
38
63
  "pathParams": [],
39
- "queryParams": []
64
+ "queryParams": [
65
+ {
66
+ "name": "limit",
67
+ "required": false,
68
+ "type": "number",
69
+ "description": "Maximum items per page. Currently accepted but not enforced; reserved for future pagination."
70
+ },
71
+ {
72
+ "name": "cursor",
73
+ "required": false,
74
+ "type": "string",
75
+ "description": "Opaque cursor from a previous response's meta.nextCursor. Currently accepted but ignored."
76
+ },
77
+ {
78
+ "name": "companyGroupIds",
79
+ "required": false,
80
+ "type": "number[]",
81
+ "description": "Restrict results to these company group identifiers"
82
+ }
83
+ ]
40
84
  },
41
85
  "getOne": {
42
86
  "method": "GET",
@@ -72,10 +116,22 @@ const routeManifest = {
72
116
  ],
73
117
  "queryParams": [
74
118
  {
75
- "name": "companyGroupId",
119
+ "name": "limit",
76
120
  "required": false,
77
121
  "type": "number",
78
- "description": "Optional company group identifier to filter by"
122
+ "description": "Maximum items per page. Currently accepted but not enforced; reserved for future pagination."
123
+ },
124
+ {
125
+ "name": "cursor",
126
+ "required": false,
127
+ "type": "string",
128
+ "description": "Opaque cursor from a previous response's meta.nextCursor. Currently accepted but ignored."
129
+ },
130
+ {
131
+ "name": "companyGroupIds",
132
+ "required": false,
133
+ "type": "number[]",
134
+ "description": "Optional list of company group identifiers to filter the position breakdown"
79
135
  },
80
136
  {
81
137
  "name": "currency",
@@ -106,6 +162,12 @@ const routeManifest = {
106
162
  "type": "number[]",
107
163
  "description": "Optional list of company group identifiers to filter the portfolio positions"
108
164
  },
165
+ {
166
+ "name": "companyIds",
167
+ "required": false,
168
+ "type": "number[]",
169
+ "description": "Optional list of company identifiers to narrow the aggregation to"
170
+ },
109
171
  {
110
172
  "name": "currency",
111
173
  "required": true,
@@ -127,7 +189,7 @@ const routeManifest = {
127
189
  "path": "/transactions/companies/:id",
128
190
  "summary": "Get transactions for one company",
129
191
  "description": null,
130
- "exampleCall": "client.transactions.getCompanyTransactions(123, { companyGroupIds: [123] })",
192
+ "exampleCall": "client.transactions.getCompanyTransactions(123, { limit: 123 })",
131
193
  "responseType": "TransactionsGetCompanyTransactionsResponse",
132
194
  "pathParams": [
133
195
  {
@@ -137,11 +199,35 @@ const routeManifest = {
137
199
  }
138
200
  ],
139
201
  "queryParams": [
202
+ {
203
+ "name": "limit",
204
+ "required": false,
205
+ "type": "number",
206
+ "description": "Maximum items per page. Currently accepted but not enforced; reserved for future pagination."
207
+ },
208
+ {
209
+ "name": "cursor",
210
+ "required": false,
211
+ "type": "string",
212
+ "description": "Opaque cursor from a previous response's meta.nextCursor. Currently accepted but ignored."
213
+ },
140
214
  {
141
215
  "name": "companyGroupIds",
142
216
  "required": false,
143
217
  "type": "number[]",
144
218
  "description": "Optional company group identifiers to filter transactions by"
219
+ },
220
+ {
221
+ "name": "types",
222
+ "required": false,
223
+ "type": "(\"Auction\" | \"ConvertibleNote\" | \"ConvertToEquity\" | \"Dividend\" | \"EquityInvestment\" | \"EquityReceived\" | \"Extend\" | \"FutureEquityAgreement\" | \"Insolvency\" | \"IPO\" | \"LimitedAuction\" | \"OptionsReceived\" | \"OtherExit\" | \"OtherInvestment\" | \"OtherRealization\" | \"Payback\" | \"Proprietary\" | \"TradeSale\" | \"ValuationChange\" | \"WriteOff\")[]",
224
+ "description": "Restrict results to these transaction types"
225
+ },
226
+ {
227
+ "name": "priorTo",
228
+ "required": false,
229
+ "type": "string",
230
+ "description": "Exclude transactions on or after this ISO 8601 date (cut-off filter)"
145
231
  }
146
232
  ]
147
233
  },
@@ -150,16 +236,40 @@ const routeManifest = {
150
236
  "path": "/transactions",
151
237
  "summary": "Get transactions for multiple companies",
152
238
  "description": null,
153
- "exampleCall": "client.transactions.getTransactions({ companyGroupIds: [123] })",
239
+ "exampleCall": "client.transactions.getTransactions({ limit: 123 })",
154
240
  "responseType": "TransactionsGetTransactionsResponse",
155
241
  "pathParams": [],
156
242
  "queryParams": [
243
+ {
244
+ "name": "limit",
245
+ "required": false,
246
+ "type": "number",
247
+ "description": "Maximum items per page. Currently accepted but not enforced; reserved for future pagination."
248
+ },
249
+ {
250
+ "name": "cursor",
251
+ "required": false,
252
+ "type": "string",
253
+ "description": "Opaque cursor from a previous response's meta.nextCursor. Currently accepted but ignored."
254
+ },
157
255
  {
158
256
  "name": "companyGroupIds",
159
257
  "required": false,
160
258
  "type": "number[]",
161
259
  "description": "Optional company group identifiers to filter transactions by"
162
260
  },
261
+ {
262
+ "name": "types",
263
+ "required": false,
264
+ "type": "(\"Auction\" | \"ConvertibleNote\" | \"ConvertToEquity\" | \"Dividend\" | \"EquityInvestment\" | \"EquityReceived\" | \"Extend\" | \"FutureEquityAgreement\" | \"Insolvency\" | \"IPO\" | \"LimitedAuction\" | \"OptionsReceived\" | \"OtherExit\" | \"OtherInvestment\" | \"OtherRealization\" | \"Payback\" | \"Proprietary\" | \"TradeSale\" | \"ValuationChange\" | \"WriteOff\")[]",
265
+ "description": "Restrict results to these transaction types"
266
+ },
267
+ {
268
+ "name": "priorTo",
269
+ "required": false,
270
+ "type": "string",
271
+ "description": "Exclude transactions on or after this ISO 8601 date (cut-off filter)"
272
+ },
163
273
  {
164
274
  "name": "companyIds",
165
275
  "required": false,
@@ -168,8 +278,102 @@ const routeManifest = {
168
278
  }
169
279
  ]
170
280
  }
281
+ },
282
+ "metrics": {
283
+ "getTypes": {
284
+ "method": "GET",
285
+ "path": "/metrics/types",
286
+ "summary": "List metric types available to the SDK consumer",
287
+ "description": "Returns predefined metric types plus user-defined metric types scoped to the caller — VC group custom types for VC users, company custom types for company users. Each entry includes a numeric id and a human-readable name suitable for display or LLM context.",
288
+ "exampleCall": "client.metrics.getTypes()",
289
+ "responseType": "MetricsGetTypesResponse",
290
+ "pathParams": [],
291
+ "queryParams": []
292
+ },
293
+ "search": {
294
+ "method": "POST",
295
+ "path": "/metrics",
296
+ "summary": "Read metric values for accessible companies, grouped by company",
297
+ "description": "Returns metric data points for companies the caller can access (companies in the caller's VC group portfolio, or the caller's own company for company users). Each entry carries company and metric type references with id and human-readable name. Filter by company, company group, metric type, timeframe, and date range to narrow the response.",
298
+ "exampleCall": "client.metrics.search({})",
299
+ "responseType": "MetricsSearchResponse",
300
+ "pathParams": [],
301
+ "queryParams": []
302
+ }
303
+ },
304
+ "companyReports": {
305
+ "list": {
306
+ "method": "GET",
307
+ "path": "/company-reports",
308
+ "summary": "List published company reports accessible to the caller (metadata only)",
309
+ "description": "Returns lightweight report metadata (id, title, period, publisher company reference). Use GET /company-reports/:id to fetch the full content of a specific report. Visibility is determined by the caller's roles — VC users see reports for managed-portfolio companies, company employees see their own company's reports, portfolio investors see Published reports shared with their visibility groups. Filters narrow the list by company ids and reporting period (timeframe + date range).",
310
+ "exampleCall": "client.companyReports.list({ limit: 123 })",
311
+ "responseType": "CompanyReportsListResponse",
312
+ "pathParams": [],
313
+ "queryParams": [
314
+ {
315
+ "name": "limit",
316
+ "required": false,
317
+ "type": "number",
318
+ "description": "Maximum items per page. Currently accepted but not enforced; reserved for future pagination."
319
+ },
320
+ {
321
+ "name": "cursor",
322
+ "required": false,
323
+ "type": "string",
324
+ "description": "Opaque cursor from a previous response's meta.nextCursor. Currently accepted but ignored."
325
+ },
326
+ {
327
+ "name": "companyIds",
328
+ "required": false,
329
+ "type": "number[]",
330
+ "description": "Restrict results to these companies. Defaults to all companies the caller can access."
331
+ },
332
+ {
333
+ "name": "companyGroupIds",
334
+ "required": false,
335
+ "type": "number[]",
336
+ "description": "Restrict to companies that belong to any of these company groups."
337
+ },
338
+ {
339
+ "name": "timeframe",
340
+ "required": false,
341
+ "type": "\"Month\" | \"Quarter\" | \"Year\"",
342
+ "description": "Restrict to a reporting period granularity (Month, Quarter, Year)."
343
+ },
344
+ {
345
+ "name": "from",
346
+ "required": false,
347
+ "type": "string",
348
+ "description": "Lower bound for the reporting period date (ISO 8601, inclusive)."
349
+ },
350
+ {
351
+ "name": "to",
352
+ "required": false,
353
+ "type": "string",
354
+ "description": "Upper bound for the reporting period date (ISO 8601, inclusive)."
355
+ }
356
+ ]
357
+ },
358
+ "getOne": {
359
+ "method": "GET",
360
+ "path": "/company-reports/:id",
361
+ "summary": "Fetch the full content of a single company report",
362
+ "description": "Returns the report metadata plus structured sections (text/markdown/image) and attachments with pre-signed URLs. Returns 404 if the report does not exist and 403 if the caller cannot access it under their role-based permissions.",
363
+ "exampleCall": "client.companyReports.getOne(123)",
364
+ "responseType": "CompanyReportsGetOneResponse",
365
+ "pathParams": [
366
+ {
367
+ "name": "id",
368
+ "type": "number",
369
+ "description": "Report identifier"
370
+ }
371
+ ],
372
+ "queryParams": []
373
+ }
171
374
  }
172
375
  }
376
+ const defaultBaseUrl = "https://api.rundit.com/api/v2/sdk"
173
377
 
174
378
  export class RunditSdkError extends Error {
175
379
  constructor(message, details) {
@@ -257,7 +461,7 @@ async function parseResponse(response) {
257
461
 
258
462
  function createRequester(options) {
259
463
  const fetchImplementation = resolveFetch(options.fetch)
260
- const baseUrl = normalizeBaseUrl(options.baseUrl)
464
+ const baseUrl = normalizeBaseUrl(options.baseUrl || defaultBaseUrl)
261
465
  const shouldBypassNgrokBrowserWarning = shouldSendNgrokBypassHeader(baseUrl)
262
466
  const defaultHeaders = {
263
467
  Accept: 'application/json',
@@ -266,58 +470,76 @@ function createRequester(options) {
266
470
  "X-API-Key": options.apiKey,
267
471
  }
268
472
 
269
- return async ({ method, path, pathParams, query, signal }) => {
473
+ return async ({ method, path, pathParams, query, body, signal }) => {
270
474
  const url = appendQueryString(baseUrl + interpolatePath(path, pathParams), query)
475
+ const hasBody = body !== undefined && body !== null
476
+ const requestHeaders = hasBody ? { ...defaultHeaders, 'Content-Type': 'application/json' } : defaultHeaders
477
+
271
478
  const response = await fetchImplementation(url, {
272
479
  method,
273
- headers: defaultHeaders,
480
+ headers: requestHeaders,
481
+ body: hasBody ? JSON.stringify(body) : undefined,
274
482
  signal,
275
483
  })
276
484
 
277
- const body = await parseResponse(response)
485
+ const responseBody = await parseResponse(response)
278
486
 
279
487
  if (!response.ok) {
280
488
  throw new RunditSdkError(`Rundit request failed with status ${response.status}`, {
281
489
  status: response.status,
282
- body,
490
+ body: responseBody,
283
491
  })
284
492
  }
285
493
 
286
- return body
494
+ return responseBody
287
495
  }
288
496
  }
289
497
 
290
498
  function createCompaniesNamespace(request) {
291
499
  return {
292
- getOne: (id, init = {}) => request({ method: "GET", path: "/companies/:id", pathParams: { id }, query: undefined, signal: init.signal }),
293
- getAll: (init = {}) => request({ method: "GET", path: "/companies", pathParams: undefined, query: undefined, signal: init.signal }),
500
+ getOne: (id, init = {}) => request({ method: "GET", path: "/companies/:id", pathParams: { id }, query: undefined, body: undefined, signal: init.signal }),
501
+ getAll: (query = {}, init = {}) => request({ method: "GET", path: "/companies", pathParams: undefined, query: query, body: undefined, signal: init.signal }),
294
502
  }
295
503
  }
296
504
 
297
505
  function createCompanyGroupsNamespace(request) {
298
506
  return {
299
- getAll: (init = {}) => request({ method: "GET", path: "/company-groups", pathParams: undefined, query: undefined, signal: init.signal }),
300
- getOne: (id, init = {}) => request({ method: "GET", path: "/company-groups/:id", pathParams: { id }, query: undefined, signal: init.signal }),
507
+ getAll: (query = {}, init = {}) => request({ method: "GET", path: "/company-groups", pathParams: undefined, query: query, body: undefined, signal: init.signal }),
508
+ getOne: (id, init = {}) => request({ method: "GET", path: "/company-groups/:id", pathParams: { id }, query: undefined, body: undefined, signal: init.signal }),
301
509
  }
302
510
  }
303
511
 
304
512
  function createPositionsNamespace(request) {
305
513
  return {
306
- getCompanyPositions: (id, query = {}, init = {}) => request({ method: "GET", path: "/positions/companies/:id", pathParams: { id }, query: query, signal: init.signal }),
307
- getPortfolioPositions: (query = {}, init = {}) => request({ method: "GET", path: "/positions/portfolio", pathParams: undefined, query: query, signal: init.signal }),
514
+ getCompanyPositions: (id, query = {}, init = {}) => request({ method: "GET", path: "/positions/companies/:id", pathParams: { id }, query: query, body: undefined, signal: init.signal }),
515
+ getPortfolioPositions: (query = {}, init = {}) => request({ method: "GET", path: "/positions/portfolio", pathParams: undefined, query: query, body: undefined, signal: init.signal }),
308
516
  }
309
517
  }
310
518
 
311
519
  function createTransactionsNamespace(request) {
312
520
  return {
313
- getCompanyTransactions: (id, query = {}, init = {}) => request({ method: "GET", path: "/transactions/companies/:id", pathParams: { id }, query: query, signal: init.signal }),
314
- getTransactions: (query = {}, init = {}) => request({ method: "GET", path: "/transactions", pathParams: undefined, query: query, signal: init.signal }),
521
+ getCompanyTransactions: (id, query = {}, init = {}) => request({ method: "GET", path: "/transactions/companies/:id", pathParams: { id }, query: query, body: undefined, signal: init.signal }),
522
+ getTransactions: (query = {}, init = {}) => request({ method: "GET", path: "/transactions", pathParams: undefined, query: query, body: undefined, signal: init.signal }),
523
+ }
524
+ }
525
+
526
+ function createMetricsNamespace(request) {
527
+ return {
528
+ getTypes: (init = {}) => request({ method: "GET", path: "/metrics/types", pathParams: undefined, query: undefined, body: undefined, signal: init.signal }),
529
+ search: (body, init = {}) => request({ method: "POST", path: "/metrics", pathParams: undefined, query: undefined, body: body, signal: init.signal }),
530
+ }
531
+ }
532
+
533
+ function createCompanyReportsNamespace(request) {
534
+ return {
535
+ list: (query = {}, init = {}) => request({ method: "GET", path: "/company-reports", pathParams: undefined, query: query, body: undefined, signal: init.signal }),
536
+ getOne: (id, init = {}) => request({ method: "GET", path: "/company-reports/:id", pathParams: { id }, query: undefined, body: undefined, signal: init.signal }),
315
537
  }
316
538
  }
317
539
 
318
540
  export function createClient(options) {
319
- if (!options || typeof options.baseUrl !== 'string' || options.baseUrl.length === 0) {
320
- throw new Error('options.baseUrl is required')
541
+ if (!options || typeof options !== 'object') {
542
+ throw new Error('options is required')
321
543
  }
322
544
 
323
545
  if (!options.apiKey) {
@@ -331,6 +553,8 @@ export function createClient(options) {
331
553
  companyGroups: createCompanyGroupsNamespace(request),
332
554
  positions: createPositionsNamespace(request),
333
555
  transactions: createTransactionsNamespace(request),
556
+ metrics: createMetricsNamespace(request),
557
+ companyReports: createCompanyReportsNamespace(request),
334
558
  }
335
559
  }
336
560