adaptic-backend 1.0.151 → 1.0.152

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.
Files changed (65) hide show
  1. package/Account.cjs +1029 -0
  2. package/Action.cjs +3460 -0
  3. package/Alert.cjs +3800 -0
  4. package/AlpacaAccount.cjs +2888 -0
  5. package/Asset.cjs +3659 -0
  6. package/Authenticator.cjs +1029 -0
  7. package/Customer.cjs +1029 -0
  8. package/NewsArticle.cjs +892 -0
  9. package/NewsArticleAssetSentiment.cjs +1243 -0
  10. package/Order.cjs +4500 -0
  11. package/Position.cjs +4288 -0
  12. package/Session.cjs +1029 -0
  13. package/StopLoss.cjs +1832 -0
  14. package/TakeProfit.cjs +1832 -0
  15. package/Trade.cjs +5276 -0
  16. package/User.cjs +3103 -0
  17. package/package.json +1 -1
  18. package/server/Account.d.ts.map +1 -1
  19. package/server/Account.js.map +1 -1
  20. package/server/Account.mjs +1029 -0
  21. package/server/Action.d.ts.map +1 -1
  22. package/server/Action.js.map +1 -1
  23. package/server/Action.mjs +3460 -0
  24. package/server/Alert.d.ts.map +1 -1
  25. package/server/Alert.js.map +1 -1
  26. package/server/Alert.mjs +3800 -0
  27. package/server/AlpacaAccount.d.ts.map +1 -1
  28. package/server/AlpacaAccount.js.map +1 -1
  29. package/server/AlpacaAccount.mjs +2888 -0
  30. package/server/Asset.d.ts.map +1 -1
  31. package/server/Asset.js.map +1 -1
  32. package/server/Asset.mjs +3659 -0
  33. package/server/Authenticator.d.ts.map +1 -1
  34. package/server/Authenticator.js.map +1 -1
  35. package/server/Authenticator.mjs +1029 -0
  36. package/server/Customer.d.ts.map +1 -1
  37. package/server/Customer.js.map +1 -1
  38. package/server/Customer.mjs +1029 -0
  39. package/server/NewsArticle.d.ts.map +1 -1
  40. package/server/NewsArticle.js.map +1 -1
  41. package/server/NewsArticle.mjs +892 -0
  42. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  43. package/server/NewsArticleAssetSentiment.js.map +1 -1
  44. package/server/NewsArticleAssetSentiment.mjs +1243 -0
  45. package/server/Order.d.ts.map +1 -1
  46. package/server/Order.js.map +1 -1
  47. package/server/Order.mjs +4500 -0
  48. package/server/Position.d.ts.map +1 -1
  49. package/server/Position.js.map +1 -1
  50. package/server/Position.mjs +4288 -0
  51. package/server/Session.d.ts.map +1 -1
  52. package/server/Session.js.map +1 -1
  53. package/server/Session.mjs +1029 -0
  54. package/server/StopLoss.d.ts.map +1 -1
  55. package/server/StopLoss.js.map +1 -1
  56. package/server/StopLoss.mjs +1832 -0
  57. package/server/TakeProfit.d.ts.map +1 -1
  58. package/server/TakeProfit.js.map +1 -1
  59. package/server/TakeProfit.mjs +1832 -0
  60. package/server/Trade.d.ts.map +1 -1
  61. package/server/Trade.js.map +1 -1
  62. package/server/Trade.mjs +5276 -0
  63. package/server/User.d.ts.map +1 -1
  64. package/server/User.js.map +1 -1
  65. package/server/User.mjs +3103 -0
package/server/Asset.mjs CHANGED
@@ -338,6 +338,115 @@ export const Asset = {
338
338
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
339
339
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
340
340
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
341
+ user: item.alpacaAccount.user ?
342
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
343
+ ? { connect: {
344
+ id: item.alpacaAccount.user.id
345
+ }
346
+ }
347
+ : { connectOrCreate: {
348
+ where: {
349
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
350
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
351
+ name: item.alpacaAccount.user.name !== undefined ? {
352
+ equals: item.alpacaAccount.user.name
353
+ } : undefined,
354
+ },
355
+ create: {
356
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
357
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
358
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
359
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
360
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
361
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
362
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
363
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
364
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
365
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
366
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
367
+ },
368
+ }
369
+ } : undefined,
370
+ orders: item.alpacaAccount.orders ?
371
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
372
+ connect: item.alpacaAccount.orders.map((item) => ({
373
+ id: item.id
374
+ }))
375
+ }
376
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
377
+ where: {
378
+ id: item.id !== undefined ? item.id : undefined,
379
+ },
380
+ create: {
381
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
382
+ qty: item.qty !== undefined ? item.qty : undefined,
383
+ notional: item.notional !== undefined ? item.notional : undefined,
384
+ side: item.side !== undefined ? item.side : undefined,
385
+ type: item.type !== undefined ? item.type : undefined,
386
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
387
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
388
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
389
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
390
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
391
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
392
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
393
+ status: item.status !== undefined ? item.status : undefined,
394
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
395
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
396
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
397
+ fee: item.fee !== undefined ? item.fee : undefined,
398
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
399
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
400
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
401
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
402
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
403
+ },
404
+ }))
405
+ } : undefined,
406
+ positions: item.alpacaAccount.positions ?
407
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
408
+ connect: item.alpacaAccount.positions.map((item) => ({
409
+ id: item.id
410
+ }))
411
+ }
412
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
413
+ where: {
414
+ id: item.id !== undefined ? item.id : undefined,
415
+ },
416
+ create: {
417
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
418
+ qty: item.qty !== undefined ? item.qty : undefined,
419
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
420
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
421
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
422
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
423
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
424
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
425
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
426
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
427
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
428
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
429
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
430
+ },
431
+ }))
432
+ } : undefined,
433
+ alerts: item.alpacaAccount.alerts ?
434
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
435
+ connect: item.alpacaAccount.alerts.map((item) => ({
436
+ id: item.id
437
+ }))
438
+ }
439
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
440
+ where: {
441
+ id: item.id !== undefined ? item.id : undefined,
442
+ },
443
+ create: {
444
+ message: item.message !== undefined ? item.message : undefined,
445
+ type: item.type !== undefined ? item.type : undefined,
446
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
447
+ },
448
+ }))
449
+ } : undefined,
341
450
  },
342
451
  }
343
452
  } : undefined,
@@ -357,6 +466,42 @@ export const Asset = {
357
466
  note: item.note !== undefined ? item.note : undefined,
358
467
  status: item.status !== undefined ? item.status : undefined,
359
468
  fee: item.fee !== undefined ? item.fee : undefined,
469
+ order: item.order ?
470
+ typeof item.order === 'object' && Object.keys(item.order).length === 1 && Object.keys(item.order)[0] === 'id'
471
+ ? { connect: {
472
+ id: item.order.id
473
+ }
474
+ }
475
+ : { connectOrCreate: {
476
+ where: {
477
+ id: item.order.id !== undefined ? item.order.id : undefined,
478
+ },
479
+ create: {
480
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
481
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
482
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
483
+ side: item.order.side !== undefined ? item.order.side : undefined,
484
+ type: item.order.type !== undefined ? item.order.type : undefined,
485
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
486
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
487
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
488
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
489
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
490
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
491
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
492
+ status: item.order.status !== undefined ? item.order.status : undefined,
493
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
494
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
495
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
496
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
497
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
498
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
499
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
500
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
501
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
502
+ },
503
+ }
504
+ } : undefined,
360
505
  },
361
506
  }))
362
507
  } : undefined,
@@ -448,6 +593,104 @@ export const Asset = {
448
593
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
449
594
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
450
595
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
596
+ user: item.alpacaAccount.user ?
597
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
598
+ ? { connect: {
599
+ id: item.alpacaAccount.user.id
600
+ }
601
+ }
602
+ : { connectOrCreate: {
603
+ where: {
604
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
605
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
606
+ name: item.alpacaAccount.user.name !== undefined ? {
607
+ equals: item.alpacaAccount.user.name
608
+ } : undefined,
609
+ },
610
+ create: {
611
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
612
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
613
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
614
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
615
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
616
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
617
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
618
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
619
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
620
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
621
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
622
+ },
623
+ }
624
+ } : undefined,
625
+ trades: item.alpacaAccount.trades ?
626
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
627
+ connect: item.alpacaAccount.trades.map((item) => ({
628
+ id: item.id
629
+ }))
630
+ }
631
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
632
+ where: {
633
+ id: item.id !== undefined ? item.id : undefined,
634
+ },
635
+ create: {
636
+ qty: item.qty !== undefined ? item.qty : undefined,
637
+ price: item.price !== undefined ? item.price : undefined,
638
+ total: item.total !== undefined ? item.total : undefined,
639
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
640
+ signal: item.signal !== undefined ? item.signal : undefined,
641
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
642
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
643
+ summary: item.summary !== undefined ? item.summary : undefined,
644
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
645
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
646
+ status: item.status !== undefined ? item.status : undefined,
647
+ },
648
+ }))
649
+ } : undefined,
650
+ positions: item.alpacaAccount.positions ?
651
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
652
+ connect: item.alpacaAccount.positions.map((item) => ({
653
+ id: item.id
654
+ }))
655
+ }
656
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
657
+ where: {
658
+ id: item.id !== undefined ? item.id : undefined,
659
+ },
660
+ create: {
661
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
662
+ qty: item.qty !== undefined ? item.qty : undefined,
663
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
664
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
665
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
666
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
667
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
668
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
669
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
670
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
671
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
672
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
673
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
674
+ },
675
+ }))
676
+ } : undefined,
677
+ alerts: item.alpacaAccount.alerts ?
678
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
679
+ connect: item.alpacaAccount.alerts.map((item) => ({
680
+ id: item.id
681
+ }))
682
+ }
683
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
684
+ where: {
685
+ id: item.id !== undefined ? item.id : undefined,
686
+ },
687
+ create: {
688
+ message: item.message !== undefined ? item.message : undefined,
689
+ type: item.type !== undefined ? item.type : undefined,
690
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
691
+ },
692
+ }))
693
+ } : undefined,
451
694
  },
452
695
  }
453
696
  } : undefined,
@@ -467,6 +710,31 @@ export const Asset = {
467
710
  note: item.action.note !== undefined ? item.action.note : undefined,
468
711
  status: item.action.status !== undefined ? item.action.status : undefined,
469
712
  fee: item.action.fee !== undefined ? item.action.fee : undefined,
713
+ trade: item.action.trade ?
714
+ typeof item.action.trade === 'object' && Object.keys(item.action.trade).length === 1 && Object.keys(item.action.trade)[0] === 'id'
715
+ ? { connect: {
716
+ id: item.action.trade.id
717
+ }
718
+ }
719
+ : { connectOrCreate: {
720
+ where: {
721
+ id: item.action.trade.id !== undefined ? item.action.trade.id : undefined,
722
+ },
723
+ create: {
724
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
725
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
726
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
727
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
728
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
729
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
730
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
731
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
732
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
733
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
734
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
735
+ },
736
+ }
737
+ } : undefined,
470
738
  },
471
739
  }
472
740
  } : undefined,
@@ -517,6 +785,113 @@ export const Asset = {
517
785
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
518
786
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
519
787
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
788
+ user: item.alpacaAccount.user ?
789
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
790
+ ? { connect: {
791
+ id: item.alpacaAccount.user.id
792
+ }
793
+ }
794
+ : { connectOrCreate: {
795
+ where: {
796
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
797
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
798
+ name: item.alpacaAccount.user.name !== undefined ? {
799
+ equals: item.alpacaAccount.user.name
800
+ } : undefined,
801
+ },
802
+ create: {
803
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
804
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
805
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
806
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
807
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
808
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
809
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
810
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
811
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
812
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
813
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
814
+ },
815
+ }
816
+ } : undefined,
817
+ trades: item.alpacaAccount.trades ?
818
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
819
+ connect: item.alpacaAccount.trades.map((item) => ({
820
+ id: item.id
821
+ }))
822
+ }
823
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
824
+ where: {
825
+ id: item.id !== undefined ? item.id : undefined,
826
+ },
827
+ create: {
828
+ qty: item.qty !== undefined ? item.qty : undefined,
829
+ price: item.price !== undefined ? item.price : undefined,
830
+ total: item.total !== undefined ? item.total : undefined,
831
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
832
+ signal: item.signal !== undefined ? item.signal : undefined,
833
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
834
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
835
+ summary: item.summary !== undefined ? item.summary : undefined,
836
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
837
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
838
+ status: item.status !== undefined ? item.status : undefined,
839
+ },
840
+ }))
841
+ } : undefined,
842
+ orders: item.alpacaAccount.orders ?
843
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
844
+ connect: item.alpacaAccount.orders.map((item) => ({
845
+ id: item.id
846
+ }))
847
+ }
848
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
849
+ where: {
850
+ id: item.id !== undefined ? item.id : undefined,
851
+ },
852
+ create: {
853
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
854
+ qty: item.qty !== undefined ? item.qty : undefined,
855
+ notional: item.notional !== undefined ? item.notional : undefined,
856
+ side: item.side !== undefined ? item.side : undefined,
857
+ type: item.type !== undefined ? item.type : undefined,
858
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
859
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
860
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
861
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
862
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
863
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
864
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
865
+ status: item.status !== undefined ? item.status : undefined,
866
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
867
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
868
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
869
+ fee: item.fee !== undefined ? item.fee : undefined,
870
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
871
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
872
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
873
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
874
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
875
+ },
876
+ }))
877
+ } : undefined,
878
+ alerts: item.alpacaAccount.alerts ?
879
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
880
+ connect: item.alpacaAccount.alerts.map((item) => ({
881
+ id: item.id
882
+ }))
883
+ }
884
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
885
+ where: {
886
+ id: item.id !== undefined ? item.id : undefined,
887
+ },
888
+ create: {
889
+ message: item.message !== undefined ? item.message : undefined,
890
+ type: item.type !== undefined ? item.type : undefined,
891
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
892
+ },
893
+ }))
894
+ } : undefined,
520
895
  },
521
896
  }
522
897
  } : undefined,
@@ -1010,6 +1385,266 @@ export const Asset = {
1010
1385
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? {
1011
1386
  set: item.alpacaAccount.volumeThreshold
1012
1387
  } : undefined,
1388
+ user: item.alpacaAccount.user ? {
1389
+ upsert: {
1390
+ where: {
1391
+ id: item.alpacaAccount.user.id !== undefined ? {
1392
+ equals: item.alpacaAccount.user.id
1393
+ } : undefined,
1394
+ name: item.alpacaAccount.user.name !== undefined ? {
1395
+ equals: item.alpacaAccount.user.name
1396
+ } : undefined,
1397
+ email: item.alpacaAccount.user.email !== undefined ? {
1398
+ equals: item.alpacaAccount.user.email
1399
+ } : undefined,
1400
+ },
1401
+ update: {
1402
+ id: item.alpacaAccount.user.id !== undefined ? {
1403
+ set: item.alpacaAccount.user.id
1404
+ } : undefined,
1405
+ name: item.alpacaAccount.user.name !== undefined ? {
1406
+ set: item.alpacaAccount.user.name
1407
+ } : undefined,
1408
+ email: item.alpacaAccount.user.email !== undefined ? {
1409
+ set: item.alpacaAccount.user.email
1410
+ } : undefined,
1411
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? {
1412
+ set: item.alpacaAccount.user.emailVerified
1413
+ } : undefined,
1414
+ image: item.alpacaAccount.user.image !== undefined ? {
1415
+ set: item.alpacaAccount.user.image
1416
+ } : undefined,
1417
+ role: item.alpacaAccount.user.role !== undefined ? {
1418
+ set: item.alpacaAccount.user.role
1419
+ } : undefined,
1420
+ bio: item.alpacaAccount.user.bio !== undefined ? {
1421
+ set: item.alpacaAccount.user.bio
1422
+ } : undefined,
1423
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? {
1424
+ set: item.alpacaAccount.user.jobTitle
1425
+ } : undefined,
1426
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? {
1427
+ set: item.alpacaAccount.user.currentAccount
1428
+ } : undefined,
1429
+ plan: item.alpacaAccount.user.plan !== undefined ? {
1430
+ set: item.alpacaAccount.user.plan
1431
+ } : undefined,
1432
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? {
1433
+ set: item.alpacaAccount.user.openaiAPIKey
1434
+ } : undefined,
1435
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? {
1436
+ set: item.alpacaAccount.user.openaiModel
1437
+ } : undefined,
1438
+ },
1439
+ create: {
1440
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
1441
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
1442
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
1443
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
1444
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
1445
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
1446
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
1447
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
1448
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
1449
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
1450
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
1451
+ },
1452
+ }
1453
+ } : undefined,
1454
+ orders: item.alpacaAccount.orders ? {
1455
+ upsert: item.alpacaAccount.orders.map((item) => ({
1456
+ where: {
1457
+ id: item.id !== undefined ? item.id : undefined,
1458
+ },
1459
+ update: {
1460
+ id: item.id !== undefined ? {
1461
+ set: item.id
1462
+ } : undefined,
1463
+ clientOrderId: item.clientOrderId !== undefined ? {
1464
+ set: item.clientOrderId
1465
+ } : undefined,
1466
+ qty: item.qty !== undefined ? {
1467
+ set: item.qty
1468
+ } : undefined,
1469
+ notional: item.notional !== undefined ? {
1470
+ set: item.notional
1471
+ } : undefined,
1472
+ side: item.side !== undefined ? {
1473
+ set: item.side
1474
+ } : undefined,
1475
+ type: item.type !== undefined ? {
1476
+ set: item.type
1477
+ } : undefined,
1478
+ orderClass: item.orderClass !== undefined ? {
1479
+ set: item.orderClass
1480
+ } : undefined,
1481
+ timeInForce: item.timeInForce !== undefined ? {
1482
+ set: item.timeInForce
1483
+ } : undefined,
1484
+ limitPrice: item.limitPrice !== undefined ? {
1485
+ set: item.limitPrice
1486
+ } : undefined,
1487
+ stopPrice: item.stopPrice !== undefined ? {
1488
+ set: item.stopPrice
1489
+ } : undefined,
1490
+ trailPrice: item.trailPrice !== undefined ? {
1491
+ set: item.trailPrice
1492
+ } : undefined,
1493
+ trailPercent: item.trailPercent !== undefined ? {
1494
+ set: item.trailPercent
1495
+ } : undefined,
1496
+ extendedHours: item.extendedHours !== undefined ? {
1497
+ set: item.extendedHours
1498
+ } : undefined,
1499
+ status: item.status !== undefined ? {
1500
+ set: item.status
1501
+ } : undefined,
1502
+ submittedAt: item.submittedAt !== undefined ? {
1503
+ set: item.submittedAt
1504
+ } : undefined,
1505
+ filledAt: item.filledAt !== undefined ? {
1506
+ set: item.filledAt
1507
+ } : undefined,
1508
+ filledAvgPrice: item.filledAvgPrice !== undefined ? {
1509
+ set: item.filledAvgPrice
1510
+ } : undefined,
1511
+ fee: item.fee !== undefined ? {
1512
+ set: item.fee
1513
+ } : undefined,
1514
+ strikePrice: item.strikePrice !== undefined ? {
1515
+ set: item.strikePrice
1516
+ } : undefined,
1517
+ expirationDate: item.expirationDate !== undefined ? {
1518
+ set: item.expirationDate
1519
+ } : undefined,
1520
+ optionType: item.optionType !== undefined ? {
1521
+ set: item.optionType
1522
+ } : undefined,
1523
+ stopLossId: item.stopLossId !== undefined ? {
1524
+ set: item.stopLossId
1525
+ } : undefined,
1526
+ takeProfitId: item.takeProfitId !== undefined ? {
1527
+ set: item.takeProfitId
1528
+ } : undefined,
1529
+ },
1530
+ create: {
1531
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
1532
+ qty: item.qty !== undefined ? item.qty : undefined,
1533
+ notional: item.notional !== undefined ? item.notional : undefined,
1534
+ side: item.side !== undefined ? item.side : undefined,
1535
+ type: item.type !== undefined ? item.type : undefined,
1536
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
1537
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
1538
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
1539
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
1540
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
1541
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
1542
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
1543
+ status: item.status !== undefined ? item.status : undefined,
1544
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
1545
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1546
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1547
+ fee: item.fee !== undefined ? item.fee : undefined,
1548
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
1549
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
1550
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
1551
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
1552
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
1553
+ },
1554
+ }))
1555
+ } : undefined,
1556
+ positions: item.alpacaAccount.positions ? {
1557
+ upsert: item.alpacaAccount.positions.map((item) => ({
1558
+ where: {
1559
+ id: item.id !== undefined ? item.id : undefined,
1560
+ },
1561
+ update: {
1562
+ id: item.id !== undefined ? {
1563
+ set: item.id
1564
+ } : undefined,
1565
+ averageEntryPrice: item.averageEntryPrice !== undefined ? {
1566
+ set: item.averageEntryPrice
1567
+ } : undefined,
1568
+ qty: item.qty !== undefined ? {
1569
+ set: item.qty
1570
+ } : undefined,
1571
+ qtyAvailable: item.qtyAvailable !== undefined ? {
1572
+ set: item.qtyAvailable
1573
+ } : undefined,
1574
+ marketValue: item.marketValue !== undefined ? {
1575
+ set: item.marketValue
1576
+ } : undefined,
1577
+ costBasis: item.costBasis !== undefined ? {
1578
+ set: item.costBasis
1579
+ } : undefined,
1580
+ unrealizedPL: item.unrealizedPL !== undefined ? {
1581
+ set: item.unrealizedPL
1582
+ } : undefined,
1583
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? {
1584
+ set: item.unrealizedPLPC
1585
+ } : undefined,
1586
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? {
1587
+ set: item.unrealisedIntradayPL
1588
+ } : undefined,
1589
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? {
1590
+ set: item.unrealisedIntradayPLPC
1591
+ } : undefined,
1592
+ currentPrice: item.currentPrice !== undefined ? {
1593
+ set: item.currentPrice
1594
+ } : undefined,
1595
+ lastTradePrice: item.lastTradePrice !== undefined ? {
1596
+ set: item.lastTradePrice
1597
+ } : undefined,
1598
+ changeToday: item.changeToday !== undefined ? {
1599
+ set: item.changeToday
1600
+ } : undefined,
1601
+ assetMarginable: item.assetMarginable !== undefined ? {
1602
+ set: item.assetMarginable
1603
+ } : undefined,
1604
+ },
1605
+ create: {
1606
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1607
+ qty: item.qty !== undefined ? item.qty : undefined,
1608
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1609
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1610
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1611
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1612
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1613
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1614
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1615
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1616
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1617
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1618
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1619
+ },
1620
+ }))
1621
+ } : undefined,
1622
+ alerts: item.alpacaAccount.alerts ? {
1623
+ upsert: item.alpacaAccount.alerts.map((item) => ({
1624
+ where: {
1625
+ id: item.id !== undefined ? item.id : undefined,
1626
+ },
1627
+ update: {
1628
+ id: item.id !== undefined ? {
1629
+ set: item.id
1630
+ } : undefined,
1631
+ message: item.message !== undefined ? {
1632
+ set: item.message
1633
+ } : undefined,
1634
+ type: item.type !== undefined ? {
1635
+ set: item.type
1636
+ } : undefined,
1637
+ isRead: item.isRead !== undefined ? {
1638
+ set: item.isRead
1639
+ } : undefined,
1640
+ },
1641
+ create: {
1642
+ message: item.message !== undefined ? item.message : undefined,
1643
+ type: item.type !== undefined ? item.type : undefined,
1644
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
1645
+ },
1646
+ }))
1647
+ } : undefined,
1013
1648
  },
1014
1649
  create: {
1015
1650
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -1021,6 +1656,115 @@ export const Asset = {
1021
1656
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
1022
1657
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
1023
1658
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
1659
+ user: item.alpacaAccount.user ?
1660
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
1661
+ ? { connect: {
1662
+ id: item.alpacaAccount.user.id
1663
+ }
1664
+ }
1665
+ : { connectOrCreate: {
1666
+ where: {
1667
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
1668
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
1669
+ name: item.alpacaAccount.user.name !== undefined ? {
1670
+ equals: item.alpacaAccount.user.name
1671
+ } : undefined,
1672
+ },
1673
+ create: {
1674
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
1675
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
1676
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
1677
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
1678
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
1679
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
1680
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
1681
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
1682
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
1683
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
1684
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
1685
+ },
1686
+ }
1687
+ } : undefined,
1688
+ orders: item.alpacaAccount.orders ?
1689
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
1690
+ connect: item.alpacaAccount.orders.map((item) => ({
1691
+ id: item.id
1692
+ }))
1693
+ }
1694
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
1695
+ where: {
1696
+ id: item.id !== undefined ? item.id : undefined,
1697
+ },
1698
+ create: {
1699
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
1700
+ qty: item.qty !== undefined ? item.qty : undefined,
1701
+ notional: item.notional !== undefined ? item.notional : undefined,
1702
+ side: item.side !== undefined ? item.side : undefined,
1703
+ type: item.type !== undefined ? item.type : undefined,
1704
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
1705
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
1706
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
1707
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
1708
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
1709
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
1710
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
1711
+ status: item.status !== undefined ? item.status : undefined,
1712
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
1713
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1714
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1715
+ fee: item.fee !== undefined ? item.fee : undefined,
1716
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
1717
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
1718
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
1719
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
1720
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
1721
+ },
1722
+ }))
1723
+ } : undefined,
1724
+ positions: item.alpacaAccount.positions ?
1725
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
1726
+ connect: item.alpacaAccount.positions.map((item) => ({
1727
+ id: item.id
1728
+ }))
1729
+ }
1730
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
1731
+ where: {
1732
+ id: item.id !== undefined ? item.id : undefined,
1733
+ },
1734
+ create: {
1735
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1736
+ qty: item.qty !== undefined ? item.qty : undefined,
1737
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1738
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1739
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1740
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1741
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1742
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1743
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1744
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1745
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1746
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1747
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1748
+ },
1749
+ }))
1750
+ } : undefined,
1751
+ alerts: item.alpacaAccount.alerts ?
1752
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
1753
+ connect: item.alpacaAccount.alerts.map((item) => ({
1754
+ id: item.id
1755
+ }))
1756
+ }
1757
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
1758
+ where: {
1759
+ id: item.id !== undefined ? item.id : undefined,
1760
+ },
1761
+ create: {
1762
+ message: item.message !== undefined ? item.message : undefined,
1763
+ type: item.type !== undefined ? item.type : undefined,
1764
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
1765
+ },
1766
+ }))
1767
+ } : undefined,
1024
1768
  },
1025
1769
  }
1026
1770
  } : undefined,
@@ -1048,6 +1792,110 @@ export const Asset = {
1048
1792
  fee: item.fee !== undefined ? {
1049
1793
  set: item.fee
1050
1794
  } : undefined,
1795
+ order: item.order ? {
1796
+ upsert: {
1797
+ where: {
1798
+ id: item.order.id !== undefined ? {
1799
+ equals: item.order.id
1800
+ } : undefined,
1801
+ },
1802
+ update: {
1803
+ id: item.order.id !== undefined ? {
1804
+ set: item.order.id
1805
+ } : undefined,
1806
+ clientOrderId: item.order.clientOrderId !== undefined ? {
1807
+ set: item.order.clientOrderId
1808
+ } : undefined,
1809
+ qty: item.order.qty !== undefined ? {
1810
+ set: item.order.qty
1811
+ } : undefined,
1812
+ notional: item.order.notional !== undefined ? {
1813
+ set: item.order.notional
1814
+ } : undefined,
1815
+ side: item.order.side !== undefined ? {
1816
+ set: item.order.side
1817
+ } : undefined,
1818
+ type: item.order.type !== undefined ? {
1819
+ set: item.order.type
1820
+ } : undefined,
1821
+ orderClass: item.order.orderClass !== undefined ? {
1822
+ set: item.order.orderClass
1823
+ } : undefined,
1824
+ timeInForce: item.order.timeInForce !== undefined ? {
1825
+ set: item.order.timeInForce
1826
+ } : undefined,
1827
+ limitPrice: item.order.limitPrice !== undefined ? {
1828
+ set: item.order.limitPrice
1829
+ } : undefined,
1830
+ stopPrice: item.order.stopPrice !== undefined ? {
1831
+ set: item.order.stopPrice
1832
+ } : undefined,
1833
+ trailPrice: item.order.trailPrice !== undefined ? {
1834
+ set: item.order.trailPrice
1835
+ } : undefined,
1836
+ trailPercent: item.order.trailPercent !== undefined ? {
1837
+ set: item.order.trailPercent
1838
+ } : undefined,
1839
+ extendedHours: item.order.extendedHours !== undefined ? {
1840
+ set: item.order.extendedHours
1841
+ } : undefined,
1842
+ status: item.order.status !== undefined ? {
1843
+ set: item.order.status
1844
+ } : undefined,
1845
+ submittedAt: item.order.submittedAt !== undefined ? {
1846
+ set: item.order.submittedAt
1847
+ } : undefined,
1848
+ filledAt: item.order.filledAt !== undefined ? {
1849
+ set: item.order.filledAt
1850
+ } : undefined,
1851
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? {
1852
+ set: item.order.filledAvgPrice
1853
+ } : undefined,
1854
+ fee: item.order.fee !== undefined ? {
1855
+ set: item.order.fee
1856
+ } : undefined,
1857
+ strikePrice: item.order.strikePrice !== undefined ? {
1858
+ set: item.order.strikePrice
1859
+ } : undefined,
1860
+ expirationDate: item.order.expirationDate !== undefined ? {
1861
+ set: item.order.expirationDate
1862
+ } : undefined,
1863
+ optionType: item.order.optionType !== undefined ? {
1864
+ set: item.order.optionType
1865
+ } : undefined,
1866
+ stopLossId: item.order.stopLossId !== undefined ? {
1867
+ set: item.order.stopLossId
1868
+ } : undefined,
1869
+ takeProfitId: item.order.takeProfitId !== undefined ? {
1870
+ set: item.order.takeProfitId
1871
+ } : undefined,
1872
+ },
1873
+ create: {
1874
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
1875
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
1876
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
1877
+ side: item.order.side !== undefined ? item.order.side : undefined,
1878
+ type: item.order.type !== undefined ? item.order.type : undefined,
1879
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
1880
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
1881
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
1882
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
1883
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
1884
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
1885
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
1886
+ status: item.order.status !== undefined ? item.order.status : undefined,
1887
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
1888
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
1889
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
1890
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
1891
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
1892
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
1893
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
1894
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
1895
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
1896
+ },
1897
+ }
1898
+ } : undefined,
1051
1899
  },
1052
1900
  create: {
1053
1901
  sequence: item.sequence !== undefined ? item.sequence : undefined,
@@ -1055,6 +1903,42 @@ export const Asset = {
1055
1903
  note: item.note !== undefined ? item.note : undefined,
1056
1904
  status: item.status !== undefined ? item.status : undefined,
1057
1905
  fee: item.fee !== undefined ? item.fee : undefined,
1906
+ order: item.order ?
1907
+ typeof item.order === 'object' && Object.keys(item.order).length === 1 && Object.keys(item.order)[0] === 'id'
1908
+ ? { connect: {
1909
+ id: item.order.id
1910
+ }
1911
+ }
1912
+ : { connectOrCreate: {
1913
+ where: {
1914
+ id: item.order.id !== undefined ? item.order.id : undefined,
1915
+ },
1916
+ create: {
1917
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
1918
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
1919
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
1920
+ side: item.order.side !== undefined ? item.order.side : undefined,
1921
+ type: item.order.type !== undefined ? item.order.type : undefined,
1922
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
1923
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
1924
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
1925
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
1926
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
1927
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
1928
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
1929
+ status: item.order.status !== undefined ? item.order.status : undefined,
1930
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
1931
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
1932
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
1933
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
1934
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
1935
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
1936
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
1937
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
1938
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
1939
+ },
1940
+ }
1941
+ } : undefined,
1058
1942
  },
1059
1943
  }))
1060
1944
  } : undefined,
@@ -1091,6 +1975,115 @@ export const Asset = {
1091
1975
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
1092
1976
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
1093
1977
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
1978
+ user: item.alpacaAccount.user ?
1979
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
1980
+ ? { connect: {
1981
+ id: item.alpacaAccount.user.id
1982
+ }
1983
+ }
1984
+ : { connectOrCreate: {
1985
+ where: {
1986
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
1987
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
1988
+ name: item.alpacaAccount.user.name !== undefined ? {
1989
+ equals: item.alpacaAccount.user.name
1990
+ } : undefined,
1991
+ },
1992
+ create: {
1993
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
1994
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
1995
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
1996
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
1997
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
1998
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
1999
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
2000
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
2001
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
2002
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
2003
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
2004
+ },
2005
+ }
2006
+ } : undefined,
2007
+ orders: item.alpacaAccount.orders ?
2008
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2009
+ connect: item.alpacaAccount.orders.map((item) => ({
2010
+ id: item.id
2011
+ }))
2012
+ }
2013
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
2014
+ where: {
2015
+ id: item.id !== undefined ? item.id : undefined,
2016
+ },
2017
+ create: {
2018
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
2019
+ qty: item.qty !== undefined ? item.qty : undefined,
2020
+ notional: item.notional !== undefined ? item.notional : undefined,
2021
+ side: item.side !== undefined ? item.side : undefined,
2022
+ type: item.type !== undefined ? item.type : undefined,
2023
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
2024
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
2025
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
2026
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
2027
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
2028
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
2029
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
2030
+ status: item.status !== undefined ? item.status : undefined,
2031
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
2032
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2033
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2034
+ fee: item.fee !== undefined ? item.fee : undefined,
2035
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
2036
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
2037
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
2038
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
2039
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
2040
+ },
2041
+ }))
2042
+ } : undefined,
2043
+ positions: item.alpacaAccount.positions ?
2044
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2045
+ connect: item.alpacaAccount.positions.map((item) => ({
2046
+ id: item.id
2047
+ }))
2048
+ }
2049
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
2050
+ where: {
2051
+ id: item.id !== undefined ? item.id : undefined,
2052
+ },
2053
+ create: {
2054
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2055
+ qty: item.qty !== undefined ? item.qty : undefined,
2056
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2057
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2058
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2059
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2060
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2061
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2062
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2063
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2064
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2065
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2066
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2067
+ },
2068
+ }))
2069
+ } : undefined,
2070
+ alerts: item.alpacaAccount.alerts ?
2071
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2072
+ connect: item.alpacaAccount.alerts.map((item) => ({
2073
+ id: item.id
2074
+ }))
2075
+ }
2076
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
2077
+ where: {
2078
+ id: item.id !== undefined ? item.id : undefined,
2079
+ },
2080
+ create: {
2081
+ message: item.message !== undefined ? item.message : undefined,
2082
+ type: item.type !== undefined ? item.type : undefined,
2083
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
2084
+ },
2085
+ }))
2086
+ } : undefined,
1094
2087
  },
1095
2088
  }
1096
2089
  } : undefined,
@@ -1110,6 +2103,42 @@ export const Asset = {
1110
2103
  note: item.note !== undefined ? item.note : undefined,
1111
2104
  status: item.status !== undefined ? item.status : undefined,
1112
2105
  fee: item.fee !== undefined ? item.fee : undefined,
2106
+ order: item.order ?
2107
+ typeof item.order === 'object' && Object.keys(item.order).length === 1 && Object.keys(item.order)[0] === 'id'
2108
+ ? { connect: {
2109
+ id: item.order.id
2110
+ }
2111
+ }
2112
+ : { connectOrCreate: {
2113
+ where: {
2114
+ id: item.order.id !== undefined ? item.order.id : undefined,
2115
+ },
2116
+ create: {
2117
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
2118
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
2119
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
2120
+ side: item.order.side !== undefined ? item.order.side : undefined,
2121
+ type: item.order.type !== undefined ? item.order.type : undefined,
2122
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
2123
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
2124
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
2125
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
2126
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
2127
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
2128
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
2129
+ status: item.order.status !== undefined ? item.order.status : undefined,
2130
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
2131
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
2132
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
2133
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
2134
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
2135
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
2136
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
2137
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
2138
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
2139
+ },
2140
+ }
2141
+ } : undefined,
1113
2142
  },
1114
2143
  }))
1115
2144
  } : undefined,
@@ -1277,6 +2306,222 @@ export const Asset = {
1277
2306
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? {
1278
2307
  set: item.alpacaAccount.volumeThreshold
1279
2308
  } : undefined,
2309
+ user: item.alpacaAccount.user ? {
2310
+ upsert: {
2311
+ where: {
2312
+ id: item.alpacaAccount.user.id !== undefined ? {
2313
+ equals: item.alpacaAccount.user.id
2314
+ } : undefined,
2315
+ name: item.alpacaAccount.user.name !== undefined ? {
2316
+ equals: item.alpacaAccount.user.name
2317
+ } : undefined,
2318
+ email: item.alpacaAccount.user.email !== undefined ? {
2319
+ equals: item.alpacaAccount.user.email
2320
+ } : undefined,
2321
+ },
2322
+ update: {
2323
+ id: item.alpacaAccount.user.id !== undefined ? {
2324
+ set: item.alpacaAccount.user.id
2325
+ } : undefined,
2326
+ name: item.alpacaAccount.user.name !== undefined ? {
2327
+ set: item.alpacaAccount.user.name
2328
+ } : undefined,
2329
+ email: item.alpacaAccount.user.email !== undefined ? {
2330
+ set: item.alpacaAccount.user.email
2331
+ } : undefined,
2332
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? {
2333
+ set: item.alpacaAccount.user.emailVerified
2334
+ } : undefined,
2335
+ image: item.alpacaAccount.user.image !== undefined ? {
2336
+ set: item.alpacaAccount.user.image
2337
+ } : undefined,
2338
+ role: item.alpacaAccount.user.role !== undefined ? {
2339
+ set: item.alpacaAccount.user.role
2340
+ } : undefined,
2341
+ bio: item.alpacaAccount.user.bio !== undefined ? {
2342
+ set: item.alpacaAccount.user.bio
2343
+ } : undefined,
2344
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? {
2345
+ set: item.alpacaAccount.user.jobTitle
2346
+ } : undefined,
2347
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? {
2348
+ set: item.alpacaAccount.user.currentAccount
2349
+ } : undefined,
2350
+ plan: item.alpacaAccount.user.plan !== undefined ? {
2351
+ set: item.alpacaAccount.user.plan
2352
+ } : undefined,
2353
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? {
2354
+ set: item.alpacaAccount.user.openaiAPIKey
2355
+ } : undefined,
2356
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? {
2357
+ set: item.alpacaAccount.user.openaiModel
2358
+ } : undefined,
2359
+ },
2360
+ create: {
2361
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
2362
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
2363
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
2364
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
2365
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
2366
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
2367
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
2368
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
2369
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
2370
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
2371
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
2372
+ },
2373
+ }
2374
+ } : undefined,
2375
+ trades: item.alpacaAccount.trades ? {
2376
+ upsert: item.alpacaAccount.trades.map((item) => ({
2377
+ where: {
2378
+ id: item.id !== undefined ? item.id : undefined,
2379
+ },
2380
+ update: {
2381
+ id: item.id !== undefined ? {
2382
+ set: item.id
2383
+ } : undefined,
2384
+ qty: item.qty !== undefined ? {
2385
+ set: item.qty
2386
+ } : undefined,
2387
+ price: item.price !== undefined ? {
2388
+ set: item.price
2389
+ } : undefined,
2390
+ total: item.total !== undefined ? {
2391
+ set: item.total
2392
+ } : undefined,
2393
+ optionType: item.optionType !== undefined ? {
2394
+ set: item.optionType
2395
+ } : undefined,
2396
+ signal: item.signal !== undefined ? {
2397
+ set: item.signal
2398
+ } : undefined,
2399
+ strategy: item.strategy !== undefined ? {
2400
+ set: item.strategy
2401
+ } : undefined,
2402
+ analysis: item.analysis !== undefined ? {
2403
+ set: item.analysis
2404
+ } : undefined,
2405
+ summary: item.summary !== undefined ? {
2406
+ set: item.summary
2407
+ } : undefined,
2408
+ confidence: item.confidence !== undefined ? {
2409
+ set: item.confidence
2410
+ } : undefined,
2411
+ timestamp: item.timestamp !== undefined ? {
2412
+ set: item.timestamp
2413
+ } : undefined,
2414
+ status: item.status !== undefined ? {
2415
+ set: item.status
2416
+ } : undefined,
2417
+ },
2418
+ create: {
2419
+ qty: item.qty !== undefined ? item.qty : undefined,
2420
+ price: item.price !== undefined ? item.price : undefined,
2421
+ total: item.total !== undefined ? item.total : undefined,
2422
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
2423
+ signal: item.signal !== undefined ? item.signal : undefined,
2424
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2425
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2426
+ summary: item.summary !== undefined ? item.summary : undefined,
2427
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2428
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2429
+ status: item.status !== undefined ? item.status : undefined,
2430
+ },
2431
+ }))
2432
+ } : undefined,
2433
+ positions: item.alpacaAccount.positions ? {
2434
+ upsert: item.alpacaAccount.positions.map((item) => ({
2435
+ where: {
2436
+ id: item.id !== undefined ? item.id : undefined,
2437
+ },
2438
+ update: {
2439
+ id: item.id !== undefined ? {
2440
+ set: item.id
2441
+ } : undefined,
2442
+ averageEntryPrice: item.averageEntryPrice !== undefined ? {
2443
+ set: item.averageEntryPrice
2444
+ } : undefined,
2445
+ qty: item.qty !== undefined ? {
2446
+ set: item.qty
2447
+ } : undefined,
2448
+ qtyAvailable: item.qtyAvailable !== undefined ? {
2449
+ set: item.qtyAvailable
2450
+ } : undefined,
2451
+ marketValue: item.marketValue !== undefined ? {
2452
+ set: item.marketValue
2453
+ } : undefined,
2454
+ costBasis: item.costBasis !== undefined ? {
2455
+ set: item.costBasis
2456
+ } : undefined,
2457
+ unrealizedPL: item.unrealizedPL !== undefined ? {
2458
+ set: item.unrealizedPL
2459
+ } : undefined,
2460
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? {
2461
+ set: item.unrealizedPLPC
2462
+ } : undefined,
2463
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? {
2464
+ set: item.unrealisedIntradayPL
2465
+ } : undefined,
2466
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? {
2467
+ set: item.unrealisedIntradayPLPC
2468
+ } : undefined,
2469
+ currentPrice: item.currentPrice !== undefined ? {
2470
+ set: item.currentPrice
2471
+ } : undefined,
2472
+ lastTradePrice: item.lastTradePrice !== undefined ? {
2473
+ set: item.lastTradePrice
2474
+ } : undefined,
2475
+ changeToday: item.changeToday !== undefined ? {
2476
+ set: item.changeToday
2477
+ } : undefined,
2478
+ assetMarginable: item.assetMarginable !== undefined ? {
2479
+ set: item.assetMarginable
2480
+ } : undefined,
2481
+ },
2482
+ create: {
2483
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2484
+ qty: item.qty !== undefined ? item.qty : undefined,
2485
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2486
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2487
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2488
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2489
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2490
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2491
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2492
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2493
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2494
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2495
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2496
+ },
2497
+ }))
2498
+ } : undefined,
2499
+ alerts: item.alpacaAccount.alerts ? {
2500
+ upsert: item.alpacaAccount.alerts.map((item) => ({
2501
+ where: {
2502
+ id: item.id !== undefined ? item.id : undefined,
2503
+ },
2504
+ update: {
2505
+ id: item.id !== undefined ? {
2506
+ set: item.id
2507
+ } : undefined,
2508
+ message: item.message !== undefined ? {
2509
+ set: item.message
2510
+ } : undefined,
2511
+ type: item.type !== undefined ? {
2512
+ set: item.type
2513
+ } : undefined,
2514
+ isRead: item.isRead !== undefined ? {
2515
+ set: item.isRead
2516
+ } : undefined,
2517
+ },
2518
+ create: {
2519
+ message: item.message !== undefined ? item.message : undefined,
2520
+ type: item.type !== undefined ? item.type : undefined,
2521
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
2522
+ },
2523
+ }))
2524
+ } : undefined,
1280
2525
  },
1281
2526
  create: {
1282
2527
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -1288,6 +2533,104 @@ export const Asset = {
1288
2533
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
1289
2534
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
1290
2535
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
2536
+ user: item.alpacaAccount.user ?
2537
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
2538
+ ? { connect: {
2539
+ id: item.alpacaAccount.user.id
2540
+ }
2541
+ }
2542
+ : { connectOrCreate: {
2543
+ where: {
2544
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
2545
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
2546
+ name: item.alpacaAccount.user.name !== undefined ? {
2547
+ equals: item.alpacaAccount.user.name
2548
+ } : undefined,
2549
+ },
2550
+ create: {
2551
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
2552
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
2553
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
2554
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
2555
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
2556
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
2557
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
2558
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
2559
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
2560
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
2561
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
2562
+ },
2563
+ }
2564
+ } : undefined,
2565
+ trades: item.alpacaAccount.trades ?
2566
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2567
+ connect: item.alpacaAccount.trades.map((item) => ({
2568
+ id: item.id
2569
+ }))
2570
+ }
2571
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
2572
+ where: {
2573
+ id: item.id !== undefined ? item.id : undefined,
2574
+ },
2575
+ create: {
2576
+ qty: item.qty !== undefined ? item.qty : undefined,
2577
+ price: item.price !== undefined ? item.price : undefined,
2578
+ total: item.total !== undefined ? item.total : undefined,
2579
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
2580
+ signal: item.signal !== undefined ? item.signal : undefined,
2581
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2582
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2583
+ summary: item.summary !== undefined ? item.summary : undefined,
2584
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2585
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2586
+ status: item.status !== undefined ? item.status : undefined,
2587
+ },
2588
+ }))
2589
+ } : undefined,
2590
+ positions: item.alpacaAccount.positions ?
2591
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2592
+ connect: item.alpacaAccount.positions.map((item) => ({
2593
+ id: item.id
2594
+ }))
2595
+ }
2596
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
2597
+ where: {
2598
+ id: item.id !== undefined ? item.id : undefined,
2599
+ },
2600
+ create: {
2601
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2602
+ qty: item.qty !== undefined ? item.qty : undefined,
2603
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2604
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2605
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2606
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2607
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2608
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2609
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2610
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2611
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2612
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2613
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2614
+ },
2615
+ }))
2616
+ } : undefined,
2617
+ alerts: item.alpacaAccount.alerts ?
2618
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2619
+ connect: item.alpacaAccount.alerts.map((item) => ({
2620
+ id: item.id
2621
+ }))
2622
+ }
2623
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
2624
+ where: {
2625
+ id: item.id !== undefined ? item.id : undefined,
2626
+ },
2627
+ create: {
2628
+ message: item.message !== undefined ? item.message : undefined,
2629
+ type: item.type !== undefined ? item.type : undefined,
2630
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
2631
+ },
2632
+ }))
2633
+ } : undefined,
1291
2634
  },
1292
2635
  }
1293
2636
  } : undefined,
@@ -1317,6 +2660,66 @@ export const Asset = {
1317
2660
  fee: item.action.fee !== undefined ? {
1318
2661
  set: item.action.fee
1319
2662
  } : undefined,
2663
+ trade: item.action.trade ? {
2664
+ upsert: {
2665
+ where: {
2666
+ id: item.action.trade.id !== undefined ? {
2667
+ equals: item.action.trade.id
2668
+ } : undefined,
2669
+ },
2670
+ update: {
2671
+ id: item.action.trade.id !== undefined ? {
2672
+ set: item.action.trade.id
2673
+ } : undefined,
2674
+ qty: item.action.trade.qty !== undefined ? {
2675
+ set: item.action.trade.qty
2676
+ } : undefined,
2677
+ price: item.action.trade.price !== undefined ? {
2678
+ set: item.action.trade.price
2679
+ } : undefined,
2680
+ total: item.action.trade.total !== undefined ? {
2681
+ set: item.action.trade.total
2682
+ } : undefined,
2683
+ optionType: item.action.trade.optionType !== undefined ? {
2684
+ set: item.action.trade.optionType
2685
+ } : undefined,
2686
+ signal: item.action.trade.signal !== undefined ? {
2687
+ set: item.action.trade.signal
2688
+ } : undefined,
2689
+ strategy: item.action.trade.strategy !== undefined ? {
2690
+ set: item.action.trade.strategy
2691
+ } : undefined,
2692
+ analysis: item.action.trade.analysis !== undefined ? {
2693
+ set: item.action.trade.analysis
2694
+ } : undefined,
2695
+ summary: item.action.trade.summary !== undefined ? {
2696
+ set: item.action.trade.summary
2697
+ } : undefined,
2698
+ confidence: item.action.trade.confidence !== undefined ? {
2699
+ set: item.action.trade.confidence
2700
+ } : undefined,
2701
+ timestamp: item.action.trade.timestamp !== undefined ? {
2702
+ set: item.action.trade.timestamp
2703
+ } : undefined,
2704
+ status: item.action.trade.status !== undefined ? {
2705
+ set: item.action.trade.status
2706
+ } : undefined,
2707
+ },
2708
+ create: {
2709
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
2710
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
2711
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
2712
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
2713
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
2714
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
2715
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
2716
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
2717
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
2718
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
2719
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
2720
+ },
2721
+ }
2722
+ } : undefined,
1320
2723
  },
1321
2724
  create: {
1322
2725
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -1324,6 +2727,31 @@ export const Asset = {
1324
2727
  note: item.action.note !== undefined ? item.action.note : undefined,
1325
2728
  status: item.action.status !== undefined ? item.action.status : undefined,
1326
2729
  fee: item.action.fee !== undefined ? item.action.fee : undefined,
2730
+ trade: item.action.trade ?
2731
+ typeof item.action.trade === 'object' && Object.keys(item.action.trade).length === 1 && Object.keys(item.action.trade)[0] === 'id'
2732
+ ? { connect: {
2733
+ id: item.action.trade.id
2734
+ }
2735
+ }
2736
+ : { connectOrCreate: {
2737
+ where: {
2738
+ id: item.action.trade.id !== undefined ? item.action.trade.id : undefined,
2739
+ },
2740
+ create: {
2741
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
2742
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
2743
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
2744
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
2745
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
2746
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
2747
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
2748
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
2749
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
2750
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
2751
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
2752
+ },
2753
+ }
2754
+ } : undefined,
1327
2755
  },
1328
2756
  }
1329
2757
  } : undefined,
@@ -1403,6 +2831,104 @@ export const Asset = {
1403
2831
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
1404
2832
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
1405
2833
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
2834
+ user: item.alpacaAccount.user ?
2835
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
2836
+ ? { connect: {
2837
+ id: item.alpacaAccount.user.id
2838
+ }
2839
+ }
2840
+ : { connectOrCreate: {
2841
+ where: {
2842
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
2843
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
2844
+ name: item.alpacaAccount.user.name !== undefined ? {
2845
+ equals: item.alpacaAccount.user.name
2846
+ } : undefined,
2847
+ },
2848
+ create: {
2849
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
2850
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
2851
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
2852
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
2853
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
2854
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
2855
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
2856
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
2857
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
2858
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
2859
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
2860
+ },
2861
+ }
2862
+ } : undefined,
2863
+ trades: item.alpacaAccount.trades ?
2864
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2865
+ connect: item.alpacaAccount.trades.map((item) => ({
2866
+ id: item.id
2867
+ }))
2868
+ }
2869
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
2870
+ where: {
2871
+ id: item.id !== undefined ? item.id : undefined,
2872
+ },
2873
+ create: {
2874
+ qty: item.qty !== undefined ? item.qty : undefined,
2875
+ price: item.price !== undefined ? item.price : undefined,
2876
+ total: item.total !== undefined ? item.total : undefined,
2877
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
2878
+ signal: item.signal !== undefined ? item.signal : undefined,
2879
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2880
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2881
+ summary: item.summary !== undefined ? item.summary : undefined,
2882
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2883
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2884
+ status: item.status !== undefined ? item.status : undefined,
2885
+ },
2886
+ }))
2887
+ } : undefined,
2888
+ positions: item.alpacaAccount.positions ?
2889
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2890
+ connect: item.alpacaAccount.positions.map((item) => ({
2891
+ id: item.id
2892
+ }))
2893
+ }
2894
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
2895
+ where: {
2896
+ id: item.id !== undefined ? item.id : undefined,
2897
+ },
2898
+ create: {
2899
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2900
+ qty: item.qty !== undefined ? item.qty : undefined,
2901
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2902
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2903
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2904
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2905
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2906
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2907
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2908
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2909
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2910
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2911
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2912
+ },
2913
+ }))
2914
+ } : undefined,
2915
+ alerts: item.alpacaAccount.alerts ?
2916
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2917
+ connect: item.alpacaAccount.alerts.map((item) => ({
2918
+ id: item.id
2919
+ }))
2920
+ }
2921
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
2922
+ where: {
2923
+ id: item.id !== undefined ? item.id : undefined,
2924
+ },
2925
+ create: {
2926
+ message: item.message !== undefined ? item.message : undefined,
2927
+ type: item.type !== undefined ? item.type : undefined,
2928
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
2929
+ },
2930
+ }))
2931
+ } : undefined,
1406
2932
  },
1407
2933
  }
1408
2934
  } : undefined,
@@ -1422,6 +2948,31 @@ export const Asset = {
1422
2948
  note: item.action.note !== undefined ? item.action.note : undefined,
1423
2949
  status: item.action.status !== undefined ? item.action.status : undefined,
1424
2950
  fee: item.action.fee !== undefined ? item.action.fee : undefined,
2951
+ trade: item.action.trade ?
2952
+ typeof item.action.trade === 'object' && Object.keys(item.action.trade).length === 1 && Object.keys(item.action.trade)[0] === 'id'
2953
+ ? { connect: {
2954
+ id: item.action.trade.id
2955
+ }
2956
+ }
2957
+ : { connectOrCreate: {
2958
+ where: {
2959
+ id: item.action.trade.id !== undefined ? item.action.trade.id : undefined,
2960
+ },
2961
+ create: {
2962
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
2963
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
2964
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
2965
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
2966
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
2967
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
2968
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
2969
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
2970
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
2971
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
2972
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
2973
+ },
2974
+ }
2975
+ } : undefined,
1425
2976
  },
1426
2977
  }
1427
2978
  } : undefined,
@@ -1514,6 +3065,258 @@ export const Asset = {
1514
3065
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? {
1515
3066
  set: item.alpacaAccount.volumeThreshold
1516
3067
  } : undefined,
3068
+ user: item.alpacaAccount.user ? {
3069
+ upsert: {
3070
+ where: {
3071
+ id: item.alpacaAccount.user.id !== undefined ? {
3072
+ equals: item.alpacaAccount.user.id
3073
+ } : undefined,
3074
+ name: item.alpacaAccount.user.name !== undefined ? {
3075
+ equals: item.alpacaAccount.user.name
3076
+ } : undefined,
3077
+ email: item.alpacaAccount.user.email !== undefined ? {
3078
+ equals: item.alpacaAccount.user.email
3079
+ } : undefined,
3080
+ },
3081
+ update: {
3082
+ id: item.alpacaAccount.user.id !== undefined ? {
3083
+ set: item.alpacaAccount.user.id
3084
+ } : undefined,
3085
+ name: item.alpacaAccount.user.name !== undefined ? {
3086
+ set: item.alpacaAccount.user.name
3087
+ } : undefined,
3088
+ email: item.alpacaAccount.user.email !== undefined ? {
3089
+ set: item.alpacaAccount.user.email
3090
+ } : undefined,
3091
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? {
3092
+ set: item.alpacaAccount.user.emailVerified
3093
+ } : undefined,
3094
+ image: item.alpacaAccount.user.image !== undefined ? {
3095
+ set: item.alpacaAccount.user.image
3096
+ } : undefined,
3097
+ role: item.alpacaAccount.user.role !== undefined ? {
3098
+ set: item.alpacaAccount.user.role
3099
+ } : undefined,
3100
+ bio: item.alpacaAccount.user.bio !== undefined ? {
3101
+ set: item.alpacaAccount.user.bio
3102
+ } : undefined,
3103
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? {
3104
+ set: item.alpacaAccount.user.jobTitle
3105
+ } : undefined,
3106
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? {
3107
+ set: item.alpacaAccount.user.currentAccount
3108
+ } : undefined,
3109
+ plan: item.alpacaAccount.user.plan !== undefined ? {
3110
+ set: item.alpacaAccount.user.plan
3111
+ } : undefined,
3112
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? {
3113
+ set: item.alpacaAccount.user.openaiAPIKey
3114
+ } : undefined,
3115
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? {
3116
+ set: item.alpacaAccount.user.openaiModel
3117
+ } : undefined,
3118
+ },
3119
+ create: {
3120
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
3121
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
3122
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
3123
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
3124
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
3125
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
3126
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
3127
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
3128
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
3129
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
3130
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
3131
+ },
3132
+ }
3133
+ } : undefined,
3134
+ trades: item.alpacaAccount.trades ? {
3135
+ upsert: item.alpacaAccount.trades.map((item) => ({
3136
+ where: {
3137
+ id: item.id !== undefined ? item.id : undefined,
3138
+ },
3139
+ update: {
3140
+ id: item.id !== undefined ? {
3141
+ set: item.id
3142
+ } : undefined,
3143
+ qty: item.qty !== undefined ? {
3144
+ set: item.qty
3145
+ } : undefined,
3146
+ price: item.price !== undefined ? {
3147
+ set: item.price
3148
+ } : undefined,
3149
+ total: item.total !== undefined ? {
3150
+ set: item.total
3151
+ } : undefined,
3152
+ optionType: item.optionType !== undefined ? {
3153
+ set: item.optionType
3154
+ } : undefined,
3155
+ signal: item.signal !== undefined ? {
3156
+ set: item.signal
3157
+ } : undefined,
3158
+ strategy: item.strategy !== undefined ? {
3159
+ set: item.strategy
3160
+ } : undefined,
3161
+ analysis: item.analysis !== undefined ? {
3162
+ set: item.analysis
3163
+ } : undefined,
3164
+ summary: item.summary !== undefined ? {
3165
+ set: item.summary
3166
+ } : undefined,
3167
+ confidence: item.confidence !== undefined ? {
3168
+ set: item.confidence
3169
+ } : undefined,
3170
+ timestamp: item.timestamp !== undefined ? {
3171
+ set: item.timestamp
3172
+ } : undefined,
3173
+ status: item.status !== undefined ? {
3174
+ set: item.status
3175
+ } : undefined,
3176
+ },
3177
+ create: {
3178
+ qty: item.qty !== undefined ? item.qty : undefined,
3179
+ price: item.price !== undefined ? item.price : undefined,
3180
+ total: item.total !== undefined ? item.total : undefined,
3181
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
3182
+ signal: item.signal !== undefined ? item.signal : undefined,
3183
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
3184
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
3185
+ summary: item.summary !== undefined ? item.summary : undefined,
3186
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
3187
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
3188
+ status: item.status !== undefined ? item.status : undefined,
3189
+ },
3190
+ }))
3191
+ } : undefined,
3192
+ orders: item.alpacaAccount.orders ? {
3193
+ upsert: item.alpacaAccount.orders.map((item) => ({
3194
+ where: {
3195
+ id: item.id !== undefined ? item.id : undefined,
3196
+ },
3197
+ update: {
3198
+ id: item.id !== undefined ? {
3199
+ set: item.id
3200
+ } : undefined,
3201
+ clientOrderId: item.clientOrderId !== undefined ? {
3202
+ set: item.clientOrderId
3203
+ } : undefined,
3204
+ qty: item.qty !== undefined ? {
3205
+ set: item.qty
3206
+ } : undefined,
3207
+ notional: item.notional !== undefined ? {
3208
+ set: item.notional
3209
+ } : undefined,
3210
+ side: item.side !== undefined ? {
3211
+ set: item.side
3212
+ } : undefined,
3213
+ type: item.type !== undefined ? {
3214
+ set: item.type
3215
+ } : undefined,
3216
+ orderClass: item.orderClass !== undefined ? {
3217
+ set: item.orderClass
3218
+ } : undefined,
3219
+ timeInForce: item.timeInForce !== undefined ? {
3220
+ set: item.timeInForce
3221
+ } : undefined,
3222
+ limitPrice: item.limitPrice !== undefined ? {
3223
+ set: item.limitPrice
3224
+ } : undefined,
3225
+ stopPrice: item.stopPrice !== undefined ? {
3226
+ set: item.stopPrice
3227
+ } : undefined,
3228
+ trailPrice: item.trailPrice !== undefined ? {
3229
+ set: item.trailPrice
3230
+ } : undefined,
3231
+ trailPercent: item.trailPercent !== undefined ? {
3232
+ set: item.trailPercent
3233
+ } : undefined,
3234
+ extendedHours: item.extendedHours !== undefined ? {
3235
+ set: item.extendedHours
3236
+ } : undefined,
3237
+ status: item.status !== undefined ? {
3238
+ set: item.status
3239
+ } : undefined,
3240
+ submittedAt: item.submittedAt !== undefined ? {
3241
+ set: item.submittedAt
3242
+ } : undefined,
3243
+ filledAt: item.filledAt !== undefined ? {
3244
+ set: item.filledAt
3245
+ } : undefined,
3246
+ filledAvgPrice: item.filledAvgPrice !== undefined ? {
3247
+ set: item.filledAvgPrice
3248
+ } : undefined,
3249
+ fee: item.fee !== undefined ? {
3250
+ set: item.fee
3251
+ } : undefined,
3252
+ strikePrice: item.strikePrice !== undefined ? {
3253
+ set: item.strikePrice
3254
+ } : undefined,
3255
+ expirationDate: item.expirationDate !== undefined ? {
3256
+ set: item.expirationDate
3257
+ } : undefined,
3258
+ optionType: item.optionType !== undefined ? {
3259
+ set: item.optionType
3260
+ } : undefined,
3261
+ stopLossId: item.stopLossId !== undefined ? {
3262
+ set: item.stopLossId
3263
+ } : undefined,
3264
+ takeProfitId: item.takeProfitId !== undefined ? {
3265
+ set: item.takeProfitId
3266
+ } : undefined,
3267
+ },
3268
+ create: {
3269
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
3270
+ qty: item.qty !== undefined ? item.qty : undefined,
3271
+ notional: item.notional !== undefined ? item.notional : undefined,
3272
+ side: item.side !== undefined ? item.side : undefined,
3273
+ type: item.type !== undefined ? item.type : undefined,
3274
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
3275
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
3276
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
3277
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
3278
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
3279
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
3280
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
3281
+ status: item.status !== undefined ? item.status : undefined,
3282
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
3283
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
3284
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
3285
+ fee: item.fee !== undefined ? item.fee : undefined,
3286
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
3287
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
3288
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
3289
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
3290
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
3291
+ },
3292
+ }))
3293
+ } : undefined,
3294
+ alerts: item.alpacaAccount.alerts ? {
3295
+ upsert: item.alpacaAccount.alerts.map((item) => ({
3296
+ where: {
3297
+ id: item.id !== undefined ? item.id : undefined,
3298
+ },
3299
+ update: {
3300
+ id: item.id !== undefined ? {
3301
+ set: item.id
3302
+ } : undefined,
3303
+ message: item.message !== undefined ? {
3304
+ set: item.message
3305
+ } : undefined,
3306
+ type: item.type !== undefined ? {
3307
+ set: item.type
3308
+ } : undefined,
3309
+ isRead: item.isRead !== undefined ? {
3310
+ set: item.isRead
3311
+ } : undefined,
3312
+ },
3313
+ create: {
3314
+ message: item.message !== undefined ? item.message : undefined,
3315
+ type: item.type !== undefined ? item.type : undefined,
3316
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
3317
+ },
3318
+ }))
3319
+ } : undefined,
1517
3320
  },
1518
3321
  create: {
1519
3322
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -1525,6 +3328,113 @@ export const Asset = {
1525
3328
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
1526
3329
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
1527
3330
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
3331
+ user: item.alpacaAccount.user ?
3332
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
3333
+ ? { connect: {
3334
+ id: item.alpacaAccount.user.id
3335
+ }
3336
+ }
3337
+ : { connectOrCreate: {
3338
+ where: {
3339
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
3340
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
3341
+ name: item.alpacaAccount.user.name !== undefined ? {
3342
+ equals: item.alpacaAccount.user.name
3343
+ } : undefined,
3344
+ },
3345
+ create: {
3346
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
3347
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
3348
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
3349
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
3350
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
3351
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
3352
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
3353
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
3354
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
3355
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
3356
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
3357
+ },
3358
+ }
3359
+ } : undefined,
3360
+ trades: item.alpacaAccount.trades ?
3361
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3362
+ connect: item.alpacaAccount.trades.map((item) => ({
3363
+ id: item.id
3364
+ }))
3365
+ }
3366
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
3367
+ where: {
3368
+ id: item.id !== undefined ? item.id : undefined,
3369
+ },
3370
+ create: {
3371
+ qty: item.qty !== undefined ? item.qty : undefined,
3372
+ price: item.price !== undefined ? item.price : undefined,
3373
+ total: item.total !== undefined ? item.total : undefined,
3374
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
3375
+ signal: item.signal !== undefined ? item.signal : undefined,
3376
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
3377
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
3378
+ summary: item.summary !== undefined ? item.summary : undefined,
3379
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
3380
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
3381
+ status: item.status !== undefined ? item.status : undefined,
3382
+ },
3383
+ }))
3384
+ } : undefined,
3385
+ orders: item.alpacaAccount.orders ?
3386
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3387
+ connect: item.alpacaAccount.orders.map((item) => ({
3388
+ id: item.id
3389
+ }))
3390
+ }
3391
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
3392
+ where: {
3393
+ id: item.id !== undefined ? item.id : undefined,
3394
+ },
3395
+ create: {
3396
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
3397
+ qty: item.qty !== undefined ? item.qty : undefined,
3398
+ notional: item.notional !== undefined ? item.notional : undefined,
3399
+ side: item.side !== undefined ? item.side : undefined,
3400
+ type: item.type !== undefined ? item.type : undefined,
3401
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
3402
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
3403
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
3404
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
3405
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
3406
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
3407
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
3408
+ status: item.status !== undefined ? item.status : undefined,
3409
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
3410
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
3411
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
3412
+ fee: item.fee !== undefined ? item.fee : undefined,
3413
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
3414
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
3415
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
3416
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
3417
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
3418
+ },
3419
+ }))
3420
+ } : undefined,
3421
+ alerts: item.alpacaAccount.alerts ?
3422
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3423
+ connect: item.alpacaAccount.alerts.map((item) => ({
3424
+ id: item.id
3425
+ }))
3426
+ }
3427
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
3428
+ where: {
3429
+ id: item.id !== undefined ? item.id : undefined,
3430
+ },
3431
+ create: {
3432
+ message: item.message !== undefined ? item.message : undefined,
3433
+ type: item.type !== undefined ? item.type : undefined,
3434
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
3435
+ },
3436
+ }))
3437
+ } : undefined,
1528
3438
  },
1529
3439
  }
1530
3440
  } : undefined,
@@ -1563,6 +3473,113 @@ export const Asset = {
1563
3473
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
1564
3474
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
1565
3475
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
3476
+ user: item.alpacaAccount.user ?
3477
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
3478
+ ? { connect: {
3479
+ id: item.alpacaAccount.user.id
3480
+ }
3481
+ }
3482
+ : { connectOrCreate: {
3483
+ where: {
3484
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
3485
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
3486
+ name: item.alpacaAccount.user.name !== undefined ? {
3487
+ equals: item.alpacaAccount.user.name
3488
+ } : undefined,
3489
+ },
3490
+ create: {
3491
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
3492
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
3493
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
3494
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
3495
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
3496
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
3497
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
3498
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
3499
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
3500
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
3501
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
3502
+ },
3503
+ }
3504
+ } : undefined,
3505
+ trades: item.alpacaAccount.trades ?
3506
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3507
+ connect: item.alpacaAccount.trades.map((item) => ({
3508
+ id: item.id
3509
+ }))
3510
+ }
3511
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
3512
+ where: {
3513
+ id: item.id !== undefined ? item.id : undefined,
3514
+ },
3515
+ create: {
3516
+ qty: item.qty !== undefined ? item.qty : undefined,
3517
+ price: item.price !== undefined ? item.price : undefined,
3518
+ total: item.total !== undefined ? item.total : undefined,
3519
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
3520
+ signal: item.signal !== undefined ? item.signal : undefined,
3521
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
3522
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
3523
+ summary: item.summary !== undefined ? item.summary : undefined,
3524
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
3525
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
3526
+ status: item.status !== undefined ? item.status : undefined,
3527
+ },
3528
+ }))
3529
+ } : undefined,
3530
+ orders: item.alpacaAccount.orders ?
3531
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3532
+ connect: item.alpacaAccount.orders.map((item) => ({
3533
+ id: item.id
3534
+ }))
3535
+ }
3536
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
3537
+ where: {
3538
+ id: item.id !== undefined ? item.id : undefined,
3539
+ },
3540
+ create: {
3541
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
3542
+ qty: item.qty !== undefined ? item.qty : undefined,
3543
+ notional: item.notional !== undefined ? item.notional : undefined,
3544
+ side: item.side !== undefined ? item.side : undefined,
3545
+ type: item.type !== undefined ? item.type : undefined,
3546
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
3547
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
3548
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
3549
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
3550
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
3551
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
3552
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
3553
+ status: item.status !== undefined ? item.status : undefined,
3554
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
3555
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
3556
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
3557
+ fee: item.fee !== undefined ? item.fee : undefined,
3558
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
3559
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
3560
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
3561
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
3562
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
3563
+ },
3564
+ }))
3565
+ } : undefined,
3566
+ alerts: item.alpacaAccount.alerts ?
3567
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3568
+ connect: item.alpacaAccount.alerts.map((item) => ({
3569
+ id: item.id
3570
+ }))
3571
+ }
3572
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
3573
+ where: {
3574
+ id: item.id !== undefined ? item.id : undefined,
3575
+ },
3576
+ create: {
3577
+ message: item.message !== undefined ? item.message : undefined,
3578
+ type: item.type !== undefined ? item.type : undefined,
3579
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
3580
+ },
3581
+ }))
3582
+ } : undefined,
1566
3583
  },
1567
3584
  }
1568
3585
  } : undefined,
@@ -2053,6 +4070,266 @@ export const Asset = {
2053
4070
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? {
2054
4071
  set: item.alpacaAccount.volumeThreshold
2055
4072
  } : undefined,
4073
+ user: item.alpacaAccount.user ? {
4074
+ upsert: {
4075
+ where: {
4076
+ id: item.alpacaAccount.user.id !== undefined ? {
4077
+ equals: item.alpacaAccount.user.id
4078
+ } : undefined,
4079
+ name: item.alpacaAccount.user.name !== undefined ? {
4080
+ equals: item.alpacaAccount.user.name
4081
+ } : undefined,
4082
+ email: item.alpacaAccount.user.email !== undefined ? {
4083
+ equals: item.alpacaAccount.user.email
4084
+ } : undefined,
4085
+ },
4086
+ update: {
4087
+ id: item.alpacaAccount.user.id !== undefined ? {
4088
+ set: item.alpacaAccount.user.id
4089
+ } : undefined,
4090
+ name: item.alpacaAccount.user.name !== undefined ? {
4091
+ set: item.alpacaAccount.user.name
4092
+ } : undefined,
4093
+ email: item.alpacaAccount.user.email !== undefined ? {
4094
+ set: item.alpacaAccount.user.email
4095
+ } : undefined,
4096
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? {
4097
+ set: item.alpacaAccount.user.emailVerified
4098
+ } : undefined,
4099
+ image: item.alpacaAccount.user.image !== undefined ? {
4100
+ set: item.alpacaAccount.user.image
4101
+ } : undefined,
4102
+ role: item.alpacaAccount.user.role !== undefined ? {
4103
+ set: item.alpacaAccount.user.role
4104
+ } : undefined,
4105
+ bio: item.alpacaAccount.user.bio !== undefined ? {
4106
+ set: item.alpacaAccount.user.bio
4107
+ } : undefined,
4108
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? {
4109
+ set: item.alpacaAccount.user.jobTitle
4110
+ } : undefined,
4111
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? {
4112
+ set: item.alpacaAccount.user.currentAccount
4113
+ } : undefined,
4114
+ plan: item.alpacaAccount.user.plan !== undefined ? {
4115
+ set: item.alpacaAccount.user.plan
4116
+ } : undefined,
4117
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? {
4118
+ set: item.alpacaAccount.user.openaiAPIKey
4119
+ } : undefined,
4120
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? {
4121
+ set: item.alpacaAccount.user.openaiModel
4122
+ } : undefined,
4123
+ },
4124
+ create: {
4125
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
4126
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
4127
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
4128
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
4129
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
4130
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
4131
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
4132
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
4133
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
4134
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
4135
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
4136
+ },
4137
+ }
4138
+ } : undefined,
4139
+ orders: item.alpacaAccount.orders ? {
4140
+ upsert: item.alpacaAccount.orders.map((item) => ({
4141
+ where: {
4142
+ id: item.id !== undefined ? item.id : undefined,
4143
+ },
4144
+ update: {
4145
+ id: item.id !== undefined ? {
4146
+ set: item.id
4147
+ } : undefined,
4148
+ clientOrderId: item.clientOrderId !== undefined ? {
4149
+ set: item.clientOrderId
4150
+ } : undefined,
4151
+ qty: item.qty !== undefined ? {
4152
+ set: item.qty
4153
+ } : undefined,
4154
+ notional: item.notional !== undefined ? {
4155
+ set: item.notional
4156
+ } : undefined,
4157
+ side: item.side !== undefined ? {
4158
+ set: item.side
4159
+ } : undefined,
4160
+ type: item.type !== undefined ? {
4161
+ set: item.type
4162
+ } : undefined,
4163
+ orderClass: item.orderClass !== undefined ? {
4164
+ set: item.orderClass
4165
+ } : undefined,
4166
+ timeInForce: item.timeInForce !== undefined ? {
4167
+ set: item.timeInForce
4168
+ } : undefined,
4169
+ limitPrice: item.limitPrice !== undefined ? {
4170
+ set: item.limitPrice
4171
+ } : undefined,
4172
+ stopPrice: item.stopPrice !== undefined ? {
4173
+ set: item.stopPrice
4174
+ } : undefined,
4175
+ trailPrice: item.trailPrice !== undefined ? {
4176
+ set: item.trailPrice
4177
+ } : undefined,
4178
+ trailPercent: item.trailPercent !== undefined ? {
4179
+ set: item.trailPercent
4180
+ } : undefined,
4181
+ extendedHours: item.extendedHours !== undefined ? {
4182
+ set: item.extendedHours
4183
+ } : undefined,
4184
+ status: item.status !== undefined ? {
4185
+ set: item.status
4186
+ } : undefined,
4187
+ submittedAt: item.submittedAt !== undefined ? {
4188
+ set: item.submittedAt
4189
+ } : undefined,
4190
+ filledAt: item.filledAt !== undefined ? {
4191
+ set: item.filledAt
4192
+ } : undefined,
4193
+ filledAvgPrice: item.filledAvgPrice !== undefined ? {
4194
+ set: item.filledAvgPrice
4195
+ } : undefined,
4196
+ fee: item.fee !== undefined ? {
4197
+ set: item.fee
4198
+ } : undefined,
4199
+ strikePrice: item.strikePrice !== undefined ? {
4200
+ set: item.strikePrice
4201
+ } : undefined,
4202
+ expirationDate: item.expirationDate !== undefined ? {
4203
+ set: item.expirationDate
4204
+ } : undefined,
4205
+ optionType: item.optionType !== undefined ? {
4206
+ set: item.optionType
4207
+ } : undefined,
4208
+ stopLossId: item.stopLossId !== undefined ? {
4209
+ set: item.stopLossId
4210
+ } : undefined,
4211
+ takeProfitId: item.takeProfitId !== undefined ? {
4212
+ set: item.takeProfitId
4213
+ } : undefined,
4214
+ },
4215
+ create: {
4216
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
4217
+ qty: item.qty !== undefined ? item.qty : undefined,
4218
+ notional: item.notional !== undefined ? item.notional : undefined,
4219
+ side: item.side !== undefined ? item.side : undefined,
4220
+ type: item.type !== undefined ? item.type : undefined,
4221
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
4222
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
4223
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
4224
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
4225
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
4226
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
4227
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
4228
+ status: item.status !== undefined ? item.status : undefined,
4229
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
4230
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
4231
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
4232
+ fee: item.fee !== undefined ? item.fee : undefined,
4233
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
4234
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
4235
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
4236
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
4237
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
4238
+ },
4239
+ }))
4240
+ } : undefined,
4241
+ positions: item.alpacaAccount.positions ? {
4242
+ upsert: item.alpacaAccount.positions.map((item) => ({
4243
+ where: {
4244
+ id: item.id !== undefined ? item.id : undefined,
4245
+ },
4246
+ update: {
4247
+ id: item.id !== undefined ? {
4248
+ set: item.id
4249
+ } : undefined,
4250
+ averageEntryPrice: item.averageEntryPrice !== undefined ? {
4251
+ set: item.averageEntryPrice
4252
+ } : undefined,
4253
+ qty: item.qty !== undefined ? {
4254
+ set: item.qty
4255
+ } : undefined,
4256
+ qtyAvailable: item.qtyAvailable !== undefined ? {
4257
+ set: item.qtyAvailable
4258
+ } : undefined,
4259
+ marketValue: item.marketValue !== undefined ? {
4260
+ set: item.marketValue
4261
+ } : undefined,
4262
+ costBasis: item.costBasis !== undefined ? {
4263
+ set: item.costBasis
4264
+ } : undefined,
4265
+ unrealizedPL: item.unrealizedPL !== undefined ? {
4266
+ set: item.unrealizedPL
4267
+ } : undefined,
4268
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? {
4269
+ set: item.unrealizedPLPC
4270
+ } : undefined,
4271
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? {
4272
+ set: item.unrealisedIntradayPL
4273
+ } : undefined,
4274
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? {
4275
+ set: item.unrealisedIntradayPLPC
4276
+ } : undefined,
4277
+ currentPrice: item.currentPrice !== undefined ? {
4278
+ set: item.currentPrice
4279
+ } : undefined,
4280
+ lastTradePrice: item.lastTradePrice !== undefined ? {
4281
+ set: item.lastTradePrice
4282
+ } : undefined,
4283
+ changeToday: item.changeToday !== undefined ? {
4284
+ set: item.changeToday
4285
+ } : undefined,
4286
+ assetMarginable: item.assetMarginable !== undefined ? {
4287
+ set: item.assetMarginable
4288
+ } : undefined,
4289
+ },
4290
+ create: {
4291
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
4292
+ qty: item.qty !== undefined ? item.qty : undefined,
4293
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
4294
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
4295
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
4296
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
4297
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
4298
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
4299
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
4300
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
4301
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
4302
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
4303
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
4304
+ },
4305
+ }))
4306
+ } : undefined,
4307
+ alerts: item.alpacaAccount.alerts ? {
4308
+ upsert: item.alpacaAccount.alerts.map((item) => ({
4309
+ where: {
4310
+ id: item.id !== undefined ? item.id : undefined,
4311
+ },
4312
+ update: {
4313
+ id: item.id !== undefined ? {
4314
+ set: item.id
4315
+ } : undefined,
4316
+ message: item.message !== undefined ? {
4317
+ set: item.message
4318
+ } : undefined,
4319
+ type: item.type !== undefined ? {
4320
+ set: item.type
4321
+ } : undefined,
4322
+ isRead: item.isRead !== undefined ? {
4323
+ set: item.isRead
4324
+ } : undefined,
4325
+ },
4326
+ create: {
4327
+ message: item.message !== undefined ? item.message : undefined,
4328
+ type: item.type !== undefined ? item.type : undefined,
4329
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
4330
+ },
4331
+ }))
4332
+ } : undefined,
2056
4333
  },
2057
4334
  create: {
2058
4335
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -2064,6 +4341,115 @@ export const Asset = {
2064
4341
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
2065
4342
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
2066
4343
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
4344
+ user: item.alpacaAccount.user ?
4345
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
4346
+ ? { connect: {
4347
+ id: item.alpacaAccount.user.id
4348
+ }
4349
+ }
4350
+ : { connectOrCreate: {
4351
+ where: {
4352
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
4353
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
4354
+ name: item.alpacaAccount.user.name !== undefined ? {
4355
+ equals: item.alpacaAccount.user.name
4356
+ } : undefined,
4357
+ },
4358
+ create: {
4359
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
4360
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
4361
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
4362
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
4363
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
4364
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
4365
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
4366
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
4367
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
4368
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
4369
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
4370
+ },
4371
+ }
4372
+ } : undefined,
4373
+ orders: item.alpacaAccount.orders ?
4374
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4375
+ connect: item.alpacaAccount.orders.map((item) => ({
4376
+ id: item.id
4377
+ }))
4378
+ }
4379
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
4380
+ where: {
4381
+ id: item.id !== undefined ? item.id : undefined,
4382
+ },
4383
+ create: {
4384
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
4385
+ qty: item.qty !== undefined ? item.qty : undefined,
4386
+ notional: item.notional !== undefined ? item.notional : undefined,
4387
+ side: item.side !== undefined ? item.side : undefined,
4388
+ type: item.type !== undefined ? item.type : undefined,
4389
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
4390
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
4391
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
4392
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
4393
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
4394
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
4395
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
4396
+ status: item.status !== undefined ? item.status : undefined,
4397
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
4398
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
4399
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
4400
+ fee: item.fee !== undefined ? item.fee : undefined,
4401
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
4402
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
4403
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
4404
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
4405
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
4406
+ },
4407
+ }))
4408
+ } : undefined,
4409
+ positions: item.alpacaAccount.positions ?
4410
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4411
+ connect: item.alpacaAccount.positions.map((item) => ({
4412
+ id: item.id
4413
+ }))
4414
+ }
4415
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
4416
+ where: {
4417
+ id: item.id !== undefined ? item.id : undefined,
4418
+ },
4419
+ create: {
4420
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
4421
+ qty: item.qty !== undefined ? item.qty : undefined,
4422
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
4423
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
4424
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
4425
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
4426
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
4427
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
4428
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
4429
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
4430
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
4431
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
4432
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
4433
+ },
4434
+ }))
4435
+ } : undefined,
4436
+ alerts: item.alpacaAccount.alerts ?
4437
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4438
+ connect: item.alpacaAccount.alerts.map((item) => ({
4439
+ id: item.id
4440
+ }))
4441
+ }
4442
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
4443
+ where: {
4444
+ id: item.id !== undefined ? item.id : undefined,
4445
+ },
4446
+ create: {
4447
+ message: item.message !== undefined ? item.message : undefined,
4448
+ type: item.type !== undefined ? item.type : undefined,
4449
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
4450
+ },
4451
+ }))
4452
+ } : undefined,
2067
4453
  },
2068
4454
  }
2069
4455
  } : undefined,
@@ -2091,6 +4477,110 @@ export const Asset = {
2091
4477
  fee: item.fee !== undefined ? {
2092
4478
  set: item.fee
2093
4479
  } : undefined,
4480
+ order: item.order ? {
4481
+ upsert: {
4482
+ where: {
4483
+ id: item.order.id !== undefined ? {
4484
+ equals: item.order.id
4485
+ } : undefined,
4486
+ },
4487
+ update: {
4488
+ id: item.order.id !== undefined ? {
4489
+ set: item.order.id
4490
+ } : undefined,
4491
+ clientOrderId: item.order.clientOrderId !== undefined ? {
4492
+ set: item.order.clientOrderId
4493
+ } : undefined,
4494
+ qty: item.order.qty !== undefined ? {
4495
+ set: item.order.qty
4496
+ } : undefined,
4497
+ notional: item.order.notional !== undefined ? {
4498
+ set: item.order.notional
4499
+ } : undefined,
4500
+ side: item.order.side !== undefined ? {
4501
+ set: item.order.side
4502
+ } : undefined,
4503
+ type: item.order.type !== undefined ? {
4504
+ set: item.order.type
4505
+ } : undefined,
4506
+ orderClass: item.order.orderClass !== undefined ? {
4507
+ set: item.order.orderClass
4508
+ } : undefined,
4509
+ timeInForce: item.order.timeInForce !== undefined ? {
4510
+ set: item.order.timeInForce
4511
+ } : undefined,
4512
+ limitPrice: item.order.limitPrice !== undefined ? {
4513
+ set: item.order.limitPrice
4514
+ } : undefined,
4515
+ stopPrice: item.order.stopPrice !== undefined ? {
4516
+ set: item.order.stopPrice
4517
+ } : undefined,
4518
+ trailPrice: item.order.trailPrice !== undefined ? {
4519
+ set: item.order.trailPrice
4520
+ } : undefined,
4521
+ trailPercent: item.order.trailPercent !== undefined ? {
4522
+ set: item.order.trailPercent
4523
+ } : undefined,
4524
+ extendedHours: item.order.extendedHours !== undefined ? {
4525
+ set: item.order.extendedHours
4526
+ } : undefined,
4527
+ status: item.order.status !== undefined ? {
4528
+ set: item.order.status
4529
+ } : undefined,
4530
+ submittedAt: item.order.submittedAt !== undefined ? {
4531
+ set: item.order.submittedAt
4532
+ } : undefined,
4533
+ filledAt: item.order.filledAt !== undefined ? {
4534
+ set: item.order.filledAt
4535
+ } : undefined,
4536
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? {
4537
+ set: item.order.filledAvgPrice
4538
+ } : undefined,
4539
+ fee: item.order.fee !== undefined ? {
4540
+ set: item.order.fee
4541
+ } : undefined,
4542
+ strikePrice: item.order.strikePrice !== undefined ? {
4543
+ set: item.order.strikePrice
4544
+ } : undefined,
4545
+ expirationDate: item.order.expirationDate !== undefined ? {
4546
+ set: item.order.expirationDate
4547
+ } : undefined,
4548
+ optionType: item.order.optionType !== undefined ? {
4549
+ set: item.order.optionType
4550
+ } : undefined,
4551
+ stopLossId: item.order.stopLossId !== undefined ? {
4552
+ set: item.order.stopLossId
4553
+ } : undefined,
4554
+ takeProfitId: item.order.takeProfitId !== undefined ? {
4555
+ set: item.order.takeProfitId
4556
+ } : undefined,
4557
+ },
4558
+ create: {
4559
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
4560
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
4561
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
4562
+ side: item.order.side !== undefined ? item.order.side : undefined,
4563
+ type: item.order.type !== undefined ? item.order.type : undefined,
4564
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
4565
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
4566
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
4567
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
4568
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
4569
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
4570
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
4571
+ status: item.order.status !== undefined ? item.order.status : undefined,
4572
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
4573
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
4574
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
4575
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
4576
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
4577
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
4578
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
4579
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
4580
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
4581
+ },
4582
+ }
4583
+ } : undefined,
2094
4584
  },
2095
4585
  create: {
2096
4586
  sequence: item.sequence !== undefined ? item.sequence : undefined,
@@ -2098,6 +4588,42 @@ export const Asset = {
2098
4588
  note: item.note !== undefined ? item.note : undefined,
2099
4589
  status: item.status !== undefined ? item.status : undefined,
2100
4590
  fee: item.fee !== undefined ? item.fee : undefined,
4591
+ order: item.order ?
4592
+ typeof item.order === 'object' && Object.keys(item.order).length === 1 && Object.keys(item.order)[0] === 'id'
4593
+ ? { connect: {
4594
+ id: item.order.id
4595
+ }
4596
+ }
4597
+ : { connectOrCreate: {
4598
+ where: {
4599
+ id: item.order.id !== undefined ? item.order.id : undefined,
4600
+ },
4601
+ create: {
4602
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
4603
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
4604
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
4605
+ side: item.order.side !== undefined ? item.order.side : undefined,
4606
+ type: item.order.type !== undefined ? item.order.type : undefined,
4607
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
4608
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
4609
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
4610
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
4611
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
4612
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
4613
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
4614
+ status: item.order.status !== undefined ? item.order.status : undefined,
4615
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
4616
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
4617
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
4618
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
4619
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
4620
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
4621
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
4622
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
4623
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
4624
+ },
4625
+ }
4626
+ } : undefined,
2101
4627
  },
2102
4628
  }))
2103
4629
  } : undefined,
@@ -2134,6 +4660,115 @@ export const Asset = {
2134
4660
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
2135
4661
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
2136
4662
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
4663
+ user: item.alpacaAccount.user ?
4664
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
4665
+ ? { connect: {
4666
+ id: item.alpacaAccount.user.id
4667
+ }
4668
+ }
4669
+ : { connectOrCreate: {
4670
+ where: {
4671
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
4672
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
4673
+ name: item.alpacaAccount.user.name !== undefined ? {
4674
+ equals: item.alpacaAccount.user.name
4675
+ } : undefined,
4676
+ },
4677
+ create: {
4678
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
4679
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
4680
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
4681
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
4682
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
4683
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
4684
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
4685
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
4686
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
4687
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
4688
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
4689
+ },
4690
+ }
4691
+ } : undefined,
4692
+ orders: item.alpacaAccount.orders ?
4693
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4694
+ connect: item.alpacaAccount.orders.map((item) => ({
4695
+ id: item.id
4696
+ }))
4697
+ }
4698
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
4699
+ where: {
4700
+ id: item.id !== undefined ? item.id : undefined,
4701
+ },
4702
+ create: {
4703
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
4704
+ qty: item.qty !== undefined ? item.qty : undefined,
4705
+ notional: item.notional !== undefined ? item.notional : undefined,
4706
+ side: item.side !== undefined ? item.side : undefined,
4707
+ type: item.type !== undefined ? item.type : undefined,
4708
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
4709
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
4710
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
4711
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
4712
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
4713
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
4714
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
4715
+ status: item.status !== undefined ? item.status : undefined,
4716
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
4717
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
4718
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
4719
+ fee: item.fee !== undefined ? item.fee : undefined,
4720
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
4721
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
4722
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
4723
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
4724
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
4725
+ },
4726
+ }))
4727
+ } : undefined,
4728
+ positions: item.alpacaAccount.positions ?
4729
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4730
+ connect: item.alpacaAccount.positions.map((item) => ({
4731
+ id: item.id
4732
+ }))
4733
+ }
4734
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
4735
+ where: {
4736
+ id: item.id !== undefined ? item.id : undefined,
4737
+ },
4738
+ create: {
4739
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
4740
+ qty: item.qty !== undefined ? item.qty : undefined,
4741
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
4742
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
4743
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
4744
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
4745
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
4746
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
4747
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
4748
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
4749
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
4750
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
4751
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
4752
+ },
4753
+ }))
4754
+ } : undefined,
4755
+ alerts: item.alpacaAccount.alerts ?
4756
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4757
+ connect: item.alpacaAccount.alerts.map((item) => ({
4758
+ id: item.id
4759
+ }))
4760
+ }
4761
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
4762
+ where: {
4763
+ id: item.id !== undefined ? item.id : undefined,
4764
+ },
4765
+ create: {
4766
+ message: item.message !== undefined ? item.message : undefined,
4767
+ type: item.type !== undefined ? item.type : undefined,
4768
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
4769
+ },
4770
+ }))
4771
+ } : undefined,
2137
4772
  },
2138
4773
  }
2139
4774
  } : undefined,
@@ -2153,6 +4788,42 @@ export const Asset = {
2153
4788
  note: item.note !== undefined ? item.note : undefined,
2154
4789
  status: item.status !== undefined ? item.status : undefined,
2155
4790
  fee: item.fee !== undefined ? item.fee : undefined,
4791
+ order: item.order ?
4792
+ typeof item.order === 'object' && Object.keys(item.order).length === 1 && Object.keys(item.order)[0] === 'id'
4793
+ ? { connect: {
4794
+ id: item.order.id
4795
+ }
4796
+ }
4797
+ : { connectOrCreate: {
4798
+ where: {
4799
+ id: item.order.id !== undefined ? item.order.id : undefined,
4800
+ },
4801
+ create: {
4802
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
4803
+ qty: item.order.qty !== undefined ? item.order.qty : undefined,
4804
+ notional: item.order.notional !== undefined ? item.order.notional : undefined,
4805
+ side: item.order.side !== undefined ? item.order.side : undefined,
4806
+ type: item.order.type !== undefined ? item.order.type : undefined,
4807
+ orderClass: item.order.orderClass !== undefined ? item.order.orderClass : undefined,
4808
+ timeInForce: item.order.timeInForce !== undefined ? item.order.timeInForce : undefined,
4809
+ limitPrice: item.order.limitPrice !== undefined ? item.order.limitPrice : undefined,
4810
+ stopPrice: item.order.stopPrice !== undefined ? item.order.stopPrice : undefined,
4811
+ trailPrice: item.order.trailPrice !== undefined ? item.order.trailPrice : undefined,
4812
+ trailPercent: item.order.trailPercent !== undefined ? item.order.trailPercent : undefined,
4813
+ extendedHours: item.order.extendedHours !== undefined ? item.order.extendedHours : undefined,
4814
+ status: item.order.status !== undefined ? item.order.status : undefined,
4815
+ submittedAt: item.order.submittedAt !== undefined ? item.order.submittedAt : undefined,
4816
+ filledAt: item.order.filledAt !== undefined ? item.order.filledAt : undefined,
4817
+ filledAvgPrice: item.order.filledAvgPrice !== undefined ? item.order.filledAvgPrice : undefined,
4818
+ fee: item.order.fee !== undefined ? item.order.fee : undefined,
4819
+ strikePrice: item.order.strikePrice !== undefined ? item.order.strikePrice : undefined,
4820
+ expirationDate: item.order.expirationDate !== undefined ? item.order.expirationDate : undefined,
4821
+ optionType: item.order.optionType !== undefined ? item.order.optionType : undefined,
4822
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
4823
+ takeProfitId: item.order.takeProfitId !== undefined ? item.order.takeProfitId : undefined,
4824
+ },
4825
+ }
4826
+ } : undefined,
2156
4827
  },
2157
4828
  }))
2158
4829
  } : undefined,
@@ -2320,6 +4991,222 @@ export const Asset = {
2320
4991
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? {
2321
4992
  set: item.alpacaAccount.volumeThreshold
2322
4993
  } : undefined,
4994
+ user: item.alpacaAccount.user ? {
4995
+ upsert: {
4996
+ where: {
4997
+ id: item.alpacaAccount.user.id !== undefined ? {
4998
+ equals: item.alpacaAccount.user.id
4999
+ } : undefined,
5000
+ name: item.alpacaAccount.user.name !== undefined ? {
5001
+ equals: item.alpacaAccount.user.name
5002
+ } : undefined,
5003
+ email: item.alpacaAccount.user.email !== undefined ? {
5004
+ equals: item.alpacaAccount.user.email
5005
+ } : undefined,
5006
+ },
5007
+ update: {
5008
+ id: item.alpacaAccount.user.id !== undefined ? {
5009
+ set: item.alpacaAccount.user.id
5010
+ } : undefined,
5011
+ name: item.alpacaAccount.user.name !== undefined ? {
5012
+ set: item.alpacaAccount.user.name
5013
+ } : undefined,
5014
+ email: item.alpacaAccount.user.email !== undefined ? {
5015
+ set: item.alpacaAccount.user.email
5016
+ } : undefined,
5017
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? {
5018
+ set: item.alpacaAccount.user.emailVerified
5019
+ } : undefined,
5020
+ image: item.alpacaAccount.user.image !== undefined ? {
5021
+ set: item.alpacaAccount.user.image
5022
+ } : undefined,
5023
+ role: item.alpacaAccount.user.role !== undefined ? {
5024
+ set: item.alpacaAccount.user.role
5025
+ } : undefined,
5026
+ bio: item.alpacaAccount.user.bio !== undefined ? {
5027
+ set: item.alpacaAccount.user.bio
5028
+ } : undefined,
5029
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? {
5030
+ set: item.alpacaAccount.user.jobTitle
5031
+ } : undefined,
5032
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? {
5033
+ set: item.alpacaAccount.user.currentAccount
5034
+ } : undefined,
5035
+ plan: item.alpacaAccount.user.plan !== undefined ? {
5036
+ set: item.alpacaAccount.user.plan
5037
+ } : undefined,
5038
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? {
5039
+ set: item.alpacaAccount.user.openaiAPIKey
5040
+ } : undefined,
5041
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? {
5042
+ set: item.alpacaAccount.user.openaiModel
5043
+ } : undefined,
5044
+ },
5045
+ create: {
5046
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
5047
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
5048
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
5049
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
5050
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
5051
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
5052
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
5053
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
5054
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
5055
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
5056
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
5057
+ },
5058
+ }
5059
+ } : undefined,
5060
+ trades: item.alpacaAccount.trades ? {
5061
+ upsert: item.alpacaAccount.trades.map((item) => ({
5062
+ where: {
5063
+ id: item.id !== undefined ? item.id : undefined,
5064
+ },
5065
+ update: {
5066
+ id: item.id !== undefined ? {
5067
+ set: item.id
5068
+ } : undefined,
5069
+ qty: item.qty !== undefined ? {
5070
+ set: item.qty
5071
+ } : undefined,
5072
+ price: item.price !== undefined ? {
5073
+ set: item.price
5074
+ } : undefined,
5075
+ total: item.total !== undefined ? {
5076
+ set: item.total
5077
+ } : undefined,
5078
+ optionType: item.optionType !== undefined ? {
5079
+ set: item.optionType
5080
+ } : undefined,
5081
+ signal: item.signal !== undefined ? {
5082
+ set: item.signal
5083
+ } : undefined,
5084
+ strategy: item.strategy !== undefined ? {
5085
+ set: item.strategy
5086
+ } : undefined,
5087
+ analysis: item.analysis !== undefined ? {
5088
+ set: item.analysis
5089
+ } : undefined,
5090
+ summary: item.summary !== undefined ? {
5091
+ set: item.summary
5092
+ } : undefined,
5093
+ confidence: item.confidence !== undefined ? {
5094
+ set: item.confidence
5095
+ } : undefined,
5096
+ timestamp: item.timestamp !== undefined ? {
5097
+ set: item.timestamp
5098
+ } : undefined,
5099
+ status: item.status !== undefined ? {
5100
+ set: item.status
5101
+ } : undefined,
5102
+ },
5103
+ create: {
5104
+ qty: item.qty !== undefined ? item.qty : undefined,
5105
+ price: item.price !== undefined ? item.price : undefined,
5106
+ total: item.total !== undefined ? item.total : undefined,
5107
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
5108
+ signal: item.signal !== undefined ? item.signal : undefined,
5109
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
5110
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
5111
+ summary: item.summary !== undefined ? item.summary : undefined,
5112
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
5113
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
5114
+ status: item.status !== undefined ? item.status : undefined,
5115
+ },
5116
+ }))
5117
+ } : undefined,
5118
+ positions: item.alpacaAccount.positions ? {
5119
+ upsert: item.alpacaAccount.positions.map((item) => ({
5120
+ where: {
5121
+ id: item.id !== undefined ? item.id : undefined,
5122
+ },
5123
+ update: {
5124
+ id: item.id !== undefined ? {
5125
+ set: item.id
5126
+ } : undefined,
5127
+ averageEntryPrice: item.averageEntryPrice !== undefined ? {
5128
+ set: item.averageEntryPrice
5129
+ } : undefined,
5130
+ qty: item.qty !== undefined ? {
5131
+ set: item.qty
5132
+ } : undefined,
5133
+ qtyAvailable: item.qtyAvailable !== undefined ? {
5134
+ set: item.qtyAvailable
5135
+ } : undefined,
5136
+ marketValue: item.marketValue !== undefined ? {
5137
+ set: item.marketValue
5138
+ } : undefined,
5139
+ costBasis: item.costBasis !== undefined ? {
5140
+ set: item.costBasis
5141
+ } : undefined,
5142
+ unrealizedPL: item.unrealizedPL !== undefined ? {
5143
+ set: item.unrealizedPL
5144
+ } : undefined,
5145
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? {
5146
+ set: item.unrealizedPLPC
5147
+ } : undefined,
5148
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? {
5149
+ set: item.unrealisedIntradayPL
5150
+ } : undefined,
5151
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? {
5152
+ set: item.unrealisedIntradayPLPC
5153
+ } : undefined,
5154
+ currentPrice: item.currentPrice !== undefined ? {
5155
+ set: item.currentPrice
5156
+ } : undefined,
5157
+ lastTradePrice: item.lastTradePrice !== undefined ? {
5158
+ set: item.lastTradePrice
5159
+ } : undefined,
5160
+ changeToday: item.changeToday !== undefined ? {
5161
+ set: item.changeToday
5162
+ } : undefined,
5163
+ assetMarginable: item.assetMarginable !== undefined ? {
5164
+ set: item.assetMarginable
5165
+ } : undefined,
5166
+ },
5167
+ create: {
5168
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
5169
+ qty: item.qty !== undefined ? item.qty : undefined,
5170
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
5171
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
5172
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
5173
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
5174
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
5175
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
5176
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
5177
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
5178
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
5179
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
5180
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
5181
+ },
5182
+ }))
5183
+ } : undefined,
5184
+ alerts: item.alpacaAccount.alerts ? {
5185
+ upsert: item.alpacaAccount.alerts.map((item) => ({
5186
+ where: {
5187
+ id: item.id !== undefined ? item.id : undefined,
5188
+ },
5189
+ update: {
5190
+ id: item.id !== undefined ? {
5191
+ set: item.id
5192
+ } : undefined,
5193
+ message: item.message !== undefined ? {
5194
+ set: item.message
5195
+ } : undefined,
5196
+ type: item.type !== undefined ? {
5197
+ set: item.type
5198
+ } : undefined,
5199
+ isRead: item.isRead !== undefined ? {
5200
+ set: item.isRead
5201
+ } : undefined,
5202
+ },
5203
+ create: {
5204
+ message: item.message !== undefined ? item.message : undefined,
5205
+ type: item.type !== undefined ? item.type : undefined,
5206
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
5207
+ },
5208
+ }))
5209
+ } : undefined,
2323
5210
  },
2324
5211
  create: {
2325
5212
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -2331,6 +5218,104 @@ export const Asset = {
2331
5218
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
2332
5219
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
2333
5220
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
5221
+ user: item.alpacaAccount.user ?
5222
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
5223
+ ? { connect: {
5224
+ id: item.alpacaAccount.user.id
5225
+ }
5226
+ }
5227
+ : { connectOrCreate: {
5228
+ where: {
5229
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
5230
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
5231
+ name: item.alpacaAccount.user.name !== undefined ? {
5232
+ equals: item.alpacaAccount.user.name
5233
+ } : undefined,
5234
+ },
5235
+ create: {
5236
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
5237
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
5238
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
5239
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
5240
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
5241
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
5242
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
5243
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
5244
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
5245
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
5246
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
5247
+ },
5248
+ }
5249
+ } : undefined,
5250
+ trades: item.alpacaAccount.trades ?
5251
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5252
+ connect: item.alpacaAccount.trades.map((item) => ({
5253
+ id: item.id
5254
+ }))
5255
+ }
5256
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
5257
+ where: {
5258
+ id: item.id !== undefined ? item.id : undefined,
5259
+ },
5260
+ create: {
5261
+ qty: item.qty !== undefined ? item.qty : undefined,
5262
+ price: item.price !== undefined ? item.price : undefined,
5263
+ total: item.total !== undefined ? item.total : undefined,
5264
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
5265
+ signal: item.signal !== undefined ? item.signal : undefined,
5266
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
5267
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
5268
+ summary: item.summary !== undefined ? item.summary : undefined,
5269
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
5270
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
5271
+ status: item.status !== undefined ? item.status : undefined,
5272
+ },
5273
+ }))
5274
+ } : undefined,
5275
+ positions: item.alpacaAccount.positions ?
5276
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5277
+ connect: item.alpacaAccount.positions.map((item) => ({
5278
+ id: item.id
5279
+ }))
5280
+ }
5281
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
5282
+ where: {
5283
+ id: item.id !== undefined ? item.id : undefined,
5284
+ },
5285
+ create: {
5286
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
5287
+ qty: item.qty !== undefined ? item.qty : undefined,
5288
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
5289
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
5290
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
5291
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
5292
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
5293
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
5294
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
5295
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
5296
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
5297
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
5298
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
5299
+ },
5300
+ }))
5301
+ } : undefined,
5302
+ alerts: item.alpacaAccount.alerts ?
5303
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5304
+ connect: item.alpacaAccount.alerts.map((item) => ({
5305
+ id: item.id
5306
+ }))
5307
+ }
5308
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
5309
+ where: {
5310
+ id: item.id !== undefined ? item.id : undefined,
5311
+ },
5312
+ create: {
5313
+ message: item.message !== undefined ? item.message : undefined,
5314
+ type: item.type !== undefined ? item.type : undefined,
5315
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
5316
+ },
5317
+ }))
5318
+ } : undefined,
2334
5319
  },
2335
5320
  }
2336
5321
  } : undefined,
@@ -2360,6 +5345,66 @@ export const Asset = {
2360
5345
  fee: item.action.fee !== undefined ? {
2361
5346
  set: item.action.fee
2362
5347
  } : undefined,
5348
+ trade: item.action.trade ? {
5349
+ upsert: {
5350
+ where: {
5351
+ id: item.action.trade.id !== undefined ? {
5352
+ equals: item.action.trade.id
5353
+ } : undefined,
5354
+ },
5355
+ update: {
5356
+ id: item.action.trade.id !== undefined ? {
5357
+ set: item.action.trade.id
5358
+ } : undefined,
5359
+ qty: item.action.trade.qty !== undefined ? {
5360
+ set: item.action.trade.qty
5361
+ } : undefined,
5362
+ price: item.action.trade.price !== undefined ? {
5363
+ set: item.action.trade.price
5364
+ } : undefined,
5365
+ total: item.action.trade.total !== undefined ? {
5366
+ set: item.action.trade.total
5367
+ } : undefined,
5368
+ optionType: item.action.trade.optionType !== undefined ? {
5369
+ set: item.action.trade.optionType
5370
+ } : undefined,
5371
+ signal: item.action.trade.signal !== undefined ? {
5372
+ set: item.action.trade.signal
5373
+ } : undefined,
5374
+ strategy: item.action.trade.strategy !== undefined ? {
5375
+ set: item.action.trade.strategy
5376
+ } : undefined,
5377
+ analysis: item.action.trade.analysis !== undefined ? {
5378
+ set: item.action.trade.analysis
5379
+ } : undefined,
5380
+ summary: item.action.trade.summary !== undefined ? {
5381
+ set: item.action.trade.summary
5382
+ } : undefined,
5383
+ confidence: item.action.trade.confidence !== undefined ? {
5384
+ set: item.action.trade.confidence
5385
+ } : undefined,
5386
+ timestamp: item.action.trade.timestamp !== undefined ? {
5387
+ set: item.action.trade.timestamp
5388
+ } : undefined,
5389
+ status: item.action.trade.status !== undefined ? {
5390
+ set: item.action.trade.status
5391
+ } : undefined,
5392
+ },
5393
+ create: {
5394
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
5395
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
5396
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
5397
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
5398
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
5399
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
5400
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
5401
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
5402
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
5403
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
5404
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
5405
+ },
5406
+ }
5407
+ } : undefined,
2363
5408
  },
2364
5409
  create: {
2365
5410
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -2367,6 +5412,31 @@ export const Asset = {
2367
5412
  note: item.action.note !== undefined ? item.action.note : undefined,
2368
5413
  status: item.action.status !== undefined ? item.action.status : undefined,
2369
5414
  fee: item.action.fee !== undefined ? item.action.fee : undefined,
5415
+ trade: item.action.trade ?
5416
+ typeof item.action.trade === 'object' && Object.keys(item.action.trade).length === 1 && Object.keys(item.action.trade)[0] === 'id'
5417
+ ? { connect: {
5418
+ id: item.action.trade.id
5419
+ }
5420
+ }
5421
+ : { connectOrCreate: {
5422
+ where: {
5423
+ id: item.action.trade.id !== undefined ? item.action.trade.id : undefined,
5424
+ },
5425
+ create: {
5426
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
5427
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
5428
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
5429
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
5430
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
5431
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
5432
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
5433
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
5434
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
5435
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
5436
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
5437
+ },
5438
+ }
5439
+ } : undefined,
2370
5440
  },
2371
5441
  }
2372
5442
  } : undefined,
@@ -2446,6 +5516,104 @@ export const Asset = {
2446
5516
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
2447
5517
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
2448
5518
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
5519
+ user: item.alpacaAccount.user ?
5520
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
5521
+ ? { connect: {
5522
+ id: item.alpacaAccount.user.id
5523
+ }
5524
+ }
5525
+ : { connectOrCreate: {
5526
+ where: {
5527
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
5528
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
5529
+ name: item.alpacaAccount.user.name !== undefined ? {
5530
+ equals: item.alpacaAccount.user.name
5531
+ } : undefined,
5532
+ },
5533
+ create: {
5534
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
5535
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
5536
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
5537
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
5538
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
5539
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
5540
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
5541
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
5542
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
5543
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
5544
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
5545
+ },
5546
+ }
5547
+ } : undefined,
5548
+ trades: item.alpacaAccount.trades ?
5549
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5550
+ connect: item.alpacaAccount.trades.map((item) => ({
5551
+ id: item.id
5552
+ }))
5553
+ }
5554
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
5555
+ where: {
5556
+ id: item.id !== undefined ? item.id : undefined,
5557
+ },
5558
+ create: {
5559
+ qty: item.qty !== undefined ? item.qty : undefined,
5560
+ price: item.price !== undefined ? item.price : undefined,
5561
+ total: item.total !== undefined ? item.total : undefined,
5562
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
5563
+ signal: item.signal !== undefined ? item.signal : undefined,
5564
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
5565
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
5566
+ summary: item.summary !== undefined ? item.summary : undefined,
5567
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
5568
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
5569
+ status: item.status !== undefined ? item.status : undefined,
5570
+ },
5571
+ }))
5572
+ } : undefined,
5573
+ positions: item.alpacaAccount.positions ?
5574
+ Array.isArray(item.alpacaAccount.positions) && item.alpacaAccount.positions.length > 0 && item.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5575
+ connect: item.alpacaAccount.positions.map((item) => ({
5576
+ id: item.id
5577
+ }))
5578
+ }
5579
+ : { connectOrCreate: item.alpacaAccount.positions.map((item) => ({
5580
+ where: {
5581
+ id: item.id !== undefined ? item.id : undefined,
5582
+ },
5583
+ create: {
5584
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
5585
+ qty: item.qty !== undefined ? item.qty : undefined,
5586
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
5587
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
5588
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
5589
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
5590
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
5591
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
5592
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
5593
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
5594
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
5595
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
5596
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
5597
+ },
5598
+ }))
5599
+ } : undefined,
5600
+ alerts: item.alpacaAccount.alerts ?
5601
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5602
+ connect: item.alpacaAccount.alerts.map((item) => ({
5603
+ id: item.id
5604
+ }))
5605
+ }
5606
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
5607
+ where: {
5608
+ id: item.id !== undefined ? item.id : undefined,
5609
+ },
5610
+ create: {
5611
+ message: item.message !== undefined ? item.message : undefined,
5612
+ type: item.type !== undefined ? item.type : undefined,
5613
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
5614
+ },
5615
+ }))
5616
+ } : undefined,
2449
5617
  },
2450
5618
  }
2451
5619
  } : undefined,
@@ -2465,6 +5633,31 @@ export const Asset = {
2465
5633
  note: item.action.note !== undefined ? item.action.note : undefined,
2466
5634
  status: item.action.status !== undefined ? item.action.status : undefined,
2467
5635
  fee: item.action.fee !== undefined ? item.action.fee : undefined,
5636
+ trade: item.action.trade ?
5637
+ typeof item.action.trade === 'object' && Object.keys(item.action.trade).length === 1 && Object.keys(item.action.trade)[0] === 'id'
5638
+ ? { connect: {
5639
+ id: item.action.trade.id
5640
+ }
5641
+ }
5642
+ : { connectOrCreate: {
5643
+ where: {
5644
+ id: item.action.trade.id !== undefined ? item.action.trade.id : undefined,
5645
+ },
5646
+ create: {
5647
+ qty: item.action.trade.qty !== undefined ? item.action.trade.qty : undefined,
5648
+ price: item.action.trade.price !== undefined ? item.action.trade.price : undefined,
5649
+ total: item.action.trade.total !== undefined ? item.action.trade.total : undefined,
5650
+ optionType: item.action.trade.optionType !== undefined ? item.action.trade.optionType : undefined,
5651
+ signal: item.action.trade.signal !== undefined ? item.action.trade.signal : undefined,
5652
+ strategy: item.action.trade.strategy !== undefined ? item.action.trade.strategy : undefined,
5653
+ analysis: item.action.trade.analysis !== undefined ? item.action.trade.analysis : undefined,
5654
+ summary: item.action.trade.summary !== undefined ? item.action.trade.summary : undefined,
5655
+ confidence: item.action.trade.confidence !== undefined ? item.action.trade.confidence : undefined,
5656
+ timestamp: item.action.trade.timestamp !== undefined ? item.action.trade.timestamp : undefined,
5657
+ status: item.action.trade.status !== undefined ? item.action.trade.status : undefined,
5658
+ },
5659
+ }
5660
+ } : undefined,
2468
5661
  },
2469
5662
  }
2470
5663
  } : undefined,
@@ -2557,6 +5750,258 @@ export const Asset = {
2557
5750
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? {
2558
5751
  set: item.alpacaAccount.volumeThreshold
2559
5752
  } : undefined,
5753
+ user: item.alpacaAccount.user ? {
5754
+ upsert: {
5755
+ where: {
5756
+ id: item.alpacaAccount.user.id !== undefined ? {
5757
+ equals: item.alpacaAccount.user.id
5758
+ } : undefined,
5759
+ name: item.alpacaAccount.user.name !== undefined ? {
5760
+ equals: item.alpacaAccount.user.name
5761
+ } : undefined,
5762
+ email: item.alpacaAccount.user.email !== undefined ? {
5763
+ equals: item.alpacaAccount.user.email
5764
+ } : undefined,
5765
+ },
5766
+ update: {
5767
+ id: item.alpacaAccount.user.id !== undefined ? {
5768
+ set: item.alpacaAccount.user.id
5769
+ } : undefined,
5770
+ name: item.alpacaAccount.user.name !== undefined ? {
5771
+ set: item.alpacaAccount.user.name
5772
+ } : undefined,
5773
+ email: item.alpacaAccount.user.email !== undefined ? {
5774
+ set: item.alpacaAccount.user.email
5775
+ } : undefined,
5776
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? {
5777
+ set: item.alpacaAccount.user.emailVerified
5778
+ } : undefined,
5779
+ image: item.alpacaAccount.user.image !== undefined ? {
5780
+ set: item.alpacaAccount.user.image
5781
+ } : undefined,
5782
+ role: item.alpacaAccount.user.role !== undefined ? {
5783
+ set: item.alpacaAccount.user.role
5784
+ } : undefined,
5785
+ bio: item.alpacaAccount.user.bio !== undefined ? {
5786
+ set: item.alpacaAccount.user.bio
5787
+ } : undefined,
5788
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? {
5789
+ set: item.alpacaAccount.user.jobTitle
5790
+ } : undefined,
5791
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? {
5792
+ set: item.alpacaAccount.user.currentAccount
5793
+ } : undefined,
5794
+ plan: item.alpacaAccount.user.plan !== undefined ? {
5795
+ set: item.alpacaAccount.user.plan
5796
+ } : undefined,
5797
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? {
5798
+ set: item.alpacaAccount.user.openaiAPIKey
5799
+ } : undefined,
5800
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? {
5801
+ set: item.alpacaAccount.user.openaiModel
5802
+ } : undefined,
5803
+ },
5804
+ create: {
5805
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
5806
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
5807
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
5808
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
5809
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
5810
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
5811
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
5812
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
5813
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
5814
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
5815
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
5816
+ },
5817
+ }
5818
+ } : undefined,
5819
+ trades: item.alpacaAccount.trades ? {
5820
+ upsert: item.alpacaAccount.trades.map((item) => ({
5821
+ where: {
5822
+ id: item.id !== undefined ? item.id : undefined,
5823
+ },
5824
+ update: {
5825
+ id: item.id !== undefined ? {
5826
+ set: item.id
5827
+ } : undefined,
5828
+ qty: item.qty !== undefined ? {
5829
+ set: item.qty
5830
+ } : undefined,
5831
+ price: item.price !== undefined ? {
5832
+ set: item.price
5833
+ } : undefined,
5834
+ total: item.total !== undefined ? {
5835
+ set: item.total
5836
+ } : undefined,
5837
+ optionType: item.optionType !== undefined ? {
5838
+ set: item.optionType
5839
+ } : undefined,
5840
+ signal: item.signal !== undefined ? {
5841
+ set: item.signal
5842
+ } : undefined,
5843
+ strategy: item.strategy !== undefined ? {
5844
+ set: item.strategy
5845
+ } : undefined,
5846
+ analysis: item.analysis !== undefined ? {
5847
+ set: item.analysis
5848
+ } : undefined,
5849
+ summary: item.summary !== undefined ? {
5850
+ set: item.summary
5851
+ } : undefined,
5852
+ confidence: item.confidence !== undefined ? {
5853
+ set: item.confidence
5854
+ } : undefined,
5855
+ timestamp: item.timestamp !== undefined ? {
5856
+ set: item.timestamp
5857
+ } : undefined,
5858
+ status: item.status !== undefined ? {
5859
+ set: item.status
5860
+ } : undefined,
5861
+ },
5862
+ create: {
5863
+ qty: item.qty !== undefined ? item.qty : undefined,
5864
+ price: item.price !== undefined ? item.price : undefined,
5865
+ total: item.total !== undefined ? item.total : undefined,
5866
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
5867
+ signal: item.signal !== undefined ? item.signal : undefined,
5868
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
5869
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
5870
+ summary: item.summary !== undefined ? item.summary : undefined,
5871
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
5872
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
5873
+ status: item.status !== undefined ? item.status : undefined,
5874
+ },
5875
+ }))
5876
+ } : undefined,
5877
+ orders: item.alpacaAccount.orders ? {
5878
+ upsert: item.alpacaAccount.orders.map((item) => ({
5879
+ where: {
5880
+ id: item.id !== undefined ? item.id : undefined,
5881
+ },
5882
+ update: {
5883
+ id: item.id !== undefined ? {
5884
+ set: item.id
5885
+ } : undefined,
5886
+ clientOrderId: item.clientOrderId !== undefined ? {
5887
+ set: item.clientOrderId
5888
+ } : undefined,
5889
+ qty: item.qty !== undefined ? {
5890
+ set: item.qty
5891
+ } : undefined,
5892
+ notional: item.notional !== undefined ? {
5893
+ set: item.notional
5894
+ } : undefined,
5895
+ side: item.side !== undefined ? {
5896
+ set: item.side
5897
+ } : undefined,
5898
+ type: item.type !== undefined ? {
5899
+ set: item.type
5900
+ } : undefined,
5901
+ orderClass: item.orderClass !== undefined ? {
5902
+ set: item.orderClass
5903
+ } : undefined,
5904
+ timeInForce: item.timeInForce !== undefined ? {
5905
+ set: item.timeInForce
5906
+ } : undefined,
5907
+ limitPrice: item.limitPrice !== undefined ? {
5908
+ set: item.limitPrice
5909
+ } : undefined,
5910
+ stopPrice: item.stopPrice !== undefined ? {
5911
+ set: item.stopPrice
5912
+ } : undefined,
5913
+ trailPrice: item.trailPrice !== undefined ? {
5914
+ set: item.trailPrice
5915
+ } : undefined,
5916
+ trailPercent: item.trailPercent !== undefined ? {
5917
+ set: item.trailPercent
5918
+ } : undefined,
5919
+ extendedHours: item.extendedHours !== undefined ? {
5920
+ set: item.extendedHours
5921
+ } : undefined,
5922
+ status: item.status !== undefined ? {
5923
+ set: item.status
5924
+ } : undefined,
5925
+ submittedAt: item.submittedAt !== undefined ? {
5926
+ set: item.submittedAt
5927
+ } : undefined,
5928
+ filledAt: item.filledAt !== undefined ? {
5929
+ set: item.filledAt
5930
+ } : undefined,
5931
+ filledAvgPrice: item.filledAvgPrice !== undefined ? {
5932
+ set: item.filledAvgPrice
5933
+ } : undefined,
5934
+ fee: item.fee !== undefined ? {
5935
+ set: item.fee
5936
+ } : undefined,
5937
+ strikePrice: item.strikePrice !== undefined ? {
5938
+ set: item.strikePrice
5939
+ } : undefined,
5940
+ expirationDate: item.expirationDate !== undefined ? {
5941
+ set: item.expirationDate
5942
+ } : undefined,
5943
+ optionType: item.optionType !== undefined ? {
5944
+ set: item.optionType
5945
+ } : undefined,
5946
+ stopLossId: item.stopLossId !== undefined ? {
5947
+ set: item.stopLossId
5948
+ } : undefined,
5949
+ takeProfitId: item.takeProfitId !== undefined ? {
5950
+ set: item.takeProfitId
5951
+ } : undefined,
5952
+ },
5953
+ create: {
5954
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
5955
+ qty: item.qty !== undefined ? item.qty : undefined,
5956
+ notional: item.notional !== undefined ? item.notional : undefined,
5957
+ side: item.side !== undefined ? item.side : undefined,
5958
+ type: item.type !== undefined ? item.type : undefined,
5959
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
5960
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
5961
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
5962
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
5963
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
5964
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
5965
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
5966
+ status: item.status !== undefined ? item.status : undefined,
5967
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
5968
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
5969
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
5970
+ fee: item.fee !== undefined ? item.fee : undefined,
5971
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
5972
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
5973
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
5974
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
5975
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
5976
+ },
5977
+ }))
5978
+ } : undefined,
5979
+ alerts: item.alpacaAccount.alerts ? {
5980
+ upsert: item.alpacaAccount.alerts.map((item) => ({
5981
+ where: {
5982
+ id: item.id !== undefined ? item.id : undefined,
5983
+ },
5984
+ update: {
5985
+ id: item.id !== undefined ? {
5986
+ set: item.id
5987
+ } : undefined,
5988
+ message: item.message !== undefined ? {
5989
+ set: item.message
5990
+ } : undefined,
5991
+ type: item.type !== undefined ? {
5992
+ set: item.type
5993
+ } : undefined,
5994
+ isRead: item.isRead !== undefined ? {
5995
+ set: item.isRead
5996
+ } : undefined,
5997
+ },
5998
+ create: {
5999
+ message: item.message !== undefined ? item.message : undefined,
6000
+ type: item.type !== undefined ? item.type : undefined,
6001
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
6002
+ },
6003
+ }))
6004
+ } : undefined,
2560
6005
  },
2561
6006
  create: {
2562
6007
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -2568,6 +6013,113 @@ export const Asset = {
2568
6013
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
2569
6014
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
2570
6015
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
6016
+ user: item.alpacaAccount.user ?
6017
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
6018
+ ? { connect: {
6019
+ id: item.alpacaAccount.user.id
6020
+ }
6021
+ }
6022
+ : { connectOrCreate: {
6023
+ where: {
6024
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
6025
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
6026
+ name: item.alpacaAccount.user.name !== undefined ? {
6027
+ equals: item.alpacaAccount.user.name
6028
+ } : undefined,
6029
+ },
6030
+ create: {
6031
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
6032
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
6033
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
6034
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
6035
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
6036
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
6037
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
6038
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
6039
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
6040
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
6041
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
6042
+ },
6043
+ }
6044
+ } : undefined,
6045
+ trades: item.alpacaAccount.trades ?
6046
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6047
+ connect: item.alpacaAccount.trades.map((item) => ({
6048
+ id: item.id
6049
+ }))
6050
+ }
6051
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
6052
+ where: {
6053
+ id: item.id !== undefined ? item.id : undefined,
6054
+ },
6055
+ create: {
6056
+ qty: item.qty !== undefined ? item.qty : undefined,
6057
+ price: item.price !== undefined ? item.price : undefined,
6058
+ total: item.total !== undefined ? item.total : undefined,
6059
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
6060
+ signal: item.signal !== undefined ? item.signal : undefined,
6061
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
6062
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
6063
+ summary: item.summary !== undefined ? item.summary : undefined,
6064
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
6065
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
6066
+ status: item.status !== undefined ? item.status : undefined,
6067
+ },
6068
+ }))
6069
+ } : undefined,
6070
+ orders: item.alpacaAccount.orders ?
6071
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6072
+ connect: item.alpacaAccount.orders.map((item) => ({
6073
+ id: item.id
6074
+ }))
6075
+ }
6076
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
6077
+ where: {
6078
+ id: item.id !== undefined ? item.id : undefined,
6079
+ },
6080
+ create: {
6081
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
6082
+ qty: item.qty !== undefined ? item.qty : undefined,
6083
+ notional: item.notional !== undefined ? item.notional : undefined,
6084
+ side: item.side !== undefined ? item.side : undefined,
6085
+ type: item.type !== undefined ? item.type : undefined,
6086
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
6087
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
6088
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
6089
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
6090
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
6091
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
6092
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
6093
+ status: item.status !== undefined ? item.status : undefined,
6094
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
6095
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
6096
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
6097
+ fee: item.fee !== undefined ? item.fee : undefined,
6098
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
6099
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
6100
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
6101
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
6102
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
6103
+ },
6104
+ }))
6105
+ } : undefined,
6106
+ alerts: item.alpacaAccount.alerts ?
6107
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6108
+ connect: item.alpacaAccount.alerts.map((item) => ({
6109
+ id: item.id
6110
+ }))
6111
+ }
6112
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
6113
+ where: {
6114
+ id: item.id !== undefined ? item.id : undefined,
6115
+ },
6116
+ create: {
6117
+ message: item.message !== undefined ? item.message : undefined,
6118
+ type: item.type !== undefined ? item.type : undefined,
6119
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
6120
+ },
6121
+ }))
6122
+ } : undefined,
2571
6123
  },
2572
6124
  }
2573
6125
  } : undefined,
@@ -2606,6 +6158,113 @@ export const Asset = {
2606
6158
  maxOrderSize: item.alpacaAccount.maxOrderSize !== undefined ? item.alpacaAccount.maxOrderSize : undefined,
2607
6159
  minPercentageChange: item.alpacaAccount.minPercentageChange !== undefined ? item.alpacaAccount.minPercentageChange : undefined,
2608
6160
  volumeThreshold: item.alpacaAccount.volumeThreshold !== undefined ? item.alpacaAccount.volumeThreshold : undefined,
6161
+ user: item.alpacaAccount.user ?
6162
+ typeof item.alpacaAccount.user === 'object' && Object.keys(item.alpacaAccount.user).length === 1 && Object.keys(item.alpacaAccount.user)[0] === 'id'
6163
+ ? { connect: {
6164
+ id: item.alpacaAccount.user.id
6165
+ }
6166
+ }
6167
+ : { connectOrCreate: {
6168
+ where: {
6169
+ id: item.alpacaAccount.user.id !== undefined ? item.alpacaAccount.user.id : undefined,
6170
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
6171
+ name: item.alpacaAccount.user.name !== undefined ? {
6172
+ equals: item.alpacaAccount.user.name
6173
+ } : undefined,
6174
+ },
6175
+ create: {
6176
+ name: item.alpacaAccount.user.name !== undefined ? item.alpacaAccount.user.name : undefined,
6177
+ email: item.alpacaAccount.user.email !== undefined ? item.alpacaAccount.user.email : undefined,
6178
+ emailVerified: item.alpacaAccount.user.emailVerified !== undefined ? item.alpacaAccount.user.emailVerified : undefined,
6179
+ image: item.alpacaAccount.user.image !== undefined ? item.alpacaAccount.user.image : undefined,
6180
+ role: item.alpacaAccount.user.role !== undefined ? item.alpacaAccount.user.role : undefined,
6181
+ bio: item.alpacaAccount.user.bio !== undefined ? item.alpacaAccount.user.bio : undefined,
6182
+ jobTitle: item.alpacaAccount.user.jobTitle !== undefined ? item.alpacaAccount.user.jobTitle : undefined,
6183
+ currentAccount: item.alpacaAccount.user.currentAccount !== undefined ? item.alpacaAccount.user.currentAccount : undefined,
6184
+ plan: item.alpacaAccount.user.plan !== undefined ? item.alpacaAccount.user.plan : undefined,
6185
+ openaiAPIKey: item.alpacaAccount.user.openaiAPIKey !== undefined ? item.alpacaAccount.user.openaiAPIKey : undefined,
6186
+ openaiModel: item.alpacaAccount.user.openaiModel !== undefined ? item.alpacaAccount.user.openaiModel : undefined,
6187
+ },
6188
+ }
6189
+ } : undefined,
6190
+ trades: item.alpacaAccount.trades ?
6191
+ Array.isArray(item.alpacaAccount.trades) && item.alpacaAccount.trades.length > 0 && item.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6192
+ connect: item.alpacaAccount.trades.map((item) => ({
6193
+ id: item.id
6194
+ }))
6195
+ }
6196
+ : { connectOrCreate: item.alpacaAccount.trades.map((item) => ({
6197
+ where: {
6198
+ id: item.id !== undefined ? item.id : undefined,
6199
+ },
6200
+ create: {
6201
+ qty: item.qty !== undefined ? item.qty : undefined,
6202
+ price: item.price !== undefined ? item.price : undefined,
6203
+ total: item.total !== undefined ? item.total : undefined,
6204
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
6205
+ signal: item.signal !== undefined ? item.signal : undefined,
6206
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
6207
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
6208
+ summary: item.summary !== undefined ? item.summary : undefined,
6209
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
6210
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
6211
+ status: item.status !== undefined ? item.status : undefined,
6212
+ },
6213
+ }))
6214
+ } : undefined,
6215
+ orders: item.alpacaAccount.orders ?
6216
+ Array.isArray(item.alpacaAccount.orders) && item.alpacaAccount.orders.length > 0 && item.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6217
+ connect: item.alpacaAccount.orders.map((item) => ({
6218
+ id: item.id
6219
+ }))
6220
+ }
6221
+ : { connectOrCreate: item.alpacaAccount.orders.map((item) => ({
6222
+ where: {
6223
+ id: item.id !== undefined ? item.id : undefined,
6224
+ },
6225
+ create: {
6226
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
6227
+ qty: item.qty !== undefined ? item.qty : undefined,
6228
+ notional: item.notional !== undefined ? item.notional : undefined,
6229
+ side: item.side !== undefined ? item.side : undefined,
6230
+ type: item.type !== undefined ? item.type : undefined,
6231
+ orderClass: item.orderClass !== undefined ? item.orderClass : undefined,
6232
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
6233
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
6234
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
6235
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
6236
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
6237
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
6238
+ status: item.status !== undefined ? item.status : undefined,
6239
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
6240
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
6241
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
6242
+ fee: item.fee !== undefined ? item.fee : undefined,
6243
+ strikePrice: item.strikePrice !== undefined ? item.strikePrice : undefined,
6244
+ expirationDate: item.expirationDate !== undefined ? item.expirationDate : undefined,
6245
+ optionType: item.optionType !== undefined ? item.optionType : undefined,
6246
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
6247
+ takeProfitId: item.takeProfitId !== undefined ? item.takeProfitId : undefined,
6248
+ },
6249
+ }))
6250
+ } : undefined,
6251
+ alerts: item.alpacaAccount.alerts ?
6252
+ Array.isArray(item.alpacaAccount.alerts) && item.alpacaAccount.alerts.length > 0 && item.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6253
+ connect: item.alpacaAccount.alerts.map((item) => ({
6254
+ id: item.id
6255
+ }))
6256
+ }
6257
+ : { connectOrCreate: item.alpacaAccount.alerts.map((item) => ({
6258
+ where: {
6259
+ id: item.id !== undefined ? item.id : undefined,
6260
+ },
6261
+ create: {
6262
+ message: item.message !== undefined ? item.message : undefined,
6263
+ type: item.type !== undefined ? item.type : undefined,
6264
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
6265
+ },
6266
+ }))
6267
+ } : undefined,
2609
6268
  },
2610
6269
  }
2611
6270
  } : undefined,