adaptic-backend 1.0.75 → 1.0.76

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 +255 -190
  2. package/Action.cjs +594 -524
  3. package/Alert.cjs +343 -278
  4. package/AlpacaAccount.cjs +1181 -1021
  5. package/Asset.cjs +478 -368
  6. package/Authenticator.cjs +276 -211
  7. package/Customer.cjs +255 -190
  8. package/NewsArticle.cjs +232 -212
  9. package/NewsArticleAssetSentiment.cjs +345 -290
  10. package/Order.cjs +676 -541
  11. package/Position.cjs +603 -488
  12. package/Session.cjs +279 -214
  13. package/Trade.cjs +748 -613
  14. package/User.cjs +394 -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 +255 -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 +343 -278
  25. package/server/AlpacaAccount.d.ts.map +1 -1
  26. package/server/AlpacaAccount.js.map +1 -1
  27. package/server/AlpacaAccount.mjs +1181 -1021
  28. package/server/Asset.d.ts.map +1 -1
  29. package/server/Asset.js.map +1 -1
  30. package/server/Asset.mjs +478 -368
  31. package/server/Authenticator.d.ts.map +1 -1
  32. package/server/Authenticator.js.map +1 -1
  33. package/server/Authenticator.mjs +276 -211
  34. package/server/Customer.d.ts.map +1 -1
  35. package/server/Customer.js.map +1 -1
  36. package/server/Customer.mjs +255 -190
  37. package/server/NewsArticle.d.ts.map +1 -1
  38. package/server/NewsArticle.js.map +1 -1
  39. package/server/NewsArticle.mjs +232 -212
  40. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  41. package/server/NewsArticleAssetSentiment.js.map +1 -1
  42. package/server/NewsArticleAssetSentiment.mjs +345 -290
  43. package/server/Order.d.ts.map +1 -1
  44. package/server/Order.js.map +1 -1
  45. package/server/Order.mjs +676 -541
  46. package/server/Position.d.ts.map +1 -1
  47. package/server/Position.js.map +1 -1
  48. package/server/Position.mjs +603 -488
  49. package/server/Session.d.ts.map +1 -1
  50. package/server/Session.js.map +1 -1
  51. package/server/Session.mjs +279 -214
  52. package/server/Trade.d.ts.map +1 -1
  53. package/server/Trade.js.map +1 -1
  54. package/server/Trade.mjs +748 -613
  55. package/server/User.d.ts.map +1 -1
  56. package/server/User.js.map +1 -1
  57. package/server/User.mjs +394 -309
package/Asset.cjs CHANGED
@@ -323,182 +323,232 @@ 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
+ typeof props.trades[0] === 'object' && Object.keys(props.trades).length === 1 && Object.keys(props.trades)[0] === 'id'
328
+ ? { connect: props.trades.map((item) => ({
329
+ id: item.id
330
+ }))
331
+ }
332
+ : { connectOrCreate: props.trades.map((item) => ({
333
+ where: {
334
+ id: item.id !== undefined ? item.id : undefined,
335
+ },
336
+ create: {
337
+ qty: item.qty !== undefined ? item.qty : undefined,
338
+ price: item.price !== undefined ? item.price : undefined,
339
+ total: item.total !== undefined ? item.total : undefined,
340
+ signal: item.signal !== undefined ? item.signal : undefined,
341
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
342
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
343
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
344
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
345
+ status: item.status !== undefined ? item.status : undefined,
346
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
347
+ alpacaAccount: item.alpacaAccount ?
348
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
349
+ ? { connect: {
350
+ id: item.alpacaAccount.id
351
+ }
352
+ }
353
+ : { connectOrCreate: {
354
+ where: {
355
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
356
+ },
357
+ create: {
358
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
359
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
360
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
361
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
362
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
363
+ },
364
+ }
365
+ } : undefined,
366
+ actions: item.actions ?
367
+ typeof item.actions[0] === 'object' && Object.keys(item.actions).length === 1 && Object.keys(item.actions)[0] === 'id'
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
+ typeof props.orders[0] === 'object' && Object.keys(props.orders).length === 1 && Object.keys(props.orders)[0] === 'id'
390
+ ? { connect: props.orders.map((item) => ({
391
+ id: item.id
392
+ }))
393
+ }
394
+ : { connectOrCreate: props.orders.map((item) => ({
395
+ where: {
396
+ id: item.id !== undefined ? item.id : undefined,
397
+ },
398
+ create: {
399
+ qty: item.qty !== undefined ? item.qty : undefined,
400
+ notional: item.notional !== undefined ? item.notional : undefined,
401
+ side: item.side !== undefined ? item.side : undefined,
402
+ type: item.type !== undefined ? item.type : undefined,
403
+ timeInForce: item.timeInForce !== undefined ? item.timeInForce : undefined,
404
+ limitPrice: item.limitPrice !== undefined ? item.limitPrice : undefined,
405
+ stopPrice: item.stopPrice !== undefined ? item.stopPrice : undefined,
406
+ trailPrice: item.trailPrice !== undefined ? item.trailPrice : undefined,
407
+ trailPercent: item.trailPercent !== undefined ? item.trailPercent : undefined,
408
+ extendedHours: item.extendedHours !== undefined ? item.extendedHours : undefined,
409
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
410
+ status: item.status !== undefined ? item.status : undefined,
411
+ submittedAt: item.submittedAt !== undefined ? item.submittedAt : undefined,
412
+ filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
413
+ filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
414
+ fee: item.fee !== undefined ? item.fee : undefined,
415
+ alpacaAccount: item.alpacaAccount ?
416
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
417
+ ? { connect: {
418
+ id: item.alpacaAccount.id
419
+ }
420
+ }
421
+ : { connectOrCreate: {
422
+ where: {
423
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
424
+ },
425
+ create: {
426
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
427
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
428
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
429
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
430
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
431
+ },
432
+ }
433
+ } : undefined,
434
+ action: item.action ?
435
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
436
+ ? { connect: {
437
+ id: item.action.id
438
+ }
439
+ }
440
+ : { connectOrCreate: {
441
+ where: {
442
+ id: item.action.id !== undefined ? item.action.id : undefined,
443
+ },
444
+ create: {
445
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
446
+ type: item.action.type !== undefined ? item.action.type : undefined,
447
+ note: item.action.note !== undefined ? item.action.note : undefined,
448
+ status: item.action.status !== undefined ? item.action.status : undefined,
449
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
450
+ },
451
+ }
452
+ } : undefined,
453
+ },
454
+ }))
455
+ } : undefined,
456
+ positions: props.positions ?
457
+ typeof props.positions[0] === 'object' && Object.keys(props.positions).length === 1 && Object.keys(props.positions)[0] === 'id'
458
+ ? { connect: props.positions.map((item) => ({
459
+ id: item.id
460
+ }))
461
+ }
462
+ : { connectOrCreate: props.positions.map((item) => ({
463
+ where: {
464
+ id: item.id !== undefined ? item.id : undefined,
465
+ },
466
+ create: {
467
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
468
+ qty: item.qty !== undefined ? item.qty : undefined,
469
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
470
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
471
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
472
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
473
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
474
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
475
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
476
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
477
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
478
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
479
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
480
+ alpacaAccount: item.alpacaAccount ?
481
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
482
+ ? { connect: {
483
+ id: item.alpacaAccount.id
484
+ }
485
+ }
486
+ : { connectOrCreate: {
487
+ where: {
488
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
489
+ },
490
+ create: {
491
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
492
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
493
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
494
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
495
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
496
+ },
497
+ }
498
+ } : undefined,
499
+ },
500
+ }))
501
+ } : undefined,
502
+ newsMentions: props.newsMentions ?
503
+ typeof props.newsMentions[0] === 'object' && Object.keys(props.newsMentions).length === 1 && Object.keys(props.newsMentions)[0] === 'id'
504
+ ? { connect: props.newsMentions.map((item) => ({
505
+ id: item.id
506
+ }))
507
+ }
508
+ : { connectOrCreate: props.newsMentions.map((item) => ({
509
+ where: {
510
+ id: item.id !== undefined ? item.id : undefined,
511
+ url: item.url !== undefined ? item.url : undefined,
512
+ },
513
+ create: {
514
+ url: item.url !== undefined ? item.url : undefined,
515
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
516
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
517
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
518
+ news: item.news ?
519
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
520
+ ? { connect: {
521
+ id: item.news.id
522
+ }
523
+ }
524
+ : { connectOrCreate: {
525
+ where: {
526
+ id: item.news.id !== undefined ? item.news.id : undefined,
527
+ url: item.news.url !== undefined ? item.news.url : undefined,
528
+ title: item.news.title !== undefined ? {
529
+ equals: item.news.title
530
+ } : undefined,
531
+ },
532
+ create: {
533
+ title: item.news.title !== undefined ? item.news.title : undefined,
534
+ content: item.news.content !== undefined ? item.news.content : undefined,
535
+ source: item.news.source !== undefined ? item.news.source : undefined,
536
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
537
+ url: item.news.url !== undefined ? item.news.url : undefined,
538
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
539
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
540
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
541
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
542
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
543
+ category: item.news.category !== undefined ? item.news.category : undefined,
544
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
545
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
546
+ },
547
+ }
548
+ } : undefined,
549
+ },
550
+ }))
551
+ } : undefined,
502
552
  },
503
553
  };
504
554
  const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
@@ -1166,34 +1216,44 @@ exports.Asset = {
1166
1216
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1167
1217
  status: item.status !== undefined ? item.status : undefined,
1168
1218
  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,
1219
+ alpacaAccount: item.alpacaAccount ?
1220
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1221
+ ? { connect: {
1222
+ id: item.alpacaAccount.id
1223
+ }
1224
+ }
1225
+ : { connectOrCreate: {
1226
+ where: {
1227
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1228
+ },
1229
+ create: {
1230
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1231
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1232
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1233
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1234
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1235
+ },
1236
+ }
1237
+ } : undefined,
1238
+ actions: item.actions ?
1239
+ typeof item.actions[0] === 'object' && Object.keys(item.actions).length === 1 && Object.keys(item.actions)[0] === 'id'
1240
+ ? { connect: item.actions.map((item) => ({
1241
+ id: item.id
1242
+ }))
1243
+ }
1244
+ : { connectOrCreate: item.actions.map((item) => ({
1245
+ where: {
1246
+ id: item.id !== undefined ? item.id : undefined,
1247
+ },
1248
+ create: {
1249
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
1250
+ type: item.type !== undefined ? item.type : undefined,
1251
+ note: item.note !== undefined ? item.note : undefined,
1252
+ status: item.status !== undefined ? item.status : undefined,
1253
+ fee: item.fee !== undefined ? item.fee : undefined,
1254
+ },
1255
+ }))
1256
+ } : undefined,
1197
1257
  },
1198
1258
  }))
1199
1259
  } : undefined,
@@ -1344,34 +1404,44 @@ exports.Asset = {
1344
1404
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
1345
1405
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
1346
1406
  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,
1407
+ alpacaAccount: item.alpacaAccount ?
1408
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1409
+ ? { connect: {
1410
+ id: item.alpacaAccount.id
1411
+ }
1412
+ }
1413
+ : { connectOrCreate: {
1414
+ where: {
1415
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1416
+ },
1417
+ create: {
1418
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1419
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1420
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1421
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1422
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1423
+ },
1424
+ }
1425
+ } : undefined,
1426
+ action: item.action ?
1427
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
1428
+ ? { connect: {
1429
+ id: item.action.id
1430
+ }
1431
+ }
1432
+ : { connectOrCreate: {
1433
+ where: {
1434
+ id: item.action.id !== undefined ? item.action.id : undefined,
1435
+ },
1436
+ create: {
1437
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
1438
+ type: item.action.type !== undefined ? item.action.type : undefined,
1439
+ note: item.action.note !== undefined ? item.action.note : undefined,
1440
+ status: item.action.status !== undefined ? item.action.status : undefined,
1441
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
1442
+ },
1443
+ }
1444
+ } : undefined,
1375
1445
  },
1376
1446
  }))
1377
1447
  } : undefined,
@@ -1474,20 +1544,25 @@ exports.Asset = {
1474
1544
  lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1475
1545
  changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1476
1546
  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,
1547
+ alpacaAccount: item.alpacaAccount ?
1548
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
1549
+ ? { connect: {
1550
+ id: item.alpacaAccount.id
1551
+ }
1552
+ }
1553
+ : { connectOrCreate: {
1554
+ where: {
1555
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
1556
+ },
1557
+ create: {
1558
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
1559
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
1560
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
1561
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
1562
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
1563
+ },
1564
+ }
1565
+ } : undefined,
1491
1566
  },
1492
1567
  }))
1493
1568
  } : undefined,
@@ -1593,32 +1668,37 @@ exports.Asset = {
1593
1668
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1594
1669
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1595
1670
  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,
1671
+ news: item.news ?
1672
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
1673
+ ? { connect: {
1674
+ id: item.news.id
1675
+ }
1676
+ }
1677
+ : { connectOrCreate: {
1678
+ where: {
1679
+ id: item.news.id !== undefined ? item.news.id : undefined,
1680
+ url: item.news.url !== undefined ? item.news.url : undefined,
1681
+ title: item.news.title !== undefined ? {
1682
+ equals: item.news.title
1683
+ } : undefined,
1684
+ },
1685
+ create: {
1686
+ title: item.news.title !== undefined ? item.news.title : undefined,
1687
+ content: item.news.content !== undefined ? item.news.content : undefined,
1688
+ source: item.news.source !== undefined ? item.news.source : undefined,
1689
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
1690
+ url: item.news.url !== undefined ? item.news.url : undefined,
1691
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
1692
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
1693
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
1694
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
1695
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
1696
+ category: item.news.category !== undefined ? item.news.category : undefined,
1697
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
1698
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
1699
+ },
1700
+ }
1701
+ } : undefined,
1622
1702
  },
1623
1703
  }))
1624
1704
  } : undefined,
@@ -1956,34 +2036,44 @@ exports.Asset = {
1956
2036
  timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1957
2037
  status: item.status !== undefined ? item.status : undefined,
1958
2038
  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,
2039
+ alpacaAccount: item.alpacaAccount ?
2040
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2041
+ ? { connect: {
2042
+ id: item.alpacaAccount.id
2043
+ }
2044
+ }
2045
+ : { connectOrCreate: {
2046
+ where: {
2047
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2048
+ },
2049
+ create: {
2050
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2051
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2052
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2053
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2054
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2055
+ },
2056
+ }
2057
+ } : undefined,
2058
+ actions: item.actions ?
2059
+ typeof item.actions[0] === 'object' && Object.keys(item.actions).length === 1 && Object.keys(item.actions)[0] === 'id'
2060
+ ? { connect: item.actions.map((item) => ({
2061
+ id: item.id
2062
+ }))
2063
+ }
2064
+ : { connectOrCreate: item.actions.map((item) => ({
2065
+ where: {
2066
+ id: item.id !== undefined ? item.id : undefined,
2067
+ },
2068
+ create: {
2069
+ sequence: item.sequence !== undefined ? item.sequence : undefined,
2070
+ type: item.type !== undefined ? item.type : undefined,
2071
+ note: item.note !== undefined ? item.note : undefined,
2072
+ status: item.status !== undefined ? item.status : undefined,
2073
+ fee: item.fee !== undefined ? item.fee : undefined,
2074
+ },
2075
+ }))
2076
+ } : undefined,
1987
2077
  },
1988
2078
  }))
1989
2079
  } : undefined,
@@ -2134,34 +2224,44 @@ exports.Asset = {
2134
2224
  filledAt: item.filledAt !== undefined ? item.filledAt : undefined,
2135
2225
  filledAvgPrice: item.filledAvgPrice !== undefined ? item.filledAvgPrice : undefined,
2136
2226
  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,
2227
+ alpacaAccount: item.alpacaAccount ?
2228
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2229
+ ? { connect: {
2230
+ id: item.alpacaAccount.id
2231
+ }
2232
+ }
2233
+ : { connectOrCreate: {
2234
+ where: {
2235
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2236
+ },
2237
+ create: {
2238
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2239
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2240
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2241
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2242
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2243
+ },
2244
+ }
2245
+ } : undefined,
2246
+ action: item.action ?
2247
+ typeof item.action === 'object' && Object.keys(item.action).length === 1 && Object.keys(item.action)[0] === 'id'
2248
+ ? { connect: {
2249
+ id: item.action.id
2250
+ }
2251
+ }
2252
+ : { connectOrCreate: {
2253
+ where: {
2254
+ id: item.action.id !== undefined ? item.action.id : undefined,
2255
+ },
2256
+ create: {
2257
+ sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
2258
+ type: item.action.type !== undefined ? item.action.type : undefined,
2259
+ note: item.action.note !== undefined ? item.action.note : undefined,
2260
+ status: item.action.status !== undefined ? item.action.status : undefined,
2261
+ fee: item.action.fee !== undefined ? item.action.fee : undefined,
2262
+ },
2263
+ }
2264
+ } : undefined,
2165
2265
  },
2166
2266
  }))
2167
2267
  } : undefined,
@@ -2264,20 +2364,25 @@ exports.Asset = {
2264
2364
  lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2265
2365
  changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2266
2366
  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,
2367
+ alpacaAccount: item.alpacaAccount ?
2368
+ typeof item.alpacaAccount === 'object' && Object.keys(item.alpacaAccount).length === 1 && Object.keys(item.alpacaAccount)[0] === 'id'
2369
+ ? { connect: {
2370
+ id: item.alpacaAccount.id
2371
+ }
2372
+ }
2373
+ : { connectOrCreate: {
2374
+ where: {
2375
+ id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
2376
+ },
2377
+ create: {
2378
+ type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
2379
+ APIKey: item.alpacaAccount.APIKey !== undefined ? item.alpacaAccount.APIKey : undefined,
2380
+ APISecret: item.alpacaAccount.APISecret !== undefined ? item.alpacaAccount.APISecret : undefined,
2381
+ configuration: item.alpacaAccount.configuration !== undefined ? item.alpacaAccount.configuration : undefined,
2382
+ marketOpen: item.alpacaAccount.marketOpen !== undefined ? item.alpacaAccount.marketOpen : undefined,
2383
+ },
2384
+ }
2385
+ } : undefined,
2281
2386
  },
2282
2387
  }))
2283
2388
  } : undefined,
@@ -2383,32 +2488,37 @@ exports.Asset = {
2383
2488
  relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2384
2489
  sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2385
2490
  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,
2491
+ news: item.news ?
2492
+ typeof item.news === 'object' && Object.keys(item.news).length === 1 && Object.keys(item.news)[0] === 'id'
2493
+ ? { connect: {
2494
+ id: item.news.id
2495
+ }
2496
+ }
2497
+ : { connectOrCreate: {
2498
+ where: {
2499
+ id: item.news.id !== undefined ? item.news.id : undefined,
2500
+ url: item.news.url !== undefined ? item.news.url : undefined,
2501
+ title: item.news.title !== undefined ? {
2502
+ equals: item.news.title
2503
+ } : undefined,
2504
+ },
2505
+ create: {
2506
+ title: item.news.title !== undefined ? item.news.title : undefined,
2507
+ content: item.news.content !== undefined ? item.news.content : undefined,
2508
+ source: item.news.source !== undefined ? item.news.source : undefined,
2509
+ sourceDomain: item.news.sourceDomain !== undefined ? item.news.sourceDomain : undefined,
2510
+ url: item.news.url !== undefined ? item.news.url : undefined,
2511
+ sentiment: item.news.sentiment !== undefined ? item.news.sentiment : undefined,
2512
+ authors: item.news.authors !== undefined ? item.news.authors : undefined,
2513
+ summary: item.news.summary !== undefined ? item.news.summary : undefined,
2514
+ bannerImage: item.news.bannerImage !== undefined ? item.news.bannerImage : undefined,
2515
+ timePublished: item.news.timePublished !== undefined ? item.news.timePublished : undefined,
2516
+ category: item.news.category !== undefined ? item.news.category : undefined,
2517
+ topics: item.news.topics !== undefined ? item.news.topics : undefined,
2518
+ logo: item.news.logo !== undefined ? item.news.logo : undefined,
2519
+ },
2520
+ }
2521
+ } : undefined,
2412
2522
  },
2413
2523
  }))
2414
2524
  } : undefined,