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