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