( _dataSources: (DS | CDS)[], reader: Reader, root: string, isCustomDs: IsCustomDs<DS, CDS> )
| 119 | } |
| 120 | |
| 121 | export async function updateDataSourcesV1_0_0<DS extends BaseDataSource, CDS extends DS & BaseCustomDataSource>( |
| 122 | _dataSources: (DS | CDS)[], |
| 123 | reader: Reader, |
| 124 | root: string, |
| 125 | isCustomDs: IsCustomDs<DS, CDS> |
| 126 | ): Promise<(DS | CDS)[]> { |
| 127 | // force convert to updated ds |
| 128 | return Promise.all( |
| 129 | _dataSources.map(async (dataSource) => { |
| 130 | dataSource.startBlock = dataSource.startBlock ?? 1; |
| 131 | const entryScript = await loadDataSourceScript(reader, dataSource.mapping.file); |
| 132 | if (isAssetsDs(dataSource) && dataSource.assets) { |
| 133 | for (const [, asset] of dataSource.assets.entries()) { |
| 134 | // Only need to resolve path for local file |
| 135 | if (reader instanceof LocalReader) { |
| 136 | asset.file = path.resolve(root, asset.file); |
| 137 | } else { |
| 138 | asset.file = await fetchAndSaveFile(reader, root, asset.file, ''); |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | const file = await updateDataSourcesEntry(reader, dataSource.mapping.file, root, entryScript); |
| 143 | if (isCustomDs(dataSource)) { |
| 144 | if (dataSource.processor) { |
| 145 | dataSource.processor.file = await updateProcessor(reader, root, dataSource.processor.file); |
| 146 | } |
| 147 | return { |
| 148 | ...dataSource, |
| 149 | mapping: {...dataSource.mapping, file}, |
| 150 | }; |
| 151 | } else { |
| 152 | return { |
| 153 | ...dataSource, |
| 154 | mapping: {...dataSource.mapping, file}, |
| 155 | }; |
| 156 | } |
| 157 | }) |
| 158 | ); |
| 159 | } |
| 160 | |
| 161 | export async function updateDataSourcesEntry( |
| 162 | reader: Reader, |
no test coverage detected