@ganaka/sdk 1.2.0 → 1.4.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/dist/index.mjs CHANGED
@@ -4172,7 +4172,7 @@ object({
4172
4172
  statusCode: number$1(),
4173
4173
  message: string()
4174
4174
  });
4175
- const m = [
4175
+ const c = [
4176
4176
  "1minute",
4177
4177
  "2minute",
4178
4178
  "3minute",
@@ -4225,7 +4225,7 @@ const m = [
4225
4225
  name: string(),
4226
4226
  price: number$1(),
4227
4227
  quoteData: a.nullable().optional()
4228
- }), c = _enum(["TOP_GAINERS", "VOLUME_SHOCKERS"]), b = object({
4228
+ }), m = _enum(["TOP_GAINERS", "VOLUME_SHOCKERS"]), b = object({
4229
4229
  nseSymbol: string(),
4230
4230
  quoteData: a
4231
4231
  });
@@ -4234,7 +4234,7 @@ const m = [
4234
4234
  data: object({
4235
4235
  timestamp: n,
4236
4236
  timezone: o.optional(),
4237
- shortlistType: c,
4237
+ shortlistType: m,
4238
4238
  entries: array(d)
4239
4239
  })
4240
4240
  }),
@@ -4243,7 +4243,7 @@ const m = [
4243
4243
  id: string(),
4244
4244
  timestamp: string(),
4245
4245
  // Format: YYYY-MM-DDTHH:mm:ss (UTC)
4246
- shortlistType: c,
4246
+ shortlistType: m,
4247
4247
  entriesCount: number$1()
4248
4248
  })
4249
4249
  })
@@ -4294,10 +4294,10 @@ const p = object({
4294
4294
  end_time: string(),
4295
4295
  interval_in_minutes: number$1()
4296
4296
  })
4297
- }), f = {
4297
+ }), v = {
4298
4298
  query: object({
4299
4299
  symbol: string(),
4300
- interval: _enum(m),
4300
+ interval: _enum(c),
4301
4301
  start_datetime: n,
4302
4302
  end_datetime: n,
4303
4303
  timezone: o.optional()
@@ -4305,7 +4305,7 @@ const p = object({
4305
4305
  response: t.extend({
4306
4306
  data: p
4307
4307
  })
4308
- }, v = {
4308
+ }, f = {
4309
4309
  query: object({
4310
4310
  symbol: string(),
4311
4311
  exchange: _enum(["NSE", "BSE"]).optional(),
@@ -4323,7 +4323,8 @@ const p = object({
4323
4323
  }, x = {
4324
4324
  query: object({
4325
4325
  symbol: string(),
4326
- date: i
4326
+ end_datetime: n,
4327
+ timezone: o.optional()
4327
4328
  }),
4328
4329
  response: t.extend({
4329
4330
  data: object({
@@ -4350,11 +4351,11 @@ const p = object({
4350
4351
  response: t.extend({
4351
4352
  data: a.nullable()
4352
4353
  })
4353
- }, ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4354
+ }, je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4354
4355
  __proto__: null,
4355
- getGrowwHistoricalCandles: f,
4356
+ getGrowwHistoricalCandles: v,
4356
4357
  getGrowwNiftyQuote: P,
4357
- getGrowwQuote: v,
4358
+ getGrowwQuote: f,
4358
4359
  getGrowwQuoteTimeline: x,
4359
4360
  getGrowwToken: T,
4360
4361
  growwHistoricalCandlesSchema: p
@@ -4362,7 +4363,7 @@ const p = object({
4362
4363
  name: string(),
4363
4364
  price: number$1(),
4364
4365
  nseSymbol: string()
4365
- }), q = {
4366
+ }), O = {
4366
4367
  query: object({
4367
4368
  type: _enum(["top-gainers", "volume-shockers"]),
4368
4369
  datetime: n.optional(),
@@ -4371,11 +4372,38 @@ const p = object({
4371
4372
  response: t.extend({
4372
4373
  data: array(g).nullable()
4373
4374
  })
4374
- }, je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4375
+ }, he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4375
4376
  __proto__: null,
4376
- getLists: q,
4377
+ getLists: O,
4377
4378
  listSchema: g
4378
- }, Symbol.toStringTag, { value: "Module" })), O = {
4379
+ }, Symbol.toStringTag, { value: "Module" })), q = {
4380
+ query: object({
4381
+ type: _enum(["top-gainers", "volume-shockers"]),
4382
+ start_datetime: n,
4383
+ end_datetime: n,
4384
+ timezone: o.optional()
4385
+ }),
4386
+ response: t.extend({
4387
+ data: object({
4388
+ start_datetime: string(),
4389
+ end_datetime: string(),
4390
+ type: _enum(["top-gainers", "volume-shockers"]),
4391
+ totalSnapshots: number$1(),
4392
+ instruments: array(
4393
+ object({
4394
+ nseSymbol: string(),
4395
+ name: string(),
4396
+ appearanceCount: number$1(),
4397
+ totalSnapshots: number$1(),
4398
+ percentage: number$1()
4399
+ })
4400
+ )
4401
+ })
4402
+ })
4403
+ }, Se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4404
+ __proto__: null,
4405
+ getShortlistPersistence: q
4406
+ }, Symbol.toStringTag, { value: "Module" })), z = {
4379
4407
  query: object({}),
4380
4408
  response: t.extend({
4381
4409
  data: object({
@@ -4391,12 +4419,12 @@ const p = object({
4391
4419
  })
4392
4420
  }, w = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4393
4421
  __proto__: null,
4394
- getAvailableDatetimes: O
4395
- }, Symbol.toStringTag, { value: "Module" })), z = {
4422
+ getAvailableDatetimes: z
4423
+ }, Symbol.toStringTag, { value: "Module" })), D = {
4396
4424
  query: object({
4397
4425
  symbol: string(),
4398
4426
  date: i,
4399
- interval: _enum(m).optional()
4427
+ interval: _enum(c).optional()
4400
4428
  }),
4401
4429
  response: t.extend({
4402
4430
  data: object({
@@ -4414,10 +4442,10 @@ const p = object({
4414
4442
  interval_in_minutes: number$1()
4415
4443
  })
4416
4444
  })
4417
- }, D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4445
+ }, C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4418
4446
  __proto__: null,
4419
- getCandles: z
4420
- }, Symbol.toStringTag, { value: "Module" })), C = {
4447
+ getCandles: D
4448
+ }, Symbol.toStringTag, { value: "Module" })), M = {
4421
4449
  query: object({
4422
4450
  date: i,
4423
4451
  type: _enum(t$1)
@@ -4437,10 +4465,10 @@ const p = object({
4437
4465
  )
4438
4466
  })
4439
4467
  })
4440
- }, M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4468
+ }, R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4441
4469
  __proto__: null,
4442
- getDailyPersistentCompanies: C
4443
- }, Symbol.toStringTag, { value: "Module" })), R = {
4470
+ getDailyPersistentCompanies: M
4471
+ }, Symbol.toStringTag, { value: "Module" })), A = {
4444
4472
  query: object({
4445
4473
  date: i,
4446
4474
  type: _enum(t$1)
@@ -4452,23 +4480,23 @@ const p = object({
4452
4480
  uniqueCount: number$1()
4453
4481
  })
4454
4482
  })
4455
- }, A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4483
+ }, k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4456
4484
  __proto__: null,
4457
- getDailyUniqueCompanies: R
4458
- }, Symbol.toStringTag, { value: "Module" })), k = object({
4485
+ getDailyUniqueCompanies: A
4486
+ }, Symbol.toStringTag, { value: "Module" })), E = object({
4459
4487
  id: uuid(),
4460
4488
  username: string()
4461
- }), E = {
4489
+ }), I = {
4462
4490
  body: object({
4463
4491
  developerToken: string().nonempty("Developer token is required")
4464
4492
  }),
4465
4493
  response: t.extend({
4466
- data: k
4494
+ data: E
4467
4495
  })
4468
- }, I = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4496
+ }, L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4469
4497
  __proto__: null,
4470
- signIn: E
4471
- }, Symbol.toStringTag, { value: "Module" })), L = {
4498
+ signIn: I
4499
+ }, Symbol.toStringTag, { value: "Module" })), N = {
4472
4500
  query: object({
4473
4501
  symbol: string(),
4474
4502
  date: i
@@ -4490,10 +4518,10 @@ const p = object({
4490
4518
  )
4491
4519
  })
4492
4520
  })
4493
- }, N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4521
+ }, G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4494
4522
  __proto__: null,
4495
- getQuoteTimeline: L
4496
- }, Symbol.toStringTag, { value: "Module" })), G = object({
4523
+ getQuoteTimeline: N
4524
+ }, Symbol.toStringTag, { value: "Module" })), U = object({
4497
4525
  id: uuid(),
4498
4526
  start_datetime: string(),
4499
4527
  end_datetime: string(),
@@ -4501,15 +4529,15 @@ const p = object({
4501
4529
  orderCount: number$1(),
4502
4530
  name: string().nullable().optional(),
4503
4531
  tags: array(string()).optional()
4504
- }), U = record(
4532
+ }), Q = record(
4505
4533
  string(),
4506
4534
  // date string (YYYY-MM-DD)
4507
- array(G)
4508
- ), Q = {
4535
+ array(U)
4536
+ ), Y = {
4509
4537
  response: t.extend({
4510
- data: U
4538
+ data: Q
4511
4539
  })
4512
- }, Y = object({
4540
+ }, H = object({
4513
4541
  id: uuid(),
4514
4542
  nseSymbol: string(),
4515
4543
  entryPrice: number(),
@@ -4528,7 +4556,7 @@ const p = object({
4528
4556
  stopLossHit: boolean().optional(),
4529
4557
  stopLossTimestamp: string().optional(),
4530
4558
  timeToStopLossMinutes: number$1().optional()
4531
- }), H = {
4559
+ }), $ = {
4532
4560
  params: object({
4533
4561
  runId: uuid()
4534
4562
  }),
@@ -4536,46 +4564,46 @@ const p = object({
4536
4564
  targetGainPercentage: number().optional()
4537
4565
  }),
4538
4566
  response: t.extend({
4539
- data: array(Y)
4567
+ data: array(H)
4540
4568
  })
4541
- }, $ = object({
4569
+ }, F = object({
4542
4570
  start_datetime: n,
4543
4571
  end_datetime: n,
4544
4572
  timezone: o.optional(),
4545
4573
  name: string().optional(),
4546
4574
  tags: array(string().min(1).max(50)).optional()
4547
- }), F = object({
4575
+ }), B = object({
4548
4576
  id: uuid(),
4549
4577
  start_datetime: n,
4550
4578
  end_datetime: n,
4551
4579
  completed: boolean(),
4552
4580
  name: string().nullable().optional(),
4553
4581
  tags: array(string()).optional()
4554
- }), B = {
4555
- body: $,
4582
+ }), K = {
4583
+ body: F,
4556
4584
  response: t.extend({
4557
- data: F
4585
+ data: B
4558
4586
  })
4559
- }, K = object({
4587
+ }, Z = object({
4560
4588
  completed: boolean().optional(),
4561
4589
  name: string().nullable().optional(),
4562
4590
  tags: array(string().min(1).max(50)).optional()
4563
- }), Z = object({
4591
+ }), V = object({
4564
4592
  id: uuid(),
4565
4593
  start_datetime: string(),
4566
4594
  end_datetime: string(),
4567
4595
  completed: boolean(),
4568
4596
  name: string().nullable().optional(),
4569
4597
  tags: array(string()).optional()
4570
- }), V = {
4598
+ }), J = {
4571
4599
  params: object({
4572
4600
  runId: uuid()
4573
4601
  }),
4574
- body: K,
4602
+ body: Z,
4575
4603
  response: t.extend({
4576
- data: Z
4604
+ data: V
4577
4605
  })
4578
- }, J = {
4606
+ }, W = {
4579
4607
  params: object({
4580
4608
  runId: uuid()
4581
4609
  }),
@@ -4584,14 +4612,14 @@ const p = object({
4584
4612
  id: uuid()
4585
4613
  })
4586
4614
  })
4587
- }, W = object({
4615
+ }, X = object({
4588
4616
  nseSymbol: string(),
4589
4617
  entryPrice: number(),
4590
4618
  stopLossPrice: number(),
4591
4619
  takeProfitPrice: number(),
4592
4620
  datetime: n,
4593
4621
  timezone: o.optional()
4594
- }), X = object({
4622
+ }), ee = object({
4595
4623
  id: uuid(),
4596
4624
  nseSymbol: string(),
4597
4625
  entryPrice: number(),
@@ -4599,28 +4627,28 @@ const p = object({
4599
4627
  takeProfitPrice: number(),
4600
4628
  datetime: string(),
4601
4629
  runId: uuid()
4602
- }), ee = {
4630
+ }), te = {
4603
4631
  params: object({
4604
4632
  runId: uuid()
4605
4633
  }),
4606
- body: W,
4634
+ body: X,
4607
4635
  response: t.extend({
4608
- data: X
4636
+ data: ee
4609
4637
  })
4610
- }, te = {
4638
+ }, ne = {
4611
4639
  response: t.extend({
4612
4640
  data: array(string())
4613
4641
  })
4614
- }, ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4642
+ }, oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4615
4643
  __proto__: null,
4616
- createOrder: ee,
4617
- createRun: B,
4618
- deleteRun: J,
4619
- getRunOrders: H,
4620
- getRunTags: te,
4621
- getRuns: Q,
4622
- updateRun: V
4623
- }, Symbol.toStringTag, { value: "Module" })), oe = {
4644
+ createOrder: te,
4645
+ createRun: K,
4646
+ deleteRun: W,
4647
+ getRunOrders: $,
4648
+ getRunTags: ne,
4649
+ getRuns: Y,
4650
+ updateRun: J
4651
+ }, Symbol.toStringTag, { value: "Module" })), ae = {
4624
4652
  query: object({
4625
4653
  datetime: n,
4626
4654
  timezone: o.optional(),
@@ -4637,19 +4665,19 @@ const p = object({
4637
4665
  }).nullable()
4638
4666
  })
4639
4667
  })
4640
- }, ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4668
+ }, re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4641
4669
  __proto__: null,
4642
- getShortlists: oe
4643
- }, Symbol.toStringTag, { value: "Module" })), he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4670
+ getShortlists: ae
4671
+ }, Symbol.toStringTag, { value: "Module" })), ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4644
4672
  __proto__: null,
4645
- v1_dashboard_auth_schemas: I,
4673
+ v1_dashboard_auth_schemas: L,
4646
4674
  v1_dashboard_available_datetimes_schemas: w,
4647
- v1_dashboard_candles_schemas: D,
4648
- v1_dashboard_daily_persistent_companies_schemas: M,
4649
- v1_dashboard_daily_unique_companies_schemas: A,
4650
- v1_dashboard_quote_timeline_schemas: N,
4651
- v1_dashboard_runs_schemas: ne,
4652
- v1_dashboard_shortlists_schemas: ae
4675
+ v1_dashboard_candles_schemas: C,
4676
+ v1_dashboard_daily_persistent_companies_schemas: R,
4677
+ v1_dashboard_daily_unique_companies_schemas: k,
4678
+ v1_dashboard_quote_timeline_schemas: G,
4679
+ v1_dashboard_runs_schemas: oe,
4680
+ v1_dashboard_shortlists_schemas: re
4653
4681
  }, Symbol.toStringTag, { value: "Module" }));
4654
4682
  ({
4655
4683
  response: t.extend({
@@ -7938,7 +7966,7 @@ const fetchCandles = ({
7938
7966
  );
7939
7967
  }
7940
7968
  try {
7941
- const validatedParams = ye.getGrowwHistoricalCandles.query.parse(params);
7969
+ const validatedParams = je.getGrowwHistoricalCandles.query.parse(params);
7942
7970
  const headers = {
7943
7971
  Authorization: `Bearer ${developerToken}`
7944
7972
  };
@@ -7982,7 +8010,7 @@ const fetchQuote = ({
7982
8010
  );
7983
8011
  }
7984
8012
  try {
7985
- const validatedParams = ye.getGrowwQuote.query.parse(params);
8013
+ const validatedParams = je.getGrowwQuote.query.parse(params);
7986
8014
  const headers = {
7987
8015
  Authorization: `Bearer ${developerToken}`
7988
8016
  };
@@ -8022,7 +8050,7 @@ const fetchQuoteTimeline = ({
8022
8050
  throw new Error("Developer token not found. Please set DEVELOPER_KEY environment variable.");
8023
8051
  }
8024
8052
  try {
8025
- const validatedParams = ye.getGrowwQuoteTimeline.query.parse({
8053
+ const validatedParams = je.getGrowwQuoteTimeline.query.parse({
8026
8054
  symbol,
8027
8055
  date: date2
8028
8056
  });
@@ -8069,7 +8097,7 @@ const fetchShortlist = ({
8069
8097
  );
8070
8098
  }
8071
8099
  try {
8072
- const validatedParams = je.getLists.query.parse(queryParams);
8100
+ const validatedParams = he.getLists.query.parse(queryParams);
8073
8101
  const headers = {
8074
8102
  Authorization: `Bearer ${developerToken}`
8075
8103
  };
@@ -8100,6 +8128,52 @@ const fetchShortlist = ({
8100
8128
  };
8101
8129
  dayjs.extend(utc);
8102
8130
  dayjs.extend(timezone);
8131
+ const fetchShortlistPersistence = ({
8132
+ developerToken,
8133
+ apiDomain,
8134
+ runId,
8135
+ currentTimestamp,
8136
+ currentTimezone = "Asia/Kolkata"
8137
+ }) => async (queryParams) => {
8138
+ if (!developerToken) {
8139
+ throw new Error(
8140
+ "Developer token not found. Please set DEVELOPER_TOKEN environment variable."
8141
+ );
8142
+ }
8143
+ try {
8144
+ const validatedParams = Se.getShortlistPersistence.query.parse(queryParams);
8145
+ const headers = {
8146
+ Authorization: `Bearer ${developerToken}`
8147
+ };
8148
+ if (runId) {
8149
+ headers["X-Run-Id"] = runId;
8150
+ }
8151
+ if (currentTimestamp) {
8152
+ headers["X-Current-Timestamp"] = currentTimestamp;
8153
+ }
8154
+ if (currentTimezone) {
8155
+ headers["X-Current-Timezone"] = currentTimezone;
8156
+ }
8157
+ const response = await axios.get(`${apiDomain}/v1/developer/shortlists/persistence`, {
8158
+ params: validatedParams,
8159
+ headers
8160
+ });
8161
+ return response.data.data;
8162
+ } catch (error) {
8163
+ if (axios.isAxiosError(error)) {
8164
+ logger.error(
8165
+ `Error fetching shortlist persistence for ${queryParams.type}: ${error.message}`
8166
+ );
8167
+ throw new Error(
8168
+ `Failed to fetch shortlist persistence: ${error.response?.data?.message || error.message}`
8169
+ );
8170
+ }
8171
+ logger.error(`Unexpected error fetching shortlist persistence: ${error}`);
8172
+ throw error;
8173
+ }
8174
+ };
8175
+ dayjs.extend(utc);
8176
+ dayjs.extend(timezone);
8103
8177
  const fetchNiftyQuote = ({
8104
8178
  developerToken,
8105
8179
  apiDomain,
@@ -8111,7 +8185,7 @@ const fetchNiftyQuote = ({
8111
8185
  throw new Error("Developer token not found. Please set DEVELOPER_KEY environment variable.");
8112
8186
  }
8113
8187
  try {
8114
- const validatedParams = ye.getGrowwNiftyQuote.query.parse(params);
8188
+ const validatedParams = je.getGrowwNiftyQuote.query.parse(params);
8115
8189
  const headers = {
8116
8190
  Authorization: `Bearer ${developerToken}`
8117
8191
  };
@@ -8218,7 +8292,7 @@ const placeOrder = ({ runId, apiClient }) => async (data) => {
8218
8292
  try {
8219
8293
  await retryWithBackoff(
8220
8294
  async () => {
8221
- const validatedData = he.v1_dashboard_runs_schemas.createOrder.body.parse(data);
8295
+ const validatedData = ve.v1_dashboard_runs_schemas.createOrder.body.parse(data);
8222
8296
  await apiClient.post(`/v1/dashboard/runs/${runId}/orders`, validatedData);
8223
8297
  logger.debug(`Order persisted for ${data.nseSymbol} in runId: ${runId}`);
8224
8298
  },
@@ -8564,6 +8638,13 @@ async function ganaka({
8564
8638
  currentTimestamp,
8565
8639
  currentTimezone: "Asia/Kolkata"
8566
8640
  }),
8641
+ fetchShortlistPersistence: fetchShortlistPersistence({
8642
+ developerToken,
8643
+ apiDomain,
8644
+ runId,
8645
+ currentTimestamp,
8646
+ currentTimezone: "Asia/Kolkata"
8647
+ }),
8567
8648
  currentTimestamp
8568
8649
  });
8569
8650
  }