({
provider,
providerData,
storageEngine,
storageRunning,
schemaMap,
}: DataToLoad)
| 177 | } |
| 178 | |
| 179 | export function processConnectionsAfterInitialInsertion({ |
| 180 | provider, |
| 181 | providerData, |
| 182 | storageEngine, |
| 183 | storageRunning, |
| 184 | schemaMap, |
| 185 | }: DataToLoad): void { |
| 186 | const additionalConnections: { |
| 187 | [key: string]: ServiceConnection[] |
| 188 | } = filterConnectionsByPriorityOfInsertion(providerData.connections, true) |
| 189 | if (!isEmpty(additionalConnections)) { |
| 190 | // Filter resourceTypes that have additional connections to process |
| 191 | const resourcesWithAdditionalConnections = new Set( |
| 192 | Object.values(additionalConnections) |
| 193 | .flat() |
| 194 | .map(({ resourceType }) => resourceType) |
| 195 | ) |
| 196 | // Filter entities that match filtered resourceTypes |
| 197 | const entities = providerData.entities.filter(({ name }) => |
| 198 | resourcesWithAdditionalConnections.has(name) |
| 199 | ) |
| 200 | for (const entity of entities) { |
| 201 | try { |
| 202 | const { data, name } = entity |
| 203 | data.map((service: any) => { |
| 204 | const connections = getConnectedEntity( |
| 205 | service, |
| 206 | providerData, |
| 207 | name, |
| 208 | true |
| 209 | ) |
| 210 | if (!isEmpty(connections)) { |
| 211 | if (storageRunning) { |
| 212 | const query = generateMutation({ |
| 213 | type: 'update', |
| 214 | provider, |
| 215 | entity, |
| 216 | schemaMap, |
| 217 | }) |
| 218 | const patch = generateUpdateVarsObject(service, connections) |
| 219 | // Add service mutation to promises array |
| 220 | storageEngine.push({ query, patch, name }) |
| 221 | } |
| 222 | } |
| 223 | }) |
| 224 | } catch (error) { |
| 225 | logger.debug(error) |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | export const loadAllData = ( |
| 232 | providerClient: Client, |
no test coverage detected