({
schemaResult,
printLoadMessage = true,
cwd = process.cwd(),
}: {
schemaResult: GetSchemaResult
printLoadMessage?: boolean
cwd?: string
})
| 76 | } |
| 77 | |
| 78 | export async function processSchemaResult({ |
| 79 | schemaResult, |
| 80 | printLoadMessage = true, |
| 81 | cwd = process.cwd(), |
| 82 | }: { |
| 83 | schemaResult: GetSchemaResult |
| 84 | printLoadMessage?: boolean |
| 85 | cwd?: string |
| 86 | }): Promise<SchemaContext> { |
| 87 | const loadedFromPathForLogMessages = path.relative(cwd, schemaResult.schemaPath) |
| 88 | const schemaRootDir = schemaResult.schemaRootDir || cwd |
| 89 | |
| 90 | if (printLoadMessage) { |
| 91 | printSchemaLoadedMessage(loadedFromPathForLogMessages) |
| 92 | } |
| 93 | |
| 94 | const configFromPsl = await getConfig({ datamodel: schemaResult.schemas }) |
| 95 | |
| 96 | const primaryDatasource = configFromPsl.datasources.at(0) |
| 97 | |
| 98 | return { |
| 99 | schemaFiles: schemaResult.schemas, |
| 100 | schemaPath: schemaResult.schemaPath, |
| 101 | schemaRootDir, |
| 102 | datasources: configFromPsl.datasources, |
| 103 | generators: configFromPsl.generators, |
| 104 | primaryDatasource, |
| 105 | warnings: configFromPsl.warnings, |
| 106 | loadedFromPathForLogMessages, |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | export function getSchemaDatasourceProvider(schemaContext: SchemaContext): ActiveConnectorType { |
| 111 | if (schemaContext.primaryDatasource === undefined) { |
no test coverage detected