Closed freaz closed 1 year ago
Goal is to be able to pass ASTs directly in super.json. See example bellow.
Eventually I will add ast to SuperJson, but for internal use this should be sufficient.
ast
import type { SuperJsonDocument } from '@superfaceai/ast'; import { readFile } from 'fs/promises'; import { resolve } from 'path'; import { SuperfaceClient } from '../node'; async function readAst(file: string): Promise<string> { // eslint-disable-next-line @typescript-eslint/no-unsafe-return return await readFile(resolve(__dirname, file), { encoding: 'utf8' }); } async function main() { const superJson: SuperJsonDocument = { profiles: { profile: { ast: await readAst('./profile.supr.ast.json'), providers: { provider: { ast: await readAst('./map.suma.ast.json'), }, }, }, }, providers: { provider: { ast: await readAst('./provider.json'), // I know it is not ast, but consistency with profile and map(profile provider) }, }, } as unknown as SuperJsonDocument; // this is needed for TS to compile const client = new SuperfaceClient({ superJson, superfacePath: __dirname }); const profile = await client.getProfile('profile'); const result = await profile.getUseCase('UseCase').perform({ foo: 'foo' }); console.log(result); } void main();
Goal is to be able to pass ASTs directly in super.json. See example bellow.
Eventually I will add
ast
to SuperJson, but for internal use this should be sufficient.