adaptic-backend 1.0.75 → 1.0.77

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 +264 -190
  2. package/Action.cjs +594 -524
  3. package/Alert.cjs +352 -278
  4. package/AlpacaAccount.cjs +1197 -1021
  5. package/Asset.cjs +485 -368
  6. package/Authenticator.cjs +285 -211
  7. package/Customer.cjs +268 -190
  8. package/NewsArticle.cjs +233 -212
  9. package/NewsArticleAssetSentiment.cjs +354 -290
  10. package/Order.cjs +694 -541
  11. package/Position.cjs +621 -488
  12. package/Session.cjs +288 -214
  13. package/Trade.cjs +767 -613
  14. package/User.cjs +410 -309
  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 +264 -190
  19. package/server/Action.d.ts.map +1 -1
  20. package/server/Action.js.map +1 -1
  21. package/server/Action.mjs +594 -524
  22. package/server/Alert.d.ts.map +1 -1
  23. package/server/Alert.js.map +1 -1
  24. package/server/Alert.mjs +352 -278
  25. package/server/AlpacaAccount.d.ts.map +1 -1
  26. package/server/AlpacaAccount.js.map +1 -1
  27. package/server/AlpacaAccount.mjs +1197 -1021
  28. package/server/Asset.d.ts.map +1 -1
  29. package/server/Asset.js.map +1 -1
  30. package/server/Asset.mjs +485 -368
  31. package/server/Authenticator.d.ts.map +1 -1
  32. package/server/Authenticator.js.map +1 -1
  33. package/server/Authenticator.mjs +285 -211
  34. package/server/Customer.d.ts.map +1 -1
  35. package/server/Customer.js.map +1 -1
  36. package/server/Customer.mjs +268 -190
  37. package/server/NewsArticle.d.ts.map +1 -1
  38. package/server/NewsArticle.js.map +1 -1
  39. package/server/NewsArticle.mjs +233 -212
  40. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  41. package/server/NewsArticleAssetSentiment.js.map +1 -1
  42. package/server/NewsArticleAssetSentiment.mjs +354 -290
  43. package/server/Order.d.ts.map +1 -1
  44. package/server/Order.js.map +1 -1
  45. package/server/Order.mjs +694 -541
  46. package/server/Position.d.ts.map +1 -1
  47. package/server/Position.js.map +1 -1
  48. package/server/Position.mjs +621 -488
  49. package/server/Session.d.ts.map +1 -1
  50. package/server/Session.js.map +1 -1
  51. package/server/Session.mjs +288 -214
  52. package/server/Trade.d.ts.map +1 -1
  53. package/server/Trade.js.map +1 -1
  54. package/server/Trade.mjs +767 -613
  55. package/server/User.d.ts.map +1 -1
  56. package/server/User.js.map +1 -1
  57. package/server/User.mjs +410 -309
package/server/Asset.mjs CHANGED
@@ -321,182 +321,237 @@ export const Asset = {
321
321
  exDividendDate: props.exDividendDate !== undefined ? props.exDividendDate : undefined,
322
322
  sellPrice: props.sellPrice !== undefined ? props.sellPrice : undefined,
323
323
  buyPrice: props.buyPrice !== undefined ? props.buyPrice : undefined,
324
- trades: props.trades ? {
325
- connectOrCreate: props.trades.map((item) => ({
326
- where: {
327
- id: item.id !== undefined ? item.id : undefined,
328
- },
329
- create: {
330
- qty: item.qty !== undefined ? item.qty : undefined,
331
- price: item.price !== undefined ? item.price : undefined,
332
- total: item.total !== undefined ? item.total : undefined,
333
- signal: item.signal !== undefined ? item.signal : undefined,
334
- strategy: item.strategy !== undefined ? item.strategy : undefined,
335
- analysis: item.analysis !== undefined ? item.analysis : undefined,
336
- confidence: item.confidence !== undefined ? item.confidence : undefined,
337
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
338
- status: item.status !== undefined ? item.status : undefined,
339
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
340
- alpacaAccount: item.alpacaAccount ? {
341
- connectOrCreate: {
342
- where: {
343
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
344
- },
345
- create: {
346
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
347
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
348
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
349
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
350
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
351
- },
352
- }
353
- } : undefined,
354
- actions: item.actions ? {
355
- connectOrCreate: item.actions.map((item) => ({
356
- where: {
357
- id: item.id !== undefined ? item.id : undefined,
358
- },
359
- create: {
360
- sequence: item.sequence !== undefined ? item.sequence : undefined,
361
- type: item.type !== undefined ? item.type : undefined,
362
- note: item.note !== undefined ? item.note : undefined,
363
- status: item.status !== undefined ? item.status : undefined,
364
- fee: item.fee !== undefined ? item.fee : undefined,
365
- },
366
- }))
367
- } : undefined,
368
- },
369
- }))
370
- } : undefined,
371
- orders: props.orders ? {
372
- connectOrCreate: props.orders.map((item) => ({
373
- where: {
374
- id: item.id !== undefined ? item.id : undefined,
375
- },
376
- create: {
377
- qty: item.qty !== undefined ? item.qty : undefined,
378
- notional: item.notional !== undefined ? item.notional : undefined,
379
- side: item.side !== undefined ? item.side : undefined,
380
- type: item.type !== undefined ? item.type : undefined,
381
- timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
382
- limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
383
- stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
384
- trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
385
- trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
386
- extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
387
- clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
388
- status: item.status !== undefined ? item.status : undefined,
389
- submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
390
- filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
391
- filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
392
- fee: item.fee !== undefined ? item.fee : undefined,
393
- alpacaAccount: item.alpacaAccount ? {
394
- connectOrCreate: {
395
- where: {
396
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
397
- },
398
- create: {
399
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
400
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
401
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
402
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
403
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
404
- },
405
- }
406
- } : undefined,
407
- action: item.action ? {
408
- connectOrCreate: {
409
- where: {
410
- id: item.action.id !== undefined ? item.action.id : undefined,
411
- },
412
- create: {
413
- sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
414
- type: item.action.type !== undefined ? item.action.type : undefined,
415
- note: item.action.note !== undefined ? item.action.note : undefined,
416
- status: item.action.status !== undefined ? item.action.status : undefined,
417
- fee: item.action.fee !== undefined ? item.action.fee : undefined,
418
- },
419
- }
420
- } : undefined,
421
- },
422
- }))
423
- } : undefined,
424
- positions: props.positions ? {
425
- connectOrCreate: props.positions.map((item) => ({
426
- where: {
427
- id: item.id !== undefined ? item.id : undefined,
428
- },
429
- create: {
430
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
431
- qty: item.qty !== undefined ? item.qty : undefined,
432
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
433
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
434
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
435
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
436
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
437
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
438
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
439
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
440
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
441
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
442
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
443
- alpacaAccount: item.alpacaAccount ? {
444
- connectOrCreate: {
445
- where: {
446
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
447
- },
448
- create: {
449
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
450
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
451
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
452
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
453
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
454
- },
455
- }
456
- } : undefined,
457
- },
458
- }))
459
- } : undefined,
460
- newsMentions: props.newsMentions ? {
461
- connectOrCreate: props.newsMentions.map((item) => ({
462
- where: {
463
- id: item.id !== undefined ? item.id : undefined,
464
- url: item.url !== undefined ? item.url : undefined,
465
- },
466
- create: {
467
- url: item.url !== undefined ? item.url : undefined,
468
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
469
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
470
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
471
- news: item.news ? {
472
- connectOrCreate: {
473
- where: {
474
- id: item.news.id !== undefined ? item.news.id : undefined,
475
- url: item.news.url !== undefined ? item.news.url : undefined,
476
- title: item.news.title !== undefined ? {
477
- equals: item.news.title
478
- } : undefined,
479
- },
480
- create: {
481
- title: item.news.title !== undefined ? item.news.title : undefined,
482
- content: item.news.content !== undefined ? item.news.content : undefined,
483
- source: item.news.source !== undefined ? item.news.source : undefined,
484
- sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
485
- url: item.news.url !== undefined ? item.news.url : undefined,
486
- sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
487
- authors: item.news.authors !== undefined ? item.news.authors : undefined,
488
- summary: item.news.summary !== undefined ? item.news.summary : undefined,
489
- bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
490
- timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
491
- category: item.news.category !== undefined ? item.news.category : undefined,
492
- topics: item.news.topics !== undefined ? item.news.topics : undefined,
493
- logo: item.news.logo !== undefined ? item.news.logo : undefined,
494
- },
495
- }
496
- } : undefined,
497
- },
498
- }))
499
- } : undefined,
324
+ trades: props.trades ?
325
+ Array.isArray(props.trades) && props.trades.length > 0
326
+ ? props.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
327
+ connect: props.trades.map((item) => ({
328
+ id: item.id
329
+ }))
330
+ }
331
+ : { connectOrCreate: props.trades.map((item) => ({
332
+ where: {
333
+ id: item.id !== undefined ? item.id : undefined,
334
+ },
335
+ create: {
336
+ qty: item.qty !== undefined ? item.qty : undefined,
337
+ price: item.price !== undefined ? item.price : undefined,
338
+ total: item.total !== undefined ? item.total : undefined,
339
+ signal: item.signal !== undefined ? item.signal : undefined,
340
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
341
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
342
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
343
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
344
+ status: item.status !== undefined ? item.status : undefined,
345
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
346
+ alpacaAccount: item.alpacaAccount ?
347
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
348
+ ? { connect: {
349
+ id: item.alpacaAccount.id
350
+ }
351
+ }
352
+ : { connectOrCreate: {
353
+ where: {
354
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
355
+ },
356
+ create: {
357
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
358
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
359
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
360
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
361
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
362
+ },
363
+ }
364
+ } : undefined,
365
+ actions: item.actions ?
366
+ Array.isArray(item.actions) && item.actions.length > 0
367
+ ? item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
368
+ connect: item.actions.map((item) => ({
369
+ id: item.id
370
+ }))
371
+ }
372
+ : { connectOrCreate: item.actions.map((item) => ({
373
+ where: {
374
+ id: item.id !== undefined ? item.id : undefined,
375
+ },
376
+ create: {
377
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
378
+ type: item.type !== undefined ? item.type : undefined,
379
+ note: item.note !== undefined ? item.note : undefined,
380
+ status: item.status !== undefined ? item.status : undefined,
381
+ fee: item.fee !== undefined ? item.fee : undefined,
382
+ },
383
+ }))
384
+ } : undefined,
385
+ },
386
+ }))
387
+ } : undefined,
388
+ orders: props.orders ?
389
+ Array.isArray(props.orders) && props.orders.length > 0
390
+ ? props.orders.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
391
+ connect: props.orders.map((item) => ({
392
+ id: item.id
393
+ }))
394
+ }
395
+ : { connectOrCreate: props.orders.map((item) => ({
396
+ where: {
397
+ id: item.id !== undefined ? item.id : undefined,
398
+ },
399
+ create: {
400
+ qty: item.qty !== undefined ? item.qty : undefined,
401
+ notional: item.notional !== undefined ? item.notional : undefined,
402
+ side: item.side !== undefined ? item.side : undefined,
403
+ type: item.type !== undefined ? item.type : undefined,
404
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
405
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
406
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
407
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
408
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
409
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
410
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
411
+ status: item.status !== undefined ? item.status : undefined,
412
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
413
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
414
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
415
+ fee: item.fee !== undefined ? item.fee : undefined,
416
+ alpacaAccount: item.alpacaAccount ?
417
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
418
+ ? { connect: {
419
+ id: item.alpacaAccount.id
420
+ }
421
+ }
422
+ : { connectOrCreate: {
423
+ where: {
424
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
425
+ },
426
+ create: {
427
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
428
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
429
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
430
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
431
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
432
+ },
433
+ }
434
+ } : undefined,
435
+ action: item.action ?
436
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
437
+ ? { connect: {
438
+ id: item.action.id
439
+ }
440
+ }
441
+ : { connectOrCreate: {
442
+ where: {
443
+ id: item.action.id !== undefined ? item.action.id : undefined,
444
+ },
445
+ create: {
446
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
447
+ type: item.action.type !== undefined ? item.action.type : undefined,
448
+ note: item.action.note !== undefined ? item.action.note : undefined,
449
+ status: item.action.status !== undefined ? item.action.status : undefined,
450
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
451
+ },
452
+ }
453
+ } : undefined,
454
+ },
455
+ }))
456
+ } : undefined,
457
+ positions: props.positions ?
458
+ Array.isArray(props.positions) && props.positions.length > 0
459
+ ? props.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
460
+ connect: props.positions.map((item) => ({
461
+ id: item.id
462
+ }))
463
+ }
464
+ : { connectOrCreate: props.positions.map((item) => ({
465
+ where: {
466
+ id: item.id !== undefined ? item.id : undefined,
467
+ },
468
+ create: {
469
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
470
+ qty: item.qty !== undefined ? item.qty : undefined,
471
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
472
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
473
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
474
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
475
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
476
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
477
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
478
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
479
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
480
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
481
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
482
+ alpacaAccount: item.alpacaAccount ?
483
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
484
+ ? { connect: {
485
+ id: item.alpacaAccount.id
486
+ }
487
+ }
488
+ : { connectOrCreate: {
489
+ where: {
490
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
491
+ },
492
+ create: {
493
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
494
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
495
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
496
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
497
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
498
+ },
499
+ }
500
+ } : undefined,
501
+ },
502
+ }))
503
+ } : undefined,
504
+ newsMentions: props.newsMentions ?
505
+ Array.isArray(props.newsMentions) && props.newsMentions.length > 0
506
+ ? props.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
507
+ connect: props.newsMentions.map((item) => ({
508
+ id: item.id
509
+ }))
510
+ }
511
+ : { connectOrCreate: props.newsMentions.map((item) => ({
512
+ where: {
513
+ id: item.id !== undefined ? item.id : undefined,
514
+ url: item.url !== undefined ? item.url : undefined,
515
+ },
516
+ create: {
517
+ url: item.url !== undefined ? item.url : undefined,
518
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
519
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
520
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
521
+ news: item.news ?
522
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
523
+ ? { connect: {
524
+ id: item.news.id
525
+ }
526
+ }
527
+ : { connectOrCreate: {
528
+ where: {
529
+ id: item.news.id !== undefined ? item.news.id : undefined,
530
+ url: item.news.url !== undefined ? item.news.url : undefined,
531
+ title: item.news.title !== undefined ? {
532
+ equals: item.news.title
533
+ } : undefined,
534
+ },
535
+ create: {
536
+ title: item.news.title !== undefined ? item.news.title : undefined,
537
+ content: item.news.content !== undefined ? item.news.content : undefined,
538
+ source: item.news.source !== undefined ? item.news.source : undefined,
539
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
540
+ url: item.news.url !== undefined ? item.news.url : undefined,
541
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
542
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
543
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
544
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
545
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
546
+ category: item.news.category !== undefined ? item.news.category : undefined,
547
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
548
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
549
+ },
550
+ }
551
+ } : undefined,
552
+ },
553
+ }))
554
+ } : undefined,
500
555
  },
501
556
  };
502
557
  const filteredVariables = removeUndefinedProps(variables);
@@ -1164,34 +1219,45 @@ export const Asset = {
1164
1219
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1165
1220
  status: item.status !== undefined ? item.status : undefined,
1166
1221
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1167
- alpacaAccount: item.alpacaAccount ? {
1168
- connectOrCreate: {
1169
- where: {
1170
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1171
- },
1172
- create: {
1173
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1174
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1175
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1176
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1177
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1178
- },
1179
- }
1180
- } : undefined,
1181
- actions: item.actions ? {
1182
- connectOrCreate: item.actions.map((item) => ({
1183
- where: {
1184
- id: item.id !== undefined ? item.id : undefined,
1185
- },
1186
- create: {
1187
- sequence: item.sequence !== undefined ? item.sequence : undefined,
1188
- type: item.type !== undefined ? item.type : undefined,
1189
- note: item.note !== undefined ? item.note : undefined,
1190
- status: item.status !== undefined ? item.status : undefined,
1191
- fee: item.fee !== undefined ? item.fee : undefined,
1192
- },
1193
- }))
1194
- } : undefined,
1222
+ alpacaAccount: item.alpacaAccount ?
1223
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1224
+ ? { connect: {
1225
+ id: item.alpacaAccount.id
1226
+ }
1227
+ }
1228
+ : { connectOrCreate: {
1229
+ where: {
1230
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1231
+ },
1232
+ create: {
1233
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1234
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1235
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1236
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1237
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1238
+ },
1239
+ }
1240
+ } : undefined,
1241
+ actions: item.actions ?
1242
+ Array.isArray(item.actions) && item.actions.length > 0
1243
+ ? item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1244
+ connect: item.actions.map((item) => ({
1245
+ id: item.id
1246
+ }))
1247
+ }
1248
+ : { connectOrCreate: item.actions.map((item) => ({
1249
+ where: {
1250
+ id: item.id !== undefined ? item.id : undefined,
1251
+ },
1252
+ create: {
1253
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
1254
+ type: item.type !== undefined ? item.type : undefined,
1255
+ note: item.note !== undefined ? item.note : undefined,
1256
+ status: item.status !== undefined ? item.status : undefined,
1257
+ fee: item.fee !== undefined ? item.fee : undefined,
1258
+ },
1259
+ }))
1260
+ } : undefined,
1195
1261
  },
1196
1262
  }))
1197
1263
  } : undefined,
@@ -1342,34 +1408,44 @@ export const Asset = {
1342
1408
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1343
1409
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1344
1410
  fee: item.fee !== undefined ? item.fee : undefined,
1345
- alpacaAccount: item.alpacaAccount ? {
1346
- connectOrCreate: {
1347
- where: {
1348
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1349
- },
1350
- create: {
1351
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1352
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1353
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1354
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1355
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1356
- },
1357
- }
1358
- } : undefined,
1359
- action: item.action ? {
1360
- connectOrCreate: {
1361
- where: {
1362
- id: item.action.id !== undefined ? item.action.id : undefined,
1363
- },
1364
- create: {
1365
- sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
1366
- type: item.action.type !== undefined ? item.action.type : undefined,
1367
- note: item.action.note !== undefined ? item.action.note : undefined,
1368
- status: item.action.status !== undefined ? item.action.status : undefined,
1369
- fee: item.action.fee !== undefined ? item.action.fee : undefined,
1370
- },
1371
- }
1372
- } : undefined,
1411
+ alpacaAccount: item.alpacaAccount ?
1412
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1413
+ ? { connect: {
1414
+ id: item.alpacaAccount.id
1415
+ }
1416
+ }
1417
+ : { connectOrCreate: {
1418
+ where: {
1419
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1420
+ },
1421
+ create: {
1422
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1423
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1424
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1425
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1426
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1427
+ },
1428
+ }
1429
+ } : undefined,
1430
+ action: item.action ?
1431
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
1432
+ ? { connect: {
1433
+ id: item.action.id
1434
+ }
1435
+ }
1436
+ : { connectOrCreate: {
1437
+ where: {
1438
+ id: item.action.id !== undefined ? item.action.id : undefined,
1439
+ },
1440
+ create: {
1441
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
1442
+ type: item.action.type !== undefined ? item.action.type : undefined,
1443
+ note: item.action.note !== undefined ? item.action.note : undefined,
1444
+ status: item.action.status !== undefined ? item.action.status : undefined,
1445
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
1446
+ },
1447
+ }
1448
+ } : undefined,
1373
1449
  },
1374
1450
  }))
1375
1451
  } : undefined,
@@ -1472,20 +1548,25 @@ export const Asset = {
1472
1548
  lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1473
1549
  changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1474
1550
  assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1475
- alpacaAccount: item.alpacaAccount ? {
1476
- connectOrCreate: {
1477
- where: {
1478
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1479
- },
1480
- create: {
1481
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1482
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1483
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1484
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1485
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1486
- },
1487
- }
1488
- } : undefined,
1551
+ alpacaAccount: item.alpacaAccount ?
1552
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1553
+ ? { connect: {
1554
+ id: item.alpacaAccount.id
1555
+ }
1556
+ }
1557
+ : { connectOrCreate: {
1558
+ where: {
1559
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1560
+ },
1561
+ create: {
1562
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1563
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1564
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1565
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1566
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1567
+ },
1568
+ }
1569
+ } : undefined,
1489
1570
  },
1490
1571
  }))
1491
1572
  } : undefined,
@@ -1591,32 +1672,37 @@ export const Asset = {
1591
1672
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1592
1673
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1593
1674
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1594
- news: item.news ? {
1595
- connectOrCreate: {
1596
- where: {
1597
- id: item.news.id !== undefined ? item.news.id : undefined,
1598
- url: item.news.url !== undefined ? item.news.url : undefined,
1599
- title: item.news.title !== undefined ? {
1600
- equals: item.news.title
1601
- } : undefined,
1602
- },
1603
- create: {
1604
- title: item.news.title !== undefined ? item.news.title : undefined,
1605
- content: item.news.content !== undefined ? item.news.content : undefined,
1606
- source: item.news.source !== undefined ? item.news.source : undefined,
1607
- sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
1608
- url: item.news.url !== undefined ? item.news.url : undefined,
1609
- sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
1610
- authors: item.news.authors !== undefined ? item.news.authors : undefined,
1611
- summary: item.news.summary !== undefined ? item.news.summary : undefined,
1612
- bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
1613
- timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
1614
- category: item.news.category !== undefined ? item.news.category : undefined,
1615
- topics: item.news.topics !== undefined ? item.news.topics : undefined,
1616
- logo: item.news.logo !== undefined ? item.news.logo : undefined,
1617
- },
1618
- }
1619
- } : undefined,
1675
+ news: item.news ?
1676
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
1677
+ ? { connect: {
1678
+ id: item.news.id
1679
+ }
1680
+ }
1681
+ : { connectOrCreate: {
1682
+ where: {
1683
+ id: item.news.id !== undefined ? item.news.id : undefined,
1684
+ url: item.news.url !== undefined ? item.news.url : undefined,
1685
+ title: item.news.title !== undefined ? {
1686
+ equals: item.news.title
1687
+ } : undefined,
1688
+ },
1689
+ create: {
1690
+ title: item.news.title !== undefined ? item.news.title : undefined,
1691
+ content: item.news.content !== undefined ? item.news.content : undefined,
1692
+ source: item.news.source !== undefined ? item.news.source : undefined,
1693
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
1694
+ url: item.news.url !== undefined ? item.news.url : undefined,
1695
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
1696
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
1697
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
1698
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
1699
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
1700
+ category: item.news.category !== undefined ? item.news.category : undefined,
1701
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
1702
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
1703
+ },
1704
+ }
1705
+ } : undefined,
1620
1706
  },
1621
1707
  }))
1622
1708
  } : undefined,
@@ -1954,34 +2040,45 @@ export const Asset = {
1954
2040
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1955
2041
  status: item.status !== undefined ? item.status : undefined,
1956
2042
  optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1957
- alpacaAccount: item.alpacaAccount ? {
1958
- connectOrCreate: {
1959
- where: {
1960
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1961
- },
1962
- create: {
1963
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1964
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1965
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1966
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1967
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1968
- },
1969
- }
1970
- } : undefined,
1971
- actions: item.actions ? {
1972
- connectOrCreate: item.actions.map((item) => ({
1973
- where: {
1974
- id: item.id !== undefined ? item.id : undefined,
1975
- },
1976
- create: {
1977
- sequence: item.sequence !== undefined ? item.sequence : undefined,
1978
- type: item.type !== undefined ? item.type : undefined,
1979
- note: item.note !== undefined ? item.note : undefined,
1980
- status: item.status !== undefined ? item.status : undefined,
1981
- fee: item.fee !== undefined ? item.fee : undefined,
1982
- },
1983
- }))
1984
- } : undefined,
2043
+ alpacaAccount: item.alpacaAccount ?
2044
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2045
+ ? { connect: {
2046
+ id: item.alpacaAccount.id
2047
+ }
2048
+ }
2049
+ : { connectOrCreate: {
2050
+ where: {
2051
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2052
+ },
2053
+ create: {
2054
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2055
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2056
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2057
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2058
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2059
+ },
2060
+ }
2061
+ } : undefined,
2062
+ actions: item.actions ?
2063
+ Array.isArray(item.actions) && item.actions.length > 0
2064
+ ? item.actions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2065
+ connect: item.actions.map((item) => ({
2066
+ id: item.id
2067
+ }))
2068
+ }
2069
+ : { connectOrCreate: item.actions.map((item) => ({
2070
+ where: {
2071
+ id: item.id !== undefined ? item.id : undefined,
2072
+ },
2073
+ create: {
2074
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
2075
+ type: item.type !== undefined ? item.type : undefined,
2076
+ note: item.note !== undefined ? item.note : undefined,
2077
+ status: item.status !== undefined ? item.status : undefined,
2078
+ fee: item.fee !== undefined ? item.fee : undefined,
2079
+ },
2080
+ }))
2081
+ } : undefined,
1985
2082
  },
1986
2083
  }))
1987
2084
  } : undefined,
@@ -2132,34 +2229,44 @@ export const Asset = {
2132
2229
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2133
2230
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2134
2231
  fee: item.fee !== undefined ? item.fee : undefined,
2135
- alpacaAccount: item.alpacaAccount ? {
2136
- connectOrCreate: {
2137
- where: {
2138
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2139
- },
2140
- create: {
2141
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2142
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2143
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2144
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2145
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2146
- },
2147
- }
2148
- } : undefined,
2149
- action: item.action ? {
2150
- connectOrCreate: {
2151
- where: {
2152
- id: item.action.id !== undefined ? item.action.id : undefined,
2153
- },
2154
- create: {
2155
- sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
2156
- type: item.action.type !== undefined ? item.action.type : undefined,
2157
- note: item.action.note !== undefined ? item.action.note : undefined,
2158
- status: item.action.status !== undefined ? item.action.status : undefined,
2159
- fee: item.action.fee !== undefined ? item.action.fee : undefined,
2160
- },
2161
- }
2162
- } : undefined,
2232
+ alpacaAccount: item.alpacaAccount ?
2233
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2234
+ ? { connect: {
2235
+ id: item.alpacaAccount.id
2236
+ }
2237
+ }
2238
+ : { connectOrCreate: {
2239
+ where: {
2240
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2241
+ },
2242
+ create: {
2243
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2244
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2245
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2246
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2247
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2248
+ },
2249
+ }
2250
+ } : undefined,
2251
+ action: item.action ?
2252
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
2253
+ ? { connect: {
2254
+ id: item.action.id
2255
+ }
2256
+ }
2257
+ : { connectOrCreate: {
2258
+ where: {
2259
+ id: item.action.id !== undefined ? item.action.id : undefined,
2260
+ },
2261
+ create: {
2262
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
2263
+ type: item.action.type !== undefined ? item.action.type : undefined,
2264
+ note: item.action.note !== undefined ? item.action.note : undefined,
2265
+ status: item.action.status !== undefined ? item.action.status : undefined,
2266
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
2267
+ },
2268
+ }
2269
+ } : undefined,
2163
2270
  },
2164
2271
  }))
2165
2272
  } : undefined,
@@ -2262,20 +2369,25 @@ export const Asset = {
2262
2369
  lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2263
2370
  changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2264
2371
  assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2265
- alpacaAccount: item.alpacaAccount ? {
2266
- connectOrCreate: {
2267
- where: {
2268
- id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2269
- },
2270
- create: {
2271
- type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2272
- APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2273
- APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2274
- configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2275
- marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2276
- },
2277
- }
2278
- } : undefined,
2372
+ alpacaAccount: item.alpacaAccount ?
2373
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2374
+ ? { connect: {
2375
+ id: item.alpacaAccount.id
2376
+ }
2377
+ }
2378
+ : { connectOrCreate: {
2379
+ where: {
2380
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2381
+ },
2382
+ create: {
2383
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2384
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2385
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2386
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2387
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2388
+ },
2389
+ }
2390
+ } : undefined,
2279
2391
  },
2280
2392
  }))
2281
2393
  } : undefined,
@@ -2381,32 +2493,37 @@ export const Asset = {
2381
2493
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2382
2494
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2383
2495
  sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
2384
- news: item.news ? {
2385
- connectOrCreate: {
2386
- where: {
2387
- id: item.news.id !== undefined ? item.news.id : undefined,
2388
- url: item.news.url !== undefined ? item.news.url : undefined,
2389
- title: item.news.title !== undefined ? {
2390
- equals: item.news.title
2391
- } : undefined,
2392
- },
2393
- create: {
2394
- title: item.news.title !== undefined ? item.news.title : undefined,
2395
- content: item.news.content !== undefined ? item.news.content : undefined,
2396
- source: item.news.source !== undefined ? item.news.source : undefined,
2397
- sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
2398
- url: item.news.url !== undefined ? item.news.url : undefined,
2399
- sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
2400
- authors: item.news.authors !== undefined ? item.news.authors : undefined,
2401
- summary: item.news.summary !== undefined ? item.news.summary : undefined,
2402
- bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
2403
- timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
2404
- category: item.news.category !== undefined ? item.news.category : undefined,
2405
- topics: item.news.topics !== undefined ? item.news.topics : undefined,
2406
- logo: item.news.logo !== undefined ? item.news.logo : undefined,
2407
- },
2408
- }
2409
- } : undefined,
2496
+ news: item.news ?
2497
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
2498
+ ? { connect: {
2499
+ id: item.news.id
2500
+ }
2501
+ }
2502
+ : { connectOrCreate: {
2503
+ where: {
2504
+ id: item.news.id !== undefined ? item.news.id : undefined,
2505
+ url: item.news.url !== undefined ? item.news.url : undefined,
2506
+ title: item.news.title !== undefined ? {
2507
+ equals: item.news.title
2508
+ } : undefined,
2509
+ },
2510
+ create: {
2511
+ title: item.news.title !== undefined ? item.news.title : undefined,
2512
+ content: item.news.content !== undefined ? item.news.content : undefined,
2513
+ source: item.news.source !== undefined ? item.news.source : undefined,
2514
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
2515
+ url: item.news.url !== undefined ? item.news.url : undefined,
2516
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
2517
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
2518
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
2519
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
2520
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
2521
+ category: item.news.category !== undefined ? item.news.category : undefined,
2522
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
2523
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
2524
+ },
2525
+ }
2526
+ } : undefined,
2410
2527
  },
2411
2528
  }))
2412
2529
  } : undefined,