/** * CLI commands for FunctionGraphExecutionNodeState * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { CLIOptions, Inquirerer, extractFirst } from 'inquirerer'; import { getClient } from '../executor'; import { coerceAnswers, parseFindFirstArgs, parseFindManyArgs, stripUndefined } from '../utils'; import type { FieldSchema } from '../utils'; import type { CreateFunctionGraphExecutionNodeStateInput, FunctionGraphExecutionNodeStatePatch, FunctionGraphExecutionNodeStateSelect, FunctionGraphExecutionNodeStateFilter, FunctionGraphExecutionNodeStateOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, FindFirstArgs } from '../../orm/select-types'; const fieldSchema: FieldSchema = { callbackInputs: 'json', callbackMeta: 'json', callbackTokenHash: 'string', completedAt: 'string', createdAt: 'string', errorCode: 'string', errorMessage: 'string', executionId: 'uuid', expiryDefaultOutput: 'json', expiryEscalatedAt: 'string', expiryPolicy: 'string', id: 'uuid', nodeName: 'string', nodePath: 'string', outputId: 'uuid', scopeId: 'uuid', startedAt: 'string', status: 'string', waitingDeadlineAt: 'string', waitingOn: 'string', waitingSince: 'string', }; const usage = '\nfunction-graph-execution-node-state \n\nCommands:\n list List functionGraphExecutionNodeState records\n find-first Find first matching functionGraphExecutionNodeState record\n get Get a functionGraphExecutionNodeState by ID\n create Create a new functionGraphExecutionNodeState\n update Update an existing functionGraphExecutionNodeState\n delete Delete a functionGraphExecutionNodeState\n\nList Options:\n --limit Max number of records to return (forward pagination)\n --last Number of records from the end (backward pagination)\n --after Cursor for forward pagination\n --before Cursor for backward pagination\n --offset Number of records to skip\n --select Comma-separated list of fields to return\n --where.. Filter (dot-notation, e.g. --where.name.equalTo foo)\n --condition.. Condition filter (dot-notation)\n --orderBy Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\nFind-First Options:\n --select Comma-separated list of fields to return\n --where.. Filter (dot-notation, e.g. --where.status.equalTo active)\n --condition.. Condition filter (dot-notation)\n --orderBy Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\n\n --help, -h Show this help message\n'; export default async ( argv: Partial>, prompter: Inquirerer, _options: CLIOptions ) => { if (argv.help || argv.h) { console.log(usage); process.exit(0); } const { first: subcommand, newArgv } = extractFirst(argv); if (!subcommand) { const answer = await prompter.prompt(argv, [ { type: 'autocomplete', name: 'subcommand', message: 'What do you want to do?', options: ['list', 'find-first', 'get', 'create', 'update', 'delete'], }, ]); return handleTableSubcommand(answer.subcommand as string, newArgv, prompter); } return handleTableSubcommand(subcommand, newArgv, prompter); }; async function handleTableSubcommand( subcommand: string, argv: Partial>, prompter: Inquirerer ) { switch (subcommand) { case 'list': return handleList(argv, prompter); case 'find-first': return handleFindFirst(argv, prompter); case 'get': return handleGet(argv, prompter); case 'create': return handleCreate(argv, prompter); case 'update': return handleUpdate(argv, prompter); case 'delete': return handleDelete(argv, prompter); default: console.log(usage); process.exit(1); } } async function handleList(argv: Partial>, _prompter: Inquirerer) { try { const defaultSelect = { callbackInputs: true, callbackMeta: true, callbackTokenHash: true, completedAt: true, createdAt: true, errorCode: true, errorMessage: true, executionId: true, expiryDefaultOutput: true, expiryEscalatedAt: true, expiryPolicy: true, id: true, nodeName: true, nodePath: true, outputId: true, scopeId: true, startedAt: true, status: true, waitingDeadlineAt: true, waitingOn: true, waitingSince: true, }; const findManyArgs = parseFindManyArgs< FindManyArgs< FunctionGraphExecutionNodeStateSelect, FunctionGraphExecutionNodeStateFilter, FunctionGraphExecutionNodeStateOrderBy > & { select: FunctionGraphExecutionNodeStateSelect; } >(argv, defaultSelect); const client = getClient(); const result = await client.functionGraphExecutionNodeState.findMany(findManyArgs).execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed to list records.'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } } async function handleFindFirst(argv: Partial>, _prompter: Inquirerer) { try { const defaultSelect = { callbackInputs: true, callbackMeta: true, callbackTokenHash: true, completedAt: true, createdAt: true, errorCode: true, errorMessage: true, executionId: true, expiryDefaultOutput: true, expiryEscalatedAt: true, expiryPolicy: true, id: true, nodeName: true, nodePath: true, outputId: true, scopeId: true, startedAt: true, status: true, waitingDeadlineAt: true, waitingOn: true, waitingSince: true, }; const findFirstArgs = parseFindFirstArgs< FindFirstArgs< FunctionGraphExecutionNodeStateSelect, FunctionGraphExecutionNodeStateFilter, FunctionGraphExecutionNodeStateOrderBy > & { select: FunctionGraphExecutionNodeStateSelect; } >(argv, defaultSelect); const client = getClient(); const result = await client.functionGraphExecutionNodeState.findFirst(findFirstArgs).execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed to find record.'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } } async function handleGet(argv: Partial>, prompter: Inquirerer) { try { const answers = await prompter.prompt(argv, [ { type: 'text', name: 'id', message: 'id', required: true, }, ]); const client = getClient(); const result = await client.functionGraphExecutionNodeState .findOne({ id: answers.id as string, select: { callbackInputs: true, callbackMeta: true, callbackTokenHash: true, completedAt: true, createdAt: true, errorCode: true, errorMessage: true, executionId: true, expiryDefaultOutput: true, expiryEscalatedAt: true, expiryPolicy: true, id: true, nodeName: true, nodePath: true, outputId: true, scopeId: true, startedAt: true, status: true, waitingDeadlineAt: true, waitingOn: true, waitingSince: true, }, }) .execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Record not found.'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } } async function handleCreate(argv: Partial>, prompter: Inquirerer) { try { const rawAnswers = await prompter.prompt(argv, [ { type: 'json', name: 'callbackInputs', message: 'callbackInputs', required: false, skipPrompt: true, }, { type: 'json', name: 'callbackMeta', message: 'callbackMeta', required: false, skipPrompt: true, }, { type: 'text', name: 'callbackTokenHash', message: 'callbackTokenHash', required: false, skipPrompt: true, }, { type: 'text', name: 'completedAt', message: 'completedAt', required: false, skipPrompt: true, }, { type: 'text', name: 'errorCode', message: 'errorCode', required: false, skipPrompt: true, }, { type: 'text', name: 'errorMessage', message: 'errorMessage', required: false, skipPrompt: true, }, { type: 'text', name: 'executionId', message: 'executionId', required: true, }, { type: 'json', name: 'expiryDefaultOutput', message: 'expiryDefaultOutput', required: false, skipPrompt: true, }, { type: 'text', name: 'expiryEscalatedAt', message: 'expiryEscalatedAt', required: false, skipPrompt: true, }, { type: 'text', name: 'expiryPolicy', message: 'expiryPolicy', required: false, skipPrompt: true, }, { type: 'text', name: 'nodeName', message: 'nodeName', required: true, }, { type: 'text', name: 'nodePath', message: 'nodePath', required: false, skipPrompt: true, }, { type: 'text', name: 'outputId', message: 'outputId', required: false, skipPrompt: true, }, { type: 'text', name: 'scopeId', message: 'scopeId', required: true, }, { type: 'text', name: 'startedAt', message: 'startedAt', required: false, skipPrompt: true, }, { type: 'text', name: 'status', message: 'status', required: false, skipPrompt: true, }, { type: 'text', name: 'waitingDeadlineAt', message: 'waitingDeadlineAt', required: false, skipPrompt: true, }, { type: 'text', name: 'waitingOn', message: 'waitingOn', required: false, skipPrompt: true, }, { type: 'text', name: 'waitingSince', message: 'waitingSince', required: false, skipPrompt: true, }, ]); const answers = coerceAnswers(rawAnswers, fieldSchema); const cleanedData = stripUndefined( answers, fieldSchema ) as CreateFunctionGraphExecutionNodeStateInput['functionGraphExecutionNodeState']; const client = getClient(); const result = await client.functionGraphExecutionNodeState .create({ data: { callbackInputs: cleanedData.callbackInputs, callbackMeta: cleanedData.callbackMeta, callbackTokenHash: cleanedData.callbackTokenHash, completedAt: cleanedData.completedAt, errorCode: cleanedData.errorCode, errorMessage: cleanedData.errorMessage, executionId: cleanedData.executionId, expiryDefaultOutput: cleanedData.expiryDefaultOutput, expiryEscalatedAt: cleanedData.expiryEscalatedAt, expiryPolicy: cleanedData.expiryPolicy, nodeName: cleanedData.nodeName, nodePath: cleanedData.nodePath, outputId: cleanedData.outputId, scopeId: cleanedData.scopeId, startedAt: cleanedData.startedAt, status: cleanedData.status, waitingDeadlineAt: cleanedData.waitingDeadlineAt, waitingOn: cleanedData.waitingOn, waitingSince: cleanedData.waitingSince, }, select: { callbackInputs: true, callbackMeta: true, callbackTokenHash: true, completedAt: true, createdAt: true, errorCode: true, errorMessage: true, executionId: true, expiryDefaultOutput: true, expiryEscalatedAt: true, expiryPolicy: true, id: true, nodeName: true, nodePath: true, outputId: true, scopeId: true, startedAt: true, status: true, waitingDeadlineAt: true, waitingOn: true, waitingSince: true, }, }) .execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed to create record.'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } } async function handleUpdate(argv: Partial>, prompter: Inquirerer) { try { const rawAnswers = await prompter.prompt(argv, [ { type: 'text', name: 'id', message: 'id', required: true, }, { type: 'text', name: 'createdAt', message: 'createdAt', required: true, }, { type: 'json', name: 'callbackInputs', message: 'callbackInputs', required: false, skipPrompt: true, }, { type: 'json', name: 'callbackMeta', message: 'callbackMeta', required: false, skipPrompt: true, }, { type: 'text', name: 'callbackTokenHash', message: 'callbackTokenHash', required: false, skipPrompt: true, }, { type: 'text', name: 'completedAt', message: 'completedAt', required: false, skipPrompt: true, }, { type: 'text', name: 'errorCode', message: 'errorCode', required: false, skipPrompt: true, }, { type: 'text', name: 'errorMessage', message: 'errorMessage', required: false, skipPrompt: true, }, { type: 'text', name: 'executionId', message: 'executionId', required: false, }, { type: 'json', name: 'expiryDefaultOutput', message: 'expiryDefaultOutput', required: false, skipPrompt: true, }, { type: 'text', name: 'expiryEscalatedAt', message: 'expiryEscalatedAt', required: false, skipPrompt: true, }, { type: 'text', name: 'expiryPolicy', message: 'expiryPolicy', required: false, skipPrompt: true, }, { type: 'text', name: 'nodeName', message: 'nodeName', required: false, }, { type: 'text', name: 'nodePath', message: 'nodePath', required: false, skipPrompt: true, }, { type: 'text', name: 'outputId', message: 'outputId', required: false, skipPrompt: true, }, { type: 'text', name: 'scopeId', message: 'scopeId', required: false, }, { type: 'text', name: 'startedAt', message: 'startedAt', required: false, skipPrompt: true, }, { type: 'text', name: 'status', message: 'status', required: false, skipPrompt: true, }, { type: 'text', name: 'waitingDeadlineAt', message: 'waitingDeadlineAt', required: false, skipPrompt: true, }, { type: 'text', name: 'waitingOn', message: 'waitingOn', required: false, skipPrompt: true, }, { type: 'text', name: 'waitingSince', message: 'waitingSince', required: false, skipPrompt: true, }, ]); const answers = coerceAnswers(rawAnswers, fieldSchema); const cleanedData = stripUndefined( answers, fieldSchema ) as FunctionGraphExecutionNodeStatePatch; const client = getClient(); const result = await client.functionGraphExecutionNodeState .update({ where: { id: answers.id as string, createdAt: answers.createdAt as string, }, data: { callbackInputs: cleanedData.callbackInputs, callbackMeta: cleanedData.callbackMeta, callbackTokenHash: cleanedData.callbackTokenHash, completedAt: cleanedData.completedAt, errorCode: cleanedData.errorCode, errorMessage: cleanedData.errorMessage, executionId: cleanedData.executionId, expiryDefaultOutput: cleanedData.expiryDefaultOutput, expiryEscalatedAt: cleanedData.expiryEscalatedAt, expiryPolicy: cleanedData.expiryPolicy, nodeName: cleanedData.nodeName, nodePath: cleanedData.nodePath, outputId: cleanedData.outputId, scopeId: cleanedData.scopeId, startedAt: cleanedData.startedAt, status: cleanedData.status, waitingDeadlineAt: cleanedData.waitingDeadlineAt, waitingOn: cleanedData.waitingOn, waitingSince: cleanedData.waitingSince, }, select: { callbackInputs: true, callbackMeta: true, callbackTokenHash: true, completedAt: true, createdAt: true, errorCode: true, errorMessage: true, executionId: true, expiryDefaultOutput: true, expiryEscalatedAt: true, expiryPolicy: true, id: true, nodeName: true, nodePath: true, outputId: true, scopeId: true, startedAt: true, status: true, waitingDeadlineAt: true, waitingOn: true, waitingSince: true, }, }) .execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed to update record.'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } } async function handleDelete(argv: Partial>, prompter: Inquirerer) { try { const rawAnswers = await prompter.prompt(argv, [ { type: 'text', name: 'id', message: 'id', required: true, }, { type: 'text', name: 'createdAt', message: 'createdAt', required: true, }, ]); const answers = coerceAnswers(rawAnswers, fieldSchema); const client = getClient(); const result = await client.functionGraphExecutionNodeState .delete({ where: { id: answers.id as string, createdAt: answers.createdAt as string, }, select: { id: true, }, }) .execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed to delete record.'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } }