adaptic-backend 1.0.78 → 1.0.80

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 (57) hide show
  1. package/Account.cjs +983 -54
  2. package/Action.cjs +3226 -0
  3. package/Alert.cjs +3589 -54
  4. package/AlpacaAccount.cjs +2695 -96
  5. package/Asset.cjs +3343 -42
  6. package/Authenticator.cjs +983 -54
  7. package/Customer.cjs +1003 -78
  8. package/NewsArticle.cjs +806 -6
  9. package/NewsArticleAssetSentiment.cjs +876 -54
  10. package/Order.cjs +4434 -108
  11. package/Position.cjs +3762 -108
  12. package/Session.cjs +983 -54
  13. package/Trade.cjs +4447 -114
  14. package/User.cjs +2927 -96
  15. package/package.json +1 -1
  16. package/server/Account.d.ts.map +1 -1
  17. package/server/Account.js.map +1 -1
  18. package/server/Account.mjs +983 -54
  19. package/server/Action.d.ts.map +1 -1
  20. package/server/Action.js.map +1 -1
  21. package/server/Action.mjs +3226 -0
  22. package/server/Alert.d.ts.map +1 -1
  23. package/server/Alert.js.map +1 -1
  24. package/server/Alert.mjs +3589 -54
  25. package/server/AlpacaAccount.d.ts.map +1 -1
  26. package/server/AlpacaAccount.js.map +1 -1
  27. package/server/AlpacaAccount.mjs +2695 -96
  28. package/server/Asset.d.ts.map +1 -1
  29. package/server/Asset.js.map +1 -1
  30. package/server/Asset.mjs +3343 -42
  31. package/server/Authenticator.d.ts.map +1 -1
  32. package/server/Authenticator.js.map +1 -1
  33. package/server/Authenticator.mjs +983 -54
  34. package/server/Customer.d.ts.map +1 -1
  35. package/server/Customer.js.map +1 -1
  36. package/server/Customer.mjs +1003 -78
  37. package/server/NewsArticle.d.ts.map +1 -1
  38. package/server/NewsArticle.js.map +1 -1
  39. package/server/NewsArticle.mjs +806 -6
  40. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  41. package/server/NewsArticleAssetSentiment.js.map +1 -1
  42. package/server/NewsArticleAssetSentiment.mjs +876 -54
  43. package/server/Order.d.ts.map +1 -1
  44. package/server/Order.js.map +1 -1
  45. package/server/Order.mjs +4434 -108
  46. package/server/Position.d.ts.map +1 -1
  47. package/server/Position.js.map +1 -1
  48. package/server/Position.mjs +3762 -108
  49. package/server/Session.d.ts.map +1 -1
  50. package/server/Session.js.map +1 -1
  51. package/server/Session.mjs +983 -54
  52. package/server/Trade.d.ts.map +1 -1
  53. package/server/Trade.js.map +1 -1
  54. package/server/Trade.mjs +4447 -114
  55. package/server/User.d.ts.map +1 -1
  56. package/server/User.js.map +1 -1
  57. package/server/User.mjs +2927 -96
package/Position.cjs CHANGED
@@ -314,12 +314,11 @@ exports.Position = {
314
314
  sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
315
315
  buyPrice: props.asset.buyPrice !== undefined ? props.asset.buyPrice : undefined,
316
316
  trades: props.asset.trades ?
317
- Array.isArray(props.asset.trades) && props.asset.trades.length > 0
318
- ? props.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
319
- connect: props.asset.trades.map((item) => ({
320
- id: item.id
321
- }))
322
- }
317
+ Array.isArray(props.asset.trades) && props.asset.trades.length > 0 && props.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
318
+ connect: props.asset.trades.map((item) => ({
319
+ id: item.id
320
+ }))
321
+ }
323
322
  : { connectOrCreate: props.asset.trades.map((item) => ({
324
323
  where: {
325
324
  id: item.id !== undefined ? item.id : undefined,
@@ -335,16 +334,53 @@ exports.Position = {
335
334
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
336
335
  status: item.status !== undefined ? item.status : undefined,
337
336
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
337
+ alpacaAccount: item.alpacaAccount ?
338
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
339
+ ? { connect: {
340
+ id: item.alpacaAccount.id
341
+ }
342
+ }
343
+ : { connectOrCreate: {
344
+ where: {
345
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
346
+ },
347
+ create: {
348
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
349
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
350
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
351
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
352
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
353
+ },
354
+ }
355
+ } : undefined,
356
+ actions: item.actions ?
357
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
358
+ connect: item.actions.map((item) => ({
359
+ id: item.id
360
+ }))
361
+ }
362
+ : { connectOrCreate: item.actions.map((item) => ({
363
+ where: {
364
+ id: item.id !== undefined ? item.id : undefined,
365
+ },
366
+ create: {
367
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
368
+ type: item.type !== undefined ? item.type : undefined,
369
+ note: item.note !== undefined ? item.note : undefined,
370
+ status: item.status !== undefined ? item.status : undefined,
371
+ fee: item.fee !== undefined ? item.fee : undefined,
372
+ },
373
+ }))
374
+ } : undefined,
338
375
  },
339
376
  }))
340
377
  } : undefined,
341
378
  orders: props.asset.orders ?
342
- Array.isArray(props.asset.orders) && props.asset.orders.length > 0
343
- ? props.asset.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
344
- connect: props.asset.orders.map((item) => ({
345
- id: item.id
346
- }))
347
- }
379
+ Array.isArray(props.asset.orders) && props.asset.orders.length > 0 && props.asset.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
380
+ connect: props.asset.orders.map((item) => ({
381
+ id: item.id
382
+ }))
383
+ }
348
384
  : { connectOrCreate: props.asset.orders.map((item) => ({
349
385
  where: {
350
386
  id: item.id !== undefined ? item.id : undefined,
@@ -366,16 +402,53 @@ exports.Position = {
366
402
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
367
403
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
368
404
  fee: item.fee !== undefined ? item.fee : undefined,
405
+ alpacaAccount: item.alpacaAccount ?
406
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
407
+ ? { connect: {
408
+ id: item.alpacaAccount.id
409
+ }
410
+ }
411
+ : { connectOrCreate: {
412
+ where: {
413
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
414
+ },
415
+ create: {
416
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
417
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
418
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
419
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
420
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
421
+ },
422
+ }
423
+ } : undefined,
424
+ action: item.action ?
425
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
426
+ ? { connect: {
427
+ id: item.action.id
428
+ }
429
+ }
430
+ : { connectOrCreate: {
431
+ where: {
432
+ id: item.action.id !== undefined ? item.action.id : undefined,
433
+ },
434
+ create: {
435
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
436
+ type: item.action.type !== undefined ? item.action.type : undefined,
437
+ note: item.action.note !== undefined ? item.action.note : undefined,
438
+ status: item.action.status !== undefined ? item.action.status : undefined,
439
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
440
+ },
441
+ }
442
+ } : undefined,
369
443
  },
370
444
  }))
371
445
  } : undefined,
372
446
  newsMentions: props.asset.newsMentions ?
373
- Array.isArray(props.asset.newsMentions) && props.asset.newsMentions.length > 0
374
- ? props.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
375
- connect: props.asset.newsMentions.map((item) => ({
376
- id: item.id
377
- }))
378
- }
447
+ Array.isArray(props.asset.newsMentions) && props.asset.newsMentions.length > 0 && props.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
448
+ connect: props.asset.newsMentions.map((item) => ({
449
+ id: item.id
450
+ }))
451
+ }
379
452
  : { connectOrCreate: props.asset.newsMentions.map((item) => ({
380
453
  where: {
381
454
  id: item.id !== undefined ? item.id : undefined,
@@ -386,6 +459,37 @@ exports.Position = {
386
459
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
387
460
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
388
461
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
462
+ news: item.news ?
463
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
464
+ ? { connect: {
465
+ id: item.news.id
466
+ }
467
+ }
468
+ : { connectOrCreate: {
469
+ where: {
470
+ id: item.news.id !== undefined ? item.news.id : undefined,
471
+ url: item.news.url !== undefined ? item.news.url : undefined,
472
+ title: item.news.title !== undefined ? {
473
+ equals: item.news.title
474
+ } : undefined,
475
+ },
476
+ create: {
477
+ title: item.news.title !== undefined ? item.news.title : undefined,
478
+ content: item.news.content !== undefined ? item.news.content : undefined,
479
+ source: item.news.source !== undefined ? item.news.source : undefined,
480
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
481
+ url: item.news.url !== undefined ? item.news.url : undefined,
482
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
483
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
484
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
485
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
486
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
487
+ category: item.news.category !== undefined ? item.news.category : undefined,
488
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
489
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
490
+ },
491
+ }
492
+ } : undefined,
389
493
  },
390
494
  }))
391
495
  } : undefined,
@@ -432,16 +536,96 @@ exports.Position = {
432
536
  jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
433
537
  currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
434
538
  plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
539
+ customer: props.alpacaAccount.user.customer ?
540
+ typeof props.alpacaAccount.user.customer === 'object' && Object.keys(props.alpacaAccount.user.customer).length === 1 && Object.keys(props.alpacaAccount.user.customer)[0] === 'id'
541
+ ? { connect: {
542
+ id: props.alpacaAccount.user.customer.id
543
+ }
544
+ }
545
+ : { connectOrCreate: {
546
+ where: {
547
+ id: props.alpacaAccount.user.customer.id !== undefined ? props.alpacaAccount.user.customer.id : undefined,
548
+ name: props.alpacaAccount.user.customer.name !== undefined ? {
549
+ equals: props.alpacaAccount.user.customer.name
550
+ } : undefined,
551
+ },
552
+ create: {
553
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
554
+ name: props.alpacaAccount.user.customer.name !== undefined ? props.alpacaAccount.user.customer.name : undefined,
555
+ plan: props.alpacaAccount.user.customer.plan !== undefined ? props.alpacaAccount.user.customer.plan : undefined,
556
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
557
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
558
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? props.alpacaAccount.user.customer.stripePriceId : undefined,
559
+ stripeCurrentPeriodEnd: props.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? props.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
560
+ },
561
+ }
562
+ } : undefined,
563
+ accounts: props.alpacaAccount.user.accounts ?
564
+ Array.isArray(props.alpacaAccount.user.accounts) && props.alpacaAccount.user.accounts.length > 0 && props.alpacaAccount.user.accounts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
565
+ connect: props.alpacaAccount.user.accounts.map((item) => ({
566
+ id: item.id
567
+ }))
568
+ }
569
+ : { connectOrCreate: props.alpacaAccount.user.accounts.map((item) => ({
570
+ where: {
571
+ id: item.id !== undefined ? item.id : undefined,
572
+ },
573
+ create: {
574
+ type: item.type !== undefined ? item.type : undefined,
575
+ provider: item.provider !== undefined ? item.provider : undefined,
576
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
577
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
578
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
579
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
580
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
581
+ scope: item.scope !== undefined ? item.scope : undefined,
582
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
583
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
584
+ },
585
+ }))
586
+ } : undefined,
587
+ sessions: props.alpacaAccount.user.sessions ?
588
+ Array.isArray(props.alpacaAccount.user.sessions) && props.alpacaAccount.user.sessions.length > 0 && props.alpacaAccount.user.sessions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
589
+ connect: props.alpacaAccount.user.sessions.map((item) => ({
590
+ id: item.id
591
+ }))
592
+ }
593
+ : { connectOrCreate: props.alpacaAccount.user.sessions.map((item) => ({
594
+ where: {
595
+ id: item.id !== undefined ? item.id : undefined,
596
+ },
597
+ create: {
598
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
599
+ expires: item.expires !== undefined ? item.expires : undefined,
600
+ },
601
+ }))
602
+ } : undefined,
603
+ authenticators: props.alpacaAccount.user.authenticators ?
604
+ Array.isArray(props.alpacaAccount.user.authenticators) && props.alpacaAccount.user.authenticators.length > 0 && props.alpacaAccount.user.authenticators.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
605
+ connect: props.alpacaAccount.user.authenticators.map((item) => ({
606
+ id: item.id
607
+ }))
608
+ }
609
+ : { connectOrCreate: props.alpacaAccount.user.authenticators.map((item) => ({
610
+ where: {
611
+ id: item.id !== undefined ? item.id : undefined,
612
+ },
613
+ create: {
614
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
615
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
616
+ counter: item.counter !== undefined ? item.counter : undefined,
617
+ },
618
+ }))
619
+ } : undefined,
435
620
  },
436
621
  }
437
622
  } : undefined,
438
623
  trades: props.alpacaAccount.trades ?
439
- Array.isArray(props.alpacaAccount.trades) && props.alpacaAccount.trades.length > 0
440
- ? props.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
441
- connect: props.alpacaAccount.trades.map((item) => ({
442
- id: item.id
443
- }))
444
- }
624
+ Array.isArray(props.alpacaAccount.trades) && props.alpacaAccount.trades.length > 0 && props.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
625
+ connect: props.alpacaAccount.trades.map((item) => ({
626
+ id: item.id
627
+ }))
628
+ }
445
629
  : { connectOrCreate: props.alpacaAccount.trades.map((item) => ({
446
630
  where: {
447
631
  id: item.id !== undefined ? item.id : undefined,
@@ -457,16 +641,105 @@ exports.Position = {
457
641
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
458
642
  status: item.status !== undefined ? item.status : undefined,
459
643
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
644
+ asset: item.asset ?
645
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
646
+ ? { connect: {
647
+ id: item.asset.id
648
+ }
649
+ }
650
+ : { connectOrCreate: {
651
+ where: {
652
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
653
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
654
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
655
+ },
656
+ create: {
657
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
658
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
659
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
660
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
661
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
662
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
663
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
664
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
665
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
666
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
667
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
668
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
669
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
670
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
671
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
672
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
673
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
674
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
675
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
676
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
677
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
678
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
679
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
680
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
681
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
682
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
683
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
684
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
685
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
686
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
687
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
688
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
689
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
690
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
691
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
692
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
693
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
694
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
695
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
696
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
697
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
698
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
699
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
700
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
701
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
702
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
703
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
704
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
705
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
706
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
707
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
708
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
709
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
710
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
711
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
712
+ },
713
+ }
714
+ } : undefined,
715
+ actions: item.actions ?
716
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
717
+ connect: item.actions.map((item) => ({
718
+ id: item.id
719
+ }))
720
+ }
721
+ : { connectOrCreate: item.actions.map((item) => ({
722
+ where: {
723
+ id: item.id !== undefined ? item.id : undefined,
724
+ },
725
+ create: {
726
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
727
+ type: item.type !== undefined ? item.type : undefined,
728
+ note: item.note !== undefined ? item.note : undefined,
729
+ status: item.status !== undefined ? item.status : undefined,
730
+ fee: item.fee !== undefined ? item.fee : undefined,
731
+ },
732
+ }))
733
+ } : undefined,
460
734
  },
461
735
  }))
462
736
  } : undefined,
463
737
  orders: props.alpacaAccount.orders ?
464
- Array.isArray(props.alpacaAccount.orders) && props.alpacaAccount.orders.length > 0
465
- ? props.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
466
- connect: props.alpacaAccount.orders.map((item) => ({
467
- id: item.id
468
- }))
469
- }
738
+ Array.isArray(props.alpacaAccount.orders) && props.alpacaAccount.orders.length > 0 && props.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
739
+ connect: props.alpacaAccount.orders.map((item) => ({
740
+ id: item.id
741
+ }))
742
+ }
470
743
  : { connectOrCreate: props.alpacaAccount.orders.map((item) => ({
471
744
  where: {
472
745
  id: item.id !== undefined ? item.id : undefined,
@@ -488,16 +761,105 @@ exports.Position = {
488
761
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
489
762
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
490
763
  fee: item.fee !== undefined ? item.fee : undefined,
764
+ action: item.action ?
765
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
766
+ ? { connect: {
767
+ id: item.action.id
768
+ }
769
+ }
770
+ : { connectOrCreate: {
771
+ where: {
772
+ id: item.action.id !== undefined ? item.action.id : undefined,
773
+ },
774
+ create: {
775
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
776
+ type: item.action.type !== undefined ? item.action.type : undefined,
777
+ note: item.action.note !== undefined ? item.action.note : undefined,
778
+ status: item.action.status !== undefined ? item.action.status : undefined,
779
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
780
+ },
781
+ }
782
+ } : undefined,
783
+ asset: item.asset ?
784
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
785
+ ? { connect: {
786
+ id: item.asset.id
787
+ }
788
+ }
789
+ : { connectOrCreate: {
790
+ where: {
791
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
792
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
793
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
794
+ },
795
+ create: {
796
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
797
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
798
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
799
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
800
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
801
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
802
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
803
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
804
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
805
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
806
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
807
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
808
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
809
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
810
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
811
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
812
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
813
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
814
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
815
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
816
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
817
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
818
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
819
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
820
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
821
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
822
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
823
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
824
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
825
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
826
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
827
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
828
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
829
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
830
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
831
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
832
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
833
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
834
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
835
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
836
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
837
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
838
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
839
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
840
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
841
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
842
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
843
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
844
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
845
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
846
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
847
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
848
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
849
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
850
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
851
+ },
852
+ }
853
+ } : undefined,
491
854
  },
492
855
  }))
493
856
  } : undefined,
494
857
  alerts: props.alpacaAccount.alerts ?
495
- Array.isArray(props.alpacaAccount.alerts) && props.alpacaAccount.alerts.length > 0
496
- ? props.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
497
- connect: props.alpacaAccount.alerts.map((item) => ({
498
- id: item.id
499
- }))
500
- }
858
+ Array.isArray(props.alpacaAccount.alerts) && props.alpacaAccount.alerts.length > 0 && props.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
859
+ connect: props.alpacaAccount.alerts.map((item) => ({
860
+ id: item.id
861
+ }))
862
+ }
501
863
  : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
502
864
  where: {
503
865
  id: item.id !== undefined ? item.id : undefined,
@@ -1069,6 +1431,76 @@ exports.Position = {
1069
1431
  optionContractType: item.optionContractType !== undefined ? {
1070
1432
  set: item.optionContractType
1071
1433
  } : undefined,
1434
+ alpacaAccount: item.alpacaAccount ? {
1435
+ upsert: {
1436
+ where: {
1437
+ id: item.alpacaAccount.id !== undefined ? {
1438
+ equals: item.alpacaAccount.id
1439
+ } : undefined,
1440
+ },
1441
+ update: {
1442
+ id: item.alpacaAccount.id !== undefined ? {
1443
+ set: item.alpacaAccount.id
1444
+ } : undefined,
1445
+ type: item.alpacaAccount.type !== undefined ? {
1446
+ set: item.alpacaAccount.type
1447
+ } : undefined,
1448
+ APIKey: item.alpacaAccount.APIKey !== undefined ? {
1449
+ set: item.alpacaAccount.APIKey
1450
+ } : undefined,
1451
+ APISecret: item.alpacaAccount.APISecret !== undefined ? {
1452
+ set: item.alpacaAccount.APISecret
1453
+ } : undefined,
1454
+ configuration: item.alpacaAccount.configuration !== undefined ? {
1455
+ set: item.alpacaAccount.configuration
1456
+ } : undefined,
1457
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? {
1458
+ set: item.alpacaAccount.marketOpen
1459
+ } : undefined,
1460
+ },
1461
+ create: {
1462
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1463
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1464
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1465
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1466
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1467
+ },
1468
+ }
1469
+ } : undefined,
1470
+ actions: item.actions ? {
1471
+ upsert: item.actions.map((item) => ({
1472
+ where: {
1473
+ id: item.id !== undefined ? item.id : undefined,
1474
+ },
1475
+ update: {
1476
+ id: item.id !== undefined ? {
1477
+ set: item.id
1478
+ } : undefined,
1479
+ sequence: item.sequence !== undefined ? {
1480
+ set: item.sequence
1481
+ } : undefined,
1482
+ type: item.type !== undefined ? {
1483
+ set: item.type
1484
+ } : undefined,
1485
+ note: item.note !== undefined ? {
1486
+ set: item.note
1487
+ } : undefined,
1488
+ status: item.status !== undefined ? {
1489
+ set: item.status
1490
+ } : undefined,
1491
+ fee: item.fee !== undefined ? {
1492
+ set: item.fee
1493
+ } : undefined,
1494
+ },
1495
+ create: {
1496
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
1497
+ type: item.type !== undefined ? item.type : undefined,
1498
+ note: item.note !== undefined ? item.note : undefined,
1499
+ status: item.status !== undefined ? item.status : undefined,
1500
+ fee: item.fee !== undefined ? item.fee : undefined,
1501
+ },
1502
+ }))
1503
+ } : undefined,
1072
1504
  },
1073
1505
  create: {
1074
1506
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -1081,6 +1513,44 @@ exports.Position = {
1081
1513
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1082
1514
  status: item.status !== undefined ? item.status : undefined,
1083
1515
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1516
+ alpacaAccount: item.alpacaAccount ?
1517
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1518
+ ? { connect: {
1519
+ id: item.alpacaAccount.id
1520
+ }
1521
+ }
1522
+ : { connectOrCreate: {
1523
+ where: {
1524
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1525
+ },
1526
+ create: {
1527
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1528
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1529
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1530
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1531
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1532
+ },
1533
+ }
1534
+ } : undefined,
1535
+ actions: item.actions ?
1536
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
1537
+ connect: item.actions.map((item) => ({
1538
+ id: item.id
1539
+ }))
1540
+ }
1541
+ : { connectOrCreate: item.actions.map((item) => ({
1542
+ where: {
1543
+ id: item.id !== undefined ? item.id : undefined,
1544
+ },
1545
+ create: {
1546
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
1547
+ type: item.type !== undefined ? item.type : undefined,
1548
+ note: item.note !== undefined ? item.note : undefined,
1549
+ status: item.status !== undefined ? item.status : undefined,
1550
+ fee: item.fee !== undefined ? item.fee : undefined,
1551
+ },
1552
+ }))
1553
+ } : undefined,
1084
1554
  },
1085
1555
  }))
1086
1556
  } : undefined,
@@ -1141,6 +1611,78 @@ exports.Position = {
1141
1611
  fee: item.fee !== undefined ? {
1142
1612
  set: item.fee
1143
1613
  } : undefined,
1614
+ alpacaAccount: item.alpacaAccount ? {
1615
+ upsert: {
1616
+ where: {
1617
+ id: item.alpacaAccount.id !== undefined ? {
1618
+ equals: item.alpacaAccount.id
1619
+ } : undefined,
1620
+ },
1621
+ update: {
1622
+ id: item.alpacaAccount.id !== undefined ? {
1623
+ set: item.alpacaAccount.id
1624
+ } : undefined,
1625
+ type: item.alpacaAccount.type !== undefined ? {
1626
+ set: item.alpacaAccount.type
1627
+ } : undefined,
1628
+ APIKey: item.alpacaAccount.APIKey !== undefined ? {
1629
+ set: item.alpacaAccount.APIKey
1630
+ } : undefined,
1631
+ APISecret: item.alpacaAccount.APISecret !== undefined ? {
1632
+ set: item.alpacaAccount.APISecret
1633
+ } : undefined,
1634
+ configuration: item.alpacaAccount.configuration !== undefined ? {
1635
+ set: item.alpacaAccount.configuration
1636
+ } : undefined,
1637
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? {
1638
+ set: item.alpacaAccount.marketOpen
1639
+ } : undefined,
1640
+ },
1641
+ create: {
1642
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1643
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1644
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1645
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1646
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1647
+ },
1648
+ }
1649
+ } : undefined,
1650
+ action: item.action ? {
1651
+ upsert: {
1652
+ where: {
1653
+ id: item.action.id !== undefined ? {
1654
+ equals: item.action.id
1655
+ } : undefined,
1656
+ },
1657
+ update: {
1658
+ id: item.action.id !== undefined ? {
1659
+ set: item.action.id
1660
+ } : undefined,
1661
+ sequence: item.action.sequence !== undefined ? {
1662
+ set: item.action.sequence
1663
+ } : undefined,
1664
+ type: item.action.type !== undefined ? {
1665
+ set: item.action.type
1666
+ } : undefined,
1667
+ note: item.action.note !== undefined ? {
1668
+ set: item.action.note
1669
+ } : undefined,
1670
+ status: item.action.status !== undefined ? {
1671
+ set: item.action.status
1672
+ } : undefined,
1673
+ fee: item.action.fee !== undefined ? {
1674
+ set: item.action.fee
1675
+ } : undefined,
1676
+ },
1677
+ create: {
1678
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
1679
+ type: item.action.type !== undefined ? item.action.type : undefined,
1680
+ note: item.action.note !== undefined ? item.action.note : undefined,
1681
+ status: item.action.status !== undefined ? item.action.status : undefined,
1682
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
1683
+ },
1684
+ }
1685
+ } : undefined,
1144
1686
  },
1145
1687
  create: {
1146
1688
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -1159,6 +1701,44 @@ exports.Position = {
1159
1701
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1160
1702
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1161
1703
  fee: item.fee !== undefined ? item.fee : undefined,
1704
+ alpacaAccount: item.alpacaAccount ?
1705
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1706
+ ? { connect: {
1707
+ id: item.alpacaAccount.id
1708
+ }
1709
+ }
1710
+ : { connectOrCreate: {
1711
+ where: {
1712
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1713
+ },
1714
+ create: {
1715
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1716
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1717
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1718
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1719
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1720
+ },
1721
+ }
1722
+ } : undefined,
1723
+ action: item.action ?
1724
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
1725
+ ? { connect: {
1726
+ id: item.action.id
1727
+ }
1728
+ }
1729
+ : { connectOrCreate: {
1730
+ where: {
1731
+ id: item.action.id !== undefined ? item.action.id : undefined,
1732
+ },
1733
+ create: {
1734
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
1735
+ type: item.action.type !== undefined ? item.action.type : undefined,
1736
+ note: item.action.note !== undefined ? item.action.note : undefined,
1737
+ status: item.action.status !== undefined ? item.action.status : undefined,
1738
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
1739
+ },
1740
+ }
1741
+ } : undefined,
1162
1742
  },
1163
1743
  }))
1164
1744
  } : undefined,
@@ -1184,12 +1764,117 @@ exports.Position = {
1184
1764
  sentimentLabel: item.sentimentLabel !== undefined ? {
1185
1765
  set: item.sentimentLabel
1186
1766
  } : undefined,
1767
+ news: item.news ? {
1768
+ upsert: {
1769
+ where: {
1770
+ id: item.news.id !== undefined ? {
1771
+ equals: item.news.id
1772
+ } : undefined,
1773
+ title: item.news.title !== undefined ? {
1774
+ equals: item.news.title
1775
+ } : undefined,
1776
+ url: item.news.url !== undefined ? {
1777
+ equals: item.news.url
1778
+ } : undefined,
1779
+ },
1780
+ update: {
1781
+ id: item.news.id !== undefined ? {
1782
+ set: item.news.id
1783
+ } : undefined,
1784
+ title: item.news.title !== undefined ? {
1785
+ set: item.news.title
1786
+ } : undefined,
1787
+ content: item.news.content !== undefined ? {
1788
+ set: item.news.content
1789
+ } : undefined,
1790
+ source: item.news.source !== undefined ? {
1791
+ set: item.news.source
1792
+ } : undefined,
1793
+ sourceDomain: item.news.sourceDomain !== undefined ? {
1794
+ set: item.news.sourceDomain
1795
+ } : undefined,
1796
+ url: item.news.url !== undefined ? {
1797
+ set: item.news.url
1798
+ } : undefined,
1799
+ sentiment: item.news.sentiment !== undefined ? {
1800
+ set: item.news.sentiment
1801
+ } : undefined,
1802
+ authors: item.news.authors !== undefined ? {
1803
+ set: item.news.authors
1804
+ } : undefined,
1805
+ summary: item.news.summary !== undefined ? {
1806
+ set: item.news.summary
1807
+ } : undefined,
1808
+ bannerImage: item.news.bannerImage !== undefined ? {
1809
+ set: item.news.bannerImage
1810
+ } : undefined,
1811
+ timePublished: item.news.timePublished !== undefined ? {
1812
+ set: item.news.timePublished
1813
+ } : undefined,
1814
+ category: item.news.category !== undefined ? {
1815
+ set: item.news.category
1816
+ } : undefined,
1817
+ topics: item.news.topics !== undefined ? {
1818
+ set: item.news.topics
1819
+ } : undefined,
1820
+ logo: item.news.logo !== undefined ? {
1821
+ set: item.news.logo
1822
+ } : undefined,
1823
+ },
1824
+ create: {
1825
+ title: item.news.title !== undefined ? item.news.title : undefined,
1826
+ content: item.news.content !== undefined ? item.news.content : undefined,
1827
+ source: item.news.source !== undefined ? item.news.source : undefined,
1828
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
1829
+ url: item.news.url !== undefined ? item.news.url : undefined,
1830
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
1831
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
1832
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
1833
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
1834
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
1835
+ category: item.news.category !== undefined ? item.news.category : undefined,
1836
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
1837
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
1838
+ },
1839
+ }
1840
+ } : undefined,
1187
1841
  },
1188
1842
  create: {
1189
1843
  url: item.url !== undefined ? item.url : undefined,
1190
1844
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1191
1845
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1192
1846
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1847
+ news: item.news ?
1848
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
1849
+ ? { connect: {
1850
+ id: item.news.id
1851
+ }
1852
+ }
1853
+ : { connectOrCreate: {
1854
+ where: {
1855
+ id: item.news.id !== undefined ? item.news.id : undefined,
1856
+ url: item.news.url !== undefined ? item.news.url : undefined,
1857
+ title: item.news.title !== undefined ? {
1858
+ equals: item.news.title
1859
+ } : undefined,
1860
+ },
1861
+ create: {
1862
+ title: item.news.title !== undefined ? item.news.title : undefined,
1863
+ content: item.news.content !== undefined ? item.news.content : undefined,
1864
+ source: item.news.source !== undefined ? item.news.source : undefined,
1865
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
1866
+ url: item.news.url !== undefined ? item.news.url : undefined,
1867
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
1868
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
1869
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
1870
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
1871
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
1872
+ category: item.news.category !== undefined ? item.news.category : undefined,
1873
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
1874
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
1875
+ },
1876
+ }
1877
+ } : undefined,
1193
1878
  },
1194
1879
  }))
1195
1880
  } : undefined,
@@ -1251,12 +1936,11 @@ exports.Position = {
1251
1936
  sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
1252
1937
  buyPrice: props.asset.buyPrice !== undefined ? props.asset.buyPrice : undefined,
1253
1938
  trades: props.asset.trades ?
1254
- Array.isArray(props.asset.trades) && props.asset.trades.length > 0
1255
- ? props.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1256
- connect: props.asset.trades.map((item) => ({
1257
- id: item.id
1258
- }))
1259
- }
1939
+ Array.isArray(props.asset.trades) && props.asset.trades.length > 0 && props.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
1940
+ connect: props.asset.trades.map((item) => ({
1941
+ id: item.id
1942
+ }))
1943
+ }
1260
1944
  : { connectOrCreate: props.asset.trades.map((item) => ({
1261
1945
  where: {
1262
1946
  id: item.id !== undefined ? item.id : undefined,
@@ -1272,16 +1956,53 @@ exports.Position = {
1272
1956
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1273
1957
  status: item.status !== undefined ? item.status : undefined,
1274
1958
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1959
+ alpacaAccount: item.alpacaAccount ?
1960
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1961
+ ? { connect: {
1962
+ id: item.alpacaAccount.id
1963
+ }
1964
+ }
1965
+ : { connectOrCreate: {
1966
+ where: {
1967
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1968
+ },
1969
+ create: {
1970
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1971
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1972
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1973
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1974
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1975
+ },
1976
+ }
1977
+ } : undefined,
1978
+ actions: item.actions ?
1979
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
1980
+ connect: item.actions.map((item) => ({
1981
+ id: item.id
1982
+ }))
1983
+ }
1984
+ : { connectOrCreate: item.actions.map((item) => ({
1985
+ where: {
1986
+ id: item.id !== undefined ? item.id : undefined,
1987
+ },
1988
+ create: {
1989
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
1990
+ type: item.type !== undefined ? item.type : undefined,
1991
+ note: item.note !== undefined ? item.note : undefined,
1992
+ status: item.status !== undefined ? item.status : undefined,
1993
+ fee: item.fee !== undefined ? item.fee : undefined,
1994
+ },
1995
+ }))
1996
+ } : undefined,
1275
1997
  },
1276
1998
  }))
1277
1999
  } : undefined,
1278
2000
  orders: props.asset.orders ?
1279
- Array.isArray(props.asset.orders) && props.asset.orders.length > 0
1280
- ? props.asset.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1281
- connect: props.asset.orders.map((item) => ({
1282
- id: item.id
1283
- }))
1284
- }
2001
+ Array.isArray(props.asset.orders) && props.asset.orders.length > 0 && props.asset.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2002
+ connect: props.asset.orders.map((item) => ({
2003
+ id: item.id
2004
+ }))
2005
+ }
1285
2006
  : { connectOrCreate: props.asset.orders.map((item) => ({
1286
2007
  where: {
1287
2008
  id: item.id !== undefined ? item.id : undefined,
@@ -1303,16 +2024,53 @@ exports.Position = {
1303
2024
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1304
2025
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1305
2026
  fee: item.fee !== undefined ? item.fee : undefined,
2027
+ alpacaAccount: item.alpacaAccount ?
2028
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2029
+ ? { connect: {
2030
+ id: item.alpacaAccount.id
2031
+ }
2032
+ }
2033
+ : { connectOrCreate: {
2034
+ where: {
2035
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2036
+ },
2037
+ create: {
2038
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2039
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2040
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2041
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2042
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2043
+ },
2044
+ }
2045
+ } : undefined,
2046
+ action: item.action ?
2047
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
2048
+ ? { connect: {
2049
+ id: item.action.id
2050
+ }
2051
+ }
2052
+ : { connectOrCreate: {
2053
+ where: {
2054
+ id: item.action.id !== undefined ? item.action.id : undefined,
2055
+ },
2056
+ create: {
2057
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
2058
+ type: item.action.type !== undefined ? item.action.type : undefined,
2059
+ note: item.action.note !== undefined ? item.action.note : undefined,
2060
+ status: item.action.status !== undefined ? item.action.status : undefined,
2061
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
2062
+ },
2063
+ }
2064
+ } : undefined,
1306
2065
  },
1307
2066
  }))
1308
2067
  } : undefined,
1309
2068
  newsMentions: props.asset.newsMentions ?
1310
- Array.isArray(props.asset.newsMentions) && props.asset.newsMentions.length > 0
1311
- ? props.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1312
- connect: props.asset.newsMentions.map((item) => ({
1313
- id: item.id
1314
- }))
1315
- }
2069
+ Array.isArray(props.asset.newsMentions) && props.asset.newsMentions.length > 0 && props.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2070
+ connect: props.asset.newsMentions.map((item) => ({
2071
+ id: item.id
2072
+ }))
2073
+ }
1316
2074
  : { connectOrCreate: props.asset.newsMentions.map((item) => ({
1317
2075
  where: {
1318
2076
  id: item.id !== undefined ? item.id : undefined,
@@ -1323,6 +2081,37 @@ exports.Position = {
1323
2081
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1324
2082
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1325
2083
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
2084
+ news: item.news ?
2085
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
2086
+ ? { connect: {
2087
+ id: item.news.id
2088
+ }
2089
+ }
2090
+ : { connectOrCreate: {
2091
+ where: {
2092
+ id: item.news.id !== undefined ? item.news.id : undefined,
2093
+ url: item.news.url !== undefined ? item.news.url : undefined,
2094
+ title: item.news.title !== undefined ? {
2095
+ equals: item.news.title
2096
+ } : undefined,
2097
+ },
2098
+ create: {
2099
+ title: item.news.title !== undefined ? item.news.title : undefined,
2100
+ content: item.news.content !== undefined ? item.news.content : undefined,
2101
+ source: item.news.source !== undefined ? item.news.source : undefined,
2102
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
2103
+ url: item.news.url !== undefined ? item.news.url : undefined,
2104
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
2105
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
2106
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
2107
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
2108
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
2109
+ category: item.news.category !== undefined ? item.news.category : undefined,
2110
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
2111
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
2112
+ },
2113
+ }
2114
+ } : undefined,
1326
2115
  },
1327
2116
  }))
1328
2117
  } : undefined,
@@ -1399,6 +2188,152 @@ exports.Position = {
1399
2188
  plan: props.alpacaAccount.user.plan !== undefined ? {
1400
2189
  set: props.alpacaAccount.user.plan
1401
2190
  } : undefined,
2191
+ customer: props.alpacaAccount.user.customer ? {
2192
+ upsert: {
2193
+ where: {
2194
+ id: props.alpacaAccount.user.customer.id !== undefined ? {
2195
+ equals: props.alpacaAccount.user.customer.id
2196
+ } : undefined,
2197
+ name: props.alpacaAccount.user.customer.name !== undefined ? {
2198
+ equals: props.alpacaAccount.user.customer.name
2199
+ } : undefined,
2200
+ },
2201
+ update: {
2202
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? {
2203
+ set: props.alpacaAccount.user.customer.authUserId
2204
+ } : undefined,
2205
+ name: props.alpacaAccount.user.customer.name !== undefined ? {
2206
+ set: props.alpacaAccount.user.customer.name
2207
+ } : undefined,
2208
+ plan: props.alpacaAccount.user.customer.plan !== undefined ? {
2209
+ set: props.alpacaAccount.user.customer.plan
2210
+ } : undefined,
2211
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? {
2212
+ set: props.alpacaAccount.user.customer.stripeCustomerId
2213
+ } : undefined,
2214
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? {
2215
+ set: props.alpacaAccount.user.customer.stripeSubscriptionId
2216
+ } : undefined,
2217
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? {
2218
+ set: props.alpacaAccount.user.customer.stripePriceId
2219
+ } : undefined,
2220
+ stripeCurrentPeriodEnd: props.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? {
2221
+ set: props.alpacaAccount.user.customer.stripeCurrentPeriodEnd
2222
+ } : undefined,
2223
+ },
2224
+ create: {
2225
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
2226
+ name: props.alpacaAccount.user.customer.name !== undefined ? props.alpacaAccount.user.customer.name : undefined,
2227
+ plan: props.alpacaAccount.user.customer.plan !== undefined ? props.alpacaAccount.user.customer.plan : undefined,
2228
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
2229
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
2230
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? props.alpacaAccount.user.customer.stripePriceId : undefined,
2231
+ stripeCurrentPeriodEnd: props.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? props.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
2232
+ },
2233
+ }
2234
+ } : undefined,
2235
+ accounts: props.alpacaAccount.user.accounts ? {
2236
+ upsert: props.alpacaAccount.user.accounts.map((item) => ({
2237
+ where: {
2238
+ id: item.id !== undefined ? item.id : undefined,
2239
+ },
2240
+ update: {
2241
+ id: item.id !== undefined ? {
2242
+ set: item.id
2243
+ } : undefined,
2244
+ type: item.type !== undefined ? {
2245
+ set: item.type
2246
+ } : undefined,
2247
+ provider: item.provider !== undefined ? {
2248
+ set: item.provider
2249
+ } : undefined,
2250
+ providerAccountId: item.providerAccountId !== undefined ? {
2251
+ set: item.providerAccountId
2252
+ } : undefined,
2253
+ refresh_token: item.refresh_token !== undefined ? {
2254
+ set: item.refresh_token
2255
+ } : undefined,
2256
+ access_token: item.access_token !== undefined ? {
2257
+ set: item.access_token
2258
+ } : undefined,
2259
+ expires_at: item.expires_at !== undefined ? {
2260
+ set: item.expires_at
2261
+ } : undefined,
2262
+ token_type: item.token_type !== undefined ? {
2263
+ set: item.token_type
2264
+ } : undefined,
2265
+ scope: item.scope !== undefined ? {
2266
+ set: item.scope
2267
+ } : undefined,
2268
+ id_token: item.id_token !== undefined ? {
2269
+ set: item.id_token
2270
+ } : undefined,
2271
+ session_state: item.session_state !== undefined ? {
2272
+ set: item.session_state
2273
+ } : undefined,
2274
+ },
2275
+ create: {
2276
+ type: item.type !== undefined ? item.type : undefined,
2277
+ provider: item.provider !== undefined ? item.provider : undefined,
2278
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
2279
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
2280
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
2281
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
2282
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
2283
+ scope: item.scope !== undefined ? item.scope : undefined,
2284
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
2285
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
2286
+ },
2287
+ }))
2288
+ } : undefined,
2289
+ sessions: props.alpacaAccount.user.sessions ? {
2290
+ upsert: props.alpacaAccount.user.sessions.map((item) => ({
2291
+ where: {
2292
+ id: item.id !== undefined ? item.id : undefined,
2293
+ },
2294
+ update: {
2295
+ id: item.id !== undefined ? {
2296
+ set: item.id
2297
+ } : undefined,
2298
+ sessionToken: item.sessionToken !== undefined ? {
2299
+ set: item.sessionToken
2300
+ } : undefined,
2301
+ expires: item.expires !== undefined ? {
2302
+ set: item.expires
2303
+ } : undefined,
2304
+ },
2305
+ create: {
2306
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
2307
+ expires: item.expires !== undefined ? item.expires : undefined,
2308
+ },
2309
+ }))
2310
+ } : undefined,
2311
+ authenticators: props.alpacaAccount.user.authenticators ? {
2312
+ upsert: props.alpacaAccount.user.authenticators.map((item) => ({
2313
+ where: {
2314
+ id: item.id !== undefined ? item.id : undefined,
2315
+ },
2316
+ update: {
2317
+ id: item.id !== undefined ? {
2318
+ set: item.id
2319
+ } : undefined,
2320
+ credentialID: item.credentialID !== undefined ? {
2321
+ set: item.credentialID
2322
+ } : undefined,
2323
+ publicKey: item.publicKey !== undefined ? {
2324
+ set: item.publicKey
2325
+ } : undefined,
2326
+ counter: item.counter !== undefined ? {
2327
+ set: item.counter
2328
+ } : undefined,
2329
+ },
2330
+ create: {
2331
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
2332
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
2333
+ counter: item.counter !== undefined ? item.counter : undefined,
2334
+ },
2335
+ }))
2336
+ } : undefined,
1402
2337
  },
1403
2338
  create: {
1404
2339
  name: props.alpacaAccount.user.name !== undefined ? props.alpacaAccount.user.name : undefined,
@@ -1410,6 +2345,87 @@ exports.Position = {
1410
2345
  jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
1411
2346
  currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
1412
2347
  plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
2348
+ customer: props.alpacaAccount.user.customer ?
2349
+ typeof props.alpacaAccount.user.customer === 'object' && Object.keys(props.alpacaAccount.user.customer).length === 1 && Object.keys(props.alpacaAccount.user.customer)[0] === 'id'
2350
+ ? { connect: {
2351
+ id: props.alpacaAccount.user.customer.id
2352
+ }
2353
+ }
2354
+ : { connectOrCreate: {
2355
+ where: {
2356
+ id: props.alpacaAccount.user.customer.id !== undefined ? props.alpacaAccount.user.customer.id : undefined,
2357
+ name: props.alpacaAccount.user.customer.name !== undefined ? {
2358
+ equals: props.alpacaAccount.user.customer.name
2359
+ } : undefined,
2360
+ },
2361
+ create: {
2362
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
2363
+ name: props.alpacaAccount.user.customer.name !== undefined ? props.alpacaAccount.user.customer.name : undefined,
2364
+ plan: props.alpacaAccount.user.customer.plan !== undefined ? props.alpacaAccount.user.customer.plan : undefined,
2365
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
2366
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
2367
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? props.alpacaAccount.user.customer.stripePriceId : undefined,
2368
+ stripeCurrentPeriodEnd: props.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? props.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
2369
+ },
2370
+ }
2371
+ } : undefined,
2372
+ accounts: props.alpacaAccount.user.accounts ?
2373
+ Array.isArray(props.alpacaAccount.user.accounts) && props.alpacaAccount.user.accounts.length > 0 && props.alpacaAccount.user.accounts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2374
+ connect: props.alpacaAccount.user.accounts.map((item) => ({
2375
+ id: item.id
2376
+ }))
2377
+ }
2378
+ : { connectOrCreate: props.alpacaAccount.user.accounts.map((item) => ({
2379
+ where: {
2380
+ id: item.id !== undefined ? item.id : undefined,
2381
+ },
2382
+ create: {
2383
+ type: item.type !== undefined ? item.type : undefined,
2384
+ provider: item.provider !== undefined ? item.provider : undefined,
2385
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
2386
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
2387
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
2388
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
2389
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
2390
+ scope: item.scope !== undefined ? item.scope : undefined,
2391
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
2392
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
2393
+ },
2394
+ }))
2395
+ } : undefined,
2396
+ sessions: props.alpacaAccount.user.sessions ?
2397
+ Array.isArray(props.alpacaAccount.user.sessions) && props.alpacaAccount.user.sessions.length > 0 && props.alpacaAccount.user.sessions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2398
+ connect: props.alpacaAccount.user.sessions.map((item) => ({
2399
+ id: item.id
2400
+ }))
2401
+ }
2402
+ : { connectOrCreate: props.alpacaAccount.user.sessions.map((item) => ({
2403
+ where: {
2404
+ id: item.id !== undefined ? item.id : undefined,
2405
+ },
2406
+ create: {
2407
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
2408
+ expires: item.expires !== undefined ? item.expires : undefined,
2409
+ },
2410
+ }))
2411
+ } : undefined,
2412
+ authenticators: props.alpacaAccount.user.authenticators ?
2413
+ Array.isArray(props.alpacaAccount.user.authenticators) && props.alpacaAccount.user.authenticators.length > 0 && props.alpacaAccount.user.authenticators.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2414
+ connect: props.alpacaAccount.user.authenticators.map((item) => ({
2415
+ id: item.id
2416
+ }))
2417
+ }
2418
+ : { connectOrCreate: props.alpacaAccount.user.authenticators.map((item) => ({
2419
+ where: {
2420
+ id: item.id !== undefined ? item.id : undefined,
2421
+ },
2422
+ create: {
2423
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
2424
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
2425
+ counter: item.counter !== undefined ? item.counter : undefined,
2426
+ },
2427
+ }))
2428
+ } : undefined,
1413
2429
  },
1414
2430
  }
1415
2431
  } : undefined,
@@ -1452,6 +2468,282 @@ exports.Position = {
1452
2468
  optionContractType: item.optionContractType !== undefined ? {
1453
2469
  set: item.optionContractType
1454
2470
  } : undefined,
2471
+ asset: item.asset ? {
2472
+ upsert: {
2473
+ where: {
2474
+ id: item.asset.id !== undefined ? {
2475
+ equals: item.asset.id
2476
+ } : undefined,
2477
+ symbol: item.asset.symbol !== undefined ? {
2478
+ equals: item.asset.symbol
2479
+ } : undefined,
2480
+ name: item.asset.name !== undefined ? {
2481
+ equals: item.asset.name
2482
+ } : undefined,
2483
+ },
2484
+ update: {
2485
+ id: item.asset.id !== undefined ? {
2486
+ set: item.asset.id
2487
+ } : undefined,
2488
+ symbol: item.asset.symbol !== undefined ? {
2489
+ set: item.asset.symbol
2490
+ } : undefined,
2491
+ name: item.asset.name !== undefined ? {
2492
+ set: item.asset.name
2493
+ } : undefined,
2494
+ type: item.asset.type !== undefined ? {
2495
+ set: item.asset.type
2496
+ } : undefined,
2497
+ logoUrl: item.asset.logoUrl !== undefined ? {
2498
+ set: item.asset.logoUrl
2499
+ } : undefined,
2500
+ description: item.asset.description !== undefined ? {
2501
+ set: item.asset.description
2502
+ } : undefined,
2503
+ cik: item.asset.cik !== undefined ? {
2504
+ set: item.asset.cik
2505
+ } : undefined,
2506
+ exchange: item.asset.exchange !== undefined ? {
2507
+ set: item.asset.exchange
2508
+ } : undefined,
2509
+ currency: item.asset.currency !== undefined ? {
2510
+ set: item.asset.currency
2511
+ } : undefined,
2512
+ country: item.asset.country !== undefined ? {
2513
+ set: item.asset.country
2514
+ } : undefined,
2515
+ sector: item.asset.sector !== undefined ? {
2516
+ set: item.asset.sector
2517
+ } : undefined,
2518
+ industry: item.asset.industry !== undefined ? {
2519
+ set: item.asset.industry
2520
+ } : undefined,
2521
+ address: item.asset.address !== undefined ? {
2522
+ set: item.asset.address
2523
+ } : undefined,
2524
+ officialSite: item.asset.officialSite !== undefined ? {
2525
+ set: item.asset.officialSite
2526
+ } : undefined,
2527
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
2528
+ set: item.asset.fiscalYearEnd
2529
+ } : undefined,
2530
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
2531
+ set: item.asset.latestQuarter
2532
+ } : undefined,
2533
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
2534
+ set: item.asset.marketCapitalization
2535
+ } : undefined,
2536
+ ebitda: item.asset.ebitda !== undefined ? {
2537
+ set: item.asset.ebitda
2538
+ } : undefined,
2539
+ peRatio: item.asset.peRatio !== undefined ? {
2540
+ set: item.asset.peRatio
2541
+ } : undefined,
2542
+ pegRatio: item.asset.pegRatio !== undefined ? {
2543
+ set: item.asset.pegRatio
2544
+ } : undefined,
2545
+ bookValue: item.asset.bookValue !== undefined ? {
2546
+ set: item.asset.bookValue
2547
+ } : undefined,
2548
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
2549
+ set: item.asset.dividendPerShare
2550
+ } : undefined,
2551
+ dividendYield: item.asset.dividendYield !== undefined ? {
2552
+ set: item.asset.dividendYield
2553
+ } : undefined,
2554
+ eps: item.asset.eps !== undefined ? {
2555
+ set: item.asset.eps
2556
+ } : undefined,
2557
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
2558
+ set: item.asset.revenuePerShareTTM
2559
+ } : undefined,
2560
+ profitMargin: item.asset.profitMargin !== undefined ? {
2561
+ set: item.asset.profitMargin
2562
+ } : undefined,
2563
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
2564
+ set: item.asset.operatingMarginTTM
2565
+ } : undefined,
2566
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
2567
+ set: item.asset.returnOnAssetsTTM
2568
+ } : undefined,
2569
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
2570
+ set: item.asset.returnOnEquityTTM
2571
+ } : undefined,
2572
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
2573
+ set: item.asset.revenueTTM
2574
+ } : undefined,
2575
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
2576
+ set: item.asset.grossProfitTTM
2577
+ } : undefined,
2578
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
2579
+ set: item.asset.dilutedEPSTTM
2580
+ } : undefined,
2581
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
2582
+ set: item.asset.quarterlyEarningsGrowthYOY
2583
+ } : undefined,
2584
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
2585
+ set: item.asset.quarterlyRevenueGrowthYOY
2586
+ } : undefined,
2587
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
2588
+ set: item.asset.analystTargetPrice
2589
+ } : undefined,
2590
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
2591
+ set: item.asset.analystRatingStrongBuy
2592
+ } : undefined,
2593
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
2594
+ set: item.asset.analystRatingBuy
2595
+ } : undefined,
2596
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
2597
+ set: item.asset.analystRatingHold
2598
+ } : undefined,
2599
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
2600
+ set: item.asset.analystRatingSell
2601
+ } : undefined,
2602
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
2603
+ set: item.asset.analystRatingStrongSell
2604
+ } : undefined,
2605
+ trailingPE: item.asset.trailingPE !== undefined ? {
2606
+ set: item.asset.trailingPE
2607
+ } : undefined,
2608
+ forwardPE: item.asset.forwardPE !== undefined ? {
2609
+ set: item.asset.forwardPE
2610
+ } : undefined,
2611
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
2612
+ set: item.asset.priceToSalesRatioTTM
2613
+ } : undefined,
2614
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
2615
+ set: item.asset.priceToBookRatio
2616
+ } : undefined,
2617
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
2618
+ set: item.asset.evToRevenue
2619
+ } : undefined,
2620
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
2621
+ set: item.asset.evToEbitda
2622
+ } : undefined,
2623
+ beta: item.asset.beta !== undefined ? {
2624
+ set: item.asset.beta
2625
+ } : undefined,
2626
+ week52High: item.asset.week52High !== undefined ? {
2627
+ set: item.asset.week52High
2628
+ } : undefined,
2629
+ week52Low: item.asset.week52Low !== undefined ? {
2630
+ set: item.asset.week52Low
2631
+ } : undefined,
2632
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
2633
+ set: item.asset.day50MovingAverage
2634
+ } : undefined,
2635
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
2636
+ set: item.asset.day200MovingAverage
2637
+ } : undefined,
2638
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
2639
+ set: item.asset.sharesOutstanding
2640
+ } : undefined,
2641
+ dividendDate: item.asset.dividendDate !== undefined ? {
2642
+ set: item.asset.dividendDate
2643
+ } : undefined,
2644
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
2645
+ set: item.asset.exDividendDate
2646
+ } : undefined,
2647
+ sellPrice: item.asset.sellPrice !== undefined ? {
2648
+ set: item.asset.sellPrice
2649
+ } : undefined,
2650
+ buyPrice: item.asset.buyPrice !== undefined ? {
2651
+ set: item.asset.buyPrice
2652
+ } : undefined,
2653
+ },
2654
+ create: {
2655
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
2656
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
2657
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
2658
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
2659
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
2660
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
2661
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
2662
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
2663
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
2664
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
2665
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
2666
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
2667
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
2668
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
2669
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
2670
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
2671
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
2672
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
2673
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
2674
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
2675
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
2676
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
2677
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
2678
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
2679
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
2680
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
2681
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
2682
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
2683
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
2684
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
2685
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
2686
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
2687
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
2688
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
2689
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
2690
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
2691
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
2692
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
2693
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
2694
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
2695
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
2696
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
2697
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
2698
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
2699
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
2700
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
2701
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
2702
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
2703
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
2704
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
2705
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
2706
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
2707
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
2708
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
2709
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
2710
+ },
2711
+ }
2712
+ } : undefined,
2713
+ actions: item.actions ? {
2714
+ upsert: item.actions.map((item) => ({
2715
+ where: {
2716
+ id: item.id !== undefined ? item.id : undefined,
2717
+ },
2718
+ update: {
2719
+ id: item.id !== undefined ? {
2720
+ set: item.id
2721
+ } : undefined,
2722
+ sequence: item.sequence !== undefined ? {
2723
+ set: item.sequence
2724
+ } : undefined,
2725
+ type: item.type !== undefined ? {
2726
+ set: item.type
2727
+ } : undefined,
2728
+ note: item.note !== undefined ? {
2729
+ set: item.note
2730
+ } : undefined,
2731
+ status: item.status !== undefined ? {
2732
+ set: item.status
2733
+ } : undefined,
2734
+ fee: item.fee !== undefined ? {
2735
+ set: item.fee
2736
+ } : undefined,
2737
+ },
2738
+ create: {
2739
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
2740
+ type: item.type !== undefined ? item.type : undefined,
2741
+ note: item.note !== undefined ? item.note : undefined,
2742
+ status: item.status !== undefined ? item.status : undefined,
2743
+ fee: item.fee !== undefined ? item.fee : undefined,
2744
+ },
2745
+ }))
2746
+ } : undefined,
1455
2747
  },
1456
2748
  create: {
1457
2749
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -1464,6 +2756,96 @@ exports.Position = {
1464
2756
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1465
2757
  status: item.status !== undefined ? item.status : undefined,
1466
2758
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2759
+ asset: item.asset ?
2760
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
2761
+ ? { connect: {
2762
+ id: item.asset.id
2763
+ }
2764
+ }
2765
+ : { connectOrCreate: {
2766
+ where: {
2767
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
2768
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
2769
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
2770
+ },
2771
+ create: {
2772
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
2773
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
2774
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
2775
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
2776
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
2777
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
2778
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
2779
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
2780
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
2781
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
2782
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
2783
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
2784
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
2785
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
2786
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
2787
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
2788
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
2789
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
2790
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
2791
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
2792
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
2793
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
2794
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
2795
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
2796
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
2797
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
2798
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
2799
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
2800
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
2801
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
2802
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
2803
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
2804
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
2805
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
2806
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
2807
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
2808
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
2809
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
2810
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
2811
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
2812
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
2813
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
2814
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
2815
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
2816
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
2817
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
2818
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
2819
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
2820
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
2821
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
2822
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
2823
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
2824
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
2825
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
2826
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
2827
+ },
2828
+ }
2829
+ } : undefined,
2830
+ actions: item.actions ?
2831
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
2832
+ connect: item.actions.map((item) => ({
2833
+ id: item.id
2834
+ }))
2835
+ }
2836
+ : { connectOrCreate: item.actions.map((item) => ({
2837
+ where: {
2838
+ id: item.id !== undefined ? item.id : undefined,
2839
+ },
2840
+ create: {
2841
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
2842
+ type: item.type !== undefined ? item.type : undefined,
2843
+ note: item.note !== undefined ? item.note : undefined,
2844
+ status: item.status !== undefined ? item.status : undefined,
2845
+ fee: item.fee !== undefined ? item.fee : undefined,
2846
+ },
2847
+ }))
2848
+ } : undefined,
1467
2849
  },
1468
2850
  }))
1469
2851
  } : undefined,
@@ -1524,6 +2906,284 @@ exports.Position = {
1524
2906
  fee: item.fee !== undefined ? {
1525
2907
  set: item.fee
1526
2908
  } : undefined,
2909
+ action: item.action ? {
2910
+ upsert: {
2911
+ where: {
2912
+ id: item.action.id !== undefined ? {
2913
+ equals: item.action.id
2914
+ } : undefined,
2915
+ },
2916
+ update: {
2917
+ id: item.action.id !== undefined ? {
2918
+ set: item.action.id
2919
+ } : undefined,
2920
+ sequence: item.action.sequence !== undefined ? {
2921
+ set: item.action.sequence
2922
+ } : undefined,
2923
+ type: item.action.type !== undefined ? {
2924
+ set: item.action.type
2925
+ } : undefined,
2926
+ note: item.action.note !== undefined ? {
2927
+ set: item.action.note
2928
+ } : undefined,
2929
+ status: item.action.status !== undefined ? {
2930
+ set: item.action.status
2931
+ } : undefined,
2932
+ fee: item.action.fee !== undefined ? {
2933
+ set: item.action.fee
2934
+ } : undefined,
2935
+ },
2936
+ create: {
2937
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
2938
+ type: item.action.type !== undefined ? item.action.type : undefined,
2939
+ note: item.action.note !== undefined ? item.action.note : undefined,
2940
+ status: item.action.status !== undefined ? item.action.status : undefined,
2941
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
2942
+ },
2943
+ }
2944
+ } : undefined,
2945
+ asset: item.asset ? {
2946
+ upsert: {
2947
+ where: {
2948
+ id: item.asset.id !== undefined ? {
2949
+ equals: item.asset.id
2950
+ } : undefined,
2951
+ symbol: item.asset.symbol !== undefined ? {
2952
+ equals: item.asset.symbol
2953
+ } : undefined,
2954
+ name: item.asset.name !== undefined ? {
2955
+ equals: item.asset.name
2956
+ } : undefined,
2957
+ },
2958
+ update: {
2959
+ id: item.asset.id !== undefined ? {
2960
+ set: item.asset.id
2961
+ } : undefined,
2962
+ symbol: item.asset.symbol !== undefined ? {
2963
+ set: item.asset.symbol
2964
+ } : undefined,
2965
+ name: item.asset.name !== undefined ? {
2966
+ set: item.asset.name
2967
+ } : undefined,
2968
+ type: item.asset.type !== undefined ? {
2969
+ set: item.asset.type
2970
+ } : undefined,
2971
+ logoUrl: item.asset.logoUrl !== undefined ? {
2972
+ set: item.asset.logoUrl
2973
+ } : undefined,
2974
+ description: item.asset.description !== undefined ? {
2975
+ set: item.asset.description
2976
+ } : undefined,
2977
+ cik: item.asset.cik !== undefined ? {
2978
+ set: item.asset.cik
2979
+ } : undefined,
2980
+ exchange: item.asset.exchange !== undefined ? {
2981
+ set: item.asset.exchange
2982
+ } : undefined,
2983
+ currency: item.asset.currency !== undefined ? {
2984
+ set: item.asset.currency
2985
+ } : undefined,
2986
+ country: item.asset.country !== undefined ? {
2987
+ set: item.asset.country
2988
+ } : undefined,
2989
+ sector: item.asset.sector !== undefined ? {
2990
+ set: item.asset.sector
2991
+ } : undefined,
2992
+ industry: item.asset.industry !== undefined ? {
2993
+ set: item.asset.industry
2994
+ } : undefined,
2995
+ address: item.asset.address !== undefined ? {
2996
+ set: item.asset.address
2997
+ } : undefined,
2998
+ officialSite: item.asset.officialSite !== undefined ? {
2999
+ set: item.asset.officialSite
3000
+ } : undefined,
3001
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
3002
+ set: item.asset.fiscalYearEnd
3003
+ } : undefined,
3004
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
3005
+ set: item.asset.latestQuarter
3006
+ } : undefined,
3007
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
3008
+ set: item.asset.marketCapitalization
3009
+ } : undefined,
3010
+ ebitda: item.asset.ebitda !== undefined ? {
3011
+ set: item.asset.ebitda
3012
+ } : undefined,
3013
+ peRatio: item.asset.peRatio !== undefined ? {
3014
+ set: item.asset.peRatio
3015
+ } : undefined,
3016
+ pegRatio: item.asset.pegRatio !== undefined ? {
3017
+ set: item.asset.pegRatio
3018
+ } : undefined,
3019
+ bookValue: item.asset.bookValue !== undefined ? {
3020
+ set: item.asset.bookValue
3021
+ } : undefined,
3022
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
3023
+ set: item.asset.dividendPerShare
3024
+ } : undefined,
3025
+ dividendYield: item.asset.dividendYield !== undefined ? {
3026
+ set: item.asset.dividendYield
3027
+ } : undefined,
3028
+ eps: item.asset.eps !== undefined ? {
3029
+ set: item.asset.eps
3030
+ } : undefined,
3031
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
3032
+ set: item.asset.revenuePerShareTTM
3033
+ } : undefined,
3034
+ profitMargin: item.asset.profitMargin !== undefined ? {
3035
+ set: item.asset.profitMargin
3036
+ } : undefined,
3037
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
3038
+ set: item.asset.operatingMarginTTM
3039
+ } : undefined,
3040
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
3041
+ set: item.asset.returnOnAssetsTTM
3042
+ } : undefined,
3043
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
3044
+ set: item.asset.returnOnEquityTTM
3045
+ } : undefined,
3046
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
3047
+ set: item.asset.revenueTTM
3048
+ } : undefined,
3049
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
3050
+ set: item.asset.grossProfitTTM
3051
+ } : undefined,
3052
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
3053
+ set: item.asset.dilutedEPSTTM
3054
+ } : undefined,
3055
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
3056
+ set: item.asset.quarterlyEarningsGrowthYOY
3057
+ } : undefined,
3058
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
3059
+ set: item.asset.quarterlyRevenueGrowthYOY
3060
+ } : undefined,
3061
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
3062
+ set: item.asset.analystTargetPrice
3063
+ } : undefined,
3064
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
3065
+ set: item.asset.analystRatingStrongBuy
3066
+ } : undefined,
3067
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
3068
+ set: item.asset.analystRatingBuy
3069
+ } : undefined,
3070
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
3071
+ set: item.asset.analystRatingHold
3072
+ } : undefined,
3073
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
3074
+ set: item.asset.analystRatingSell
3075
+ } : undefined,
3076
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
3077
+ set: item.asset.analystRatingStrongSell
3078
+ } : undefined,
3079
+ trailingPE: item.asset.trailingPE !== undefined ? {
3080
+ set: item.asset.trailingPE
3081
+ } : undefined,
3082
+ forwardPE: item.asset.forwardPE !== undefined ? {
3083
+ set: item.asset.forwardPE
3084
+ } : undefined,
3085
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
3086
+ set: item.asset.priceToSalesRatioTTM
3087
+ } : undefined,
3088
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
3089
+ set: item.asset.priceToBookRatio
3090
+ } : undefined,
3091
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
3092
+ set: item.asset.evToRevenue
3093
+ } : undefined,
3094
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
3095
+ set: item.asset.evToEbitda
3096
+ } : undefined,
3097
+ beta: item.asset.beta !== undefined ? {
3098
+ set: item.asset.beta
3099
+ } : undefined,
3100
+ week52High: item.asset.week52High !== undefined ? {
3101
+ set: item.asset.week52High
3102
+ } : undefined,
3103
+ week52Low: item.asset.week52Low !== undefined ? {
3104
+ set: item.asset.week52Low
3105
+ } : undefined,
3106
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
3107
+ set: item.asset.day50MovingAverage
3108
+ } : undefined,
3109
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
3110
+ set: item.asset.day200MovingAverage
3111
+ } : undefined,
3112
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
3113
+ set: item.asset.sharesOutstanding
3114
+ } : undefined,
3115
+ dividendDate: item.asset.dividendDate !== undefined ? {
3116
+ set: item.asset.dividendDate
3117
+ } : undefined,
3118
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
3119
+ set: item.asset.exDividendDate
3120
+ } : undefined,
3121
+ sellPrice: item.asset.sellPrice !== undefined ? {
3122
+ set: item.asset.sellPrice
3123
+ } : undefined,
3124
+ buyPrice: item.asset.buyPrice !== undefined ? {
3125
+ set: item.asset.buyPrice
3126
+ } : undefined,
3127
+ },
3128
+ create: {
3129
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3130
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3131
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
3132
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
3133
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
3134
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
3135
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
3136
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
3137
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
3138
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
3139
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
3140
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
3141
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
3142
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
3143
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
3144
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
3145
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
3146
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
3147
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
3148
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
3149
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
3150
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
3151
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
3152
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
3153
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
3154
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
3155
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
3156
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
3157
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
3158
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
3159
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
3160
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
3161
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
3162
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
3163
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
3164
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
3165
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
3166
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
3167
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
3168
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
3169
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
3170
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
3171
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
3172
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
3173
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
3174
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
3175
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
3176
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
3177
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
3178
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
3179
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
3180
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
3181
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
3182
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
3183
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
3184
+ },
3185
+ }
3186
+ } : undefined,
1527
3187
  },
1528
3188
  create: {
1529
3189
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -1542,6 +3202,96 @@ exports.Position = {
1542
3202
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1543
3203
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1544
3204
  fee: item.fee !== undefined ? item.fee : undefined,
3205
+ action: item.action ?
3206
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
3207
+ ? { connect: {
3208
+ id: item.action.id
3209
+ }
3210
+ }
3211
+ : { connectOrCreate: {
3212
+ where: {
3213
+ id: item.action.id !== undefined ? item.action.id : undefined,
3214
+ },
3215
+ create: {
3216
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
3217
+ type: item.action.type !== undefined ? item.action.type : undefined,
3218
+ note: item.action.note !== undefined ? item.action.note : undefined,
3219
+ status: item.action.status !== undefined ? item.action.status : undefined,
3220
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
3221
+ },
3222
+ }
3223
+ } : undefined,
3224
+ asset: item.asset ?
3225
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
3226
+ ? { connect: {
3227
+ id: item.asset.id
3228
+ }
3229
+ }
3230
+ : { connectOrCreate: {
3231
+ where: {
3232
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
3233
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3234
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3235
+ },
3236
+ create: {
3237
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3238
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3239
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
3240
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
3241
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
3242
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
3243
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
3244
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
3245
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
3246
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
3247
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
3248
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
3249
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
3250
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
3251
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
3252
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
3253
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
3254
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
3255
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
3256
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
3257
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
3258
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
3259
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
3260
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
3261
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
3262
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
3263
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
3264
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
3265
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
3266
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
3267
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
3268
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
3269
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
3270
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
3271
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
3272
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
3273
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
3274
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
3275
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
3276
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
3277
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
3278
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
3279
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
3280
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
3281
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
3282
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
3283
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
3284
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
3285
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
3286
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
3287
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
3288
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
3289
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
3290
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
3291
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
3292
+ },
3293
+ }
3294
+ } : undefined,
1545
3295
  },
1546
3296
  }))
1547
3297
  } : undefined,
@@ -1602,16 +3352,96 @@ exports.Position = {
1602
3352
  jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
1603
3353
  currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
1604
3354
  plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
3355
+ customer: props.alpacaAccount.user.customer ?
3356
+ typeof props.alpacaAccount.user.customer === 'object' && Object.keys(props.alpacaAccount.user.customer).length === 1 && Object.keys(props.alpacaAccount.user.customer)[0] === 'id'
3357
+ ? { connect: {
3358
+ id: props.alpacaAccount.user.customer.id
3359
+ }
3360
+ }
3361
+ : { connectOrCreate: {
3362
+ where: {
3363
+ id: props.alpacaAccount.user.customer.id !== undefined ? props.alpacaAccount.user.customer.id : undefined,
3364
+ name: props.alpacaAccount.user.customer.name !== undefined ? {
3365
+ equals: props.alpacaAccount.user.customer.name
3366
+ } : undefined,
3367
+ },
3368
+ create: {
3369
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
3370
+ name: props.alpacaAccount.user.customer.name !== undefined ? props.alpacaAccount.user.customer.name : undefined,
3371
+ plan: props.alpacaAccount.user.customer.plan !== undefined ? props.alpacaAccount.user.customer.plan : undefined,
3372
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
3373
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
3374
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? props.alpacaAccount.user.customer.stripePriceId : undefined,
3375
+ stripeCurrentPeriodEnd: props.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? props.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
3376
+ },
3377
+ }
3378
+ } : undefined,
3379
+ accounts: props.alpacaAccount.user.accounts ?
3380
+ Array.isArray(props.alpacaAccount.user.accounts) && props.alpacaAccount.user.accounts.length > 0 && props.alpacaAccount.user.accounts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3381
+ connect: props.alpacaAccount.user.accounts.map((item) => ({
3382
+ id: item.id
3383
+ }))
3384
+ }
3385
+ : { connectOrCreate: props.alpacaAccount.user.accounts.map((item) => ({
3386
+ where: {
3387
+ id: item.id !== undefined ? item.id : undefined,
3388
+ },
3389
+ create: {
3390
+ type: item.type !== undefined ? item.type : undefined,
3391
+ provider: item.provider !== undefined ? item.provider : undefined,
3392
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
3393
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
3394
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
3395
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
3396
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
3397
+ scope: item.scope !== undefined ? item.scope : undefined,
3398
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
3399
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
3400
+ },
3401
+ }))
3402
+ } : undefined,
3403
+ sessions: props.alpacaAccount.user.sessions ?
3404
+ Array.isArray(props.alpacaAccount.user.sessions) && props.alpacaAccount.user.sessions.length > 0 && props.alpacaAccount.user.sessions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3405
+ connect: props.alpacaAccount.user.sessions.map((item) => ({
3406
+ id: item.id
3407
+ }))
3408
+ }
3409
+ : { connectOrCreate: props.alpacaAccount.user.sessions.map((item) => ({
3410
+ where: {
3411
+ id: item.id !== undefined ? item.id : undefined,
3412
+ },
3413
+ create: {
3414
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
3415
+ expires: item.expires !== undefined ? item.expires : undefined,
3416
+ },
3417
+ }))
3418
+ } : undefined,
3419
+ authenticators: props.alpacaAccount.user.authenticators ?
3420
+ Array.isArray(props.alpacaAccount.user.authenticators) && props.alpacaAccount.user.authenticators.length > 0 && props.alpacaAccount.user.authenticators.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3421
+ connect: props.alpacaAccount.user.authenticators.map((item) => ({
3422
+ id: item.id
3423
+ }))
3424
+ }
3425
+ : { connectOrCreate: props.alpacaAccount.user.authenticators.map((item) => ({
3426
+ where: {
3427
+ id: item.id !== undefined ? item.id : undefined,
3428
+ },
3429
+ create: {
3430
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
3431
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
3432
+ counter: item.counter !== undefined ? item.counter : undefined,
3433
+ },
3434
+ }))
3435
+ } : undefined,
1605
3436
  },
1606
3437
  }
1607
3438
  } : undefined,
1608
3439
  trades: props.alpacaAccount.trades ?
1609
- Array.isArray(props.alpacaAccount.trades) && props.alpacaAccount.trades.length > 0
1610
- ? props.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1611
- connect: props.alpacaAccount.trades.map((item) => ({
1612
- id: item.id
1613
- }))
1614
- }
3440
+ Array.isArray(props.alpacaAccount.trades) && props.alpacaAccount.trades.length > 0 && props.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3441
+ connect: props.alpacaAccount.trades.map((item) => ({
3442
+ id: item.id
3443
+ }))
3444
+ }
1615
3445
  : { connectOrCreate: props.alpacaAccount.trades.map((item) => ({
1616
3446
  where: {
1617
3447
  id: item.id !== undefined ? item.id : undefined,
@@ -1627,16 +3457,105 @@ exports.Position = {
1627
3457
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1628
3458
  status: item.status !== undefined ? item.status : undefined,
1629
3459
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
3460
+ asset: item.asset ?
3461
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
3462
+ ? { connect: {
3463
+ id: item.asset.id
3464
+ }
3465
+ }
3466
+ : { connectOrCreate: {
3467
+ where: {
3468
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
3469
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3470
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3471
+ },
3472
+ create: {
3473
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3474
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3475
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
3476
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
3477
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
3478
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
3479
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
3480
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
3481
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
3482
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
3483
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
3484
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
3485
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
3486
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
3487
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
3488
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
3489
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
3490
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
3491
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
3492
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
3493
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
3494
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
3495
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
3496
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
3497
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
3498
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
3499
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
3500
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
3501
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
3502
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
3503
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
3504
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
3505
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
3506
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
3507
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
3508
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
3509
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
3510
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
3511
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
3512
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
3513
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
3514
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
3515
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
3516
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
3517
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
3518
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
3519
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
3520
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
3521
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
3522
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
3523
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
3524
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
3525
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
3526
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
3527
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
3528
+ },
3529
+ }
3530
+ } : undefined,
3531
+ actions: item.actions ?
3532
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3533
+ connect: item.actions.map((item) => ({
3534
+ id: item.id
3535
+ }))
3536
+ }
3537
+ : { connectOrCreate: item.actions.map((item) => ({
3538
+ where: {
3539
+ id: item.id !== undefined ? item.id : undefined,
3540
+ },
3541
+ create: {
3542
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
3543
+ type: item.type !== undefined ? item.type : undefined,
3544
+ note: item.note !== undefined ? item.note : undefined,
3545
+ status: item.status !== undefined ? item.status : undefined,
3546
+ fee: item.fee !== undefined ? item.fee : undefined,
3547
+ },
3548
+ }))
3549
+ } : undefined,
1630
3550
  },
1631
3551
  }))
1632
3552
  } : undefined,
1633
3553
  orders: props.alpacaAccount.orders ?
1634
- Array.isArray(props.alpacaAccount.orders) && props.alpacaAccount.orders.length > 0
1635
- ? props.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1636
- connect: props.alpacaAccount.orders.map((item) => ({
1637
- id: item.id
1638
- }))
1639
- }
3554
+ Array.isArray(props.alpacaAccount.orders) && props.alpacaAccount.orders.length > 0 && props.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3555
+ connect: props.alpacaAccount.orders.map((item) => ({
3556
+ id: item.id
3557
+ }))
3558
+ }
1640
3559
  : { connectOrCreate: props.alpacaAccount.orders.map((item) => ({
1641
3560
  where: {
1642
3561
  id: item.id !== undefined ? item.id : undefined,
@@ -1658,16 +3577,105 @@ exports.Position = {
1658
3577
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1659
3578
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1660
3579
  fee: item.fee !== undefined ? item.fee : undefined,
3580
+ action: item.action ?
3581
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
3582
+ ? { connect: {
3583
+ id: item.action.id
3584
+ }
3585
+ }
3586
+ : { connectOrCreate: {
3587
+ where: {
3588
+ id: item.action.id !== undefined ? item.action.id : undefined,
3589
+ },
3590
+ create: {
3591
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
3592
+ type: item.action.type !== undefined ? item.action.type : undefined,
3593
+ note: item.action.note !== undefined ? item.action.note : undefined,
3594
+ status: item.action.status !== undefined ? item.action.status : undefined,
3595
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
3596
+ },
3597
+ }
3598
+ } : undefined,
3599
+ asset: item.asset ?
3600
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
3601
+ ? { connect: {
3602
+ id: item.asset.id
3603
+ }
3604
+ }
3605
+ : { connectOrCreate: {
3606
+ where: {
3607
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
3608
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3609
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3610
+ },
3611
+ create: {
3612
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
3613
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
3614
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
3615
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
3616
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
3617
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
3618
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
3619
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
3620
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
3621
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
3622
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
3623
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
3624
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
3625
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
3626
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
3627
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
3628
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
3629
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
3630
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
3631
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
3632
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
3633
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
3634
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
3635
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
3636
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
3637
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
3638
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
3639
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
3640
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
3641
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
3642
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
3643
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
3644
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
3645
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
3646
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
3647
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
3648
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
3649
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
3650
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
3651
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
3652
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
3653
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
3654
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
3655
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
3656
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
3657
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
3658
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
3659
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
3660
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
3661
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
3662
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
3663
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
3664
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
3665
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
3666
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
3667
+ },
3668
+ }
3669
+ } : undefined,
1661
3670
  },
1662
3671
  }))
1663
3672
  } : undefined,
1664
3673
  alerts: props.alpacaAccount.alerts ?
1665
- Array.isArray(props.alpacaAccount.alerts) && props.alpacaAccount.alerts.length > 0
1666
- ? props.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1667
- connect: props.alpacaAccount.alerts.map((item) => ({
1668
- id: item.id
1669
- }))
1670
- }
3674
+ Array.isArray(props.alpacaAccount.alerts) && props.alpacaAccount.alerts.length > 0 && props.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
3675
+ connect: props.alpacaAccount.alerts.map((item) => ({
3676
+ id: item.id
3677
+ }))
3678
+ }
1671
3679
  : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
1672
3680
  where: {
1673
3681
  id: item.id !== undefined ? item.id : undefined,
@@ -1982,6 +3990,76 @@ exports.Position = {
1982
3990
  optionContractType: item.optionContractType !== undefined ? {
1983
3991
  set: item.optionContractType
1984
3992
  } : undefined,
3993
+ alpacaAccount: item.alpacaAccount ? {
3994
+ upsert: {
3995
+ where: {
3996
+ id: item.alpacaAccount.id !== undefined ? {
3997
+ equals: item.alpacaAccount.id
3998
+ } : undefined,
3999
+ },
4000
+ update: {
4001
+ id: item.alpacaAccount.id !== undefined ? {
4002
+ set: item.alpacaAccount.id
4003
+ } : undefined,
4004
+ type: item.alpacaAccount.type !== undefined ? {
4005
+ set: item.alpacaAccount.type
4006
+ } : undefined,
4007
+ APIKey: item.alpacaAccount.APIKey !== undefined ? {
4008
+ set: item.alpacaAccount.APIKey
4009
+ } : undefined,
4010
+ APISecret: item.alpacaAccount.APISecret !== undefined ? {
4011
+ set: item.alpacaAccount.APISecret
4012
+ } : undefined,
4013
+ configuration: item.alpacaAccount.configuration !== undefined ? {
4014
+ set: item.alpacaAccount.configuration
4015
+ } : undefined,
4016
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? {
4017
+ set: item.alpacaAccount.marketOpen
4018
+ } : undefined,
4019
+ },
4020
+ create: {
4021
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
4022
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
4023
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
4024
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
4025
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
4026
+ },
4027
+ }
4028
+ } : undefined,
4029
+ actions: item.actions ? {
4030
+ upsert: item.actions.map((item) => ({
4031
+ where: {
4032
+ id: item.id !== undefined ? item.id : undefined,
4033
+ },
4034
+ update: {
4035
+ id: item.id !== undefined ? {
4036
+ set: item.id
4037
+ } : undefined,
4038
+ sequence: item.sequence !== undefined ? {
4039
+ set: item.sequence
4040
+ } : undefined,
4041
+ type: item.type !== undefined ? {
4042
+ set: item.type
4043
+ } : undefined,
4044
+ note: item.note !== undefined ? {
4045
+ set: item.note
4046
+ } : undefined,
4047
+ status: item.status !== undefined ? {
4048
+ set: item.status
4049
+ } : undefined,
4050
+ fee: item.fee !== undefined ? {
4051
+ set: item.fee
4052
+ } : undefined,
4053
+ },
4054
+ create: {
4055
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
4056
+ type: item.type !== undefined ? item.type : undefined,
4057
+ note: item.note !== undefined ? item.note : undefined,
4058
+ status: item.status !== undefined ? item.status : undefined,
4059
+ fee: item.fee !== undefined ? item.fee : undefined,
4060
+ },
4061
+ }))
4062
+ } : undefined,
1985
4063
  },
1986
4064
  create: {
1987
4065
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -1994,6 +4072,44 @@ exports.Position = {
1994
4072
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1995
4073
  status: item.status !== undefined ? item.status : undefined,
1996
4074
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
4075
+ alpacaAccount: item.alpacaAccount ?
4076
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
4077
+ ? { connect: {
4078
+ id: item.alpacaAccount.id
4079
+ }
4080
+ }
4081
+ : { connectOrCreate: {
4082
+ where: {
4083
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
4084
+ },
4085
+ create: {
4086
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
4087
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
4088
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
4089
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
4090
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
4091
+ },
4092
+ }
4093
+ } : undefined,
4094
+ actions: item.actions ?
4095
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4096
+ connect: item.actions.map((item) => ({
4097
+ id: item.id
4098
+ }))
4099
+ }
4100
+ : { connectOrCreate: item.actions.map((item) => ({
4101
+ where: {
4102
+ id: item.id !== undefined ? item.id : undefined,
4103
+ },
4104
+ create: {
4105
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
4106
+ type: item.type !== undefined ? item.type : undefined,
4107
+ note: item.note !== undefined ? item.note : undefined,
4108
+ status: item.status !== undefined ? item.status : undefined,
4109
+ fee: item.fee !== undefined ? item.fee : undefined,
4110
+ },
4111
+ }))
4112
+ } : undefined,
1997
4113
  },
1998
4114
  }))
1999
4115
  } : undefined,
@@ -2054,6 +4170,78 @@ exports.Position = {
2054
4170
  fee: item.fee !== undefined ? {
2055
4171
  set: item.fee
2056
4172
  } : undefined,
4173
+ alpacaAccount: item.alpacaAccount ? {
4174
+ upsert: {
4175
+ where: {
4176
+ id: item.alpacaAccount.id !== undefined ? {
4177
+ equals: item.alpacaAccount.id
4178
+ } : undefined,
4179
+ },
4180
+ update: {
4181
+ id: item.alpacaAccount.id !== undefined ? {
4182
+ set: item.alpacaAccount.id
4183
+ } : undefined,
4184
+ type: item.alpacaAccount.type !== undefined ? {
4185
+ set: item.alpacaAccount.type
4186
+ } : undefined,
4187
+ APIKey: item.alpacaAccount.APIKey !== undefined ? {
4188
+ set: item.alpacaAccount.APIKey
4189
+ } : undefined,
4190
+ APISecret: item.alpacaAccount.APISecret !== undefined ? {
4191
+ set: item.alpacaAccount.APISecret
4192
+ } : undefined,
4193
+ configuration: item.alpacaAccount.configuration !== undefined ? {
4194
+ set: item.alpacaAccount.configuration
4195
+ } : undefined,
4196
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? {
4197
+ set: item.alpacaAccount.marketOpen
4198
+ } : undefined,
4199
+ },
4200
+ create: {
4201
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
4202
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
4203
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
4204
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
4205
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
4206
+ },
4207
+ }
4208
+ } : undefined,
4209
+ action: item.action ? {
4210
+ upsert: {
4211
+ where: {
4212
+ id: item.action.id !== undefined ? {
4213
+ equals: item.action.id
4214
+ } : undefined,
4215
+ },
4216
+ update: {
4217
+ id: item.action.id !== undefined ? {
4218
+ set: item.action.id
4219
+ } : undefined,
4220
+ sequence: item.action.sequence !== undefined ? {
4221
+ set: item.action.sequence
4222
+ } : undefined,
4223
+ type: item.action.type !== undefined ? {
4224
+ set: item.action.type
4225
+ } : undefined,
4226
+ note: item.action.note !== undefined ? {
4227
+ set: item.action.note
4228
+ } : undefined,
4229
+ status: item.action.status !== undefined ? {
4230
+ set: item.action.status
4231
+ } : undefined,
4232
+ fee: item.action.fee !== undefined ? {
4233
+ set: item.action.fee
4234
+ } : undefined,
4235
+ },
4236
+ create: {
4237
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
4238
+ type: item.action.type !== undefined ? item.action.type : undefined,
4239
+ note: item.action.note !== undefined ? item.action.note : undefined,
4240
+ status: item.action.status !== undefined ? item.action.status : undefined,
4241
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
4242
+ },
4243
+ }
4244
+ } : undefined,
2057
4245
  },
2058
4246
  create: {
2059
4247
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -2072,6 +4260,44 @@ exports.Position = {
2072
4260
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2073
4261
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2074
4262
  fee: item.fee !== undefined ? item.fee : undefined,
4263
+ alpacaAccount: item.alpacaAccount ?
4264
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
4265
+ ? { connect: {
4266
+ id: item.alpacaAccount.id
4267
+ }
4268
+ }
4269
+ : { connectOrCreate: {
4270
+ where: {
4271
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
4272
+ },
4273
+ create: {
4274
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
4275
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
4276
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
4277
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
4278
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
4279
+ },
4280
+ }
4281
+ } : undefined,
4282
+ action: item.action ?
4283
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
4284
+ ? { connect: {
4285
+ id: item.action.id
4286
+ }
4287
+ }
4288
+ : { connectOrCreate: {
4289
+ where: {
4290
+ id: item.action.id !== undefined ? item.action.id : undefined,
4291
+ },
4292
+ create: {
4293
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
4294
+ type: item.action.type !== undefined ? item.action.type : undefined,
4295
+ note: item.action.note !== undefined ? item.action.note : undefined,
4296
+ status: item.action.status !== undefined ? item.action.status : undefined,
4297
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
4298
+ },
4299
+ }
4300
+ } : undefined,
2075
4301
  },
2076
4302
  }))
2077
4303
  } : undefined,
@@ -2097,12 +4323,117 @@ exports.Position = {
2097
4323
  sentimentLabel: item.sentimentLabel !== undefined ? {
2098
4324
  set: item.sentimentLabel
2099
4325
  } : undefined,
4326
+ news: item.news ? {
4327
+ upsert: {
4328
+ where: {
4329
+ id: item.news.id !== undefined ? {
4330
+ equals: item.news.id
4331
+ } : undefined,
4332
+ title: item.news.title !== undefined ? {
4333
+ equals: item.news.title
4334
+ } : undefined,
4335
+ url: item.news.url !== undefined ? {
4336
+ equals: item.news.url
4337
+ } : undefined,
4338
+ },
4339
+ update: {
4340
+ id: item.news.id !== undefined ? {
4341
+ set: item.news.id
4342
+ } : undefined,
4343
+ title: item.news.title !== undefined ? {
4344
+ set: item.news.title
4345
+ } : undefined,
4346
+ content: item.news.content !== undefined ? {
4347
+ set: item.news.content
4348
+ } : undefined,
4349
+ source: item.news.source !== undefined ? {
4350
+ set: item.news.source
4351
+ } : undefined,
4352
+ sourceDomain: item.news.sourceDomain !== undefined ? {
4353
+ set: item.news.sourceDomain
4354
+ } : undefined,
4355
+ url: item.news.url !== undefined ? {
4356
+ set: item.news.url
4357
+ } : undefined,
4358
+ sentiment: item.news.sentiment !== undefined ? {
4359
+ set: item.news.sentiment
4360
+ } : undefined,
4361
+ authors: item.news.authors !== undefined ? {
4362
+ set: item.news.authors
4363
+ } : undefined,
4364
+ summary: item.news.summary !== undefined ? {
4365
+ set: item.news.summary
4366
+ } : undefined,
4367
+ bannerImage: item.news.bannerImage !== undefined ? {
4368
+ set: item.news.bannerImage
4369
+ } : undefined,
4370
+ timePublished: item.news.timePublished !== undefined ? {
4371
+ set: item.news.timePublished
4372
+ } : undefined,
4373
+ category: item.news.category !== undefined ? {
4374
+ set: item.news.category
4375
+ } : undefined,
4376
+ topics: item.news.topics !== undefined ? {
4377
+ set: item.news.topics
4378
+ } : undefined,
4379
+ logo: item.news.logo !== undefined ? {
4380
+ set: item.news.logo
4381
+ } : undefined,
4382
+ },
4383
+ create: {
4384
+ title: item.news.title !== undefined ? item.news.title : undefined,
4385
+ content: item.news.content !== undefined ? item.news.content : undefined,
4386
+ source: item.news.source !== undefined ? item.news.source : undefined,
4387
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
4388
+ url: item.news.url !== undefined ? item.news.url : undefined,
4389
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
4390
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
4391
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
4392
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
4393
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
4394
+ category: item.news.category !== undefined ? item.news.category : undefined,
4395
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
4396
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
4397
+ },
4398
+ }
4399
+ } : undefined,
2100
4400
  },
2101
4401
  create: {
2102
4402
  url: item.url !== undefined ? item.url : undefined,
2103
4403
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2104
4404
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2105
4405
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
4406
+ news: item.news ?
4407
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
4408
+ ? { connect: {
4409
+ id: item.news.id
4410
+ }
4411
+ }
4412
+ : { connectOrCreate: {
4413
+ where: {
4414
+ id: item.news.id !== undefined ? item.news.id : undefined,
4415
+ url: item.news.url !== undefined ? item.news.url : undefined,
4416
+ title: item.news.title !== undefined ? {
4417
+ equals: item.news.title
4418
+ } : undefined,
4419
+ },
4420
+ create: {
4421
+ title: item.news.title !== undefined ? item.news.title : undefined,
4422
+ content: item.news.content !== undefined ? item.news.content : undefined,
4423
+ source: item.news.source !== undefined ? item.news.source : undefined,
4424
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
4425
+ url: item.news.url !== undefined ? item.news.url : undefined,
4426
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
4427
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
4428
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
4429
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
4430
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
4431
+ category: item.news.category !== undefined ? item.news.category : undefined,
4432
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
4433
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
4434
+ },
4435
+ }
4436
+ } : undefined,
2106
4437
  },
2107
4438
  }))
2108
4439
  } : undefined,
@@ -2164,12 +4495,11 @@ exports.Position = {
2164
4495
  sellPrice: prop.asset.sellPrice !== undefined ? prop.asset.sellPrice : undefined,
2165
4496
  buyPrice: prop.asset.buyPrice !== undefined ? prop.asset.buyPrice : undefined,
2166
4497
  trades: prop.asset.trades ?
2167
- Array.isArray(prop.asset.trades) && prop.asset.trades.length > 0
2168
- ? prop.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2169
- connect: prop.asset.trades.map((item) => ({
2170
- id: item.id
2171
- }))
2172
- }
4498
+ Array.isArray(prop.asset.trades) && prop.asset.trades.length > 0 && prop.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4499
+ connect: prop.asset.trades.map((item) => ({
4500
+ id: item.id
4501
+ }))
4502
+ }
2173
4503
  : { connectOrCreate: prop.asset.trades.map((item) => ({
2174
4504
  where: {
2175
4505
  id: item.id !== undefined ? item.id : undefined,
@@ -2185,16 +4515,53 @@ exports.Position = {
2185
4515
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2186
4516
  status: item.status !== undefined ? item.status : undefined,
2187
4517
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
4518
+ alpacaAccount: item.alpacaAccount ?
4519
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
4520
+ ? { connect: {
4521
+ id: item.alpacaAccount.id
4522
+ }
4523
+ }
4524
+ : { connectOrCreate: {
4525
+ where: {
4526
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
4527
+ },
4528
+ create: {
4529
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
4530
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
4531
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
4532
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
4533
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
4534
+ },
4535
+ }
4536
+ } : undefined,
4537
+ actions: item.actions ?
4538
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4539
+ connect: item.actions.map((item) => ({
4540
+ id: item.id
4541
+ }))
4542
+ }
4543
+ : { connectOrCreate: item.actions.map((item) => ({
4544
+ where: {
4545
+ id: item.id !== undefined ? item.id : undefined,
4546
+ },
4547
+ create: {
4548
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
4549
+ type: item.type !== undefined ? item.type : undefined,
4550
+ note: item.note !== undefined ? item.note : undefined,
4551
+ status: item.status !== undefined ? item.status : undefined,
4552
+ fee: item.fee !== undefined ? item.fee : undefined,
4553
+ },
4554
+ }))
4555
+ } : undefined,
2188
4556
  },
2189
4557
  }))
2190
4558
  } : undefined,
2191
4559
  orders: prop.asset.orders ?
2192
- Array.isArray(prop.asset.orders) && prop.asset.orders.length > 0
2193
- ? prop.asset.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2194
- connect: prop.asset.orders.map((item) => ({
2195
- id: item.id
2196
- }))
2197
- }
4560
+ Array.isArray(prop.asset.orders) && prop.asset.orders.length > 0 && prop.asset.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4561
+ connect: prop.asset.orders.map((item) => ({
4562
+ id: item.id
4563
+ }))
4564
+ }
2198
4565
  : { connectOrCreate: prop.asset.orders.map((item) => ({
2199
4566
  where: {
2200
4567
  id: item.id !== undefined ? item.id : undefined,
@@ -2216,16 +4583,53 @@ exports.Position = {
2216
4583
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2217
4584
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2218
4585
  fee: item.fee !== undefined ? item.fee : undefined,
4586
+ alpacaAccount: item.alpacaAccount ?
4587
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
4588
+ ? { connect: {
4589
+ id: item.alpacaAccount.id
4590
+ }
4591
+ }
4592
+ : { connectOrCreate: {
4593
+ where: {
4594
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
4595
+ },
4596
+ create: {
4597
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
4598
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
4599
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
4600
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
4601
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
4602
+ },
4603
+ }
4604
+ } : undefined,
4605
+ action: item.action ?
4606
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
4607
+ ? { connect: {
4608
+ id: item.action.id
4609
+ }
4610
+ }
4611
+ : { connectOrCreate: {
4612
+ where: {
4613
+ id: item.action.id !== undefined ? item.action.id : undefined,
4614
+ },
4615
+ create: {
4616
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
4617
+ type: item.action.type !== undefined ? item.action.type : undefined,
4618
+ note: item.action.note !== undefined ? item.action.note : undefined,
4619
+ status: item.action.status !== undefined ? item.action.status : undefined,
4620
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
4621
+ },
4622
+ }
4623
+ } : undefined,
2219
4624
  },
2220
4625
  }))
2221
4626
  } : undefined,
2222
4627
  newsMentions: prop.asset.newsMentions ?
2223
- Array.isArray(prop.asset.newsMentions) && prop.asset.newsMentions.length > 0
2224
- ? prop.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2225
- connect: prop.asset.newsMentions.map((item) => ({
2226
- id: item.id
2227
- }))
2228
- }
4628
+ Array.isArray(prop.asset.newsMentions) && prop.asset.newsMentions.length > 0 && prop.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4629
+ connect: prop.asset.newsMentions.map((item) => ({
4630
+ id: item.id
4631
+ }))
4632
+ }
2229
4633
  : { connectOrCreate: prop.asset.newsMentions.map((item) => ({
2230
4634
  where: {
2231
4635
  id: item.id !== undefined ? item.id : undefined,
@@ -2236,6 +4640,37 @@ exports.Position = {
2236
4640
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2237
4641
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2238
4642
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
4643
+ news: item.news ?
4644
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
4645
+ ? { connect: {
4646
+ id: item.news.id
4647
+ }
4648
+ }
4649
+ : { connectOrCreate: {
4650
+ where: {
4651
+ id: item.news.id !== undefined ? item.news.id : undefined,
4652
+ url: item.news.url !== undefined ? item.news.url : undefined,
4653
+ title: item.news.title !== undefined ? {
4654
+ equals: item.news.title
4655
+ } : undefined,
4656
+ },
4657
+ create: {
4658
+ title: item.news.title !== undefined ? item.news.title : undefined,
4659
+ content: item.news.content !== undefined ? item.news.content : undefined,
4660
+ source: item.news.source !== undefined ? item.news.source : undefined,
4661
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
4662
+ url: item.news.url !== undefined ? item.news.url : undefined,
4663
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
4664
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
4665
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
4666
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
4667
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
4668
+ category: item.news.category !== undefined ? item.news.category : undefined,
4669
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
4670
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
4671
+ },
4672
+ }
4673
+ } : undefined,
2239
4674
  },
2240
4675
  }))
2241
4676
  } : undefined,
@@ -2312,6 +4747,152 @@ exports.Position = {
2312
4747
  plan: prop.alpacaAccount.user.plan !== undefined ? {
2313
4748
  set: prop.alpacaAccount.user.plan
2314
4749
  } : undefined,
4750
+ customer: prop.alpacaAccount.user.customer ? {
4751
+ upsert: {
4752
+ where: {
4753
+ id: prop.alpacaAccount.user.customer.id !== undefined ? {
4754
+ equals: prop.alpacaAccount.user.customer.id
4755
+ } : undefined,
4756
+ name: prop.alpacaAccount.user.customer.name !== undefined ? {
4757
+ equals: prop.alpacaAccount.user.customer.name
4758
+ } : undefined,
4759
+ },
4760
+ update: {
4761
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? {
4762
+ set: prop.alpacaAccount.user.customer.authUserId
4763
+ } : undefined,
4764
+ name: prop.alpacaAccount.user.customer.name !== undefined ? {
4765
+ set: prop.alpacaAccount.user.customer.name
4766
+ } : undefined,
4767
+ plan: prop.alpacaAccount.user.customer.plan !== undefined ? {
4768
+ set: prop.alpacaAccount.user.customer.plan
4769
+ } : undefined,
4770
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? {
4771
+ set: prop.alpacaAccount.user.customer.stripeCustomerId
4772
+ } : undefined,
4773
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? {
4774
+ set: prop.alpacaAccount.user.customer.stripeSubscriptionId
4775
+ } : undefined,
4776
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? {
4777
+ set: prop.alpacaAccount.user.customer.stripePriceId
4778
+ } : undefined,
4779
+ stripeCurrentPeriodEnd: prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? {
4780
+ set: prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd
4781
+ } : undefined,
4782
+ },
4783
+ create: {
4784
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? prop.alpacaAccount.user.customer.authUserId : undefined,
4785
+ name: prop.alpacaAccount.user.customer.name !== undefined ? prop.alpacaAccount.user.customer.name : undefined,
4786
+ plan: prop.alpacaAccount.user.customer.plan !== undefined ? prop.alpacaAccount.user.customer.plan : undefined,
4787
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? prop.alpacaAccount.user.customer.stripeCustomerId : undefined,
4788
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? prop.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
4789
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? prop.alpacaAccount.user.customer.stripePriceId : undefined,
4790
+ stripeCurrentPeriodEnd: prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
4791
+ },
4792
+ }
4793
+ } : undefined,
4794
+ accounts: prop.alpacaAccount.user.accounts ? {
4795
+ upsert: prop.alpacaAccount.user.accounts.map((item) => ({
4796
+ where: {
4797
+ id: item.id !== undefined ? item.id : undefined,
4798
+ },
4799
+ update: {
4800
+ id: item.id !== undefined ? {
4801
+ set: item.id
4802
+ } : undefined,
4803
+ type: item.type !== undefined ? {
4804
+ set: item.type
4805
+ } : undefined,
4806
+ provider: item.provider !== undefined ? {
4807
+ set: item.provider
4808
+ } : undefined,
4809
+ providerAccountId: item.providerAccountId !== undefined ? {
4810
+ set: item.providerAccountId
4811
+ } : undefined,
4812
+ refresh_token: item.refresh_token !== undefined ? {
4813
+ set: item.refresh_token
4814
+ } : undefined,
4815
+ access_token: item.access_token !== undefined ? {
4816
+ set: item.access_token
4817
+ } : undefined,
4818
+ expires_at: item.expires_at !== undefined ? {
4819
+ set: item.expires_at
4820
+ } : undefined,
4821
+ token_type: item.token_type !== undefined ? {
4822
+ set: item.token_type
4823
+ } : undefined,
4824
+ scope: item.scope !== undefined ? {
4825
+ set: item.scope
4826
+ } : undefined,
4827
+ id_token: item.id_token !== undefined ? {
4828
+ set: item.id_token
4829
+ } : undefined,
4830
+ session_state: item.session_state !== undefined ? {
4831
+ set: item.session_state
4832
+ } : undefined,
4833
+ },
4834
+ create: {
4835
+ type: item.type !== undefined ? item.type : undefined,
4836
+ provider: item.provider !== undefined ? item.provider : undefined,
4837
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
4838
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
4839
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
4840
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
4841
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
4842
+ scope: item.scope !== undefined ? item.scope : undefined,
4843
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
4844
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
4845
+ },
4846
+ }))
4847
+ } : undefined,
4848
+ sessions: prop.alpacaAccount.user.sessions ? {
4849
+ upsert: prop.alpacaAccount.user.sessions.map((item) => ({
4850
+ where: {
4851
+ id: item.id !== undefined ? item.id : undefined,
4852
+ },
4853
+ update: {
4854
+ id: item.id !== undefined ? {
4855
+ set: item.id
4856
+ } : undefined,
4857
+ sessionToken: item.sessionToken !== undefined ? {
4858
+ set: item.sessionToken
4859
+ } : undefined,
4860
+ expires: item.expires !== undefined ? {
4861
+ set: item.expires
4862
+ } : undefined,
4863
+ },
4864
+ create: {
4865
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
4866
+ expires: item.expires !== undefined ? item.expires : undefined,
4867
+ },
4868
+ }))
4869
+ } : undefined,
4870
+ authenticators: prop.alpacaAccount.user.authenticators ? {
4871
+ upsert: prop.alpacaAccount.user.authenticators.map((item) => ({
4872
+ where: {
4873
+ id: item.id !== undefined ? item.id : undefined,
4874
+ },
4875
+ update: {
4876
+ id: item.id !== undefined ? {
4877
+ set: item.id
4878
+ } : undefined,
4879
+ credentialID: item.credentialID !== undefined ? {
4880
+ set: item.credentialID
4881
+ } : undefined,
4882
+ publicKey: item.publicKey !== undefined ? {
4883
+ set: item.publicKey
4884
+ } : undefined,
4885
+ counter: item.counter !== undefined ? {
4886
+ set: item.counter
4887
+ } : undefined,
4888
+ },
4889
+ create: {
4890
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
4891
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
4892
+ counter: item.counter !== undefined ? item.counter : undefined,
4893
+ },
4894
+ }))
4895
+ } : undefined,
2315
4896
  },
2316
4897
  create: {
2317
4898
  name: prop.alpacaAccount.user.name !== undefined ? prop.alpacaAccount.user.name : undefined,
@@ -2323,6 +4904,87 @@ exports.Position = {
2323
4904
  jobTitle: prop.alpacaAccount.user.jobTitle !== undefined ? prop.alpacaAccount.user.jobTitle : undefined,
2324
4905
  currentAccount: prop.alpacaAccount.user.currentAccount !== undefined ? prop.alpacaAccount.user.currentAccount : undefined,
2325
4906
  plan: prop.alpacaAccount.user.plan !== undefined ? prop.alpacaAccount.user.plan : undefined,
4907
+ customer: prop.alpacaAccount.user.customer ?
4908
+ typeof prop.alpacaAccount.user.customer === 'object' && Object.keys(prop.alpacaAccount.user.customer).length === 1 && Object.keys(prop.alpacaAccount.user.customer)[0] === 'id'
4909
+ ? { connect: {
4910
+ id: prop.alpacaAccount.user.customer.id
4911
+ }
4912
+ }
4913
+ : { connectOrCreate: {
4914
+ where: {
4915
+ id: prop.alpacaAccount.user.customer.id !== undefined ? prop.alpacaAccount.user.customer.id : undefined,
4916
+ name: prop.alpacaAccount.user.customer.name !== undefined ? {
4917
+ equals: prop.alpacaAccount.user.customer.name
4918
+ } : undefined,
4919
+ },
4920
+ create: {
4921
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? prop.alpacaAccount.user.customer.authUserId : undefined,
4922
+ name: prop.alpacaAccount.user.customer.name !== undefined ? prop.alpacaAccount.user.customer.name : undefined,
4923
+ plan: prop.alpacaAccount.user.customer.plan !== undefined ? prop.alpacaAccount.user.customer.plan : undefined,
4924
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? prop.alpacaAccount.user.customer.stripeCustomerId : undefined,
4925
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? prop.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
4926
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? prop.alpacaAccount.user.customer.stripePriceId : undefined,
4927
+ stripeCurrentPeriodEnd: prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
4928
+ },
4929
+ }
4930
+ } : undefined,
4931
+ accounts: prop.alpacaAccount.user.accounts ?
4932
+ Array.isArray(prop.alpacaAccount.user.accounts) && prop.alpacaAccount.user.accounts.length > 0 && prop.alpacaAccount.user.accounts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4933
+ connect: prop.alpacaAccount.user.accounts.map((item) => ({
4934
+ id: item.id
4935
+ }))
4936
+ }
4937
+ : { connectOrCreate: prop.alpacaAccount.user.accounts.map((item) => ({
4938
+ where: {
4939
+ id: item.id !== undefined ? item.id : undefined,
4940
+ },
4941
+ create: {
4942
+ type: item.type !== undefined ? item.type : undefined,
4943
+ provider: item.provider !== undefined ? item.provider : undefined,
4944
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
4945
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
4946
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
4947
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
4948
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
4949
+ scope: item.scope !== undefined ? item.scope : undefined,
4950
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
4951
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
4952
+ },
4953
+ }))
4954
+ } : undefined,
4955
+ sessions: prop.alpacaAccount.user.sessions ?
4956
+ Array.isArray(prop.alpacaAccount.user.sessions) && prop.alpacaAccount.user.sessions.length > 0 && prop.alpacaAccount.user.sessions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4957
+ connect: prop.alpacaAccount.user.sessions.map((item) => ({
4958
+ id: item.id
4959
+ }))
4960
+ }
4961
+ : { connectOrCreate: prop.alpacaAccount.user.sessions.map((item) => ({
4962
+ where: {
4963
+ id: item.id !== undefined ? item.id : undefined,
4964
+ },
4965
+ create: {
4966
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
4967
+ expires: item.expires !== undefined ? item.expires : undefined,
4968
+ },
4969
+ }))
4970
+ } : undefined,
4971
+ authenticators: prop.alpacaAccount.user.authenticators ?
4972
+ Array.isArray(prop.alpacaAccount.user.authenticators) && prop.alpacaAccount.user.authenticators.length > 0 && prop.alpacaAccount.user.authenticators.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
4973
+ connect: prop.alpacaAccount.user.authenticators.map((item) => ({
4974
+ id: item.id
4975
+ }))
4976
+ }
4977
+ : { connectOrCreate: prop.alpacaAccount.user.authenticators.map((item) => ({
4978
+ where: {
4979
+ id: item.id !== undefined ? item.id : undefined,
4980
+ },
4981
+ create: {
4982
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
4983
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
4984
+ counter: item.counter !== undefined ? item.counter : undefined,
4985
+ },
4986
+ }))
4987
+ } : undefined,
2326
4988
  },
2327
4989
  }
2328
4990
  } : undefined,
@@ -2365,6 +5027,282 @@ exports.Position = {
2365
5027
  optionContractType: item.optionContractType !== undefined ? {
2366
5028
  set: item.optionContractType
2367
5029
  } : undefined,
5030
+ asset: item.asset ? {
5031
+ upsert: {
5032
+ where: {
5033
+ id: item.asset.id !== undefined ? {
5034
+ equals: item.asset.id
5035
+ } : undefined,
5036
+ symbol: item.asset.symbol !== undefined ? {
5037
+ equals: item.asset.symbol
5038
+ } : undefined,
5039
+ name: item.asset.name !== undefined ? {
5040
+ equals: item.asset.name
5041
+ } : undefined,
5042
+ },
5043
+ update: {
5044
+ id: item.asset.id !== undefined ? {
5045
+ set: item.asset.id
5046
+ } : undefined,
5047
+ symbol: item.asset.symbol !== undefined ? {
5048
+ set: item.asset.symbol
5049
+ } : undefined,
5050
+ name: item.asset.name !== undefined ? {
5051
+ set: item.asset.name
5052
+ } : undefined,
5053
+ type: item.asset.type !== undefined ? {
5054
+ set: item.asset.type
5055
+ } : undefined,
5056
+ logoUrl: item.asset.logoUrl !== undefined ? {
5057
+ set: item.asset.logoUrl
5058
+ } : undefined,
5059
+ description: item.asset.description !== undefined ? {
5060
+ set: item.asset.description
5061
+ } : undefined,
5062
+ cik: item.asset.cik !== undefined ? {
5063
+ set: item.asset.cik
5064
+ } : undefined,
5065
+ exchange: item.asset.exchange !== undefined ? {
5066
+ set: item.asset.exchange
5067
+ } : undefined,
5068
+ currency: item.asset.currency !== undefined ? {
5069
+ set: item.asset.currency
5070
+ } : undefined,
5071
+ country: item.asset.country !== undefined ? {
5072
+ set: item.asset.country
5073
+ } : undefined,
5074
+ sector: item.asset.sector !== undefined ? {
5075
+ set: item.asset.sector
5076
+ } : undefined,
5077
+ industry: item.asset.industry !== undefined ? {
5078
+ set: item.asset.industry
5079
+ } : undefined,
5080
+ address: item.asset.address !== undefined ? {
5081
+ set: item.asset.address
5082
+ } : undefined,
5083
+ officialSite: item.asset.officialSite !== undefined ? {
5084
+ set: item.asset.officialSite
5085
+ } : undefined,
5086
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
5087
+ set: item.asset.fiscalYearEnd
5088
+ } : undefined,
5089
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
5090
+ set: item.asset.latestQuarter
5091
+ } : undefined,
5092
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
5093
+ set: item.asset.marketCapitalization
5094
+ } : undefined,
5095
+ ebitda: item.asset.ebitda !== undefined ? {
5096
+ set: item.asset.ebitda
5097
+ } : undefined,
5098
+ peRatio: item.asset.peRatio !== undefined ? {
5099
+ set: item.asset.peRatio
5100
+ } : undefined,
5101
+ pegRatio: item.asset.pegRatio !== undefined ? {
5102
+ set: item.asset.pegRatio
5103
+ } : undefined,
5104
+ bookValue: item.asset.bookValue !== undefined ? {
5105
+ set: item.asset.bookValue
5106
+ } : undefined,
5107
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
5108
+ set: item.asset.dividendPerShare
5109
+ } : undefined,
5110
+ dividendYield: item.asset.dividendYield !== undefined ? {
5111
+ set: item.asset.dividendYield
5112
+ } : undefined,
5113
+ eps: item.asset.eps !== undefined ? {
5114
+ set: item.asset.eps
5115
+ } : undefined,
5116
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
5117
+ set: item.asset.revenuePerShareTTM
5118
+ } : undefined,
5119
+ profitMargin: item.asset.profitMargin !== undefined ? {
5120
+ set: item.asset.profitMargin
5121
+ } : undefined,
5122
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
5123
+ set: item.asset.operatingMarginTTM
5124
+ } : undefined,
5125
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
5126
+ set: item.asset.returnOnAssetsTTM
5127
+ } : undefined,
5128
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
5129
+ set: item.asset.returnOnEquityTTM
5130
+ } : undefined,
5131
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
5132
+ set: item.asset.revenueTTM
5133
+ } : undefined,
5134
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
5135
+ set: item.asset.grossProfitTTM
5136
+ } : undefined,
5137
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
5138
+ set: item.asset.dilutedEPSTTM
5139
+ } : undefined,
5140
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
5141
+ set: item.asset.quarterlyEarningsGrowthYOY
5142
+ } : undefined,
5143
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
5144
+ set: item.asset.quarterlyRevenueGrowthYOY
5145
+ } : undefined,
5146
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
5147
+ set: item.asset.analystTargetPrice
5148
+ } : undefined,
5149
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
5150
+ set: item.asset.analystRatingStrongBuy
5151
+ } : undefined,
5152
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
5153
+ set: item.asset.analystRatingBuy
5154
+ } : undefined,
5155
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
5156
+ set: item.asset.analystRatingHold
5157
+ } : undefined,
5158
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
5159
+ set: item.asset.analystRatingSell
5160
+ } : undefined,
5161
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
5162
+ set: item.asset.analystRatingStrongSell
5163
+ } : undefined,
5164
+ trailingPE: item.asset.trailingPE !== undefined ? {
5165
+ set: item.asset.trailingPE
5166
+ } : undefined,
5167
+ forwardPE: item.asset.forwardPE !== undefined ? {
5168
+ set: item.asset.forwardPE
5169
+ } : undefined,
5170
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
5171
+ set: item.asset.priceToSalesRatioTTM
5172
+ } : undefined,
5173
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
5174
+ set: item.asset.priceToBookRatio
5175
+ } : undefined,
5176
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
5177
+ set: item.asset.evToRevenue
5178
+ } : undefined,
5179
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
5180
+ set: item.asset.evToEbitda
5181
+ } : undefined,
5182
+ beta: item.asset.beta !== undefined ? {
5183
+ set: item.asset.beta
5184
+ } : undefined,
5185
+ week52High: item.asset.week52High !== undefined ? {
5186
+ set: item.asset.week52High
5187
+ } : undefined,
5188
+ week52Low: item.asset.week52Low !== undefined ? {
5189
+ set: item.asset.week52Low
5190
+ } : undefined,
5191
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
5192
+ set: item.asset.day50MovingAverage
5193
+ } : undefined,
5194
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
5195
+ set: item.asset.day200MovingAverage
5196
+ } : undefined,
5197
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
5198
+ set: item.asset.sharesOutstanding
5199
+ } : undefined,
5200
+ dividendDate: item.asset.dividendDate !== undefined ? {
5201
+ set: item.asset.dividendDate
5202
+ } : undefined,
5203
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
5204
+ set: item.asset.exDividendDate
5205
+ } : undefined,
5206
+ sellPrice: item.asset.sellPrice !== undefined ? {
5207
+ set: item.asset.sellPrice
5208
+ } : undefined,
5209
+ buyPrice: item.asset.buyPrice !== undefined ? {
5210
+ set: item.asset.buyPrice
5211
+ } : undefined,
5212
+ },
5213
+ create: {
5214
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
5215
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
5216
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
5217
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
5218
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
5219
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
5220
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
5221
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
5222
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
5223
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
5224
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
5225
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
5226
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
5227
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
5228
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
5229
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
5230
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
5231
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
5232
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
5233
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
5234
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
5235
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
5236
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
5237
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
5238
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
5239
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
5240
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
5241
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
5242
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
5243
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
5244
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
5245
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
5246
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
5247
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
5248
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
5249
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
5250
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
5251
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
5252
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
5253
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
5254
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
5255
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
5256
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
5257
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
5258
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
5259
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
5260
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
5261
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
5262
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
5263
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
5264
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
5265
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
5266
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
5267
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
5268
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
5269
+ },
5270
+ }
5271
+ } : undefined,
5272
+ actions: item.actions ? {
5273
+ upsert: item.actions.map((item) => ({
5274
+ where: {
5275
+ id: item.id !== undefined ? item.id : undefined,
5276
+ },
5277
+ update: {
5278
+ id: item.id !== undefined ? {
5279
+ set: item.id
5280
+ } : undefined,
5281
+ sequence: item.sequence !== undefined ? {
5282
+ set: item.sequence
5283
+ } : undefined,
5284
+ type: item.type !== undefined ? {
5285
+ set: item.type
5286
+ } : undefined,
5287
+ note: item.note !== undefined ? {
5288
+ set: item.note
5289
+ } : undefined,
5290
+ status: item.status !== undefined ? {
5291
+ set: item.status
5292
+ } : undefined,
5293
+ fee: item.fee !== undefined ? {
5294
+ set: item.fee
5295
+ } : undefined,
5296
+ },
5297
+ create: {
5298
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
5299
+ type: item.type !== undefined ? item.type : undefined,
5300
+ note: item.note !== undefined ? item.note : undefined,
5301
+ status: item.status !== undefined ? item.status : undefined,
5302
+ fee: item.fee !== undefined ? item.fee : undefined,
5303
+ },
5304
+ }))
5305
+ } : undefined,
2368
5306
  },
2369
5307
  create: {
2370
5308
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -2377,6 +5315,96 @@ exports.Position = {
2377
5315
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2378
5316
  status: item.status !== undefined ? item.status : undefined,
2379
5317
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
5318
+ asset: item.asset ?
5319
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
5320
+ ? { connect: {
5321
+ id: item.asset.id
5322
+ }
5323
+ }
5324
+ : { connectOrCreate: {
5325
+ where: {
5326
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
5327
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
5328
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
5329
+ },
5330
+ create: {
5331
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
5332
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
5333
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
5334
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
5335
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
5336
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
5337
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
5338
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
5339
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
5340
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
5341
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
5342
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
5343
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
5344
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
5345
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
5346
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
5347
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
5348
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
5349
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
5350
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
5351
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
5352
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
5353
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
5354
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
5355
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
5356
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
5357
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
5358
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
5359
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
5360
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
5361
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
5362
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
5363
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
5364
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
5365
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
5366
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
5367
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
5368
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
5369
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
5370
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
5371
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
5372
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
5373
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
5374
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
5375
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
5376
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
5377
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
5378
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
5379
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
5380
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
5381
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
5382
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
5383
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
5384
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
5385
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
5386
+ },
5387
+ }
5388
+ } : undefined,
5389
+ actions: item.actions ?
5390
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5391
+ connect: item.actions.map((item) => ({
5392
+ id: item.id
5393
+ }))
5394
+ }
5395
+ : { connectOrCreate: item.actions.map((item) => ({
5396
+ where: {
5397
+ id: item.id !== undefined ? item.id : undefined,
5398
+ },
5399
+ create: {
5400
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
5401
+ type: item.type !== undefined ? item.type : undefined,
5402
+ note: item.note !== undefined ? item.note : undefined,
5403
+ status: item.status !== undefined ? item.status : undefined,
5404
+ fee: item.fee !== undefined ? item.fee : undefined,
5405
+ },
5406
+ }))
5407
+ } : undefined,
2380
5408
  },
2381
5409
  }))
2382
5410
  } : undefined,
@@ -2437,6 +5465,284 @@ exports.Position = {
2437
5465
  fee: item.fee !== undefined ? {
2438
5466
  set: item.fee
2439
5467
  } : undefined,
5468
+ action: item.action ? {
5469
+ upsert: {
5470
+ where: {
5471
+ id: item.action.id !== undefined ? {
5472
+ equals: item.action.id
5473
+ } : undefined,
5474
+ },
5475
+ update: {
5476
+ id: item.action.id !== undefined ? {
5477
+ set: item.action.id
5478
+ } : undefined,
5479
+ sequence: item.action.sequence !== undefined ? {
5480
+ set: item.action.sequence
5481
+ } : undefined,
5482
+ type: item.action.type !== undefined ? {
5483
+ set: item.action.type
5484
+ } : undefined,
5485
+ note: item.action.note !== undefined ? {
5486
+ set: item.action.note
5487
+ } : undefined,
5488
+ status: item.action.status !== undefined ? {
5489
+ set: item.action.status
5490
+ } : undefined,
5491
+ fee: item.action.fee !== undefined ? {
5492
+ set: item.action.fee
5493
+ } : undefined,
5494
+ },
5495
+ create: {
5496
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
5497
+ type: item.action.type !== undefined ? item.action.type : undefined,
5498
+ note: item.action.note !== undefined ? item.action.note : undefined,
5499
+ status: item.action.status !== undefined ? item.action.status : undefined,
5500
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
5501
+ },
5502
+ }
5503
+ } : undefined,
5504
+ asset: item.asset ? {
5505
+ upsert: {
5506
+ where: {
5507
+ id: item.asset.id !== undefined ? {
5508
+ equals: item.asset.id
5509
+ } : undefined,
5510
+ symbol: item.asset.symbol !== undefined ? {
5511
+ equals: item.asset.symbol
5512
+ } : undefined,
5513
+ name: item.asset.name !== undefined ? {
5514
+ equals: item.asset.name
5515
+ } : undefined,
5516
+ },
5517
+ update: {
5518
+ id: item.asset.id !== undefined ? {
5519
+ set: item.asset.id
5520
+ } : undefined,
5521
+ symbol: item.asset.symbol !== undefined ? {
5522
+ set: item.asset.symbol
5523
+ } : undefined,
5524
+ name: item.asset.name !== undefined ? {
5525
+ set: item.asset.name
5526
+ } : undefined,
5527
+ type: item.asset.type !== undefined ? {
5528
+ set: item.asset.type
5529
+ } : undefined,
5530
+ logoUrl: item.asset.logoUrl !== undefined ? {
5531
+ set: item.asset.logoUrl
5532
+ } : undefined,
5533
+ description: item.asset.description !== undefined ? {
5534
+ set: item.asset.description
5535
+ } : undefined,
5536
+ cik: item.asset.cik !== undefined ? {
5537
+ set: item.asset.cik
5538
+ } : undefined,
5539
+ exchange: item.asset.exchange !== undefined ? {
5540
+ set: item.asset.exchange
5541
+ } : undefined,
5542
+ currency: item.asset.currency !== undefined ? {
5543
+ set: item.asset.currency
5544
+ } : undefined,
5545
+ country: item.asset.country !== undefined ? {
5546
+ set: item.asset.country
5547
+ } : undefined,
5548
+ sector: item.asset.sector !== undefined ? {
5549
+ set: item.asset.sector
5550
+ } : undefined,
5551
+ industry: item.asset.industry !== undefined ? {
5552
+ set: item.asset.industry
5553
+ } : undefined,
5554
+ address: item.asset.address !== undefined ? {
5555
+ set: item.asset.address
5556
+ } : undefined,
5557
+ officialSite: item.asset.officialSite !== undefined ? {
5558
+ set: item.asset.officialSite
5559
+ } : undefined,
5560
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
5561
+ set: item.asset.fiscalYearEnd
5562
+ } : undefined,
5563
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
5564
+ set: item.asset.latestQuarter
5565
+ } : undefined,
5566
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
5567
+ set: item.asset.marketCapitalization
5568
+ } : undefined,
5569
+ ebitda: item.asset.ebitda !== undefined ? {
5570
+ set: item.asset.ebitda
5571
+ } : undefined,
5572
+ peRatio: item.asset.peRatio !== undefined ? {
5573
+ set: item.asset.peRatio
5574
+ } : undefined,
5575
+ pegRatio: item.asset.pegRatio !== undefined ? {
5576
+ set: item.asset.pegRatio
5577
+ } : undefined,
5578
+ bookValue: item.asset.bookValue !== undefined ? {
5579
+ set: item.asset.bookValue
5580
+ } : undefined,
5581
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
5582
+ set: item.asset.dividendPerShare
5583
+ } : undefined,
5584
+ dividendYield: item.asset.dividendYield !== undefined ? {
5585
+ set: item.asset.dividendYield
5586
+ } : undefined,
5587
+ eps: item.asset.eps !== undefined ? {
5588
+ set: item.asset.eps
5589
+ } : undefined,
5590
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
5591
+ set: item.asset.revenuePerShareTTM
5592
+ } : undefined,
5593
+ profitMargin: item.asset.profitMargin !== undefined ? {
5594
+ set: item.asset.profitMargin
5595
+ } : undefined,
5596
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
5597
+ set: item.asset.operatingMarginTTM
5598
+ } : undefined,
5599
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
5600
+ set: item.asset.returnOnAssetsTTM
5601
+ } : undefined,
5602
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
5603
+ set: item.asset.returnOnEquityTTM
5604
+ } : undefined,
5605
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
5606
+ set: item.asset.revenueTTM
5607
+ } : undefined,
5608
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
5609
+ set: item.asset.grossProfitTTM
5610
+ } : undefined,
5611
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
5612
+ set: item.asset.dilutedEPSTTM
5613
+ } : undefined,
5614
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
5615
+ set: item.asset.quarterlyEarningsGrowthYOY
5616
+ } : undefined,
5617
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
5618
+ set: item.asset.quarterlyRevenueGrowthYOY
5619
+ } : undefined,
5620
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
5621
+ set: item.asset.analystTargetPrice
5622
+ } : undefined,
5623
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
5624
+ set: item.asset.analystRatingStrongBuy
5625
+ } : undefined,
5626
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
5627
+ set: item.asset.analystRatingBuy
5628
+ } : undefined,
5629
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
5630
+ set: item.asset.analystRatingHold
5631
+ } : undefined,
5632
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
5633
+ set: item.asset.analystRatingSell
5634
+ } : undefined,
5635
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
5636
+ set: item.asset.analystRatingStrongSell
5637
+ } : undefined,
5638
+ trailingPE: item.asset.trailingPE !== undefined ? {
5639
+ set: item.asset.trailingPE
5640
+ } : undefined,
5641
+ forwardPE: item.asset.forwardPE !== undefined ? {
5642
+ set: item.asset.forwardPE
5643
+ } : undefined,
5644
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
5645
+ set: item.asset.priceToSalesRatioTTM
5646
+ } : undefined,
5647
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
5648
+ set: item.asset.priceToBookRatio
5649
+ } : undefined,
5650
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
5651
+ set: item.asset.evToRevenue
5652
+ } : undefined,
5653
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
5654
+ set: item.asset.evToEbitda
5655
+ } : undefined,
5656
+ beta: item.asset.beta !== undefined ? {
5657
+ set: item.asset.beta
5658
+ } : undefined,
5659
+ week52High: item.asset.week52High !== undefined ? {
5660
+ set: item.asset.week52High
5661
+ } : undefined,
5662
+ week52Low: item.asset.week52Low !== undefined ? {
5663
+ set: item.asset.week52Low
5664
+ } : undefined,
5665
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
5666
+ set: item.asset.day50MovingAverage
5667
+ } : undefined,
5668
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
5669
+ set: item.asset.day200MovingAverage
5670
+ } : undefined,
5671
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
5672
+ set: item.asset.sharesOutstanding
5673
+ } : undefined,
5674
+ dividendDate: item.asset.dividendDate !== undefined ? {
5675
+ set: item.asset.dividendDate
5676
+ } : undefined,
5677
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
5678
+ set: item.asset.exDividendDate
5679
+ } : undefined,
5680
+ sellPrice: item.asset.sellPrice !== undefined ? {
5681
+ set: item.asset.sellPrice
5682
+ } : undefined,
5683
+ buyPrice: item.asset.buyPrice !== undefined ? {
5684
+ set: item.asset.buyPrice
5685
+ } : undefined,
5686
+ },
5687
+ create: {
5688
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
5689
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
5690
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
5691
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
5692
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
5693
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
5694
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
5695
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
5696
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
5697
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
5698
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
5699
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
5700
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
5701
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
5702
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
5703
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
5704
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
5705
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
5706
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
5707
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
5708
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
5709
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
5710
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
5711
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
5712
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
5713
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
5714
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
5715
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
5716
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
5717
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
5718
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
5719
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
5720
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
5721
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
5722
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
5723
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
5724
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
5725
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
5726
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
5727
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
5728
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
5729
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
5730
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
5731
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
5732
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
5733
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
5734
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
5735
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
5736
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
5737
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
5738
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
5739
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
5740
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
5741
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
5742
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
5743
+ },
5744
+ }
5745
+ } : undefined,
2440
5746
  },
2441
5747
  create: {
2442
5748
  qty: item.qty !== undefined ? item.qty : undefined,
@@ -2455,6 +5761,96 @@ exports.Position = {
2455
5761
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2456
5762
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2457
5763
  fee: item.fee !== undefined ? item.fee : undefined,
5764
+ action: item.action ?
5765
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
5766
+ ? { connect: {
5767
+ id: item.action.id
5768
+ }
5769
+ }
5770
+ : { connectOrCreate: {
5771
+ where: {
5772
+ id: item.action.id !== undefined ? item.action.id : undefined,
5773
+ },
5774
+ create: {
5775
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
5776
+ type: item.action.type !== undefined ? item.action.type : undefined,
5777
+ note: item.action.note !== undefined ? item.action.note : undefined,
5778
+ status: item.action.status !== undefined ? item.action.status : undefined,
5779
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
5780
+ },
5781
+ }
5782
+ } : undefined,
5783
+ asset: item.asset ?
5784
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
5785
+ ? { connect: {
5786
+ id: item.asset.id
5787
+ }
5788
+ }
5789
+ : { connectOrCreate: {
5790
+ where: {
5791
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
5792
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
5793
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
5794
+ },
5795
+ create: {
5796
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
5797
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
5798
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
5799
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
5800
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
5801
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
5802
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
5803
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
5804
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
5805
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
5806
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
5807
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
5808
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
5809
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
5810
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
5811
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
5812
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
5813
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
5814
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
5815
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
5816
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
5817
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
5818
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
5819
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
5820
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
5821
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
5822
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
5823
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
5824
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
5825
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
5826
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
5827
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
5828
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
5829
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
5830
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
5831
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
5832
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
5833
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
5834
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
5835
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
5836
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
5837
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
5838
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
5839
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
5840
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
5841
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
5842
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
5843
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
5844
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
5845
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
5846
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
5847
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
5848
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
5849
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
5850
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
5851
+ },
5852
+ }
5853
+ } : undefined,
2458
5854
  },
2459
5855
  }))
2460
5856
  } : undefined,
@@ -2515,16 +5911,96 @@ exports.Position = {
2515
5911
  jobTitle: prop.alpacaAccount.user.jobTitle !== undefined ? prop.alpacaAccount.user.jobTitle : undefined,
2516
5912
  currentAccount: prop.alpacaAccount.user.currentAccount !== undefined ? prop.alpacaAccount.user.currentAccount : undefined,
2517
5913
  plan: prop.alpacaAccount.user.plan !== undefined ? prop.alpacaAccount.user.plan : undefined,
5914
+ customer: prop.alpacaAccount.user.customer ?
5915
+ typeof prop.alpacaAccount.user.customer === 'object' && Object.keys(prop.alpacaAccount.user.customer).length === 1 && Object.keys(prop.alpacaAccount.user.customer)[0] === 'id'
5916
+ ? { connect: {
5917
+ id: prop.alpacaAccount.user.customer.id
5918
+ }
5919
+ }
5920
+ : { connectOrCreate: {
5921
+ where: {
5922
+ id: prop.alpacaAccount.user.customer.id !== undefined ? prop.alpacaAccount.user.customer.id : undefined,
5923
+ name: prop.alpacaAccount.user.customer.name !== undefined ? {
5924
+ equals: prop.alpacaAccount.user.customer.name
5925
+ } : undefined,
5926
+ },
5927
+ create: {
5928
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? prop.alpacaAccount.user.customer.authUserId : undefined,
5929
+ name: prop.alpacaAccount.user.customer.name !== undefined ? prop.alpacaAccount.user.customer.name : undefined,
5930
+ plan: prop.alpacaAccount.user.customer.plan !== undefined ? prop.alpacaAccount.user.customer.plan : undefined,
5931
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? prop.alpacaAccount.user.customer.stripeCustomerId : undefined,
5932
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? prop.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
5933
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? prop.alpacaAccount.user.customer.stripePriceId : undefined,
5934
+ stripeCurrentPeriodEnd: prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd !== undefined ? prop.alpacaAccount.user.customer.stripeCurrentPeriodEnd : undefined,
5935
+ },
5936
+ }
5937
+ } : undefined,
5938
+ accounts: prop.alpacaAccount.user.accounts ?
5939
+ Array.isArray(prop.alpacaAccount.user.accounts) && prop.alpacaAccount.user.accounts.length > 0 && prop.alpacaAccount.user.accounts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5940
+ connect: prop.alpacaAccount.user.accounts.map((item) => ({
5941
+ id: item.id
5942
+ }))
5943
+ }
5944
+ : { connectOrCreate: prop.alpacaAccount.user.accounts.map((item) => ({
5945
+ where: {
5946
+ id: item.id !== undefined ? item.id : undefined,
5947
+ },
5948
+ create: {
5949
+ type: item.type !== undefined ? item.type : undefined,
5950
+ provider: item.provider !== undefined ? item.provider : undefined,
5951
+ providerAccountId: item.providerAccountId !== undefined ? item.providerAccountId : undefined,
5952
+ refresh_token: item.refresh_token !== undefined ? item.refresh_token : undefined,
5953
+ access_token: item.access_token !== undefined ? item.access_token : undefined,
5954
+ expires_at: item.expires_at !== undefined ? item.expires_at : undefined,
5955
+ token_type: item.token_type !== undefined ? item.token_type : undefined,
5956
+ scope: item.scope !== undefined ? item.scope : undefined,
5957
+ id_token: item.id_token !== undefined ? item.id_token : undefined,
5958
+ session_state: item.session_state !== undefined ? item.session_state : undefined,
5959
+ },
5960
+ }))
5961
+ } : undefined,
5962
+ sessions: prop.alpacaAccount.user.sessions ?
5963
+ Array.isArray(prop.alpacaAccount.user.sessions) && prop.alpacaAccount.user.sessions.length > 0 && prop.alpacaAccount.user.sessions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5964
+ connect: prop.alpacaAccount.user.sessions.map((item) => ({
5965
+ id: item.id
5966
+ }))
5967
+ }
5968
+ : { connectOrCreate: prop.alpacaAccount.user.sessions.map((item) => ({
5969
+ where: {
5970
+ id: item.id !== undefined ? item.id : undefined,
5971
+ },
5972
+ create: {
5973
+ sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
5974
+ expires: item.expires !== undefined ? item.expires : undefined,
5975
+ },
5976
+ }))
5977
+ } : undefined,
5978
+ authenticators: prop.alpacaAccount.user.authenticators ?
5979
+ Array.isArray(prop.alpacaAccount.user.authenticators) && prop.alpacaAccount.user.authenticators.length > 0 && prop.alpacaAccount.user.authenticators.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
5980
+ connect: prop.alpacaAccount.user.authenticators.map((item) => ({
5981
+ id: item.id
5982
+ }))
5983
+ }
5984
+ : { connectOrCreate: prop.alpacaAccount.user.authenticators.map((item) => ({
5985
+ where: {
5986
+ id: item.id !== undefined ? item.id : undefined,
5987
+ },
5988
+ create: {
5989
+ credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
5990
+ publicKey: item.publicKey !== undefined ? item.publicKey : undefined,
5991
+ counter: item.counter !== undefined ? item.counter : undefined,
5992
+ },
5993
+ }))
5994
+ } : undefined,
2518
5995
  },
2519
5996
  }
2520
5997
  } : undefined,
2521
5998
  trades: prop.alpacaAccount.trades ?
2522
- Array.isArray(prop.alpacaAccount.trades) && prop.alpacaAccount.trades.length > 0
2523
- ? prop.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2524
- connect: prop.alpacaAccount.trades.map((item) => ({
2525
- id: item.id
2526
- }))
2527
- }
5999
+ Array.isArray(prop.alpacaAccount.trades) && prop.alpacaAccount.trades.length > 0 && prop.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6000
+ connect: prop.alpacaAccount.trades.map((item) => ({
6001
+ id: item.id
6002
+ }))
6003
+ }
2528
6004
  : { connectOrCreate: prop.alpacaAccount.trades.map((item) => ({
2529
6005
  where: {
2530
6006
  id: item.id !== undefined ? item.id : undefined,
@@ -2540,16 +6016,105 @@ exports.Position = {
2540
6016
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2541
6017
  status: item.status !== undefined ? item.status : undefined,
2542
6018
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
6019
+ asset: item.asset ?
6020
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
6021
+ ? { connect: {
6022
+ id: item.asset.id
6023
+ }
6024
+ }
6025
+ : { connectOrCreate: {
6026
+ where: {
6027
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
6028
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
6029
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
6030
+ },
6031
+ create: {
6032
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
6033
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
6034
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
6035
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
6036
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
6037
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
6038
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
6039
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
6040
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
6041
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
6042
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
6043
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
6044
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
6045
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
6046
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
6047
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
6048
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
6049
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
6050
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
6051
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
6052
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
6053
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
6054
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
6055
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
6056
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
6057
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
6058
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
6059
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
6060
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
6061
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
6062
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
6063
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
6064
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
6065
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
6066
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
6067
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
6068
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
6069
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
6070
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
6071
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
6072
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
6073
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
6074
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
6075
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
6076
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
6077
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
6078
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
6079
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
6080
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
6081
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
6082
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
6083
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
6084
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
6085
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
6086
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
6087
+ },
6088
+ }
6089
+ } : undefined,
6090
+ actions: item.actions ?
6091
+ Array.isArray(item.actions) && item.actions.length > 0 && item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6092
+ connect: item.actions.map((item) => ({
6093
+ id: item.id
6094
+ }))
6095
+ }
6096
+ : { connectOrCreate: item.actions.map((item) => ({
6097
+ where: {
6098
+ id: item.id !== undefined ? item.id : undefined,
6099
+ },
6100
+ create: {
6101
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
6102
+ type: item.type !== undefined ? item.type : undefined,
6103
+ note: item.note !== undefined ? item.note : undefined,
6104
+ status: item.status !== undefined ? item.status : undefined,
6105
+ fee: item.fee !== undefined ? item.fee : undefined,
6106
+ },
6107
+ }))
6108
+ } : undefined,
2543
6109
  },
2544
6110
  }))
2545
6111
  } : undefined,
2546
6112
  orders: prop.alpacaAccount.orders ?
2547
- Array.isArray(prop.alpacaAccount.orders) && prop.alpacaAccount.orders.length > 0
2548
- ? prop.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2549
- connect: prop.alpacaAccount.orders.map((item) => ({
2550
- id: item.id
2551
- }))
2552
- }
6113
+ Array.isArray(prop.alpacaAccount.orders) && prop.alpacaAccount.orders.length > 0 && prop.alpacaAccount.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6114
+ connect: prop.alpacaAccount.orders.map((item) => ({
6115
+ id: item.id
6116
+ }))
6117
+ }
2553
6118
  : { connectOrCreate: prop.alpacaAccount.orders.map((item) => ({
2554
6119
  where: {
2555
6120
  id: item.id !== undefined ? item.id : undefined,
@@ -2571,16 +6136,105 @@ exports.Position = {
2571
6136
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2572
6137
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2573
6138
  fee: item.fee !== undefined ? item.fee : undefined,
6139
+ action: item.action ?
6140
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
6141
+ ? { connect: {
6142
+ id: item.action.id
6143
+ }
6144
+ }
6145
+ : { connectOrCreate: {
6146
+ where: {
6147
+ id: item.action.id !== undefined ? item.action.id : undefined,
6148
+ },
6149
+ create: {
6150
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
6151
+ type: item.action.type !== undefined ? item.action.type : undefined,
6152
+ note: item.action.note !== undefined ? item.action.note : undefined,
6153
+ status: item.action.status !== undefined ? item.action.status : undefined,
6154
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
6155
+ },
6156
+ }
6157
+ } : undefined,
6158
+ asset: item.asset ?
6159
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
6160
+ ? { connect: {
6161
+ id: item.asset.id
6162
+ }
6163
+ }
6164
+ : { connectOrCreate: {
6165
+ where: {
6166
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
6167
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
6168
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
6169
+ },
6170
+ create: {
6171
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
6172
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
6173
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
6174
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
6175
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
6176
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
6177
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
6178
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
6179
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
6180
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
6181
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
6182
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
6183
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
6184
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
6185
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
6186
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
6187
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
6188
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
6189
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
6190
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
6191
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
6192
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
6193
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
6194
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
6195
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
6196
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
6197
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
6198
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
6199
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
6200
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
6201
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
6202
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
6203
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
6204
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
6205
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
6206
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
6207
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
6208
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
6209
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
6210
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
6211
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
6212
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
6213
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
6214
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
6215
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
6216
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
6217
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
6218
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
6219
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
6220
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
6221
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
6222
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
6223
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
6224
+ sellPrice: item.asset.sellPrice !== undefined ? item.asset.sellPrice : undefined,
6225
+ buyPrice: item.asset.buyPrice !== undefined ? item.asset.buyPrice : undefined,
6226
+ },
6227
+ }
6228
+ } : undefined,
2574
6229
  },
2575
6230
  }))
2576
6231
  } : undefined,
2577
6232
  alerts: prop.alpacaAccount.alerts ?
2578
- Array.isArray(prop.alpacaAccount.alerts) && prop.alpacaAccount.alerts.length > 0
2579
- ? prop.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2580
- connect: prop.alpacaAccount.alerts.map((item) => ({
2581
- id: item.id
2582
- }))
2583
- }
6233
+ Array.isArray(prop.alpacaAccount.alerts) && prop.alpacaAccount.alerts.length > 0 && prop.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
6234
+ connect: prop.alpacaAccount.alerts.map((item) => ({
6235
+ id: item.id
6236
+ }))
6237
+ }
2584
6238
  : { connectOrCreate: prop.alpacaAccount.alerts.map((item) => ({
2585
6239
  where: {
2586
6240
  id: item.id !== undefined ? item.id : undefined,