import type { HatchetClient } from '@hatchet/v1';

export function createLoggingWorkflow(client: HatchetClient) {
  const wf = client.workflow({ name: 'logging-workflow' });
  wf.task({
    name: 'root_logger',
    fn: async () => {
      for (let i = 0; i < 12; i += 1) {
        console.info(`executed step1 - ${i}`);
        console.info({ step1: 'step1' });
        // keep this fast for e2e
      }
      return { status: 'success' };
    },
  });
  wf.task({
    name: 'context_logger',
    fn: async (_input, ctx) => {
      for (let i = 0; i < 12; i += 1) {
        // Python uses ctx.log; TS has both ctx.log (deprecated) and ctx.logger.*
        await ctx.log(`executed step1 - ${i}`);
        await ctx.log(JSON.stringify({ step1: 'step1' }));
      }
      return { status: 'success' };
    },
  });
  return wf;
}
