import { input, password } from '@inquirer/prompts' import { v4 as uuidv4 } from 'uuid' import path from 'path' import chalk from 'chalk' import crypto from 'node:crypto' import runMigrationSqlite from './../db/migration.js' import getOrCreateSqlite from './../db/sqlite.js' import TokenHelper from './../helper/token.js' // getting flow import FlowStore from './../store/flow.js' // get config import config from './../_config.js' config() // getting db and flowStore const mainDB = getOrCreateSqlite({ 'uri': process.env.APP_SQLITE_URI_MAIN, 'create': true, 'readwrite': true }) const flowStore = new FlowStore(mainDB) const token = crypto.randomBytes(64).toString('base64') const flow = { 'hash' : TokenHelper.create(token) } flow.uuid = uuidv4() // adding action flow.action = await input({ message: 'action:', async validate(value) { if (!value) { return 'Required!' } return true } }) // adding schema flow.schema = await input({ message: 'schema:' }) // adding description flow.description = await input({ message: 'description:' }) const id = flowStore.create(flow, token) if (id) { console.log(chalk.green('done')) console.log(chalk.blue('uuid: ' + flow.uuid)) console.log(chalk.blue('token: ' + token)) }