Skip to content

Checklist Automation Examples

Automate checklists with the SDK.

List Checklist Templates

typescript
import { DeIterateClient } from '@deiterate/sdk';

const client = new DeIterateClient({
  apiKey: process.env.DEITERATE_API_KEY!,
  organizationId: process.env.DEITERATE_ORG_ID,
});

const templates = await client.checklists.listTemplates();

for (const template of templates) {
  console.log(`${template.title}`);
  console.log(`  Items: ${template.items.length}`);
  console.log(`  Standard: ${template.standard || 'N/A'}`);
}

Create Checklist from Template

typescript
async function createChecklistFromTemplate(templateId: string) {
  const checklist = await client.checklists.createFromTemplate(templateId);
  console.log(`Created checklist: ${checklist.id}`);
  return checklist;
}

Submit Completed Checklist

typescript
async function completeChecklist(checklistId: string) {
  await client.checklists.submit(checklistId, {
    signature: 'John Doe',
    values: {
      'item-1': 'Yes',
      'item-2': 'Completed',
      'item-3': 'N/A',
    },
  });

  console.log('Checklist submitted');
}

Create Custom Template

typescript
async function createSecurityChecklistTemplate() {
  const template = await client.checklists.createTemplate({
    title: 'Monthly Security Review',
    description: 'Monthly security controls verification',
    standard: 'ISO 27001',
    items: [
      {
        title: 'Access reviews completed',
        description: 'Verify all access reviews are up to date',
        required: true,
      },
      {
        title: 'Backups verified',
        description: 'Confirm backup integrity tests passed',
        required: true,
      },
      {
        title: 'Incidents reviewed',
        description: 'Review any security incidents from the past month',
        required: false,
      },
    ],
    repeat: {
      frequency: 'monthly',
      startDate: new Date().toISOString(),
    },
  });

  console.log(`Created template: ${template.id}`);
}

Checklist Completion Report

typescript
async function checklistCompletionReport() {
  const checklists = await client.checklists.list();

  const stats = {
    total: checklists.length,
    completed: 0,
    inProgress: 0,
    draft: 0,
  };

  for (const checklist of checklists) {
    switch (checklist.status) {
      case 'completed':
        stats.completed++;
        break;
      case 'in-progress':
        stats.inProgress++;
        break;
      default:
        stats.draft++;
    }
  }

  console.log('Checklist Status Report');
  console.log('=======================');
  console.log(`Total: ${stats.total}`);
  console.log(`Completed: ${stats.completed}`);
  console.log(`In Progress: ${stats.inProgress}`);
  console.log(`Draft: ${stats.draft}`);
}

Released under the MIT License.