adaptic-backend 1.0.340 → 1.0.342

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 (122) hide show
  1. package/Account.cjs +2670 -2264
  2. package/Account.d.ts +19 -2
  3. package/Action.cjs +1195 -839
  4. package/Action.d.ts +19 -2
  5. package/Alert.cjs +2651 -2347
  6. package/Alert.d.ts +19 -2
  7. package/Allocation.cjs +2631 -2304
  8. package/Allocation.d.ts +19 -2
  9. package/AlpacaAccount.cjs +2654 -2104
  10. package/AlpacaAccount.d.ts +19 -2
  11. package/Asset.cjs +2611 -1544
  12. package/Asset.d.ts +19 -2
  13. package/Authenticator.cjs +2603 -2290
  14. package/Authenticator.d.ts +19 -2
  15. package/Customer.cjs +2506 -2220
  16. package/Customer.d.ts +19 -2
  17. package/EconomicEvent.cjs +708 -367
  18. package/EconomicEvent.d.ts +19 -2
  19. package/MarketSentiment.cjs +691 -340
  20. package/MarketSentiment.d.ts +19 -2
  21. package/NewsArticle.cjs +2114 -1655
  22. package/NewsArticle.d.ts +19 -2
  23. package/NewsArticleAssetSentiment.cjs +1873 -1564
  24. package/NewsArticleAssetSentiment.d.ts +19 -2
  25. package/ScheduledOptionOrder.cjs +607 -316
  26. package/ScheduledOptionOrder.d.ts +19 -2
  27. package/Session.cjs +2592 -2294
  28. package/Session.d.ts +19 -2
  29. package/Trade.cjs +1261 -795
  30. package/Trade.d.ts +19 -2
  31. package/User.cjs +2432 -2013
  32. package/User.d.ts +19 -2
  33. package/VerificationToken.cjs +637 -328
  34. package/VerificationToken.d.ts +19 -2
  35. package/esm/Account.d.ts +19 -2
  36. package/esm/Account.d.ts.map +1 -1
  37. package/esm/Account.js.map +1 -1
  38. package/esm/Account.mjs +2661 -2262
  39. package/esm/Action.d.ts +19 -2
  40. package/esm/Action.d.ts.map +1 -1
  41. package/esm/Action.js.map +1 -1
  42. package/esm/Action.mjs +1186 -837
  43. package/esm/Alert.d.ts +19 -2
  44. package/esm/Alert.d.ts.map +1 -1
  45. package/esm/Alert.js.map +1 -1
  46. package/esm/Alert.mjs +2642 -2345
  47. package/esm/Allocation.d.ts +19 -2
  48. package/esm/Allocation.d.ts.map +1 -1
  49. package/esm/Allocation.js.map +1 -1
  50. package/esm/Allocation.mjs +2622 -2302
  51. package/esm/AlpacaAccount.d.ts +19 -2
  52. package/esm/AlpacaAccount.d.ts.map +1 -1
  53. package/esm/AlpacaAccount.js.map +1 -1
  54. package/esm/AlpacaAccount.mjs +2645 -2102
  55. package/esm/Asset.d.ts +19 -2
  56. package/esm/Asset.d.ts.map +1 -1
  57. package/esm/Asset.js.map +1 -1
  58. package/esm/Asset.mjs +2602 -1542
  59. package/esm/Authenticator.d.ts +19 -2
  60. package/esm/Authenticator.d.ts.map +1 -1
  61. package/esm/Authenticator.js.map +1 -1
  62. package/esm/Authenticator.mjs +2594 -2288
  63. package/esm/Customer.d.ts +19 -2
  64. package/esm/Customer.d.ts.map +1 -1
  65. package/esm/Customer.js.map +1 -1
  66. package/esm/Customer.mjs +2497 -2218
  67. package/esm/EconomicEvent.d.ts +19 -2
  68. package/esm/EconomicEvent.d.ts.map +1 -1
  69. package/esm/EconomicEvent.js.map +1 -1
  70. package/esm/EconomicEvent.mjs +699 -365
  71. package/esm/MarketSentiment.d.ts +19 -2
  72. package/esm/MarketSentiment.d.ts.map +1 -1
  73. package/esm/MarketSentiment.js.map +1 -1
  74. package/esm/MarketSentiment.mjs +682 -338
  75. package/esm/NewsArticle.d.ts +19 -2
  76. package/esm/NewsArticle.d.ts.map +1 -1
  77. package/esm/NewsArticle.js.map +1 -1
  78. package/esm/NewsArticle.mjs +2105 -1653
  79. package/esm/NewsArticleAssetSentiment.d.ts +19 -2
  80. package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
  81. package/esm/NewsArticleAssetSentiment.js.map +1 -1
  82. package/esm/NewsArticleAssetSentiment.mjs +1864 -1562
  83. package/esm/ScheduledOptionOrder.d.ts +19 -2
  84. package/esm/ScheduledOptionOrder.d.ts.map +1 -1
  85. package/esm/ScheduledOptionOrder.js.map +1 -1
  86. package/esm/ScheduledOptionOrder.mjs +598 -314
  87. package/esm/Session.d.ts +19 -2
  88. package/esm/Session.d.ts.map +1 -1
  89. package/esm/Session.js.map +1 -1
  90. package/esm/Session.mjs +2583 -2292
  91. package/esm/Trade.d.ts +19 -2
  92. package/esm/Trade.d.ts.map +1 -1
  93. package/esm/Trade.js.map +1 -1
  94. package/esm/Trade.mjs +1252 -793
  95. package/esm/User.d.ts +19 -2
  96. package/esm/User.d.ts.map +1 -1
  97. package/esm/User.js.map +1 -1
  98. package/esm/User.mjs +2423 -2011
  99. package/esm/VerificationToken.d.ts +19 -2
  100. package/esm/VerificationToken.d.ts.map +1 -1
  101. package/esm/VerificationToken.js.map +1 -1
  102. package/esm/VerificationToken.mjs +628 -326
  103. package/esm/generated/typegraphql-prisma/enhance.js.map +1 -1
  104. package/esm/generated/typegraphql-prisma/enhance.mjs +1 -1
  105. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts +1 -1
  106. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts.map +1 -1
  107. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.js.map +1 -1
  108. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.mjs +7 -7
  109. package/esm/prismaClient.d.ts +4 -5
  110. package/esm/prismaClient.d.ts.map +1 -1
  111. package/esm/prismaClient.js.map +1 -1
  112. package/esm/prismaClient.mjs +13 -11
  113. package/generated/typegraphql-prisma/enhance.cjs +1 -1
  114. package/generated/typegraphql-prisma/enhance.js.map +1 -1
  115. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.cjs +6 -6
  116. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts +1 -1
  117. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts.map +1 -1
  118. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.js.map +1 -1
  119. package/package.json +1 -1
  120. package/prismaClient.cjs +13 -11
  121. package/prismaClient.d.ts +4 -5
  122. package/server.cjs +37 -5
package/NewsArticle.cjs CHANGED
@@ -102,70 +102,620 @@ exports.NewsArticle = {
102
102
  * @param client - Apollo Client instance.
103
103
  * @returns The created NewsArticle or null.
104
104
  */
105
+ /**
106
+ * Create a new NewsArticle record.
107
+ * Enhanced with connection resilience against Prisma connection errors.
108
+ * @param props - Properties for the new record.
109
+ * @param globalClient - Apollo Client instance.
110
+ * @returns The created NewsArticle or null.
111
+ */
105
112
  async create(props, globalClient) {
106
- const [modules, client] = await Promise.all([
107
- (0, client_1.getApolloModules)(),
108
- globalClient
109
- ? Promise.resolve(globalClient)
110
- : client_1.client
111
- ]);
112
- const { gql, ApolloError } = modules;
113
- const CREATE_ONE_NEWSARTICLE = gql `
114
- mutation createOneNewsArticle($data: NewsArticleCreateInput!) {
115
- createOneNewsArticle(data: $data) {
116
- ${selectionSet}
117
- }
113
+ var _a, _b, _c, _d, _e;
114
+ // Maximum number of retries for database connection issues
115
+ const MAX_RETRIES = 3;
116
+ let retryCount = 0;
117
+ let lastError = null;
118
+ // Retry loop to handle potential database connection issues
119
+ while (retryCount < MAX_RETRIES) {
120
+ try {
121
+ const [modules, client] = await Promise.all([
122
+ (0, client_1.getApolloModules)(),
123
+ globalClient
124
+ ? Promise.resolve(globalClient)
125
+ : client_1.client
126
+ ]);
127
+ const { gql, ApolloError } = modules;
128
+ const CREATE_ONE_NEWSARTICLE = gql `
129
+ mutation createOneNewsArticle($data: NewsArticleCreateInput!) {
130
+ createOneNewsArticle(data: $data) {
131
+ ${selectionSet}
132
+ }
133
+ }
134
+ `;
135
+ const variables = {
136
+ data: {
137
+ title: props.title !== undefined ? props.title : undefined,
138
+ content: props.content !== undefined ? props.content : undefined,
139
+ source: props.source !== undefined ? props.source : undefined,
140
+ sourceDomain: props.sourceDomain !== undefined ? props.sourceDomain : undefined,
141
+ url: props.url !== undefined ? props.url : undefined,
142
+ sentiment: props.sentiment !== undefined ? props.sentiment : undefined,
143
+ authors: props.authors !== undefined ? {
144
+ set: props.authors
145
+ } : undefined,
146
+ summary: props.summary !== undefined ? props.summary : undefined,
147
+ bannerImage: props.bannerImage !== undefined ? props.bannerImage : undefined,
148
+ timePublished: props.timePublished !== undefined ? props.timePublished : undefined,
149
+ category: props.category !== undefined ? props.category : undefined,
150
+ topics: props.topics !== undefined ? {
151
+ set: props.topics
152
+ } : undefined,
153
+ logo: props.logo !== undefined ? props.logo : undefined,
154
+ assets: props.assets ?
155
+ Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
156
+ connect: props.assets.map((item) => ({
157
+ id: item.id
158
+ }))
159
+ }
160
+ : { connectOrCreate: props.assets.map((item) => ({
161
+ where: {
162
+ id: item.id !== undefined ? item.id : undefined,
163
+ url: item.url !== undefined ? item.url : undefined,
164
+ newsArticleId: item.newsArticleId !== undefined ? {
165
+ equals: item.newsArticleId
166
+ } : undefined,
167
+ },
168
+ create: {
169
+ url: item.url !== undefined ? item.url : undefined,
170
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
171
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
172
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
173
+ asset: item.asset ?
174
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
175
+ ? { connect: {
176
+ id: item.asset.id
177
+ }
178
+ }
179
+ : { connectOrCreate: {
180
+ where: {
181
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
182
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
183
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
184
+ },
185
+ create: {
186
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
187
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
188
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
189
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
190
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
191
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
192
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
193
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
194
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
195
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
196
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
197
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
198
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
199
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
200
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
201
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
202
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
203
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
204
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
205
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
206
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
207
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
208
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
209
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
210
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
211
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
212
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
213
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
214
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
215
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
216
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
217
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
218
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
219
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
220
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
221
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
222
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
223
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
224
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
225
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
226
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
227
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
228
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
229
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
230
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
231
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
232
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
233
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
234
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
235
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
236
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
237
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
238
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
239
+ askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
240
+ bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
241
+ },
242
+ }
243
+ } : undefined,
244
+ },
245
+ }))
246
+ } : undefined,
247
+ },
248
+ };
249
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
250
+ const response = await client.mutate({
251
+ mutation: CREATE_ONE_NEWSARTICLE,
252
+ variables: filteredVariables,
253
+ // Don't cache mutations, but ensure we're using the freshest context
254
+ fetchPolicy: 'no-cache'
255
+ });
256
+ if (response.errors && response.errors.length > 0)
257
+ throw new Error(response.errors[0].message);
258
+ if (response && response.data && response.data.createOneNewsArticle) {
259
+ return response.data.createOneNewsArticle;
260
+ }
261
+ else {
262
+ return null;
263
+ }
264
+ }
265
+ catch (error) {
266
+ lastError = error;
267
+ // Check if this is a database connection error that we should retry
268
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
269
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
270
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
271
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
272
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
273
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
274
+ retryCount++;
275
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
276
+ console.warn("Database connection error, retrying...");
277
+ await new Promise(resolve => setTimeout(resolve, delay));
278
+ continue;
279
+ }
280
+ // Log the error and rethrow
281
+ console.error("Database error occurred:", error);
282
+ throw error;
283
+ }
118
284
  }
119
- `;
120
- const variables = {
121
- data: {
122
- title: props.title !== undefined ? props.title : undefined,
123
- content: props.content !== undefined ? props.content : undefined,
124
- source: props.source !== undefined ? props.source : undefined,
125
- sourceDomain: props.sourceDomain !== undefined ? props.sourceDomain : undefined,
126
- url: props.url !== undefined ? props.url : undefined,
127
- sentiment: props.sentiment !== undefined ? props.sentiment : undefined,
128
- authors: props.authors !== undefined ? {
129
- set: props.authors
130
- } : undefined,
131
- summary: props.summary !== undefined ? props.summary : undefined,
132
- bannerImage: props.bannerImage !== undefined ? props.bannerImage : undefined,
133
- timePublished: props.timePublished !== undefined ? props.timePublished : undefined,
134
- category: props.category !== undefined ? props.category : undefined,
135
- topics: props.topics !== undefined ? {
136
- set: props.topics
137
- } : undefined,
138
- logo: props.logo !== undefined ? props.logo : undefined,
139
- assets: props.assets ?
140
- Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
141
- connect: props.assets.map((item) => ({
142
- id: item.id
143
- }))
144
- }
145
- : { connectOrCreate: props.assets.map((item) => ({
146
- where: {
147
- id: item.id !== undefined ? item.id : undefined,
148
- url: item.url !== undefined ? item.url : undefined,
149
- newsArticleId: item.newsArticleId !== undefined ? {
150
- equals: item.newsArticleId
151
- } : undefined,
152
- },
153
- create: {
154
- url: item.url !== undefined ? item.url : undefined,
155
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
156
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
157
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
158
- asset: item.asset ?
159
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
160
- ? { connect: {
161
- id: item.asset.id
162
- }
163
- }
164
- : { connectOrCreate: {
285
+ // If we exhausted retries, throw the last error
286
+ throw lastError;
287
+ },
288
+ /**
289
+ * Create multiple NewsArticle records.
290
+ * Enhanced with connection resilience against Prisma connection errors.
291
+ * @param props - Array of NewsArticle objects for the new records.
292
+ * @param globalClient - Apollo Client instance.
293
+ * @returns The count of created records or null.
294
+ */
295
+ async createMany(props, globalClient) {
296
+ var _a, _b, _c, _d, _e;
297
+ // Maximum number of retries for database connection issues
298
+ const MAX_RETRIES = 3;
299
+ let retryCount = 0;
300
+ let lastError = null;
301
+ // Retry loop to handle potential database connection issues
302
+ while (retryCount < MAX_RETRIES) {
303
+ try {
304
+ const [modules, client] = await Promise.all([
305
+ (0, client_1.getApolloModules)(),
306
+ globalClient
307
+ ? Promise.resolve(globalClient)
308
+ : client_1.client
309
+ ]);
310
+ const { gql, ApolloError } = modules;
311
+ const CREATE_MANY_NEWSARTICLE = gql `
312
+ mutation createManyNewsArticle($data: [NewsArticleCreateManyInput!]!) {
313
+ createManyNewsArticle(data: $data) {
314
+ count
315
+ }
316
+ }`;
317
+ const variables = {
318
+ data: props.map(prop => ({
319
+ title: prop.title !== undefined ? prop.title : undefined,
320
+ content: prop.content !== undefined ? prop.content : undefined,
321
+ source: prop.source !== undefined ? prop.source : undefined,
322
+ sourceDomain: prop.sourceDomain !== undefined ? prop.sourceDomain : undefined,
323
+ url: prop.url !== undefined ? prop.url : undefined,
324
+ sentiment: prop.sentiment !== undefined ? prop.sentiment : undefined,
325
+ authors: prop.authors !== undefined ? {
326
+ set: prop.authors
327
+ } : undefined,
328
+ summary: prop.summary !== undefined ? prop.summary : undefined,
329
+ bannerImage: prop.bannerImage !== undefined ? prop.bannerImage : undefined,
330
+ timePublished: prop.timePublished !== undefined ? prop.timePublished : undefined,
331
+ category: prop.category !== undefined ? prop.category : undefined,
332
+ topics: prop.topics !== undefined ? {
333
+ set: prop.topics
334
+ } : undefined,
335
+ logo: prop.logo !== undefined ? prop.logo : undefined,
336
+ })),
337
+ };
338
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
339
+ const response = await client.mutate({
340
+ mutation: CREATE_MANY_NEWSARTICLE,
341
+ variables: filteredVariables,
342
+ // Don't cache mutations, but ensure we're using the freshest context
343
+ fetchPolicy: 'no-cache'
344
+ });
345
+ if (response.errors && response.errors.length > 0)
346
+ throw new Error(response.errors[0].message);
347
+ if (response && response.data && response.data.createManyNewsArticle) {
348
+ return response.data.createManyNewsArticle;
349
+ }
350
+ else {
351
+ return null;
352
+ }
353
+ }
354
+ catch (error) {
355
+ lastError = error;
356
+ // Check if this is a database connection error that we should retry
357
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
358
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
359
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
360
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
361
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
362
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
363
+ retryCount++;
364
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
365
+ console.warn("Database connection error, retrying...");
366
+ await new Promise(resolve => setTimeout(resolve, delay));
367
+ continue;
368
+ }
369
+ // Log the error and rethrow
370
+ console.error("Database error occurred:", error);
371
+ throw error;
372
+ }
373
+ }
374
+ // If we exhausted retries, throw the last error
375
+ throw lastError;
376
+ },
377
+ /**
378
+ * Update a single NewsArticle record.
379
+ * Enhanced with connection resilience against Prisma connection errors.
380
+ * @param props - Properties to update.
381
+ * @param globalClient - Apollo Client instance.
382
+ * @returns The updated NewsArticle or null.
383
+ */
384
+ async update(props, globalClient) {
385
+ var _a, _b, _c, _d, _e;
386
+ // Maximum number of retries for database connection issues
387
+ const MAX_RETRIES = 3;
388
+ let retryCount = 0;
389
+ let lastError = null;
390
+ // Retry loop to handle potential database connection issues
391
+ while (retryCount < MAX_RETRIES) {
392
+ try {
393
+ const [modules, client] = await Promise.all([
394
+ (0, client_1.getApolloModules)(),
395
+ globalClient
396
+ ? Promise.resolve(globalClient)
397
+ : client_1.client
398
+ ]);
399
+ const { gql, ApolloError } = modules;
400
+ const UPDATE_ONE_NEWSARTICLE = gql `
401
+ mutation updateOneNewsArticle($data: NewsArticleUpdateInput!, $where: NewsArticleWhereUniqueInput!) {
402
+ updateOneNewsArticle(data: $data, where: $where) {
403
+ ${selectionSet}
404
+ }
405
+ }`;
406
+ const variables = {
407
+ where: {
408
+ id: props.id !== undefined ? props.id : undefined,
409
+ url: props.url !== undefined ? props.url : undefined,
410
+ title: props.title !== undefined ? props.title : undefined,
411
+ content: props.content !== undefined ? {
412
+ equals: props.content
413
+ } : undefined,
414
+ source: props.source !== undefined ? {
415
+ equals: props.source
416
+ } : undefined,
417
+ sourceDomain: props.sourceDomain !== undefined ? {
418
+ equals: props.sourceDomain
419
+ } : undefined,
420
+ sentiment: props.sentiment !== undefined ? {
421
+ equals: props.sentiment
422
+ } : undefined,
423
+ authors: props.authors !== undefined ? {
424
+ equals: props.authors
425
+ } : undefined,
426
+ summary: props.summary !== undefined ? {
427
+ equals: props.summary
428
+ } : undefined,
429
+ bannerImage: props.bannerImage !== undefined ? {
430
+ equals: props.bannerImage
431
+ } : undefined,
432
+ timePublished: props.timePublished !== undefined ? {
433
+ equals: props.timePublished
434
+ } : undefined,
435
+ category: props.category !== undefined ? {
436
+ equals: props.category
437
+ } : undefined,
438
+ topics: props.topics !== undefined ? {
439
+ equals: props.topics
440
+ } : undefined,
441
+ logo: props.logo !== undefined ? {
442
+ equals: props.logo
443
+ } : undefined,
444
+ createdAt: props.createdAt !== undefined ? {
445
+ equals: props.createdAt
446
+ } : undefined,
447
+ updatedAt: props.updatedAt !== undefined ? {
448
+ equals: props.updatedAt
449
+ } : undefined,
450
+ },
451
+ data: {
452
+ id: props.id !== undefined ? {
453
+ set: props.id
454
+ } : undefined,
455
+ title: props.title !== undefined ? {
456
+ set: props.title
457
+ } : undefined,
458
+ content: props.content !== undefined ? {
459
+ set: props.content
460
+ } : undefined,
461
+ source: props.source !== undefined ? {
462
+ set: props.source
463
+ } : undefined,
464
+ sourceDomain: props.sourceDomain !== undefined ? {
465
+ set: props.sourceDomain
466
+ } : undefined,
467
+ url: props.url !== undefined ? {
468
+ set: props.url
469
+ } : undefined,
470
+ sentiment: props.sentiment !== undefined ? {
471
+ set: props.sentiment
472
+ } : undefined,
473
+ authors: props.authors !== undefined ? {
474
+ set: props.authors
475
+ } : undefined,
476
+ summary: props.summary !== undefined ? {
477
+ set: props.summary
478
+ } : undefined,
479
+ bannerImage: props.bannerImage !== undefined ? {
480
+ set: props.bannerImage
481
+ } : undefined,
482
+ timePublished: props.timePublished !== undefined ? {
483
+ set: props.timePublished
484
+ } : undefined,
485
+ category: props.category !== undefined ? {
486
+ set: props.category
487
+ } : undefined,
488
+ topics: props.topics !== undefined ? {
489
+ set: props.topics
490
+ } : undefined,
491
+ logo: props.logo !== undefined ? {
492
+ set: props.logo
493
+ } : undefined,
494
+ createdAt: props.createdAt !== undefined ? {
495
+ set: props.createdAt
496
+ } : undefined,
497
+ updatedAt: props.updatedAt !== undefined ? {
498
+ set: props.updatedAt
499
+ } : undefined,
500
+ assets: props.assets ?
501
+ Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && ('id' in item || 'symbol' in item) && Object.keys(item).length === 1) ? {
502
+ connect: props.assets.map((item) => ({
503
+ id: item.id
504
+ }))
505
+ } : { upsert: props.assets.map((item) => ({
506
+ where: {
507
+ id: item.id !== undefined ? item.id : undefined,
508
+ url: item.url !== undefined ? item.url : undefined,
509
+ assetId: item.assetId !== undefined ? {
510
+ equals: item.assetId
511
+ } : undefined,
512
+ newsArticleId: item.newsArticleId !== undefined ? {
513
+ equals: item.newsArticleId
514
+ } : undefined,
515
+ },
516
+ update: {
517
+ id: item.id !== undefined ? {
518
+ set: item.id
519
+ } : undefined,
520
+ url: item.url !== undefined ? {
521
+ set: item.url
522
+ } : undefined,
523
+ relevancyScore: item.relevancyScore !== undefined ? {
524
+ set: item.relevancyScore
525
+ } : undefined,
526
+ sentimentScore: item.sentimentScore !== undefined ? {
527
+ set: item.sentimentScore
528
+ } : undefined,
529
+ sentimentLabel: item.sentimentLabel !== undefined ? {
530
+ set: item.sentimentLabel
531
+ } : undefined,
532
+ asset: item.asset ?
533
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && (Object.keys(item.asset)[0] === 'id' || Object.keys(item.asset)[0] === 'symbol')
534
+ ? {
535
+ connect: {
536
+ id: item.asset.id
537
+ }
538
+ } : { upsert: {
165
539
  where: {
166
- id: item.asset.id !== undefined ? item.asset.id : undefined,
167
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
168
- name: item.asset.name !== undefined ? item.asset.name : undefined,
540
+ id: item.asset.id !== undefined ? {
541
+ equals: item.asset.id
542
+ } : undefined,
543
+ symbol: item.asset.symbol !== undefined ? {
544
+ equals: item.asset.symbol
545
+ } : undefined,
546
+ name: item.asset.name !== undefined ? {
547
+ equals: item.asset.name
548
+ } : undefined,
549
+ },
550
+ update: {
551
+ id: item.asset.id !== undefined ? {
552
+ set: item.asset.id
553
+ } : undefined,
554
+ symbol: item.asset.symbol !== undefined ? {
555
+ set: item.asset.symbol
556
+ } : undefined,
557
+ name: item.asset.name !== undefined ? {
558
+ set: item.asset.name
559
+ } : undefined,
560
+ type: item.asset.type !== undefined ? {
561
+ set: item.asset.type
562
+ } : undefined,
563
+ logoUrl: item.asset.logoUrl !== undefined ? {
564
+ set: item.asset.logoUrl
565
+ } : undefined,
566
+ description: item.asset.description !== undefined ? {
567
+ set: item.asset.description
568
+ } : undefined,
569
+ cik: item.asset.cik !== undefined ? {
570
+ set: item.asset.cik
571
+ } : undefined,
572
+ exchange: item.asset.exchange !== undefined ? {
573
+ set: item.asset.exchange
574
+ } : undefined,
575
+ currency: item.asset.currency !== undefined ? {
576
+ set: item.asset.currency
577
+ } : undefined,
578
+ country: item.asset.country !== undefined ? {
579
+ set: item.asset.country
580
+ } : undefined,
581
+ sector: item.asset.sector !== undefined ? {
582
+ set: item.asset.sector
583
+ } : undefined,
584
+ industry: item.asset.industry !== undefined ? {
585
+ set: item.asset.industry
586
+ } : undefined,
587
+ address: item.asset.address !== undefined ? {
588
+ set: item.asset.address
589
+ } : undefined,
590
+ officialSite: item.asset.officialSite !== undefined ? {
591
+ set: item.asset.officialSite
592
+ } : undefined,
593
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
594
+ set: item.asset.fiscalYearEnd
595
+ } : undefined,
596
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
597
+ set: item.asset.latestQuarter
598
+ } : undefined,
599
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
600
+ set: item.asset.marketCapitalization
601
+ } : undefined,
602
+ ebitda: item.asset.ebitda !== undefined ? {
603
+ set: item.asset.ebitda
604
+ } : undefined,
605
+ peRatio: item.asset.peRatio !== undefined ? {
606
+ set: item.asset.peRatio
607
+ } : undefined,
608
+ pegRatio: item.asset.pegRatio !== undefined ? {
609
+ set: item.asset.pegRatio
610
+ } : undefined,
611
+ bookValue: item.asset.bookValue !== undefined ? {
612
+ set: item.asset.bookValue
613
+ } : undefined,
614
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
615
+ set: item.asset.dividendPerShare
616
+ } : undefined,
617
+ dividendYield: item.asset.dividendYield !== undefined ? {
618
+ set: item.asset.dividendYield
619
+ } : undefined,
620
+ eps: item.asset.eps !== undefined ? {
621
+ set: item.asset.eps
622
+ } : undefined,
623
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
624
+ set: item.asset.revenuePerShareTTM
625
+ } : undefined,
626
+ profitMargin: item.asset.profitMargin !== undefined ? {
627
+ set: item.asset.profitMargin
628
+ } : undefined,
629
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
630
+ set: item.asset.operatingMarginTTM
631
+ } : undefined,
632
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
633
+ set: item.asset.returnOnAssetsTTM
634
+ } : undefined,
635
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
636
+ set: item.asset.returnOnEquityTTM
637
+ } : undefined,
638
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
639
+ set: item.asset.revenueTTM
640
+ } : undefined,
641
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
642
+ set: item.asset.grossProfitTTM
643
+ } : undefined,
644
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
645
+ set: item.asset.dilutedEPSTTM
646
+ } : undefined,
647
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
648
+ set: item.asset.quarterlyEarningsGrowthYOY
649
+ } : undefined,
650
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
651
+ set: item.asset.quarterlyRevenueGrowthYOY
652
+ } : undefined,
653
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
654
+ set: item.asset.analystTargetPrice
655
+ } : undefined,
656
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
657
+ set: item.asset.analystRatingStrongBuy
658
+ } : undefined,
659
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
660
+ set: item.asset.analystRatingBuy
661
+ } : undefined,
662
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
663
+ set: item.asset.analystRatingHold
664
+ } : undefined,
665
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
666
+ set: item.asset.analystRatingSell
667
+ } : undefined,
668
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
669
+ set: item.asset.analystRatingStrongSell
670
+ } : undefined,
671
+ trailingPE: item.asset.trailingPE !== undefined ? {
672
+ set: item.asset.trailingPE
673
+ } : undefined,
674
+ forwardPE: item.asset.forwardPE !== undefined ? {
675
+ set: item.asset.forwardPE
676
+ } : undefined,
677
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
678
+ set: item.asset.priceToSalesRatioTTM
679
+ } : undefined,
680
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
681
+ set: item.asset.priceToBookRatio
682
+ } : undefined,
683
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
684
+ set: item.asset.evToRevenue
685
+ } : undefined,
686
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
687
+ set: item.asset.evToEbitda
688
+ } : undefined,
689
+ beta: item.asset.beta !== undefined ? {
690
+ set: item.asset.beta
691
+ } : undefined,
692
+ week52High: item.asset.week52High !== undefined ? {
693
+ set: item.asset.week52High
694
+ } : undefined,
695
+ week52Low: item.asset.week52Low !== undefined ? {
696
+ set: item.asset.week52Low
697
+ } : undefined,
698
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
699
+ set: item.asset.day50MovingAverage
700
+ } : undefined,
701
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
702
+ set: item.asset.day200MovingAverage
703
+ } : undefined,
704
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
705
+ set: item.asset.sharesOutstanding
706
+ } : undefined,
707
+ dividendDate: item.asset.dividendDate !== undefined ? {
708
+ set: item.asset.dividendDate
709
+ } : undefined,
710
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
711
+ set: item.asset.exDividendDate
712
+ } : undefined,
713
+ askPrice: item.asset.askPrice !== undefined ? {
714
+ set: item.asset.askPrice
715
+ } : undefined,
716
+ bidPrice: item.asset.bidPrice !== undefined ? {
717
+ set: item.asset.bidPrice
718
+ } : undefined,
169
719
  },
170
720
  create: {
171
721
  symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
@@ -226,617 +776,572 @@ exports.NewsArticle = {
226
776
  },
227
777
  }
228
778
  } : undefined,
229
- },
230
- }))
231
- } : undefined,
232
- },
233
- };
234
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
235
- try {
236
- const response = await client.mutate({ mutation: CREATE_ONE_NEWSARTICLE, variables: filteredVariables });
237
- if (response.errors && response.errors.length > 0)
238
- throw new Error(response.errors[0].message);
239
- if (response && response.data && response.data.createOneNewsArticle) {
240
- return response.data.createOneNewsArticle;
241
- }
242
- else {
243
- return null;
244
- }
245
- }
246
- catch (error) {
247
- console.error('Error in createOneNewsArticle:', error);
248
- throw error;
249
- }
250
- },
251
- /**
252
- * Create multiple NewsArticle records.
253
- * @param props - Array of NewsArticle objects for the new records.
254
- * @param globalClient - Apollo Client instance.
255
- * @returns The count of created records or null.
256
- */
257
- async createMany(props, globalClient) {
258
- const [modules, client] = await Promise.all([
259
- (0, client_1.getApolloModules)(),
260
- globalClient
261
- ? Promise.resolve(globalClient)
262
- : client_1.client
263
- ]);
264
- const { gql, ApolloError } = modules;
265
- const CREATE_MANY_NEWSARTICLE = gql `
266
- mutation createManyNewsArticle($data: [NewsArticleCreateManyInput!]!) {
267
- createManyNewsArticle(data: $data) {
268
- count
269
- }
270
- }`;
271
- const variables = {
272
- data: props.map(prop => ({
273
- title: prop.title !== undefined ? prop.title : undefined,
274
- content: prop.content !== undefined ? prop.content : undefined,
275
- source: prop.source !== undefined ? prop.source : undefined,
276
- sourceDomain: prop.sourceDomain !== undefined ? prop.sourceDomain : undefined,
277
- url: prop.url !== undefined ? prop.url : undefined,
278
- sentiment: prop.sentiment !== undefined ? prop.sentiment : undefined,
279
- authors: prop.authors !== undefined ? {
280
- set: prop.authors
281
- } : undefined,
282
- summary: prop.summary !== undefined ? prop.summary : undefined,
283
- bannerImage: prop.bannerImage !== undefined ? prop.bannerImage : undefined,
284
- timePublished: prop.timePublished !== undefined ? prop.timePublished : undefined,
285
- category: prop.category !== undefined ? prop.category : undefined,
286
- topics: prop.topics !== undefined ? {
287
- set: prop.topics
288
- } : undefined,
289
- logo: prop.logo !== undefined ? prop.logo : undefined,
290
- })),
291
- };
292
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
293
- try {
294
- const response = await client.mutate({ mutation: CREATE_MANY_NEWSARTICLE, variables: filteredVariables });
295
- if (response.errors && response.errors.length > 0)
296
- throw new Error(response.errors[0].message);
297
- if (response && response.data && response.data.createManyNewsArticle) {
298
- return response.data.createManyNewsArticle;
299
- }
300
- else {
301
- return null;
302
- }
303
- }
304
- catch (error) {
305
- console.error('Error in createManyNewsArticle:', error);
306
- throw error;
307
- }
308
- },
309
- /**
310
- * Update a single NewsArticle record.
311
- * @param props - Properties to update.
312
- * @param globalClient - Apollo Client instance.
313
- * @returns The updated NewsArticle or null.
314
- */
315
- async update(props, globalClient) {
316
- const [modules, client] = await Promise.all([
317
- (0, client_1.getApolloModules)(),
318
- globalClient
319
- ? Promise.resolve(globalClient)
320
- : client_1.client
321
- ]);
322
- const { gql, ApolloError } = modules;
323
- const UPDATE_ONE_NEWSARTICLE = gql `
324
- mutation updateOneNewsArticle($data: NewsArticleUpdateInput!, $where: NewsArticleWhereUniqueInput!) {
325
- updateOneNewsArticle(data: $data, where: $where) {
326
- ${selectionSet}
327
- }
328
- }`;
329
- const variables = {
330
- where: {
331
- id: props.id !== undefined ? props.id : undefined,
332
- url: props.url !== undefined ? props.url : undefined,
333
- title: props.title !== undefined ? {
334
- equals: props.title
335
- } : undefined,
336
- },
337
- data: {
338
- id: props.id !== undefined ? {
339
- set: props.id
340
- } : undefined,
341
- title: props.title !== undefined ? {
342
- set: props.title
343
- } : undefined,
344
- content: props.content !== undefined ? {
345
- set: props.content
346
- } : undefined,
347
- source: props.source !== undefined ? {
348
- set: props.source
349
- } : undefined,
350
- sourceDomain: props.sourceDomain !== undefined ? {
351
- set: props.sourceDomain
352
- } : undefined,
353
- url: props.url !== undefined ? {
354
- set: props.url
355
- } : undefined,
356
- sentiment: props.sentiment !== undefined ? {
357
- set: props.sentiment
358
- } : undefined,
359
- authors: props.authors !== undefined ? {
360
- set: props.authors
361
- } : undefined,
362
- summary: props.summary !== undefined ? {
363
- set: props.summary
364
- } : undefined,
365
- bannerImage: props.bannerImage !== undefined ? {
366
- set: props.bannerImage
367
- } : undefined,
368
- timePublished: props.timePublished !== undefined ? {
369
- set: props.timePublished
370
- } : undefined,
371
- category: props.category !== undefined ? {
372
- set: props.category
373
- } : undefined,
374
- topics: props.topics !== undefined ? {
375
- set: props.topics
376
- } : undefined,
377
- logo: props.logo !== undefined ? {
378
- set: props.logo
379
- } : undefined,
380
- createdAt: props.createdAt !== undefined ? {
381
- set: props.createdAt
382
- } : undefined,
383
- updatedAt: props.updatedAt !== undefined ? {
384
- set: props.updatedAt
385
- } : undefined,
386
- assets: props.assets ?
387
- Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && ('id' in item || 'symbol' in item) && Object.keys(item).length === 1) ? {
388
- connect: props.assets.map((item) => ({
389
- id: item.id
390
- }))
391
- } : { upsert: props.assets.map((item) => ({
392
- where: {
393
- id: item.id !== undefined ? item.id : undefined,
394
- url: item.url !== undefined ? item.url : undefined,
395
- assetId: item.assetId !== undefined ? {
396
- equals: item.assetId
397
- } : undefined,
398
- newsArticleId: item.newsArticleId !== undefined ? {
399
- equals: item.newsArticleId
400
- } : undefined,
401
- },
402
- update: {
403
- id: item.id !== undefined ? {
404
- set: item.id
405
- } : undefined,
406
- url: item.url !== undefined ? {
407
- set: item.url
408
- } : undefined,
409
- relevancyScore: item.relevancyScore !== undefined ? {
410
- set: item.relevancyScore
411
- } : undefined,
412
- sentimentScore: item.sentimentScore !== undefined ? {
413
- set: item.sentimentScore
414
- } : undefined,
415
- sentimentLabel: item.sentimentLabel !== undefined ? {
416
- set: item.sentimentLabel
417
- } : undefined,
418
- asset: item.asset ?
419
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && (Object.keys(item.asset)[0] === 'id' || Object.keys(item.asset)[0] === 'symbol')
420
- ? {
421
- connect: {
422
- id: item.asset.id
423
- }
424
- } : { upsert: {
425
- where: {
426
- id: item.asset.id !== undefined ? {
427
- equals: item.asset.id
428
- } : undefined,
429
- symbol: item.asset.symbol !== undefined ? {
430
- equals: item.asset.symbol
431
- } : undefined,
432
- name: item.asset.name !== undefined ? {
433
- equals: item.asset.name
434
- } : undefined,
435
- },
436
- update: {
437
- id: item.asset.id !== undefined ? {
438
- set: item.asset.id
439
- } : undefined,
440
- symbol: item.asset.symbol !== undefined ? {
441
- set: item.asset.symbol
442
- } : undefined,
443
- name: item.asset.name !== undefined ? {
444
- set: item.asset.name
445
- } : undefined,
446
- type: item.asset.type !== undefined ? {
447
- set: item.asset.type
448
- } : undefined,
449
- logoUrl: item.asset.logoUrl !== undefined ? {
450
- set: item.asset.logoUrl
451
- } : undefined,
452
- description: item.asset.description !== undefined ? {
453
- set: item.asset.description
454
- } : undefined,
455
- cik: item.asset.cik !== undefined ? {
456
- set: item.asset.cik
457
- } : undefined,
458
- exchange: item.asset.exchange !== undefined ? {
459
- set: item.asset.exchange
460
- } : undefined,
461
- currency: item.asset.currency !== undefined ? {
462
- set: item.asset.currency
463
- } : undefined,
464
- country: item.asset.country !== undefined ? {
465
- set: item.asset.country
466
- } : undefined,
467
- sector: item.asset.sector !== undefined ? {
468
- set: item.asset.sector
469
- } : undefined,
470
- industry: item.asset.industry !== undefined ? {
471
- set: item.asset.industry
472
- } : undefined,
473
- address: item.asset.address !== undefined ? {
474
- set: item.asset.address
475
- } : undefined,
476
- officialSite: item.asset.officialSite !== undefined ? {
477
- set: item.asset.officialSite
478
- } : undefined,
479
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
480
- set: item.asset.fiscalYearEnd
481
- } : undefined,
482
- latestQuarter: item.asset.latestQuarter !== undefined ? {
483
- set: item.asset.latestQuarter
484
- } : undefined,
485
- marketCapitalization: item.asset.marketCapitalization !== undefined ? {
486
- set: item.asset.marketCapitalization
487
- } : undefined,
488
- ebitda: item.asset.ebitda !== undefined ? {
489
- set: item.asset.ebitda
490
- } : undefined,
491
- peRatio: item.asset.peRatio !== undefined ? {
492
- set: item.asset.peRatio
493
- } : undefined,
494
- pegRatio: item.asset.pegRatio !== undefined ? {
495
- set: item.asset.pegRatio
496
- } : undefined,
497
- bookValue: item.asset.bookValue !== undefined ? {
498
- set: item.asset.bookValue
499
- } : undefined,
500
- dividendPerShare: item.asset.dividendPerShare !== undefined ? {
501
- set: item.asset.dividendPerShare
502
- } : undefined,
503
- dividendYield: item.asset.dividendYield !== undefined ? {
504
- set: item.asset.dividendYield
505
- } : undefined,
506
- eps: item.asset.eps !== undefined ? {
507
- set: item.asset.eps
508
- } : undefined,
509
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
510
- set: item.asset.revenuePerShareTTM
511
- } : undefined,
512
- profitMargin: item.asset.profitMargin !== undefined ? {
513
- set: item.asset.profitMargin
514
- } : undefined,
515
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
516
- set: item.asset.operatingMarginTTM
517
- } : undefined,
518
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
519
- set: item.asset.returnOnAssetsTTM
520
- } : undefined,
521
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
522
- set: item.asset.returnOnEquityTTM
523
- } : undefined,
524
- revenueTTM: item.asset.revenueTTM !== undefined ? {
525
- set: item.asset.revenueTTM
526
- } : undefined,
527
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
528
- set: item.asset.grossProfitTTM
529
- } : undefined,
530
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
531
- set: item.asset.dilutedEPSTTM
532
- } : undefined,
533
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
534
- set: item.asset.quarterlyEarningsGrowthYOY
535
- } : undefined,
536
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
537
- set: item.asset.quarterlyRevenueGrowthYOY
538
- } : undefined,
539
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
540
- set: item.asset.analystTargetPrice
541
- } : undefined,
542
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
543
- set: item.asset.analystRatingStrongBuy
544
- } : undefined,
545
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
546
- set: item.asset.analystRatingBuy
547
- } : undefined,
548
- analystRatingHold: item.asset.analystRatingHold !== undefined ? {
549
- set: item.asset.analystRatingHold
550
- } : undefined,
551
- analystRatingSell: item.asset.analystRatingSell !== undefined ? {
552
- set: item.asset.analystRatingSell
553
- } : undefined,
554
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
555
- set: item.asset.analystRatingStrongSell
556
- } : undefined,
557
- trailingPE: item.asset.trailingPE !== undefined ? {
558
- set: item.asset.trailingPE
559
- } : undefined,
560
- forwardPE: item.asset.forwardPE !== undefined ? {
561
- set: item.asset.forwardPE
562
- } : undefined,
563
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
564
- set: item.asset.priceToSalesRatioTTM
565
- } : undefined,
566
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
567
- set: item.asset.priceToBookRatio
568
- } : undefined,
569
- evToRevenue: item.asset.evToRevenue !== undefined ? {
570
- set: item.asset.evToRevenue
571
- } : undefined,
572
- evToEbitda: item.asset.evToEbitda !== undefined ? {
573
- set: item.asset.evToEbitda
574
- } : undefined,
575
- beta: item.asset.beta !== undefined ? {
576
- set: item.asset.beta
577
- } : undefined,
578
- week52High: item.asset.week52High !== undefined ? {
579
- set: item.asset.week52High
580
- } : undefined,
581
- week52Low: item.asset.week52Low !== undefined ? {
582
- set: item.asset.week52Low
583
- } : undefined,
584
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
585
- set: item.asset.day50MovingAverage
586
- } : undefined,
587
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
588
- set: item.asset.day200MovingAverage
589
- } : undefined,
590
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
591
- set: item.asset.sharesOutstanding
592
- } : undefined,
593
- dividendDate: item.asset.dividendDate !== undefined ? {
594
- set: item.asset.dividendDate
595
- } : undefined,
596
- exDividendDate: item.asset.exDividendDate !== undefined ? {
597
- set: item.asset.exDividendDate
598
- } : undefined,
599
- askPrice: item.asset.askPrice !== undefined ? {
600
- set: item.asset.askPrice
601
- } : undefined,
602
- bidPrice: item.asset.bidPrice !== undefined ? {
603
- set: item.asset.bidPrice
604
- } : undefined,
605
- },
606
- create: {
607
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
608
- name: item.asset.name !== undefined ? item.asset.name : undefined,
609
- type: item.asset.type !== undefined ? item.asset.type : undefined,
610
- logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
611
- description: item.asset.description !== undefined ? item.asset.description : undefined,
612
- cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
613
- exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
614
- currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
615
- country: item.asset.country !== undefined ? item.asset.country : undefined,
616
- sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
617
- industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
618
- address: item.asset.address !== undefined ? item.asset.address : undefined,
619
- officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
620
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
621
- latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
622
- marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
623
- ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
624
- peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
625
- pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
626
- bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
627
- dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
628
- dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
629
- eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
630
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
631
- profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
632
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
633
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
634
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
635
- revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
636
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
637
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
638
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
639
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
640
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
641
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
642
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
643
- analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
644
- analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
645
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
646
- trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
647
- forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
648
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
649
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
650
- evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
651
- evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
652
- beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
653
- week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
654
- week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
655
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
656
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
657
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
658
- dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
659
- exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
660
- askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
661
- bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
662
- },
663
- }
664
- } : undefined,
665
- },
666
- create: {
667
- url: item.url !== undefined ? item.url : undefined,
668
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
669
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
670
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
671
- asset: item.asset ?
672
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
673
- ? { connect: {
674
- id: item.asset.id
675
- }
676
- }
677
- : { connectOrCreate: {
678
- where: {
679
- id: item.asset.id !== undefined ? item.asset.id : undefined,
680
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
681
- name: item.asset.name !== undefined ? item.asset.name : undefined,
682
- },
683
- create: {
684
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
685
- name: item.asset.name !== undefined ? item.asset.name : undefined,
686
- type: item.asset.type !== undefined ? item.asset.type : undefined,
687
- logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
688
- description: item.asset.description !== undefined ? item.asset.description : undefined,
689
- cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
690
- exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
691
- currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
692
- country: item.asset.country !== undefined ? item.asset.country : undefined,
693
- sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
694
- industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
695
- address: item.asset.address !== undefined ? item.asset.address : undefined,
696
- officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
697
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
698
- latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
699
- marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
700
- ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
701
- peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
702
- pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
703
- bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
704
- dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
705
- dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
706
- eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
707
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
708
- profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
709
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
710
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
711
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
712
- revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
713
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
714
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
715
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
716
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
717
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
718
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
719
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
720
- analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
721
- analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
722
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
723
- trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
724
- forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
725
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
726
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
727
- evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
728
- evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
729
- beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
730
- week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
731
- week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
732
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
733
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
734
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
735
- dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
736
- exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
737
- askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
738
- bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
739
- },
740
- }
741
- } : undefined,
742
- },
743
- }))
744
- } : undefined,
745
- },
746
- };
747
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
748
- try {
749
- const response = await client.mutate({ mutation: UPDATE_ONE_NEWSARTICLE, variables: filteredVariables });
750
- if (response.errors && response.errors.length > 0)
751
- throw new Error(response.errors[0].message);
752
- if (response && response.data && response.data.updateOneNewsArticle) {
753
- return response.data.updateOneNewsArticle;
779
+ },
780
+ create: {
781
+ url: item.url !== undefined ? item.url : undefined,
782
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
783
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
784
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
785
+ asset: item.asset ?
786
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
787
+ ? { connect: {
788
+ id: item.asset.id
789
+ }
790
+ }
791
+ : { connectOrCreate: {
792
+ where: {
793
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
794
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
795
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
796
+ },
797
+ create: {
798
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
799
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
800
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
801
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
802
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
803
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
804
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
805
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
806
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
807
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
808
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
809
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
810
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
811
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
812
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
813
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
814
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
815
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
816
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
817
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
818
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
819
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
820
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
821
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
822
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
823
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
824
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
825
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
826
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
827
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
828
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
829
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
830
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
831
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
832
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
833
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
834
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
835
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
836
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
837
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
838
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
839
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
840
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
841
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
842
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
843
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
844
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
845
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
846
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
847
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
848
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
849
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
850
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
851
+ askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
852
+ bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
853
+ },
854
+ }
855
+ } : undefined,
856
+ },
857
+ }))
858
+ } : undefined,
859
+ },
860
+ };
861
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
862
+ const response = await client.mutate({
863
+ mutation: UPDATE_ONE_NEWSARTICLE,
864
+ variables: filteredVariables,
865
+ // Don't cache mutations, but ensure we're using the freshest context
866
+ fetchPolicy: 'no-cache'
867
+ });
868
+ if (response.errors && response.errors.length > 0)
869
+ throw new Error(response.errors[0].message);
870
+ if (response && response.data && response.data.updateOneNewsArticle) {
871
+ return response.data.updateOneNewsArticle;
872
+ }
873
+ else {
874
+ return null;
875
+ }
754
876
  }
755
- else {
756
- return null;
877
+ catch (error) {
878
+ lastError = error;
879
+ // Check if this is a database connection error that we should retry
880
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
881
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
882
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
883
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
884
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
885
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
886
+ retryCount++;
887
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
888
+ console.warn("Database connection error, retrying...");
889
+ await new Promise(resolve => setTimeout(resolve, delay));
890
+ continue;
891
+ }
892
+ // Log the error and rethrow
893
+ console.error("Database error occurred:", error);
894
+ throw error;
757
895
  }
758
896
  }
759
- catch (error) {
760
- console.error('Error in updateOneNewsArticle:', error);
761
- throw error;
762
- }
897
+ // If we exhausted retries, throw the last error
898
+ throw lastError;
763
899
  },
764
900
  /**
765
901
  * Upsert a single NewsArticle record.
902
+ * Enhanced with connection resilience against Prisma connection errors.
766
903
  * @param props - Properties to update.
767
904
  * @param globalClient - Apollo Client instance.
768
905
  * @returns The updated NewsArticle or null.
769
906
  */
770
907
  async upsert(props, globalClient) {
771
- const [modules, client] = await Promise.all([
772
- (0, client_1.getApolloModules)(),
773
- globalClient
774
- ? Promise.resolve(globalClient)
775
- : client_1.client
776
- ]);
777
- const { gql, ApolloError } = modules;
778
- const UPSERT_ONE_NEWSARTICLE = gql `
779
- mutation upsertOneNewsArticle($where: NewsArticleWhereUniqueInput!, $create: NewsArticleCreateInput!, $update: NewsArticleUpdateInput!) {
780
- upsertOneNewsArticle(where: $where, create: $create, update: $update) {
781
- ${selectionSet}
782
- }
783
- }`;
784
- const variables = {
785
- where: {
786
- id: props.id !== undefined ? props.id : undefined,
787
- url: props.url !== undefined ? props.url : undefined,
788
- title: props.title !== undefined ? {
789
- equals: props.title
790
- } : undefined,
791
- },
792
- create: {
793
- title: props.title !== undefined ? props.title : undefined,
794
- content: props.content !== undefined ? props.content : undefined,
795
- source: props.source !== undefined ? props.source : undefined,
796
- sourceDomain: props.sourceDomain !== undefined ? props.sourceDomain : undefined,
797
- url: props.url !== undefined ? props.url : undefined,
798
- sentiment: props.sentiment !== undefined ? props.sentiment : undefined,
799
- authors: props.authors !== undefined ? {
800
- set: props.authors
801
- } : undefined,
802
- summary: props.summary !== undefined ? props.summary : undefined,
803
- bannerImage: props.bannerImage !== undefined ? props.bannerImage : undefined,
804
- timePublished: props.timePublished !== undefined ? props.timePublished : undefined,
805
- category: props.category !== undefined ? props.category : undefined,
806
- topics: props.topics !== undefined ? {
807
- set: props.topics
808
- } : undefined,
809
- logo: props.logo !== undefined ? props.logo : undefined,
810
- assets: props.assets ?
811
- Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
812
- connect: props.assets.map((item) => ({
813
- id: item.id
814
- }))
815
- }
816
- : { connectOrCreate: props.assets.map((item) => ({
817
- where: {
818
- id: item.id !== undefined ? item.id : undefined,
819
- url: item.url !== undefined ? item.url : undefined,
820
- newsArticleId: item.newsArticleId !== undefined ? {
821
- equals: item.newsArticleId
822
- } : undefined,
823
- },
824
- create: {
825
- url: item.url !== undefined ? item.url : undefined,
826
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
827
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
828
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
829
- asset: item.asset ?
830
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
831
- ? { connect: {
832
- id: item.asset.id
833
- }
834
- }
835
- : { connectOrCreate: {
908
+ var _a, _b, _c, _d, _e;
909
+ // Maximum number of retries for database connection issues
910
+ const MAX_RETRIES = 3;
911
+ let retryCount = 0;
912
+ let lastError = null;
913
+ // Retry loop to handle potential database connection issues
914
+ while (retryCount < MAX_RETRIES) {
915
+ try {
916
+ const [modules, client] = await Promise.all([
917
+ (0, client_1.getApolloModules)(),
918
+ globalClient
919
+ ? Promise.resolve(globalClient)
920
+ : client_1.client
921
+ ]);
922
+ const { gql, ApolloError } = modules;
923
+ const UPSERT_ONE_NEWSARTICLE = gql `
924
+ mutation upsertOneNewsArticle($where: NewsArticleWhereUniqueInput!, $create: NewsArticleCreateInput!, $update: NewsArticleUpdateInput!) {
925
+ upsertOneNewsArticle(where: $where, create: $create, update: $update) {
926
+ ${selectionSet}
927
+ }
928
+ }`;
929
+ const variables = {
930
+ where: {
931
+ id: props.id !== undefined ? props.id : undefined,
932
+ url: props.url !== undefined ? props.url : undefined,
933
+ title: props.title !== undefined ? props.title : undefined,
934
+ content: props.content !== undefined ? {
935
+ equals: props.content
936
+ } : undefined,
937
+ source: props.source !== undefined ? {
938
+ equals: props.source
939
+ } : undefined,
940
+ sourceDomain: props.sourceDomain !== undefined ? {
941
+ equals: props.sourceDomain
942
+ } : undefined,
943
+ sentiment: props.sentiment !== undefined ? {
944
+ equals: props.sentiment
945
+ } : undefined,
946
+ authors: props.authors !== undefined ? {
947
+ equals: props.authors
948
+ } : undefined,
949
+ summary: props.summary !== undefined ? {
950
+ equals: props.summary
951
+ } : undefined,
952
+ bannerImage: props.bannerImage !== undefined ? {
953
+ equals: props.bannerImage
954
+ } : undefined,
955
+ timePublished: props.timePublished !== undefined ? {
956
+ equals: props.timePublished
957
+ } : undefined,
958
+ category: props.category !== undefined ? {
959
+ equals: props.category
960
+ } : undefined,
961
+ topics: props.topics !== undefined ? {
962
+ equals: props.topics
963
+ } : undefined,
964
+ logo: props.logo !== undefined ? {
965
+ equals: props.logo
966
+ } : undefined,
967
+ createdAt: props.createdAt !== undefined ? {
968
+ equals: props.createdAt
969
+ } : undefined,
970
+ updatedAt: props.updatedAt !== undefined ? {
971
+ equals: props.updatedAt
972
+ } : undefined,
973
+ },
974
+ create: {
975
+ title: props.title !== undefined ? props.title : undefined,
976
+ content: props.content !== undefined ? props.content : undefined,
977
+ source: props.source !== undefined ? props.source : undefined,
978
+ sourceDomain: props.sourceDomain !== undefined ? props.sourceDomain : undefined,
979
+ url: props.url !== undefined ? props.url : undefined,
980
+ sentiment: props.sentiment !== undefined ? props.sentiment : undefined,
981
+ authors: props.authors !== undefined ? {
982
+ set: props.authors
983
+ } : undefined,
984
+ summary: props.summary !== undefined ? props.summary : undefined,
985
+ bannerImage: props.bannerImage !== undefined ? props.bannerImage : undefined,
986
+ timePublished: props.timePublished !== undefined ? props.timePublished : undefined,
987
+ category: props.category !== undefined ? props.category : undefined,
988
+ topics: props.topics !== undefined ? {
989
+ set: props.topics
990
+ } : undefined,
991
+ logo: props.logo !== undefined ? props.logo : undefined,
992
+ assets: props.assets ?
993
+ Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) ? {
994
+ connect: props.assets.map((item) => ({
995
+ id: item.id
996
+ }))
997
+ }
998
+ : { connectOrCreate: props.assets.map((item) => ({
999
+ where: {
1000
+ id: item.id !== undefined ? item.id : undefined,
1001
+ url: item.url !== undefined ? item.url : undefined,
1002
+ newsArticleId: item.newsArticleId !== undefined ? {
1003
+ equals: item.newsArticleId
1004
+ } : undefined,
1005
+ },
1006
+ create: {
1007
+ url: item.url !== undefined ? item.url : undefined,
1008
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1009
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1010
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1011
+ asset: item.asset ?
1012
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
1013
+ ? { connect: {
1014
+ id: item.asset.id
1015
+ }
1016
+ }
1017
+ : { connectOrCreate: {
1018
+ where: {
1019
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
1020
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1021
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1022
+ },
1023
+ create: {
1024
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1025
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1026
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
1027
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1028
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
1029
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1030
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1031
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1032
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
1033
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1034
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1035
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
1036
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1037
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1038
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1039
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1040
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1041
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1042
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1043
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1044
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1045
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1046
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1047
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1048
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1049
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1050
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1051
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1052
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1053
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1054
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1055
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1056
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1057
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1058
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1059
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1060
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1061
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1062
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1063
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1064
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1065
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1066
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1067
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1068
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1069
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1070
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1071
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1072
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1073
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1074
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1075
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1076
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1077
+ askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1078
+ bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1079
+ },
1080
+ }
1081
+ } : undefined,
1082
+ },
1083
+ }))
1084
+ } : undefined,
1085
+ },
1086
+ update: {
1087
+ title: props.title !== undefined ? {
1088
+ set: props.title
1089
+ } : undefined,
1090
+ content: props.content !== undefined ? {
1091
+ set: props.content
1092
+ } : undefined,
1093
+ source: props.source !== undefined ? {
1094
+ set: props.source
1095
+ } : undefined,
1096
+ sourceDomain: props.sourceDomain !== undefined ? {
1097
+ set: props.sourceDomain
1098
+ } : undefined,
1099
+ url: props.url !== undefined ? {
1100
+ set: props.url
1101
+ } : undefined,
1102
+ sentiment: props.sentiment !== undefined ? {
1103
+ set: props.sentiment
1104
+ } : undefined,
1105
+ authors: props.authors !== undefined ? {
1106
+ set: props.authors
1107
+ } : undefined,
1108
+ summary: props.summary !== undefined ? {
1109
+ set: props.summary
1110
+ } : undefined,
1111
+ bannerImage: props.bannerImage !== undefined ? {
1112
+ set: props.bannerImage
1113
+ } : undefined,
1114
+ timePublished: props.timePublished !== undefined ? {
1115
+ set: props.timePublished
1116
+ } : undefined,
1117
+ category: props.category !== undefined ? {
1118
+ set: props.category
1119
+ } : undefined,
1120
+ topics: props.topics !== undefined ? {
1121
+ set: props.topics
1122
+ } : undefined,
1123
+ logo: props.logo !== undefined ? {
1124
+ set: props.logo
1125
+ } : undefined,
1126
+ assets: props.assets ?
1127
+ Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && ('id' in item || 'symbol' in item) && Object.keys(item).length === 1) ? {
1128
+ connect: props.assets.map((item) => ({
1129
+ id: item.id
1130
+ }))
1131
+ } : { upsert: props.assets.map((item) => ({
1132
+ where: {
1133
+ id: item.id !== undefined ? item.id : undefined,
1134
+ url: item.url !== undefined ? item.url : undefined,
1135
+ assetId: item.assetId !== undefined ? {
1136
+ equals: item.assetId
1137
+ } : undefined,
1138
+ newsArticleId: item.newsArticleId !== undefined ? {
1139
+ equals: item.newsArticleId
1140
+ } : undefined,
1141
+ },
1142
+ update: {
1143
+ id: item.id !== undefined ? {
1144
+ set: item.id
1145
+ } : undefined,
1146
+ url: item.url !== undefined ? {
1147
+ set: item.url
1148
+ } : undefined,
1149
+ relevancyScore: item.relevancyScore !== undefined ? {
1150
+ set: item.relevancyScore
1151
+ } : undefined,
1152
+ sentimentScore: item.sentimentScore !== undefined ? {
1153
+ set: item.sentimentScore
1154
+ } : undefined,
1155
+ sentimentLabel: item.sentimentLabel !== undefined ? {
1156
+ set: item.sentimentLabel
1157
+ } : undefined,
1158
+ asset: item.asset ?
1159
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && (Object.keys(item.asset)[0] === 'id' || Object.keys(item.asset)[0] === 'symbol')
1160
+ ? {
1161
+ connect: {
1162
+ id: item.asset.id
1163
+ }
1164
+ } : { upsert: {
836
1165
  where: {
837
- id: item.asset.id !== undefined ? item.asset.id : undefined,
838
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
839
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1166
+ id: item.asset.id !== undefined ? {
1167
+ equals: item.asset.id
1168
+ } : undefined,
1169
+ symbol: item.asset.symbol !== undefined ? {
1170
+ equals: item.asset.symbol
1171
+ } : undefined,
1172
+ name: item.asset.name !== undefined ? {
1173
+ equals: item.asset.name
1174
+ } : undefined,
1175
+ },
1176
+ update: {
1177
+ id: item.asset.id !== undefined ? {
1178
+ set: item.asset.id
1179
+ } : undefined,
1180
+ symbol: item.asset.symbol !== undefined ? {
1181
+ set: item.asset.symbol
1182
+ } : undefined,
1183
+ name: item.asset.name !== undefined ? {
1184
+ set: item.asset.name
1185
+ } : undefined,
1186
+ type: item.asset.type !== undefined ? {
1187
+ set: item.asset.type
1188
+ } : undefined,
1189
+ logoUrl: item.asset.logoUrl !== undefined ? {
1190
+ set: item.asset.logoUrl
1191
+ } : undefined,
1192
+ description: item.asset.description !== undefined ? {
1193
+ set: item.asset.description
1194
+ } : undefined,
1195
+ cik: item.asset.cik !== undefined ? {
1196
+ set: item.asset.cik
1197
+ } : undefined,
1198
+ exchange: item.asset.exchange !== undefined ? {
1199
+ set: item.asset.exchange
1200
+ } : undefined,
1201
+ currency: item.asset.currency !== undefined ? {
1202
+ set: item.asset.currency
1203
+ } : undefined,
1204
+ country: item.asset.country !== undefined ? {
1205
+ set: item.asset.country
1206
+ } : undefined,
1207
+ sector: item.asset.sector !== undefined ? {
1208
+ set: item.asset.sector
1209
+ } : undefined,
1210
+ industry: item.asset.industry !== undefined ? {
1211
+ set: item.asset.industry
1212
+ } : undefined,
1213
+ address: item.asset.address !== undefined ? {
1214
+ set: item.asset.address
1215
+ } : undefined,
1216
+ officialSite: item.asset.officialSite !== undefined ? {
1217
+ set: item.asset.officialSite
1218
+ } : undefined,
1219
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
1220
+ set: item.asset.fiscalYearEnd
1221
+ } : undefined,
1222
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
1223
+ set: item.asset.latestQuarter
1224
+ } : undefined,
1225
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
1226
+ set: item.asset.marketCapitalization
1227
+ } : undefined,
1228
+ ebitda: item.asset.ebitda !== undefined ? {
1229
+ set: item.asset.ebitda
1230
+ } : undefined,
1231
+ peRatio: item.asset.peRatio !== undefined ? {
1232
+ set: item.asset.peRatio
1233
+ } : undefined,
1234
+ pegRatio: item.asset.pegRatio !== undefined ? {
1235
+ set: item.asset.pegRatio
1236
+ } : undefined,
1237
+ bookValue: item.asset.bookValue !== undefined ? {
1238
+ set: item.asset.bookValue
1239
+ } : undefined,
1240
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
1241
+ set: item.asset.dividendPerShare
1242
+ } : undefined,
1243
+ dividendYield: item.asset.dividendYield !== undefined ? {
1244
+ set: item.asset.dividendYield
1245
+ } : undefined,
1246
+ eps: item.asset.eps !== undefined ? {
1247
+ set: item.asset.eps
1248
+ } : undefined,
1249
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
1250
+ set: item.asset.revenuePerShareTTM
1251
+ } : undefined,
1252
+ profitMargin: item.asset.profitMargin !== undefined ? {
1253
+ set: item.asset.profitMargin
1254
+ } : undefined,
1255
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
1256
+ set: item.asset.operatingMarginTTM
1257
+ } : undefined,
1258
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
1259
+ set: item.asset.returnOnAssetsTTM
1260
+ } : undefined,
1261
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
1262
+ set: item.asset.returnOnEquityTTM
1263
+ } : undefined,
1264
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
1265
+ set: item.asset.revenueTTM
1266
+ } : undefined,
1267
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
1268
+ set: item.asset.grossProfitTTM
1269
+ } : undefined,
1270
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
1271
+ set: item.asset.dilutedEPSTTM
1272
+ } : undefined,
1273
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
1274
+ set: item.asset.quarterlyEarningsGrowthYOY
1275
+ } : undefined,
1276
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
1277
+ set: item.asset.quarterlyRevenueGrowthYOY
1278
+ } : undefined,
1279
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
1280
+ set: item.asset.analystTargetPrice
1281
+ } : undefined,
1282
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
1283
+ set: item.asset.analystRatingStrongBuy
1284
+ } : undefined,
1285
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
1286
+ set: item.asset.analystRatingBuy
1287
+ } : undefined,
1288
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
1289
+ set: item.asset.analystRatingHold
1290
+ } : undefined,
1291
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
1292
+ set: item.asset.analystRatingSell
1293
+ } : undefined,
1294
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
1295
+ set: item.asset.analystRatingStrongSell
1296
+ } : undefined,
1297
+ trailingPE: item.asset.trailingPE !== undefined ? {
1298
+ set: item.asset.trailingPE
1299
+ } : undefined,
1300
+ forwardPE: item.asset.forwardPE !== undefined ? {
1301
+ set: item.asset.forwardPE
1302
+ } : undefined,
1303
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
1304
+ set: item.asset.priceToSalesRatioTTM
1305
+ } : undefined,
1306
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
1307
+ set: item.asset.priceToBookRatio
1308
+ } : undefined,
1309
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
1310
+ set: item.asset.evToRevenue
1311
+ } : undefined,
1312
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
1313
+ set: item.asset.evToEbitda
1314
+ } : undefined,
1315
+ beta: item.asset.beta !== undefined ? {
1316
+ set: item.asset.beta
1317
+ } : undefined,
1318
+ week52High: item.asset.week52High !== undefined ? {
1319
+ set: item.asset.week52High
1320
+ } : undefined,
1321
+ week52Low: item.asset.week52Low !== undefined ? {
1322
+ set: item.asset.week52Low
1323
+ } : undefined,
1324
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
1325
+ set: item.asset.day50MovingAverage
1326
+ } : undefined,
1327
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
1328
+ set: item.asset.day200MovingAverage
1329
+ } : undefined,
1330
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
1331
+ set: item.asset.sharesOutstanding
1332
+ } : undefined,
1333
+ dividendDate: item.asset.dividendDate !== undefined ? {
1334
+ set: item.asset.dividendDate
1335
+ } : undefined,
1336
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
1337
+ set: item.asset.exDividendDate
1338
+ } : undefined,
1339
+ askPrice: item.asset.askPrice !== undefined ? {
1340
+ set: item.asset.askPrice
1341
+ } : undefined,
1342
+ bidPrice: item.asset.bidPrice !== undefined ? {
1343
+ set: item.asset.bidPrice
1344
+ } : undefined,
840
1345
  },
841
1346
  create: {
842
1347
  symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
@@ -897,1062 +1402,1016 @@ exports.NewsArticle = {
897
1402
  },
898
1403
  }
899
1404
  } : undefined,
900
- },
901
- }))
902
- } : undefined,
903
- },
904
- update: {
905
- title: props.title !== undefined ? {
906
- set: props.title
907
- } : undefined,
908
- content: props.content !== undefined ? {
909
- set: props.content
910
- } : undefined,
911
- source: props.source !== undefined ? {
912
- set: props.source
913
- } : undefined,
914
- sourceDomain: props.sourceDomain !== undefined ? {
915
- set: props.sourceDomain
916
- } : undefined,
917
- url: props.url !== undefined ? {
918
- set: props.url
919
- } : undefined,
920
- sentiment: props.sentiment !== undefined ? {
921
- set: props.sentiment
922
- } : undefined,
923
- authors: props.authors !== undefined ? {
924
- set: props.authors
925
- } : undefined,
926
- summary: props.summary !== undefined ? {
927
- set: props.summary
928
- } : undefined,
929
- bannerImage: props.bannerImage !== undefined ? {
930
- set: props.bannerImage
931
- } : undefined,
932
- timePublished: props.timePublished !== undefined ? {
933
- set: props.timePublished
934
- } : undefined,
935
- category: props.category !== undefined ? {
936
- set: props.category
937
- } : undefined,
938
- topics: props.topics !== undefined ? {
939
- set: props.topics
940
- } : undefined,
941
- logo: props.logo !== undefined ? {
942
- set: props.logo
943
- } : undefined,
944
- assets: props.assets ?
945
- Array.isArray(props.assets) && props.assets.length > 0 && props.assets.every((item) => typeof item === 'object' && ('id' in item || 'symbol' in item) && Object.keys(item).length === 1) ? {
946
- connect: props.assets.map((item) => ({
947
- id: item.id
948
- }))
949
- } : { upsert: props.assets.map((item) => ({
950
- where: {
951
- id: item.id !== undefined ? item.id : undefined,
952
- url: item.url !== undefined ? item.url : undefined,
953
- assetId: item.assetId !== undefined ? {
954
- equals: item.assetId
955
- } : undefined,
956
- newsArticleId: item.newsArticleId !== undefined ? {
957
- equals: item.newsArticleId
958
- } : undefined,
959
- },
960
- update: {
961
- id: item.id !== undefined ? {
962
- set: item.id
963
- } : undefined,
964
- url: item.url !== undefined ? {
965
- set: item.url
966
- } : undefined,
967
- relevancyScore: item.relevancyScore !== undefined ? {
968
- set: item.relevancyScore
969
- } : undefined,
970
- sentimentScore: item.sentimentScore !== undefined ? {
971
- set: item.sentimentScore
972
- } : undefined,
973
- sentimentLabel: item.sentimentLabel !== undefined ? {
974
- set: item.sentimentLabel
975
- } : undefined,
976
- asset: item.asset ?
977
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && (Object.keys(item.asset)[0] === 'id' || Object.keys(item.asset)[0] === 'symbol')
978
- ? {
979
- connect: {
980
- id: item.asset.id
981
- }
982
- } : { upsert: {
983
- where: {
984
- id: item.asset.id !== undefined ? {
985
- equals: item.asset.id
986
- } : undefined,
987
- symbol: item.asset.symbol !== undefined ? {
988
- equals: item.asset.symbol
989
- } : undefined,
990
- name: item.asset.name !== undefined ? {
991
- equals: item.asset.name
992
- } : undefined,
993
- },
994
- update: {
995
- id: item.asset.id !== undefined ? {
996
- set: item.asset.id
997
- } : undefined,
998
- symbol: item.asset.symbol !== undefined ? {
999
- set: item.asset.symbol
1000
- } : undefined,
1001
- name: item.asset.name !== undefined ? {
1002
- set: item.asset.name
1003
- } : undefined,
1004
- type: item.asset.type !== undefined ? {
1005
- set: item.asset.type
1006
- } : undefined,
1007
- logoUrl: item.asset.logoUrl !== undefined ? {
1008
- set: item.asset.logoUrl
1009
- } : undefined,
1010
- description: item.asset.description !== undefined ? {
1011
- set: item.asset.description
1012
- } : undefined,
1013
- cik: item.asset.cik !== undefined ? {
1014
- set: item.asset.cik
1015
- } : undefined,
1016
- exchange: item.asset.exchange !== undefined ? {
1017
- set: item.asset.exchange
1018
- } : undefined,
1019
- currency: item.asset.currency !== undefined ? {
1020
- set: item.asset.currency
1021
- } : undefined,
1022
- country: item.asset.country !== undefined ? {
1023
- set: item.asset.country
1024
- } : undefined,
1025
- sector: item.asset.sector !== undefined ? {
1026
- set: item.asset.sector
1027
- } : undefined,
1028
- industry: item.asset.industry !== undefined ? {
1029
- set: item.asset.industry
1030
- } : undefined,
1031
- address: item.asset.address !== undefined ? {
1032
- set: item.asset.address
1033
- } : undefined,
1034
- officialSite: item.asset.officialSite !== undefined ? {
1035
- set: item.asset.officialSite
1036
- } : undefined,
1037
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
1038
- set: item.asset.fiscalYearEnd
1039
- } : undefined,
1040
- latestQuarter: item.asset.latestQuarter !== undefined ? {
1041
- set: item.asset.latestQuarter
1042
- } : undefined,
1043
- marketCapitalization: item.asset.marketCapitalization !== undefined ? {
1044
- set: item.asset.marketCapitalization
1045
- } : undefined,
1046
- ebitda: item.asset.ebitda !== undefined ? {
1047
- set: item.asset.ebitda
1048
- } : undefined,
1049
- peRatio: item.asset.peRatio !== undefined ? {
1050
- set: item.asset.peRatio
1051
- } : undefined,
1052
- pegRatio: item.asset.pegRatio !== undefined ? {
1053
- set: item.asset.pegRatio
1054
- } : undefined,
1055
- bookValue: item.asset.bookValue !== undefined ? {
1056
- set: item.asset.bookValue
1057
- } : undefined,
1058
- dividendPerShare: item.asset.dividendPerShare !== undefined ? {
1059
- set: item.asset.dividendPerShare
1060
- } : undefined,
1061
- dividendYield: item.asset.dividendYield !== undefined ? {
1062
- set: item.asset.dividendYield
1063
- } : undefined,
1064
- eps: item.asset.eps !== undefined ? {
1065
- set: item.asset.eps
1066
- } : undefined,
1067
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
1068
- set: item.asset.revenuePerShareTTM
1069
- } : undefined,
1070
- profitMargin: item.asset.profitMargin !== undefined ? {
1071
- set: item.asset.profitMargin
1072
- } : undefined,
1073
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
1074
- set: item.asset.operatingMarginTTM
1075
- } : undefined,
1076
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
1077
- set: item.asset.returnOnAssetsTTM
1078
- } : undefined,
1079
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
1080
- set: item.asset.returnOnEquityTTM
1081
- } : undefined,
1082
- revenueTTM: item.asset.revenueTTM !== undefined ? {
1083
- set: item.asset.revenueTTM
1084
- } : undefined,
1085
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
1086
- set: item.asset.grossProfitTTM
1087
- } : undefined,
1088
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
1089
- set: item.asset.dilutedEPSTTM
1090
- } : undefined,
1091
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
1092
- set: item.asset.quarterlyEarningsGrowthYOY
1093
- } : undefined,
1094
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
1095
- set: item.asset.quarterlyRevenueGrowthYOY
1096
- } : undefined,
1097
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
1098
- set: item.asset.analystTargetPrice
1099
- } : undefined,
1100
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
1101
- set: item.asset.analystRatingStrongBuy
1102
- } : undefined,
1103
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
1104
- set: item.asset.analystRatingBuy
1105
- } : undefined,
1106
- analystRatingHold: item.asset.analystRatingHold !== undefined ? {
1107
- set: item.asset.analystRatingHold
1108
- } : undefined,
1109
- analystRatingSell: item.asset.analystRatingSell !== undefined ? {
1110
- set: item.asset.analystRatingSell
1111
- } : undefined,
1112
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
1113
- set: item.asset.analystRatingStrongSell
1114
- } : undefined,
1115
- trailingPE: item.asset.trailingPE !== undefined ? {
1116
- set: item.asset.trailingPE
1117
- } : undefined,
1118
- forwardPE: item.asset.forwardPE !== undefined ? {
1119
- set: item.asset.forwardPE
1120
- } : undefined,
1121
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
1122
- set: item.asset.priceToSalesRatioTTM
1123
- } : undefined,
1124
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
1125
- set: item.asset.priceToBookRatio
1126
- } : undefined,
1127
- evToRevenue: item.asset.evToRevenue !== undefined ? {
1128
- set: item.asset.evToRevenue
1129
- } : undefined,
1130
- evToEbitda: item.asset.evToEbitda !== undefined ? {
1131
- set: item.asset.evToEbitda
1132
- } : undefined,
1133
- beta: item.asset.beta !== undefined ? {
1134
- set: item.asset.beta
1135
- } : undefined,
1136
- week52High: item.asset.week52High !== undefined ? {
1137
- set: item.asset.week52High
1138
- } : undefined,
1139
- week52Low: item.asset.week52Low !== undefined ? {
1140
- set: item.asset.week52Low
1141
- } : undefined,
1142
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
1143
- set: item.asset.day50MovingAverage
1144
- } : undefined,
1145
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
1146
- set: item.asset.day200MovingAverage
1147
- } : undefined,
1148
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
1149
- set: item.asset.sharesOutstanding
1150
- } : undefined,
1151
- dividendDate: item.asset.dividendDate !== undefined ? {
1152
- set: item.asset.dividendDate
1153
- } : undefined,
1154
- exDividendDate: item.asset.exDividendDate !== undefined ? {
1155
- set: item.asset.exDividendDate
1156
- } : undefined,
1157
- askPrice: item.asset.askPrice !== undefined ? {
1158
- set: item.asset.askPrice
1159
- } : undefined,
1160
- bidPrice: item.asset.bidPrice !== undefined ? {
1161
- set: item.asset.bidPrice
1162
- } : undefined,
1163
- },
1164
- create: {
1165
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1166
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1167
- type: item.asset.type !== undefined ? item.asset.type : undefined,
1168
- logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1169
- description: item.asset.description !== undefined ? item.asset.description : undefined,
1170
- cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1171
- exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1172
- currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1173
- country: item.asset.country !== undefined ? item.asset.country : undefined,
1174
- sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1175
- industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1176
- address: item.asset.address !== undefined ? item.asset.address : undefined,
1177
- officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1178
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1179
- latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1180
- marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1181
- ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1182
- peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1183
- pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1184
- bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1185
- dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1186
- dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1187
- eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1188
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1189
- profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1190
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1191
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1192
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1193
- revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1194
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1195
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1196
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1197
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1198
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1199
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1200
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1201
- analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1202
- analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1203
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1204
- trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1205
- forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1206
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1207
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1208
- evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1209
- evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1210
- beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1211
- week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1212
- week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1213
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1214
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1215
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1216
- dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1217
- exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1218
- askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1219
- bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1220
- },
1221
- }
1222
- } : undefined,
1223
- },
1224
- create: {
1225
- url: item.url !== undefined ? item.url : undefined,
1226
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1227
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1228
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1229
- asset: item.asset ?
1230
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
1231
- ? { connect: {
1232
- id: item.asset.id
1233
- }
1234
- }
1235
- : { connectOrCreate: {
1236
- where: {
1237
- id: item.asset.id !== undefined ? item.asset.id : undefined,
1238
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1239
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1240
- },
1241
- create: {
1242
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1243
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1244
- type: item.asset.type !== undefined ? item.asset.type : undefined,
1245
- logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1246
- description: item.asset.description !== undefined ? item.asset.description : undefined,
1247
- cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1248
- exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1249
- currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1250
- country: item.asset.country !== undefined ? item.asset.country : undefined,
1251
- sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1252
- industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1253
- address: item.asset.address !== undefined ? item.asset.address : undefined,
1254
- officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1255
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1256
- latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1257
- marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1258
- ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1259
- peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1260
- pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1261
- bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1262
- dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1263
- dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1264
- eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1265
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1266
- profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1267
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1268
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1269
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1270
- revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1271
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1272
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1273
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1274
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1275
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1276
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1277
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1278
- analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1279
- analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1280
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1281
- trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1282
- forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1283
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1284
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1285
- evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1286
- evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1287
- beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1288
- week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1289
- week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1290
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1291
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1292
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1293
- dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1294
- exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1295
- askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1296
- bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1297
- },
1298
- }
1299
- } : undefined,
1300
- },
1301
- }))
1302
- } : undefined,
1303
- },
1304
- };
1305
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
1306
- try {
1307
- const response = await client.mutate({ mutation: UPSERT_ONE_NEWSARTICLE, variables: filteredVariables });
1308
- if (response.errors && response.errors.length > 0)
1309
- throw new Error(response.errors[0].message);
1310
- if (response && response.data && response.data.upsertOneNewsArticle) {
1311
- return response.data.upsertOneNewsArticle;
1405
+ },
1406
+ create: {
1407
+ url: item.url !== undefined ? item.url : undefined,
1408
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1409
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1410
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1411
+ asset: item.asset ?
1412
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
1413
+ ? { connect: {
1414
+ id: item.asset.id
1415
+ }
1416
+ }
1417
+ : { connectOrCreate: {
1418
+ where: {
1419
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
1420
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1421
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1422
+ },
1423
+ create: {
1424
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1425
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1426
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
1427
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1428
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
1429
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1430
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1431
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1432
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
1433
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1434
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1435
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
1436
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1437
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1438
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1439
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1440
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1441
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1442
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1443
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1444
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1445
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1446
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1447
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1448
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1449
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1450
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1451
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1452
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1453
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1454
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1455
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1456
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1457
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1458
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1459
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1460
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1461
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1462
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1463
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1464
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1465
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1466
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1467
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1468
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1469
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1470
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1471
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1472
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1473
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1474
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1475
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1476
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1477
+ askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1478
+ bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1479
+ },
1480
+ }
1481
+ } : undefined,
1482
+ },
1483
+ }))
1484
+ } : undefined,
1485
+ },
1486
+ };
1487
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
1488
+ const response = await client.mutate({
1489
+ mutation: UPSERT_ONE_NEWSARTICLE,
1490
+ variables: filteredVariables,
1491
+ // Don't cache mutations, but ensure we're using the freshest context
1492
+ fetchPolicy: 'no-cache'
1493
+ });
1494
+ if (response.errors && response.errors.length > 0)
1495
+ throw new Error(response.errors[0].message);
1496
+ if (response && response.data && response.data.upsertOneNewsArticle) {
1497
+ return response.data.upsertOneNewsArticle;
1498
+ }
1499
+ else {
1500
+ return null;
1501
+ }
1312
1502
  }
1313
- else {
1314
- return null;
1503
+ catch (error) {
1504
+ lastError = error;
1505
+ // Check if this is a database connection error that we should retry
1506
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1507
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1508
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1509
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1510
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1511
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1512
+ retryCount++;
1513
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1514
+ console.warn("Database connection error, retrying...");
1515
+ await new Promise(resolve => setTimeout(resolve, delay));
1516
+ continue;
1517
+ }
1518
+ // Log the error and rethrow
1519
+ console.error("Database error occurred:", error);
1520
+ throw error;
1315
1521
  }
1316
1522
  }
1317
- catch (error) {
1318
- console.error('Error in upsertOneNewsArticle:', error);
1319
- throw error;
1320
- }
1523
+ // If we exhausted retries, throw the last error
1524
+ throw lastError;
1321
1525
  },
1322
1526
  /**
1323
1527
  * Update multiple NewsArticle records.
1528
+ * Enhanced with connection resilience against Prisma connection errors.
1324
1529
  * @param props - Array of NewsArticle objects for the updated records.
1325
1530
  * @param globalClient - Apollo Client instance.
1326
1531
  * @returns The count of created records or null.
1327
1532
  */
1328
1533
  async updateMany(props, globalClient) {
1329
- const [modules, client] = await Promise.all([
1330
- (0, client_1.getApolloModules)(),
1331
- globalClient
1332
- ? Promise.resolve(globalClient)
1333
- : client_1.client
1334
- ]);
1335
- const { gql, ApolloError } = modules;
1336
- const UPDATE_MANY_NEWSARTICLE = gql `
1337
- mutation updateManyNewsArticle($data: [NewsArticleCreateManyInput!]!) {
1338
- updateManyNewsArticle(data: $data) {
1339
- count
1340
- }
1341
- }`;
1342
- const variables = props.map(prop => ({
1343
- where: {
1344
- id: prop.id !== undefined ? prop.id : undefined,
1345
- url: prop.url !== undefined ? prop.url : undefined,
1346
- title: prop.title !== undefined ? {
1347
- equals: prop.title
1348
- } : undefined,
1349
- },
1350
- data: {
1351
- id: prop.id !== undefined ? {
1352
- set: prop.id
1353
- } : undefined,
1354
- title: prop.title !== undefined ? {
1355
- set: prop.title
1356
- } : undefined,
1357
- content: prop.content !== undefined ? {
1358
- set: prop.content
1359
- } : undefined,
1360
- source: prop.source !== undefined ? {
1361
- set: prop.source
1362
- } : undefined,
1363
- sourceDomain: prop.sourceDomain !== undefined ? {
1364
- set: prop.sourceDomain
1365
- } : undefined,
1366
- url: prop.url !== undefined ? {
1367
- set: prop.url
1368
- } : undefined,
1369
- sentiment: prop.sentiment !== undefined ? {
1370
- set: prop.sentiment
1371
- } : undefined,
1372
- authors: prop.authors !== undefined ? {
1373
- set: prop.authors
1374
- } : undefined,
1375
- summary: prop.summary !== undefined ? {
1376
- set: prop.summary
1377
- } : undefined,
1378
- bannerImage: prop.bannerImage !== undefined ? {
1379
- set: prop.bannerImage
1380
- } : undefined,
1381
- timePublished: prop.timePublished !== undefined ? {
1382
- set: prop.timePublished
1383
- } : undefined,
1384
- category: prop.category !== undefined ? {
1385
- set: prop.category
1386
- } : undefined,
1387
- topics: prop.topics !== undefined ? {
1388
- set: prop.topics
1389
- } : undefined,
1390
- logo: prop.logo !== undefined ? {
1391
- set: prop.logo
1392
- } : undefined,
1393
- createdAt: prop.createdAt !== undefined ? {
1394
- set: prop.createdAt
1395
- } : undefined,
1396
- updatedAt: prop.updatedAt !== undefined ? {
1397
- set: prop.updatedAt
1398
- } : undefined,
1399
- assets: prop.assets ?
1400
- Array.isArray(prop.assets) && prop.assets.length > 0 && prop.assets.every((item) => typeof item === 'object' && ('id' in item || 'symbol' in item) && Object.keys(item).length === 1) ? {
1401
- connect: prop.assets.map((item) => ({
1402
- id: item.id
1403
- }))
1404
- } : { upsert: prop.assets.map((item) => ({
1405
- where: {
1406
- id: item.id !== undefined ? item.id : undefined,
1407
- url: item.url !== undefined ? item.url : undefined,
1408
- assetId: item.assetId !== undefined ? {
1409
- equals: item.assetId
1410
- } : undefined,
1411
- newsArticleId: item.newsArticleId !== undefined ? {
1412
- equals: item.newsArticleId
1413
- } : undefined,
1414
- },
1415
- update: {
1416
- id: item.id !== undefined ? {
1417
- set: item.id
1418
- } : undefined,
1419
- url: item.url !== undefined ? {
1420
- set: item.url
1421
- } : undefined,
1422
- relevancyScore: item.relevancyScore !== undefined ? {
1423
- set: item.relevancyScore
1424
- } : undefined,
1425
- sentimentScore: item.sentimentScore !== undefined ? {
1426
- set: item.sentimentScore
1427
- } : undefined,
1428
- sentimentLabel: item.sentimentLabel !== undefined ? {
1429
- set: item.sentimentLabel
1430
- } : undefined,
1431
- asset: item.asset ?
1432
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && (Object.keys(item.asset)[0] === 'id' || Object.keys(item.asset)[0] === 'symbol')
1433
- ? {
1434
- connect: {
1435
- id: item.asset.id
1436
- }
1437
- } : { upsert: {
1438
- where: {
1439
- id: item.asset.id !== undefined ? {
1440
- equals: item.asset.id
1441
- } : undefined,
1442
- symbol: item.asset.symbol !== undefined ? {
1443
- equals: item.asset.symbol
1444
- } : undefined,
1445
- name: item.asset.name !== undefined ? {
1446
- equals: item.asset.name
1447
- } : undefined,
1448
- },
1449
- update: {
1450
- id: item.asset.id !== undefined ? {
1451
- set: item.asset.id
1452
- } : undefined,
1453
- symbol: item.asset.symbol !== undefined ? {
1454
- set: item.asset.symbol
1455
- } : undefined,
1456
- name: item.asset.name !== undefined ? {
1457
- set: item.asset.name
1458
- } : undefined,
1459
- type: item.asset.type !== undefined ? {
1460
- set: item.asset.type
1461
- } : undefined,
1462
- logoUrl: item.asset.logoUrl !== undefined ? {
1463
- set: item.asset.logoUrl
1464
- } : undefined,
1465
- description: item.asset.description !== undefined ? {
1466
- set: item.asset.description
1467
- } : undefined,
1468
- cik: item.asset.cik !== undefined ? {
1469
- set: item.asset.cik
1470
- } : undefined,
1471
- exchange: item.asset.exchange !== undefined ? {
1472
- set: item.asset.exchange
1473
- } : undefined,
1474
- currency: item.asset.currency !== undefined ? {
1475
- set: item.asset.currency
1476
- } : undefined,
1477
- country: item.asset.country !== undefined ? {
1478
- set: item.asset.country
1479
- } : undefined,
1480
- sector: item.asset.sector !== undefined ? {
1481
- set: item.asset.sector
1482
- } : undefined,
1483
- industry: item.asset.industry !== undefined ? {
1484
- set: item.asset.industry
1485
- } : undefined,
1486
- address: item.asset.address !== undefined ? {
1487
- set: item.asset.address
1488
- } : undefined,
1489
- officialSite: item.asset.officialSite !== undefined ? {
1490
- set: item.asset.officialSite
1491
- } : undefined,
1492
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
1493
- set: item.asset.fiscalYearEnd
1494
- } : undefined,
1495
- latestQuarter: item.asset.latestQuarter !== undefined ? {
1496
- set: item.asset.latestQuarter
1497
- } : undefined,
1498
- marketCapitalization: item.asset.marketCapitalization !== undefined ? {
1499
- set: item.asset.marketCapitalization
1500
- } : undefined,
1501
- ebitda: item.asset.ebitda !== undefined ? {
1502
- set: item.asset.ebitda
1503
- } : undefined,
1504
- peRatio: item.asset.peRatio !== undefined ? {
1505
- set: item.asset.peRatio
1506
- } : undefined,
1507
- pegRatio: item.asset.pegRatio !== undefined ? {
1508
- set: item.asset.pegRatio
1509
- } : undefined,
1510
- bookValue: item.asset.bookValue !== undefined ? {
1511
- set: item.asset.bookValue
1512
- } : undefined,
1513
- dividendPerShare: item.asset.dividendPerShare !== undefined ? {
1514
- set: item.asset.dividendPerShare
1515
- } : undefined,
1516
- dividendYield: item.asset.dividendYield !== undefined ? {
1517
- set: item.asset.dividendYield
1518
- } : undefined,
1519
- eps: item.asset.eps !== undefined ? {
1520
- set: item.asset.eps
1521
- } : undefined,
1522
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
1523
- set: item.asset.revenuePerShareTTM
1524
- } : undefined,
1525
- profitMargin: item.asset.profitMargin !== undefined ? {
1526
- set: item.asset.profitMargin
1527
- } : undefined,
1528
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
1529
- set: item.asset.operatingMarginTTM
1530
- } : undefined,
1531
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
1532
- set: item.asset.returnOnAssetsTTM
1533
- } : undefined,
1534
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
1535
- set: item.asset.returnOnEquityTTM
1536
- } : undefined,
1537
- revenueTTM: item.asset.revenueTTM !== undefined ? {
1538
- set: item.asset.revenueTTM
1539
- } : undefined,
1540
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
1541
- set: item.asset.grossProfitTTM
1542
- } : undefined,
1543
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
1544
- set: item.asset.dilutedEPSTTM
1545
- } : undefined,
1546
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
1547
- set: item.asset.quarterlyEarningsGrowthYOY
1548
- } : undefined,
1549
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
1550
- set: item.asset.quarterlyRevenueGrowthYOY
1551
- } : undefined,
1552
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
1553
- set: item.asset.analystTargetPrice
1554
- } : undefined,
1555
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
1556
- set: item.asset.analystRatingStrongBuy
1557
- } : undefined,
1558
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
1559
- set: item.asset.analystRatingBuy
1560
- } : undefined,
1561
- analystRatingHold: item.asset.analystRatingHold !== undefined ? {
1562
- set: item.asset.analystRatingHold
1563
- } : undefined,
1564
- analystRatingSell: item.asset.analystRatingSell !== undefined ? {
1565
- set: item.asset.analystRatingSell
1566
- } : undefined,
1567
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
1568
- set: item.asset.analystRatingStrongSell
1569
- } : undefined,
1570
- trailingPE: item.asset.trailingPE !== undefined ? {
1571
- set: item.asset.trailingPE
1572
- } : undefined,
1573
- forwardPE: item.asset.forwardPE !== undefined ? {
1574
- set: item.asset.forwardPE
1575
- } : undefined,
1576
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
1577
- set: item.asset.priceToSalesRatioTTM
1578
- } : undefined,
1579
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
1580
- set: item.asset.priceToBookRatio
1581
- } : undefined,
1582
- evToRevenue: item.asset.evToRevenue !== undefined ? {
1583
- set: item.asset.evToRevenue
1584
- } : undefined,
1585
- evToEbitda: item.asset.evToEbitda !== undefined ? {
1586
- set: item.asset.evToEbitda
1587
- } : undefined,
1588
- beta: item.asset.beta !== undefined ? {
1589
- set: item.asset.beta
1590
- } : undefined,
1591
- week52High: item.asset.week52High !== undefined ? {
1592
- set: item.asset.week52High
1593
- } : undefined,
1594
- week52Low: item.asset.week52Low !== undefined ? {
1595
- set: item.asset.week52Low
1596
- } : undefined,
1597
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
1598
- set: item.asset.day50MovingAverage
1599
- } : undefined,
1600
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
1601
- set: item.asset.day200MovingAverage
1602
- } : undefined,
1603
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
1604
- set: item.asset.sharesOutstanding
1605
- } : undefined,
1606
- dividendDate: item.asset.dividendDate !== undefined ? {
1607
- set: item.asset.dividendDate
1608
- } : undefined,
1609
- exDividendDate: item.asset.exDividendDate !== undefined ? {
1610
- set: item.asset.exDividendDate
1611
- } : undefined,
1612
- askPrice: item.asset.askPrice !== undefined ? {
1613
- set: item.asset.askPrice
1614
- } : undefined,
1615
- bidPrice: item.asset.bidPrice !== undefined ? {
1616
- set: item.asset.bidPrice
1617
- } : undefined,
1618
- },
1619
- create: {
1620
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1621
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1622
- type: item.asset.type !== undefined ? item.asset.type : undefined,
1623
- logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1624
- description: item.asset.description !== undefined ? item.asset.description : undefined,
1625
- cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1626
- exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1627
- currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1628
- country: item.asset.country !== undefined ? item.asset.country : undefined,
1629
- sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1630
- industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1631
- address: item.asset.address !== undefined ? item.asset.address : undefined,
1632
- officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1633
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1634
- latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1635
- marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1636
- ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1637
- peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1638
- pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1639
- bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1640
- dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1641
- dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1642
- eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1643
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1644
- profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1645
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1646
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1647
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1648
- revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1649
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1650
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1651
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1652
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1653
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1654
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1655
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1656
- analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1657
- analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1658
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1659
- trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1660
- forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1661
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1662
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1663
- evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1664
- evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1665
- beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1666
- week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1667
- week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1668
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1669
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1670
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1671
- dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1672
- exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1673
- askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1674
- bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1675
- },
1676
- }
1677
- } : undefined,
1678
- },
1679
- create: {
1680
- url: item.url !== undefined ? item.url : undefined,
1681
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1682
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1683
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1684
- asset: item.asset ?
1685
- typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
1686
- ? { connect: {
1687
- id: item.asset.id
1688
- }
1689
- }
1690
- : { connectOrCreate: {
1691
- where: {
1692
- id: item.asset.id !== undefined ? item.asset.id : undefined,
1693
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1694
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1695
- },
1696
- create: {
1697
- symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1698
- name: item.asset.name !== undefined ? item.asset.name : undefined,
1699
- type: item.asset.type !== undefined ? item.asset.type : undefined,
1700
- logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1701
- description: item.asset.description !== undefined ? item.asset.description : undefined,
1702
- cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1703
- exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1704
- currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1705
- country: item.asset.country !== undefined ? item.asset.country : undefined,
1706
- sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1707
- industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1708
- address: item.asset.address !== undefined ? item.asset.address : undefined,
1709
- officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1710
- fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1711
- latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1712
- marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1713
- ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1714
- peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1715
- pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1716
- bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1717
- dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1718
- dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1719
- eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1720
- revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1721
- profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1722
- operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1723
- returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1724
- returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1725
- revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1726
- grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1727
- dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1728
- quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1729
- quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1730
- analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1731
- analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1732
- analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1733
- analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1734
- analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1735
- analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1736
- trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1737
- forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1738
- priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1739
- priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1740
- evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1741
- evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1742
- beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1743
- week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1744
- week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1745
- day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1746
- day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1747
- sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1748
- dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1749
- exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1750
- askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1751
- bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1752
- },
1753
- }
1534
+ var _a, _b, _c, _d, _e;
1535
+ // Maximum number of retries for database connection issues
1536
+ const MAX_RETRIES = 3;
1537
+ let retryCount = 0;
1538
+ let lastError = null;
1539
+ // Retry loop to handle potential database connection issues
1540
+ while (retryCount < MAX_RETRIES) {
1541
+ try {
1542
+ const [modules, client] = await Promise.all([
1543
+ (0, client_1.getApolloModules)(),
1544
+ globalClient
1545
+ ? Promise.resolve(globalClient)
1546
+ : client_1.client
1547
+ ]);
1548
+ const { gql, ApolloError } = modules;
1549
+ const UPDATE_MANY_NEWSARTICLE = gql `
1550
+ mutation updateManyNewsArticle($data: [NewsArticleCreateManyInput!]!) {
1551
+ updateManyNewsArticle(data: $data) {
1552
+ count
1553
+ }
1554
+ }`;
1555
+ const variables = props.map(prop => ({
1556
+ where: {
1557
+ id: prop.id !== undefined ? prop.id : undefined,
1558
+ url: prop.url !== undefined ? prop.url : undefined,
1559
+ title: prop.title !== undefined ? prop.title : undefined,
1560
+ content: prop.content !== undefined ? {
1561
+ equals: prop.content
1562
+ } : undefined,
1563
+ source: prop.source !== undefined ? {
1564
+ equals: prop.source
1565
+ } : undefined,
1566
+ sourceDomain: prop.sourceDomain !== undefined ? {
1567
+ equals: prop.sourceDomain
1568
+ } : undefined,
1569
+ sentiment: prop.sentiment !== undefined ? {
1570
+ equals: prop.sentiment
1571
+ } : undefined,
1572
+ authors: prop.authors !== undefined ? {
1573
+ equals: prop.authors
1574
+ } : undefined,
1575
+ summary: prop.summary !== undefined ? {
1576
+ equals: prop.summary
1577
+ } : undefined,
1578
+ bannerImage: prop.bannerImage !== undefined ? {
1579
+ equals: prop.bannerImage
1580
+ } : undefined,
1581
+ timePublished: prop.timePublished !== undefined ? {
1582
+ equals: prop.timePublished
1583
+ } : undefined,
1584
+ category: prop.category !== undefined ? {
1585
+ equals: prop.category
1586
+ } : undefined,
1587
+ topics: prop.topics !== undefined ? {
1588
+ equals: prop.topics
1589
+ } : undefined,
1590
+ logo: prop.logo !== undefined ? {
1591
+ equals: prop.logo
1592
+ } : undefined,
1593
+ createdAt: prop.createdAt !== undefined ? {
1594
+ equals: prop.createdAt
1595
+ } : undefined,
1596
+ updatedAt: prop.updatedAt !== undefined ? {
1597
+ equals: prop.updatedAt
1598
+ } : undefined,
1599
+ },
1600
+ data: {
1601
+ id: prop.id !== undefined ? {
1602
+ set: prop.id
1603
+ } : undefined,
1604
+ title: prop.title !== undefined ? {
1605
+ set: prop.title
1606
+ } : undefined,
1607
+ content: prop.content !== undefined ? {
1608
+ set: prop.content
1609
+ } : undefined,
1610
+ source: prop.source !== undefined ? {
1611
+ set: prop.source
1612
+ } : undefined,
1613
+ sourceDomain: prop.sourceDomain !== undefined ? {
1614
+ set: prop.sourceDomain
1615
+ } : undefined,
1616
+ url: prop.url !== undefined ? {
1617
+ set: prop.url
1618
+ } : undefined,
1619
+ sentiment: prop.sentiment !== undefined ? {
1620
+ set: prop.sentiment
1621
+ } : undefined,
1622
+ authors: prop.authors !== undefined ? {
1623
+ set: prop.authors
1624
+ } : undefined,
1625
+ summary: prop.summary !== undefined ? {
1626
+ set: prop.summary
1627
+ } : undefined,
1628
+ bannerImage: prop.bannerImage !== undefined ? {
1629
+ set: prop.bannerImage
1630
+ } : undefined,
1631
+ timePublished: prop.timePublished !== undefined ? {
1632
+ set: prop.timePublished
1633
+ } : undefined,
1634
+ category: prop.category !== undefined ? {
1635
+ set: prop.category
1636
+ } : undefined,
1637
+ topics: prop.topics !== undefined ? {
1638
+ set: prop.topics
1639
+ } : undefined,
1640
+ logo: prop.logo !== undefined ? {
1641
+ set: prop.logo
1642
+ } : undefined,
1643
+ createdAt: prop.createdAt !== undefined ? {
1644
+ set: prop.createdAt
1645
+ } : undefined,
1646
+ updatedAt: prop.updatedAt !== undefined ? {
1647
+ set: prop.updatedAt
1648
+ } : undefined,
1649
+ assets: prop.assets ?
1650
+ Array.isArray(prop.assets) && prop.assets.length > 0 && prop.assets.every((item) => typeof item === 'object' && ('id' in item || 'symbol' in item) && Object.keys(item).length === 1) ? {
1651
+ connect: prop.assets.map((item) => ({
1652
+ id: item.id
1653
+ }))
1654
+ } : { upsert: prop.assets.map((item) => ({
1655
+ where: {
1656
+ id: item.id !== undefined ? item.id : undefined,
1657
+ url: item.url !== undefined ? item.url : undefined,
1658
+ assetId: item.assetId !== undefined ? {
1659
+ equals: item.assetId
1660
+ } : undefined,
1661
+ newsArticleId: item.newsArticleId !== undefined ? {
1662
+ equals: item.newsArticleId
1663
+ } : undefined,
1664
+ },
1665
+ update: {
1666
+ id: item.id !== undefined ? {
1667
+ set: item.id
1668
+ } : undefined,
1669
+ url: item.url !== undefined ? {
1670
+ set: item.url
1671
+ } : undefined,
1672
+ relevancyScore: item.relevancyScore !== undefined ? {
1673
+ set: item.relevancyScore
1754
1674
  } : undefined,
1755
- },
1756
- }))
1757
- } : undefined,
1758
- },
1759
- }));
1760
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
1761
- try {
1762
- const response = await client.mutate({ mutation: UPDATE_MANY_NEWSARTICLE, variables: filteredVariables });
1763
- if (response.errors && response.errors.length > 0)
1764
- throw new Error(response.errors[0].message);
1765
- if (response && response.data && response.data.updateManyNewsArticle) {
1766
- return response.data.updateManyNewsArticle;
1675
+ sentimentScore: item.sentimentScore !== undefined ? {
1676
+ set: item.sentimentScore
1677
+ } : undefined,
1678
+ sentimentLabel: item.sentimentLabel !== undefined ? {
1679
+ set: item.sentimentLabel
1680
+ } : undefined,
1681
+ asset: item.asset ?
1682
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && (Object.keys(item.asset)[0] === 'id' || Object.keys(item.asset)[0] === 'symbol')
1683
+ ? {
1684
+ connect: {
1685
+ id: item.asset.id
1686
+ }
1687
+ } : { upsert: {
1688
+ where: {
1689
+ id: item.asset.id !== undefined ? {
1690
+ equals: item.asset.id
1691
+ } : undefined,
1692
+ symbol: item.asset.symbol !== undefined ? {
1693
+ equals: item.asset.symbol
1694
+ } : undefined,
1695
+ name: item.asset.name !== undefined ? {
1696
+ equals: item.asset.name
1697
+ } : undefined,
1698
+ },
1699
+ update: {
1700
+ id: item.asset.id !== undefined ? {
1701
+ set: item.asset.id
1702
+ } : undefined,
1703
+ symbol: item.asset.symbol !== undefined ? {
1704
+ set: item.asset.symbol
1705
+ } : undefined,
1706
+ name: item.asset.name !== undefined ? {
1707
+ set: item.asset.name
1708
+ } : undefined,
1709
+ type: item.asset.type !== undefined ? {
1710
+ set: item.asset.type
1711
+ } : undefined,
1712
+ logoUrl: item.asset.logoUrl !== undefined ? {
1713
+ set: item.asset.logoUrl
1714
+ } : undefined,
1715
+ description: item.asset.description !== undefined ? {
1716
+ set: item.asset.description
1717
+ } : undefined,
1718
+ cik: item.asset.cik !== undefined ? {
1719
+ set: item.asset.cik
1720
+ } : undefined,
1721
+ exchange: item.asset.exchange !== undefined ? {
1722
+ set: item.asset.exchange
1723
+ } : undefined,
1724
+ currency: item.asset.currency !== undefined ? {
1725
+ set: item.asset.currency
1726
+ } : undefined,
1727
+ country: item.asset.country !== undefined ? {
1728
+ set: item.asset.country
1729
+ } : undefined,
1730
+ sector: item.asset.sector !== undefined ? {
1731
+ set: item.asset.sector
1732
+ } : undefined,
1733
+ industry: item.asset.industry !== undefined ? {
1734
+ set: item.asset.industry
1735
+ } : undefined,
1736
+ address: item.asset.address !== undefined ? {
1737
+ set: item.asset.address
1738
+ } : undefined,
1739
+ officialSite: item.asset.officialSite !== undefined ? {
1740
+ set: item.asset.officialSite
1741
+ } : undefined,
1742
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? {
1743
+ set: item.asset.fiscalYearEnd
1744
+ } : undefined,
1745
+ latestQuarter: item.asset.latestQuarter !== undefined ? {
1746
+ set: item.asset.latestQuarter
1747
+ } : undefined,
1748
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? {
1749
+ set: item.asset.marketCapitalization
1750
+ } : undefined,
1751
+ ebitda: item.asset.ebitda !== undefined ? {
1752
+ set: item.asset.ebitda
1753
+ } : undefined,
1754
+ peRatio: item.asset.peRatio !== undefined ? {
1755
+ set: item.asset.peRatio
1756
+ } : undefined,
1757
+ pegRatio: item.asset.pegRatio !== undefined ? {
1758
+ set: item.asset.pegRatio
1759
+ } : undefined,
1760
+ bookValue: item.asset.bookValue !== undefined ? {
1761
+ set: item.asset.bookValue
1762
+ } : undefined,
1763
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? {
1764
+ set: item.asset.dividendPerShare
1765
+ } : undefined,
1766
+ dividendYield: item.asset.dividendYield !== undefined ? {
1767
+ set: item.asset.dividendYield
1768
+ } : undefined,
1769
+ eps: item.asset.eps !== undefined ? {
1770
+ set: item.asset.eps
1771
+ } : undefined,
1772
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? {
1773
+ set: item.asset.revenuePerShareTTM
1774
+ } : undefined,
1775
+ profitMargin: item.asset.profitMargin !== undefined ? {
1776
+ set: item.asset.profitMargin
1777
+ } : undefined,
1778
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? {
1779
+ set: item.asset.operatingMarginTTM
1780
+ } : undefined,
1781
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? {
1782
+ set: item.asset.returnOnAssetsTTM
1783
+ } : undefined,
1784
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? {
1785
+ set: item.asset.returnOnEquityTTM
1786
+ } : undefined,
1787
+ revenueTTM: item.asset.revenueTTM !== undefined ? {
1788
+ set: item.asset.revenueTTM
1789
+ } : undefined,
1790
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? {
1791
+ set: item.asset.grossProfitTTM
1792
+ } : undefined,
1793
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? {
1794
+ set: item.asset.dilutedEPSTTM
1795
+ } : undefined,
1796
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? {
1797
+ set: item.asset.quarterlyEarningsGrowthYOY
1798
+ } : undefined,
1799
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? {
1800
+ set: item.asset.quarterlyRevenueGrowthYOY
1801
+ } : undefined,
1802
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? {
1803
+ set: item.asset.analystTargetPrice
1804
+ } : undefined,
1805
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? {
1806
+ set: item.asset.analystRatingStrongBuy
1807
+ } : undefined,
1808
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? {
1809
+ set: item.asset.analystRatingBuy
1810
+ } : undefined,
1811
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? {
1812
+ set: item.asset.analystRatingHold
1813
+ } : undefined,
1814
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? {
1815
+ set: item.asset.analystRatingSell
1816
+ } : undefined,
1817
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? {
1818
+ set: item.asset.analystRatingStrongSell
1819
+ } : undefined,
1820
+ trailingPE: item.asset.trailingPE !== undefined ? {
1821
+ set: item.asset.trailingPE
1822
+ } : undefined,
1823
+ forwardPE: item.asset.forwardPE !== undefined ? {
1824
+ set: item.asset.forwardPE
1825
+ } : undefined,
1826
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? {
1827
+ set: item.asset.priceToSalesRatioTTM
1828
+ } : undefined,
1829
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? {
1830
+ set: item.asset.priceToBookRatio
1831
+ } : undefined,
1832
+ evToRevenue: item.asset.evToRevenue !== undefined ? {
1833
+ set: item.asset.evToRevenue
1834
+ } : undefined,
1835
+ evToEbitda: item.asset.evToEbitda !== undefined ? {
1836
+ set: item.asset.evToEbitda
1837
+ } : undefined,
1838
+ beta: item.asset.beta !== undefined ? {
1839
+ set: item.asset.beta
1840
+ } : undefined,
1841
+ week52High: item.asset.week52High !== undefined ? {
1842
+ set: item.asset.week52High
1843
+ } : undefined,
1844
+ week52Low: item.asset.week52Low !== undefined ? {
1845
+ set: item.asset.week52Low
1846
+ } : undefined,
1847
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? {
1848
+ set: item.asset.day50MovingAverage
1849
+ } : undefined,
1850
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? {
1851
+ set: item.asset.day200MovingAverage
1852
+ } : undefined,
1853
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? {
1854
+ set: item.asset.sharesOutstanding
1855
+ } : undefined,
1856
+ dividendDate: item.asset.dividendDate !== undefined ? {
1857
+ set: item.asset.dividendDate
1858
+ } : undefined,
1859
+ exDividendDate: item.asset.exDividendDate !== undefined ? {
1860
+ set: item.asset.exDividendDate
1861
+ } : undefined,
1862
+ askPrice: item.asset.askPrice !== undefined ? {
1863
+ set: item.asset.askPrice
1864
+ } : undefined,
1865
+ bidPrice: item.asset.bidPrice !== undefined ? {
1866
+ set: item.asset.bidPrice
1867
+ } : undefined,
1868
+ },
1869
+ create: {
1870
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1871
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1872
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
1873
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1874
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
1875
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1876
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1877
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1878
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
1879
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1880
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1881
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
1882
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1883
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1884
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1885
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1886
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1887
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1888
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1889
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1890
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1891
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1892
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1893
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1894
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1895
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1896
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1897
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1898
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1899
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1900
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1901
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1902
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1903
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1904
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1905
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1906
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1907
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1908
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1909
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1910
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1911
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1912
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1913
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1914
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1915
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1916
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1917
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1918
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1919
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1920
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1921
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1922
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
1923
+ askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
1924
+ bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
1925
+ },
1926
+ }
1927
+ } : undefined,
1928
+ },
1929
+ create: {
1930
+ url: item.url !== undefined ? item.url : undefined,
1931
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1932
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1933
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1934
+ asset: item.asset ?
1935
+ typeof item.asset === 'object' && Object.keys(item.asset).length === 1 && Object.keys(item.asset)[0] === 'id'
1936
+ ? { connect: {
1937
+ id: item.asset.id
1938
+ }
1939
+ }
1940
+ : { connectOrCreate: {
1941
+ where: {
1942
+ id: item.asset.id !== undefined ? item.asset.id : undefined,
1943
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1944
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1945
+ },
1946
+ create: {
1947
+ symbol: item.asset.symbol !== undefined ? item.asset.symbol : undefined,
1948
+ name: item.asset.name !== undefined ? item.asset.name : undefined,
1949
+ type: item.asset.type !== undefined ? item.asset.type : undefined,
1950
+ logoUrl: item.asset.logoUrl !== undefined ? item.asset.logoUrl : undefined,
1951
+ description: item.asset.description !== undefined ? item.asset.description : undefined,
1952
+ cik: item.asset.cik !== undefined ? item.asset.cik : undefined,
1953
+ exchange: item.asset.exchange !== undefined ? item.asset.exchange : undefined,
1954
+ currency: item.asset.currency !== undefined ? item.asset.currency : undefined,
1955
+ country: item.asset.country !== undefined ? item.asset.country : undefined,
1956
+ sector: item.asset.sector !== undefined ? item.asset.sector : undefined,
1957
+ industry: item.asset.industry !== undefined ? item.asset.industry : undefined,
1958
+ address: item.asset.address !== undefined ? item.asset.address : undefined,
1959
+ officialSite: item.asset.officialSite !== undefined ? item.asset.officialSite : undefined,
1960
+ fiscalYearEnd: item.asset.fiscalYearEnd !== undefined ? item.asset.fiscalYearEnd : undefined,
1961
+ latestQuarter: item.asset.latestQuarter !== undefined ? item.asset.latestQuarter : undefined,
1962
+ marketCapitalization: item.asset.marketCapitalization !== undefined ? item.asset.marketCapitalization : undefined,
1963
+ ebitda: item.asset.ebitda !== undefined ? item.asset.ebitda : undefined,
1964
+ peRatio: item.asset.peRatio !== undefined ? item.asset.peRatio : undefined,
1965
+ pegRatio: item.asset.pegRatio !== undefined ? item.asset.pegRatio : undefined,
1966
+ bookValue: item.asset.bookValue !== undefined ? item.asset.bookValue : undefined,
1967
+ dividendPerShare: item.asset.dividendPerShare !== undefined ? item.asset.dividendPerShare : undefined,
1968
+ dividendYield: item.asset.dividendYield !== undefined ? item.asset.dividendYield : undefined,
1969
+ eps: item.asset.eps !== undefined ? item.asset.eps : undefined,
1970
+ revenuePerShareTTM: item.asset.revenuePerShareTTM !== undefined ? item.asset.revenuePerShareTTM : undefined,
1971
+ profitMargin: item.asset.profitMargin !== undefined ? item.asset.profitMargin : undefined,
1972
+ operatingMarginTTM: item.asset.operatingMarginTTM !== undefined ? item.asset.operatingMarginTTM : undefined,
1973
+ returnOnAssetsTTM: item.asset.returnOnAssetsTTM !== undefined ? item.asset.returnOnAssetsTTM : undefined,
1974
+ returnOnEquityTTM: item.asset.returnOnEquityTTM !== undefined ? item.asset.returnOnEquityTTM : undefined,
1975
+ revenueTTM: item.asset.revenueTTM !== undefined ? item.asset.revenueTTM : undefined,
1976
+ grossProfitTTM: item.asset.grossProfitTTM !== undefined ? item.asset.grossProfitTTM : undefined,
1977
+ dilutedEPSTTM: item.asset.dilutedEPSTTM !== undefined ? item.asset.dilutedEPSTTM : undefined,
1978
+ quarterlyEarningsGrowthYOY: item.asset.quarterlyEarningsGrowthYOY !== undefined ? item.asset.quarterlyEarningsGrowthYOY : undefined,
1979
+ quarterlyRevenueGrowthYOY: item.asset.quarterlyRevenueGrowthYOY !== undefined ? item.asset.quarterlyRevenueGrowthYOY : undefined,
1980
+ analystTargetPrice: item.asset.analystTargetPrice !== undefined ? item.asset.analystTargetPrice : undefined,
1981
+ analystRatingStrongBuy: item.asset.analystRatingStrongBuy !== undefined ? item.asset.analystRatingStrongBuy : undefined,
1982
+ analystRatingBuy: item.asset.analystRatingBuy !== undefined ? item.asset.analystRatingBuy : undefined,
1983
+ analystRatingHold: item.asset.analystRatingHold !== undefined ? item.asset.analystRatingHold : undefined,
1984
+ analystRatingSell: item.asset.analystRatingSell !== undefined ? item.asset.analystRatingSell : undefined,
1985
+ analystRatingStrongSell: item.asset.analystRatingStrongSell !== undefined ? item.asset.analystRatingStrongSell : undefined,
1986
+ trailingPE: item.asset.trailingPE !== undefined ? item.asset.trailingPE : undefined,
1987
+ forwardPE: item.asset.forwardPE !== undefined ? item.asset.forwardPE : undefined,
1988
+ priceToSalesRatioTTM: item.asset.priceToSalesRatioTTM !== undefined ? item.asset.priceToSalesRatioTTM : undefined,
1989
+ priceToBookRatio: item.asset.priceToBookRatio !== undefined ? item.asset.priceToBookRatio : undefined,
1990
+ evToRevenue: item.asset.evToRevenue !== undefined ? item.asset.evToRevenue : undefined,
1991
+ evToEbitda: item.asset.evToEbitda !== undefined ? item.asset.evToEbitda : undefined,
1992
+ beta: item.asset.beta !== undefined ? item.asset.beta : undefined,
1993
+ week52High: item.asset.week52High !== undefined ? item.asset.week52High : undefined,
1994
+ week52Low: item.asset.week52Low !== undefined ? item.asset.week52Low : undefined,
1995
+ day50MovingAverage: item.asset.day50MovingAverage !== undefined ? item.asset.day50MovingAverage : undefined,
1996
+ day200MovingAverage: item.asset.day200MovingAverage !== undefined ? item.asset.day200MovingAverage : undefined,
1997
+ sharesOutstanding: item.asset.sharesOutstanding !== undefined ? item.asset.sharesOutstanding : undefined,
1998
+ dividendDate: item.asset.dividendDate !== undefined ? item.asset.dividendDate : undefined,
1999
+ exDividendDate: item.asset.exDividendDate !== undefined ? item.asset.exDividendDate : undefined,
2000
+ askPrice: item.asset.askPrice !== undefined ? item.asset.askPrice : undefined,
2001
+ bidPrice: item.asset.bidPrice !== undefined ? item.asset.bidPrice : undefined,
2002
+ },
2003
+ }
2004
+ } : undefined,
2005
+ },
2006
+ }))
2007
+ } : undefined,
2008
+ },
2009
+ }));
2010
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
2011
+ const response = await client.mutate({
2012
+ mutation: UPDATE_MANY_NEWSARTICLE,
2013
+ variables: filteredVariables,
2014
+ // Don't cache mutations, but ensure we're using the freshest context
2015
+ fetchPolicy: 'no-cache'
2016
+ });
2017
+ if (response.errors && response.errors.length > 0)
2018
+ throw new Error(response.errors[0].message);
2019
+ if (response && response.data && response.data.updateManyNewsArticle) {
2020
+ return response.data.updateManyNewsArticle;
2021
+ }
2022
+ else {
2023
+ return null;
2024
+ }
1767
2025
  }
1768
- else {
1769
- return null;
2026
+ catch (error) {
2027
+ lastError = error;
2028
+ // Check if this is a database connection error that we should retry
2029
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2030
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2031
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2032
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2033
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2034
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2035
+ retryCount++;
2036
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2037
+ console.warn("Database connection error, retrying...");
2038
+ await new Promise(resolve => setTimeout(resolve, delay));
2039
+ continue;
2040
+ }
2041
+ // Log the error and rethrow
2042
+ console.error("Database error occurred:", error);
2043
+ throw error;
1770
2044
  }
1771
2045
  }
1772
- catch (error) {
1773
- console.error('Error in updateManyNewsArticle:', error);
1774
- throw error;
1775
- }
2046
+ // If we exhausted retries, throw the last error
2047
+ throw lastError;
1776
2048
  },
1777
2049
  /**
1778
2050
  * Delete a single NewsArticle record.
1779
- * @param props - Properties to update.
2051
+ * Enhanced with connection resilience against Prisma connection errors.
2052
+ * @param props - Properties to identify the record to delete.
1780
2053
  * @param globalClient - Apollo Client instance.
1781
2054
  * @returns The deleted NewsArticle or null.
1782
2055
  */
1783
2056
  async delete(props, globalClient) {
1784
- const [modules, client] = await Promise.all([
1785
- (0, client_1.getApolloModules)(),
1786
- globalClient
1787
- ? Promise.resolve(globalClient)
1788
- : client_1.client
1789
- ]);
1790
- const { gql, ApolloError } = modules;
1791
- const DELETE_ONE_NEWSARTICLE = gql `
1792
- mutation deleteOneNewsArticle($where: NewsArticleWhereUniqueInput!) {
1793
- deleteOneNewsArticle(where: $where) {
1794
- id
1795
- }
1796
- }`;
1797
- const variables = {
1798
- where: {
1799
- id: props.id ? props.id : undefined,
2057
+ var _a, _b, _c, _d, _e;
2058
+ // Maximum number of retries for database connection issues
2059
+ const MAX_RETRIES = 3;
2060
+ let retryCount = 0;
2061
+ let lastError = null;
2062
+ // Retry loop to handle potential database connection issues
2063
+ while (retryCount < MAX_RETRIES) {
2064
+ try {
2065
+ const [modules, client] = await Promise.all([
2066
+ (0, client_1.getApolloModules)(),
2067
+ globalClient
2068
+ ? Promise.resolve(globalClient)
2069
+ : client_1.client
2070
+ ]);
2071
+ const { gql, ApolloError } = modules;
2072
+ const DELETE_ONE_NEWSARTICLE = gql `
2073
+ mutation deleteOneNewsArticle($where: NewsArticleWhereUniqueInput!) {
2074
+ deleteOneNewsArticle(where: $where) {
2075
+ id
1800
2076
  }
1801
- };
1802
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
1803
- try {
1804
- const response = await client.mutate({ mutation: DELETE_ONE_NEWSARTICLE, variables: filteredVariables });
1805
- if (response.errors && response.errors.length > 0)
1806
- throw new Error(response.errors[0].message);
1807
- if (response && response.data && response.data.deleteOneNewsArticle) {
1808
- return response.data.deleteOneNewsArticle;
2077
+ }`;
2078
+ const variables = {
2079
+ where: {
2080
+ id: props.id ? props.id : undefined,
2081
+ }
2082
+ };
2083
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
2084
+ const response = await client.mutate({
2085
+ mutation: DELETE_ONE_NEWSARTICLE,
2086
+ variables: filteredVariables,
2087
+ // Don't cache mutations, but ensure we're using the freshest context
2088
+ fetchPolicy: 'no-cache'
2089
+ });
2090
+ if (response.errors && response.errors.length > 0)
2091
+ throw new Error(response.errors[0].message);
2092
+ if (response && response.data && response.data.deleteOneNewsArticle) {
2093
+ return response.data.deleteOneNewsArticle;
2094
+ }
2095
+ else {
2096
+ return null;
2097
+ }
1809
2098
  }
1810
- else {
1811
- return null;
2099
+ catch (error) {
2100
+ lastError = error;
2101
+ // Check if this is a database connection error that we should retry
2102
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2103
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2104
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2105
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2106
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2107
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2108
+ retryCount++;
2109
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2110
+ console.warn("Database connection error, retrying...");
2111
+ await new Promise(resolve => setTimeout(resolve, delay));
2112
+ continue;
2113
+ }
2114
+ // Log the error and rethrow
2115
+ console.error("Database error occurred:", error);
2116
+ throw error;
1812
2117
  }
1813
2118
  }
1814
- catch (error) {
1815
- console.error('Error in deleteOneNewsArticle:', error);
1816
- throw error;
1817
- }
2119
+ // If we exhausted retries, throw the last error
2120
+ throw lastError;
1818
2121
  },
1819
2122
  /**
1820
2123
  * Retrieve a single NewsArticle record by ID.
1821
- * @param props - Properties to update.
2124
+ * Enhanced with connection resilience against Prisma connection errors.
2125
+ * @param props - Properties to identify the record.
1822
2126
  * @param globalClient - Apollo Client instance.
2127
+ * @param whereInput - Optional custom where input.
1823
2128
  * @returns The retrieved NewsArticle or null.
1824
2129
  */
1825
2130
  async get(props, globalClient, whereInput) {
1826
- var _a, _b;
1827
- const [modules, client] = await Promise.all([
1828
- (0, client_1.getApolloModules)(),
1829
- globalClient
1830
- ? Promise.resolve(globalClient)
1831
- : client_1.client
1832
- ]);
1833
- const { gql, ApolloError } = modules;
1834
- const GET_NEWSARTICLE = gql `
1835
- query getNewsArticle($where: NewsArticleWhereUniqueInput!) {
1836
- getNewsArticle(where: $where) {
1837
- ${selectionSet}
1838
- }
1839
- }`;
1840
- const variables = {
1841
- where: whereInput ? whereInput : {
1842
- id: props.id !== undefined ? props.id : undefined,
1843
- url: props.url !== undefined ? props.url : undefined,
1844
- title: props.title !== undefined ? {
1845
- equals: props.title
1846
- } : undefined,
1847
- },
1848
- };
1849
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
1850
- try {
1851
- const response = await client.query({ query: GET_NEWSARTICLE, variables: filteredVariables });
1852
- if (response.errors && response.errors.length > 0)
1853
- throw new Error(response.errors[0].message);
1854
- return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.getNewsArticle) !== null && _b !== void 0 ? _b : null;
1855
- }
1856
- catch (error) {
1857
- if (error instanceof ApolloError && error.message === 'No NewsArticle found') {
1858
- return null;
2131
+ var _a, _b, _c, _d, _e, _f, _g;
2132
+ // Maximum number of retries for database connection issues
2133
+ const MAX_RETRIES = 3;
2134
+ let retryCount = 0;
2135
+ let lastError = null;
2136
+ // Retry loop to handle potential database connection issues
2137
+ while (retryCount < MAX_RETRIES) {
2138
+ try {
2139
+ const [modules, client] = await Promise.all([
2140
+ (0, client_1.getApolloModules)(),
2141
+ globalClient
2142
+ ? Promise.resolve(globalClient)
2143
+ : client_1.client
2144
+ ]);
2145
+ const { gql, ApolloError } = modules;
2146
+ const GET_NEWSARTICLE = gql `
2147
+ query getNewsArticle($where: NewsArticleWhereUniqueInput!) {
2148
+ getNewsArticle(where: $where) {
2149
+ ${selectionSet}
2150
+ }
2151
+ }`;
2152
+ const variables = {
2153
+ where: whereInput ? whereInput : {
2154
+ id: props.id !== undefined ? props.id : undefined,
2155
+ url: props.url !== undefined ? props.url : undefined,
2156
+ title: props.title !== undefined ? props.title : undefined,
2157
+ content: props.content !== undefined ? {
2158
+ equals: props.content
2159
+ } : undefined,
2160
+ source: props.source !== undefined ? {
2161
+ equals: props.source
2162
+ } : undefined,
2163
+ sourceDomain: props.sourceDomain !== undefined ? {
2164
+ equals: props.sourceDomain
2165
+ } : undefined,
2166
+ sentiment: props.sentiment !== undefined ? {
2167
+ equals: props.sentiment
2168
+ } : undefined,
2169
+ authors: props.authors !== undefined ? {
2170
+ equals: props.authors
2171
+ } : undefined,
2172
+ summary: props.summary !== undefined ? {
2173
+ equals: props.summary
2174
+ } : undefined,
2175
+ bannerImage: props.bannerImage !== undefined ? {
2176
+ equals: props.bannerImage
2177
+ } : undefined,
2178
+ timePublished: props.timePublished !== undefined ? {
2179
+ equals: props.timePublished
2180
+ } : undefined,
2181
+ category: props.category !== undefined ? {
2182
+ equals: props.category
2183
+ } : undefined,
2184
+ topics: props.topics !== undefined ? {
2185
+ equals: props.topics
2186
+ } : undefined,
2187
+ logo: props.logo !== undefined ? {
2188
+ equals: props.logo
2189
+ } : undefined,
2190
+ createdAt: props.createdAt !== undefined ? {
2191
+ equals: props.createdAt
2192
+ } : undefined,
2193
+ updatedAt: props.updatedAt !== undefined ? {
2194
+ equals: props.updatedAt
2195
+ } : undefined,
2196
+ },
2197
+ };
2198
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
2199
+ const response = await client.query({
2200
+ query: GET_NEWSARTICLE,
2201
+ variables: filteredVariables,
2202
+ fetchPolicy: 'network-only', // Force network request to avoid stale cache
2203
+ });
2204
+ if (response.errors && response.errors.length > 0)
2205
+ throw new Error(response.errors[0].message);
2206
+ return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.getNewsArticle) !== null && _b !== void 0 ? _b : null;
1859
2207
  }
1860
- else {
1861
- console.error('Error in getNewsArticle:', error);
2208
+ catch (error) {
2209
+ lastError = error;
2210
+ // Check if this is a "No record found" error - this is an expected condition, not a failure
2211
+ if (error.message === 'No NewsArticle found') {
2212
+ return null;
2213
+ }
2214
+ // Check if this is a database connection error that we should retry
2215
+ const isConnectionError = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Server has closed the connection')) ||
2216
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Cannot reach database server')) ||
2217
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('Connection timed out')) ||
2218
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('Accelerate')) || // Prisma Accelerate proxy errors
2219
+ (error.networkError && ((_g = error.networkError.message) === null || _g === void 0 ? void 0 : _g.includes('Failed to fetch')));
2220
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2221
+ retryCount++;
2222
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2223
+ console.warn("Database connection error, retrying...");
2224
+ await new Promise(resolve => setTimeout(resolve, delay));
2225
+ continue;
2226
+ }
2227
+ // Log the error and rethrow
2228
+ console.error("Database error occurred:", error);
1862
2229
  throw error;
1863
2230
  }
1864
2231
  }
2232
+ // If we exhausted retries, throw the last error
2233
+ throw lastError;
1865
2234
  },
1866
2235
  /**
1867
2236
  * Retrieve all NewsArticles records.
2237
+ * Enhanced with connection resilience against Prisma connection errors.
1868
2238
  * @param globalClient - Apollo Client instance.
1869
2239
  * @returns An array of NewsArticle records or null.
1870
2240
  */
1871
2241
  async getAll(globalClient) {
1872
- var _a, _b;
1873
- const [modules, client] = await Promise.all([
1874
- (0, client_1.getApolloModules)(),
1875
- globalClient
1876
- ? Promise.resolve(globalClient)
1877
- : client_1.client
1878
- ]);
1879
- const { gql, ApolloError } = modules;
1880
- const GET_ALL_NEWSARTICLE = gql `
1881
- query getAllNewsArticle {
1882
- newsArticles {
1883
- ${selectionSet}
1884
- }
1885
- }`;
1886
- try {
1887
- const response = await client.query({ query: GET_ALL_NEWSARTICLE });
1888
- if (response.errors && response.errors.length > 0)
1889
- throw new Error(response.errors[0].message);
1890
- return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.newsArticles) !== null && _b !== void 0 ? _b : null;
1891
- }
1892
- catch (error) {
1893
- if (error instanceof ApolloError && error.message === 'No NewsArticle found') {
1894
- return null;
2242
+ var _a, _b, _c, _d, _e, _f, _g;
2243
+ // Maximum number of retries for database connection issues
2244
+ const MAX_RETRIES = 3;
2245
+ let retryCount = 0;
2246
+ let lastError = null;
2247
+ // Retry loop to handle potential database connection issues
2248
+ while (retryCount < MAX_RETRIES) {
2249
+ try {
2250
+ const [modules, client] = await Promise.all([
2251
+ (0, client_1.getApolloModules)(),
2252
+ globalClient
2253
+ ? Promise.resolve(globalClient)
2254
+ : client_1.client
2255
+ ]);
2256
+ const { gql, ApolloError } = modules;
2257
+ const GET_ALL_NEWSARTICLE = gql `
2258
+ query getAllNewsArticle {
2259
+ newsArticles {
2260
+ ${selectionSet}
1895
2261
  }
1896
- else {
1897
- console.error('Error in getNewsArticle:', error);
2262
+ }`;
2263
+ const response = await client.query({
2264
+ query: GET_ALL_NEWSARTICLE,
2265
+ fetchPolicy: 'network-only', // Force network request to avoid stale cache
2266
+ });
2267
+ if (response.errors && response.errors.length > 0)
2268
+ throw new Error(response.errors[0].message);
2269
+ return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.newsArticles) !== null && _b !== void 0 ? _b : null;
2270
+ }
2271
+ catch (error) {
2272
+ lastError = error;
2273
+ // Check if this is a "No record found" error - this is an expected condition, not a failure
2274
+ if (error.message === 'No NewsArticle found') {
2275
+ return null;
2276
+ }
2277
+ // Check if this is a database connection error that we should retry
2278
+ const isConnectionError = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Server has closed the connection')) ||
2279
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Cannot reach database server')) ||
2280
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('Connection timed out')) ||
2281
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('Accelerate')) || // Prisma Accelerate proxy errors
2282
+ (error.networkError && ((_g = error.networkError.message) === null || _g === void 0 ? void 0 : _g.includes('Failed to fetch')));
2283
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2284
+ retryCount++;
2285
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2286
+ console.warn("Database connection error, retrying...");
2287
+ await new Promise(resolve => setTimeout(resolve, delay));
2288
+ continue;
2289
+ }
2290
+ // Log the error and rethrow
2291
+ console.error("Database error occurred:", error);
1898
2292
  throw error;
1899
2293
  }
1900
2294
  }
2295
+ // If we exhausted retries, throw the last error
2296
+ throw lastError;
1901
2297
  },
1902
2298
  /**
1903
2299
  * Find multiple NewsArticle records based on conditions.
2300
+ * Enhanced with connection resilience against Prisma connection errors.
1904
2301
  * @param props - Conditions to find records.
1905
2302
  * @param globalClient - Apollo Client instance.
2303
+ * @param whereInput - Optional custom where input.
1906
2304
  * @returns An array of found NewsArticle records or null.
1907
2305
  */
1908
2306
  async findMany(props, globalClient, whereInput) {
1909
- const [modules, client] = await Promise.all([
1910
- (0, client_1.getApolloModules)(),
1911
- globalClient
1912
- ? Promise.resolve(globalClient)
1913
- : client_1.client
1914
- ]);
1915
- const { gql, ApolloError } = modules;
1916
- const FIND_MANY_NEWSARTICLE = gql `
1917
- query findManyNewsArticle($where: NewsArticleWhereInput!) {
1918
- newsArticles(where: $where) {
1919
- ${selectionSet}
1920
- }
1921
- }`;
1922
- const variables = {
1923
- where: whereInput ? whereInput : {
1924
- id: props.id !== undefined ? {
1925
- equals: props.id
1926
- } : undefined,
1927
- title: props.title !== undefined ? {
1928
- equals: props.title
1929
- } : undefined,
1930
- url: props.url !== undefined ? {
1931
- equals: props.url
1932
- } : undefined,
1933
- },
1934
- };
1935
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
1936
- try {
1937
- const response = await client.query({ query: FIND_MANY_NEWSARTICLE, variables: filteredVariables });
1938
- if (response.errors && response.errors.length > 0)
1939
- throw new Error(response.errors[0].message);
1940
- if (response && response.data && response.data.newsarticles) {
1941
- return response.data.newsArticles;
2307
+ var _a, _b, _c, _d, _e;
2308
+ // Maximum number of retries for database connection issues
2309
+ const MAX_RETRIES = 3;
2310
+ let retryCount = 0;
2311
+ let lastError = null;
2312
+ // Retry loop to handle potential database connection issues
2313
+ while (retryCount < MAX_RETRIES) {
2314
+ try {
2315
+ const [modules, client] = await Promise.all([
2316
+ (0, client_1.getApolloModules)(),
2317
+ globalClient
2318
+ ? Promise.resolve(globalClient)
2319
+ : client_1.client
2320
+ ]);
2321
+ const { gql, ApolloError } = modules;
2322
+ const FIND_MANY_NEWSARTICLE = gql `
2323
+ query findManyNewsArticle($where: NewsArticleWhereInput!) {
2324
+ newsArticles(where: $where) {
2325
+ ${selectionSet}
1942
2326
  }
1943
- else {
1944
- return [];
1945
- }
1946
- }
1947
- catch (error) {
1948
- if (error instanceof ApolloError && error.message === 'No NewsArticle found') {
1949
- return null;
2327
+ }`;
2328
+ const variables = {
2329
+ where: whereInput ? whereInput : {
2330
+ id: props.id !== undefined ? props.id : undefined,
2331
+ title: props.title !== undefined ? props.title : undefined,
2332
+ content: props.content !== undefined ? {
2333
+ equals: props.content
2334
+ } : undefined,
2335
+ source: props.source !== undefined ? {
2336
+ equals: props.source
2337
+ } : undefined,
2338
+ sourceDomain: props.sourceDomain !== undefined ? {
2339
+ equals: props.sourceDomain
2340
+ } : undefined,
2341
+ url: props.url !== undefined ? props.url : undefined,
2342
+ sentiment: props.sentiment !== undefined ? {
2343
+ equals: props.sentiment
2344
+ } : undefined,
2345
+ authors: props.authors !== undefined ? {
2346
+ equals: props.authors
2347
+ } : undefined,
2348
+ summary: props.summary !== undefined ? {
2349
+ equals: props.summary
2350
+ } : undefined,
2351
+ bannerImage: props.bannerImage !== undefined ? {
2352
+ equals: props.bannerImage
2353
+ } : undefined,
2354
+ timePublished: props.timePublished !== undefined ? {
2355
+ equals: props.timePublished
2356
+ } : undefined,
2357
+ category: props.category !== undefined ? {
2358
+ equals: props.category
2359
+ } : undefined,
2360
+ topics: props.topics !== undefined ? {
2361
+ equals: props.topics
2362
+ } : undefined,
2363
+ logo: props.logo !== undefined ? {
2364
+ equals: props.logo
2365
+ } : undefined,
2366
+ createdAt: props.createdAt !== undefined ? {
2367
+ equals: props.createdAt
2368
+ } : undefined,
2369
+ updatedAt: props.updatedAt !== undefined ? {
2370
+ equals: props.updatedAt
2371
+ } : undefined,
2372
+ },
2373
+ };
2374
+ const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
2375
+ const response = await client.query({
2376
+ query: FIND_MANY_NEWSARTICLE,
2377
+ variables: filteredVariables,
2378
+ fetchPolicy: 'network-only', // Force network request to avoid stale cache
2379
+ });
2380
+ if (response.errors && response.errors.length > 0)
2381
+ throw new Error(response.errors[0].message);
2382
+ if (response && response.data && response.data.newsarticles) {
2383
+ return response.data.newsArticles;
2384
+ }
2385
+ else {
2386
+ return [];
2387
+ }
1950
2388
  }
1951
- else {
1952
- console.error('Error in getNewsArticle:', error);
2389
+ catch (error) {
2390
+ lastError = error;
2391
+ // Check if this is a "No record found" error - this is an expected condition, not a failure
2392
+ if (error.message === 'No NewsArticle found') {
2393
+ return null;
2394
+ }
2395
+ // Check if this is a database connection error that we should retry
2396
+ const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2397
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2398
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2399
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2400
+ (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2401
+ if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2402
+ retryCount++;
2403
+ const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2404
+ console.warn("Database connection error, retrying...");
2405
+ await new Promise(resolve => setTimeout(resolve, delay));
2406
+ continue;
2407
+ }
2408
+ // Log the error and rethrow
2409
+ console.error("Database error occurred:", error);
1953
2410
  throw error;
1954
2411
  }
1955
2412
  }
2413
+ // If we exhausted retries, throw the last error
2414
+ throw lastError;
1956
2415
  }
1957
2416
  };
1958
2417
  //# sourceMappingURL=NewsArticle.js.map