@ganaka/sdk 1.1.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
@@ -4108,7 +4108,7 @@ const t$1 = [
4108
4108
  "TOP_GAINERS",
4109
4109
  "VOLUME_SHOCKERS"
4110
4110
  ];
4111
- const g = object({
4111
+ const _ = object({
4112
4112
  average_price: number$1().nullable(),
4113
4113
  bid_quantity: number$1().nullable(),
4114
4114
  bid_price: number$1().nullable(),
@@ -4156,7 +4156,7 @@ const g = object({
4156
4156
  week_52_low: number$1().nullable()
4157
4157
  }), a = object({
4158
4158
  status: _enum(["SUCCESS", "FAILURE"]),
4159
- payload: g
4159
+ payload: _
4160
4160
  }), y = object({
4161
4161
  nseSymbol: string(),
4162
4162
  name: string(),
@@ -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(),
@@ -4320,7 +4320,7 @@ const p = object({
4320
4320
  response: t.extend({
4321
4321
  data: string()
4322
4322
  })
4323
- }, P = {
4323
+ }, x = {
4324
4324
  query: object({
4325
4325
  symbol: string(),
4326
4326
  date: i
@@ -4342,7 +4342,7 @@ const p = object({
4342
4342
  )
4343
4343
  })
4344
4344
  })
4345
- }, q = {
4345
+ }, P = {
4346
4346
  query: object({
4347
4347
  datetime: n.optional(),
4348
4348
  timezone: o.optional()
@@ -4350,32 +4350,59 @@ const p = object({
4350
4350
  response: t.extend({
4351
4351
  data: a.nullable()
4352
4352
  })
4353
- }, ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4353
+ }, je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4354
4354
  __proto__: null,
4355
- getGrowwHistoricalCandles: f,
4356
- getGrowwNiftyQuote: q,
4357
- getGrowwQuote: v,
4358
- getGrowwQuoteTimeline: P,
4355
+ getGrowwHistoricalCandles: v,
4356
+ getGrowwNiftyQuote: P,
4357
+ getGrowwQuote: f,
4358
+ getGrowwQuoteTimeline: x,
4359
4359
  getGrowwToken: T,
4360
4360
  growwHistoricalCandlesSchema: p
4361
- }, Symbol.toStringTag, { value: "Module" })), _ = object({
4361
+ }, Symbol.toStringTag, { value: "Module" })), g = object({
4362
4362
  name: string(),
4363
4363
  price: number$1(),
4364
4364
  nseSymbol: string()
4365
- }), x = {
4365
+ }), O = {
4366
4366
  query: object({
4367
4367
  type: _enum(["top-gainers", "volume-shockers"]),
4368
4368
  datetime: n.optional(),
4369
4369
  timezone: o.optional()
4370
4370
  }),
4371
4371
  response: t.extend({
4372
- data: array(_).nullable()
4372
+ data: array(g).nullable()
4373
4373
  })
4374
- }, ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4374
+ }, he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4375
4375
  __proto__: null,
4376
- getLists: x,
4377
- listSchema: _
4378
- }, Symbol.toStringTag, { value: "Module" })), O = {
4376
+ getLists: O,
4377
+ listSchema: g
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,9 +4464,9 @@ 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
4469
+ getDailyPersistentCompanies: M
4443
4470
  }, Symbol.toStringTag, { value: "Module" })), A = {
4444
4471
  query: object({
4445
4472
  date: i,
@@ -4452,23 +4479,23 @@ const p = object({
4452
4479
  uniqueCount: number$1()
4453
4480
  })
4454
4481
  })
4455
- }, R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4482
+ }, k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4456
4483
  __proto__: null,
4457
4484
  getDailyUniqueCompanies: A
4458
- }, Symbol.toStringTag, { value: "Module" })), k = object({
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,24 +4517,26 @@ 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(),
4500
4527
  completed: boolean(),
4501
- orderCount: number$1()
4502
- }), U = record(
4528
+ orderCount: number$1(),
4529
+ name: string().nullable().optional(),
4530
+ tags: array(string()).optional()
4531
+ }), Q = record(
4503
4532
  string(),
4504
4533
  // date string (YYYY-MM-DD)
4505
- array(G)
4506
- ), Q = {
4534
+ array(U)
4535
+ ), Y = {
4507
4536
  response: t.extend({
4508
- data: U
4537
+ data: Q
4509
4538
  })
4510
- }, Y = object({
4539
+ }, H = object({
4511
4540
  id: uuid(),
4512
4541
  nseSymbol: string(),
4513
4542
  entryPrice: number(),
@@ -4526,7 +4555,7 @@ const p = object({
4526
4555
  stopLossHit: boolean().optional(),
4527
4556
  stopLossTimestamp: string().optional(),
4528
4557
  timeToStopLossMinutes: number$1().optional()
4529
- }), H = {
4558
+ }), $ = {
4530
4559
  params: object({
4531
4560
  runId: uuid()
4532
4561
  }),
@@ -4534,38 +4563,46 @@ const p = object({
4534
4563
  targetGainPercentage: number().optional()
4535
4564
  }),
4536
4565
  response: t.extend({
4537
- data: array(Y)
4566
+ data: array(H)
4538
4567
  })
4539
- }, $ = object({
4568
+ }, F = object({
4540
4569
  start_datetime: n,
4541
4570
  end_datetime: n,
4542
- timezone: o.optional()
4543
- }), F = object({
4571
+ timezone: o.optional(),
4572
+ name: string().optional(),
4573
+ tags: array(string().min(1).max(50)).optional()
4574
+ }), B = object({
4544
4575
  id: uuid(),
4545
4576
  start_datetime: n,
4546
4577
  end_datetime: n,
4547
- completed: boolean()
4548
- }), B = {
4549
- body: $,
4578
+ completed: boolean(),
4579
+ name: string().nullable().optional(),
4580
+ tags: array(string()).optional()
4581
+ }), K = {
4582
+ body: F,
4550
4583
  response: t.extend({
4551
- data: F
4584
+ data: B
4552
4585
  })
4553
- }, K = object({
4554
- completed: boolean().optional()
4555
- }), Z = object({
4586
+ }, Z = object({
4587
+ completed: boolean().optional(),
4588
+ name: string().nullable().optional(),
4589
+ tags: array(string().min(1).max(50)).optional()
4590
+ }), V = object({
4556
4591
  id: uuid(),
4557
4592
  start_datetime: string(),
4558
4593
  end_datetime: string(),
4559
- completed: boolean()
4560
- }), V = {
4594
+ completed: boolean(),
4595
+ name: string().nullable().optional(),
4596
+ tags: array(string()).optional()
4597
+ }), J = {
4561
4598
  params: object({
4562
4599
  runId: uuid()
4563
4600
  }),
4564
- body: K,
4601
+ body: Z,
4565
4602
  response: t.extend({
4566
- data: Z
4603
+ data: V
4567
4604
  })
4568
- }, J = {
4605
+ }, W = {
4569
4606
  params: object({
4570
4607
  runId: uuid()
4571
4608
  }),
@@ -4574,14 +4611,14 @@ const p = object({
4574
4611
  id: uuid()
4575
4612
  })
4576
4613
  })
4577
- }, W = object({
4614
+ }, X = object({
4578
4615
  nseSymbol: string(),
4579
4616
  entryPrice: number(),
4580
4617
  stopLossPrice: number(),
4581
4618
  takeProfitPrice: number(),
4582
4619
  datetime: n,
4583
4620
  timezone: o.optional()
4584
- }), X = object({
4621
+ }), ee = object({
4585
4622
  id: uuid(),
4586
4623
  nseSymbol: string(),
4587
4624
  entryPrice: number(),
@@ -4589,23 +4626,28 @@ const p = object({
4589
4626
  takeProfitPrice: number(),
4590
4627
  datetime: string(),
4591
4628
  runId: uuid()
4592
- }), ee = {
4629
+ }), te = {
4593
4630
  params: object({
4594
4631
  runId: uuid()
4595
4632
  }),
4596
- body: W,
4633
+ body: X,
4634
+ response: t.extend({
4635
+ data: ee
4636
+ })
4637
+ }, ne = {
4597
4638
  response: t.extend({
4598
- data: X
4639
+ data: array(string())
4599
4640
  })
4600
- }, te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4641
+ }, oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4601
4642
  __proto__: null,
4602
- createOrder: ee,
4603
- createRun: B,
4604
- deleteRun: J,
4605
- getRunOrders: H,
4606
- getRuns: Q,
4607
- updateRun: V
4608
- }, Symbol.toStringTag, { value: "Module" })), ne = {
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 = {
4609
4651
  query: object({
4610
4652
  datetime: n,
4611
4653
  timezone: o.optional(),
@@ -4622,19 +4664,19 @@ const p = object({
4622
4664
  }).nullable()
4623
4665
  })
4624
4666
  })
4625
- }, oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4667
+ }, re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4626
4668
  __proto__: null,
4627
- getShortlists: ne
4628
- }, Symbol.toStringTag, { value: "Module" })), je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4669
+ getShortlists: ae
4670
+ }, Symbol.toStringTag, { value: "Module" })), ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4629
4671
  __proto__: null,
4630
- v1_dashboard_auth_schemas: I,
4631
- v1_dashboard_available_datetimes_schemas: w,
4632
- v1_dashboard_candles_schemas: D,
4633
- v1_dashboard_daily_persistent_companies_schemas: M,
4634
- v1_dashboard_daily_unique_companies_schemas: R,
4635
- v1_dashboard_quote_timeline_schemas: N,
4636
- v1_dashboard_runs_schemas: te,
4637
- v1_dashboard_shortlists_schemas: oe
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
4638
4680
  }, Symbol.toStringTag, { value: "Module" }));
4639
4681
  ({
4640
4682
  response: t.extend({
@@ -7923,7 +7965,7 @@ const fetchCandles = ({
7923
7965
  );
7924
7966
  }
7925
7967
  try {
7926
- const validatedParams = ge.getGrowwHistoricalCandles.query.parse(params);
7968
+ const validatedParams = je.getGrowwHistoricalCandles.query.parse(params);
7927
7969
  const headers = {
7928
7970
  Authorization: `Bearer ${developerToken}`
7929
7971
  };
@@ -7967,7 +8009,7 @@ const fetchQuote = ({
7967
8009
  );
7968
8010
  }
7969
8011
  try {
7970
- const validatedParams = ge.getGrowwQuote.query.parse(params);
8012
+ const validatedParams = je.getGrowwQuote.query.parse(params);
7971
8013
  const headers = {
7972
8014
  Authorization: `Bearer ${developerToken}`
7973
8015
  };
@@ -8007,7 +8049,7 @@ const fetchQuoteTimeline = ({
8007
8049
  throw new Error("Developer token not found. Please set DEVELOPER_KEY environment variable.");
8008
8050
  }
8009
8051
  try {
8010
- const validatedParams = ge.getGrowwQuoteTimeline.query.parse({
8052
+ const validatedParams = je.getGrowwQuoteTimeline.query.parse({
8011
8053
  symbol,
8012
8054
  date: date2
8013
8055
  });
@@ -8054,7 +8096,7 @@ const fetchShortlist = ({
8054
8096
  );
8055
8097
  }
8056
8098
  try {
8057
- const validatedParams = ye.getLists.query.parse(queryParams);
8099
+ const validatedParams = he.getLists.query.parse(queryParams);
8058
8100
  const headers = {
8059
8101
  Authorization: `Bearer ${developerToken}`
8060
8102
  };
@@ -8085,6 +8127,52 @@ const fetchShortlist = ({
8085
8127
  };
8086
8128
  dayjs.extend(utc);
8087
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);
8088
8176
  const fetchNiftyQuote = ({
8089
8177
  developerToken,
8090
8178
  apiDomain,
@@ -8096,7 +8184,7 @@ const fetchNiftyQuote = ({
8096
8184
  throw new Error("Developer token not found. Please set DEVELOPER_KEY environment variable.");
8097
8185
  }
8098
8186
  try {
8099
- const validatedParams = ge.getGrowwNiftyQuote.query.parse(params);
8187
+ const validatedParams = je.getGrowwNiftyQuote.query.parse(params);
8100
8188
  const headers = {
8101
8189
  Authorization: `Bearer ${developerToken}`
8102
8190
  };
@@ -8203,7 +8291,7 @@ const placeOrder = ({ runId, apiClient }) => async (data) => {
8203
8291
  try {
8204
8292
  await retryWithBackoff(
8205
8293
  async () => {
8206
- const validatedData = je.v1_dashboard_runs_schemas.createOrder.body.parse(data);
8294
+ const validatedData = ve.v1_dashboard_runs_schemas.createOrder.body.parse(data);
8207
8295
  await apiClient.post(`/v1/dashboard/runs/${runId}/orders`, validatedData);
8208
8296
  logger.debug(`Order persisted for ${data.nseSymbol} in runId: ${runId}`);
8209
8297
  },
@@ -8462,7 +8550,9 @@ async function ganaka({
8462
8550
  startTime,
8463
8551
  endTime,
8464
8552
  intervalMinutes = 1,
8465
- deleteRunAfterCompletion = false
8553
+ deleteRunAfterCompletion = false,
8554
+ name,
8555
+ tags
8466
8556
  }) {
8467
8557
  const developerToken = process.env.DEVELOPER_KEY;
8468
8558
  const apiDomain = process.env.API_DOMAIN || "https://api.ganaka.live";
@@ -8481,7 +8571,9 @@ async function ganaka({
8481
8571
  const createRunBody = {
8482
8572
  start_datetime: startTime,
8483
8573
  end_datetime: endTime,
8484
- timezone: "Asia/Kolkata"
8574
+ timezone: "Asia/Kolkata",
8575
+ ...name !== void 0 && { name },
8576
+ ...tags !== void 0 && { tags }
8485
8577
  };
8486
8578
  try {
8487
8579
  const createRunResponse = await apiClient.post("/v1/dashboard/runs", createRunBody);
@@ -8545,6 +8637,13 @@ async function ganaka({
8545
8637
  currentTimestamp,
8546
8638
  currentTimezone: "Asia/Kolkata"
8547
8639
  }),
8640
+ fetchShortlistPersistence: fetchShortlistPersistence({
8641
+ developerToken,
8642
+ apiDomain,
8643
+ runId,
8644
+ currentTimestamp,
8645
+ currentTimezone: "Asia/Kolkata"
8646
+ }),
8548
8647
  currentTimestamp
8549
8648
  });
8550
8649
  }
@@ -8573,7 +8672,7 @@ async function ganaka({
8573
8672
  }
8574
8673
  export {
8575
8674
  ganaka,
8576
- g as growwQuotePayloadSchema,
8675
+ _ as growwQuotePayloadSchema,
8577
8676
  a as growwQuoteSchema
8578
8677
  };
8579
8678
  //# sourceMappingURL=index.mjs.map