All files / schemas/trellis/service/abalonemail/config email.schema.cts

100% Statements 164/164
100% Branches 0/0
100% Functions 0/0
100% Lines 164/164

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 1651x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * @license
 * Copyright 2022 Open Ag Data Alliance
 *
 * Use of this source code is governed by an MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT.
 */
 
import type { JSONSchema8 as Schema } from 'jsonschema8';
 
const schema: Schema = {
  $id: 'https://formats.openag.io/trellis/service/abalonemail/config/email.schema.json',
  $schema: 'http://json-schema.org/draft-07/schema#',
  description: 'Abalonemail email config format for @oada/job job',
  type: 'object',
  definitions: {
    email: {
      $comment: "TODO: Allow emails like: 'John Doe <john@example.org>'",
      description: "Object for email and associated person's name",
      oneOf: [
        {
          type: 'string',
          format: 'email',
        },
        {
          type: 'object',
          properties: {
            email: {
              type: 'string',
              format: 'email',
            },
            name: {
              type: 'string',
            },
          },
          required: ['email'],
        },
      ],
    },
  },
  properties: {
    multiple: {
      description:
        'If separate emails to each `to` (true) or if one email to all of `to` (false)',
      type: 'boolean',
    },
    from: {
      $ref: '#/definitions/email',
    },
    to: {
      oneOf: [
        {
          $ref: '#/definitions/email',
        },
        {
          type: 'array',
          items: {
            $ref: '#/definitions/email',
          },
        },
      ],
    },
    replyTo: {
      $ref: '#/definitions/email',
    },
    subject: {
      type: 'string',
      minLength: 1,
    },
    text: {
      type: 'string',
      minLength: 1,
    },
    html: {
      type: 'string',
      minLength: 1,
    },
    templateData: {
      type: 'object',
      description: 'Data to use when filling out email template',
    },
    attachments: {
      type: 'array',
      items: {
        type: 'object',
        properties: {
          content: {
            oneOf: [
              {
                description: 'Base 64 encoded attachment content',
                type: 'string',
                minLength: 1,
              },
              {
                description: 'Link to OADA resource to use as content',
                $ref: '../../../../oada.schema.json#/definitions/link',
              },
            ],
          },
          filename: {
            type: 'string',
            minLength: 1,
          },
          type: {
            type: 'string',
            minLength: 1,
          },
          disposition: {
            enum: ['inline', 'attachment'],
            default: 'attachment',
          },
          content_id: {
            type: 'string',
          },
        },
        required: ['content', 'filename'],
        if: {
          type: 'object',
          properties: {
            disposition: {
              const: 'inline',
            },
          },
          required: ['disposition'],
        },
        then: {
          type: 'object',
          required: ['content_id'],
        },
      },
    },
  },
  required: ['from', 'to'],
  examples: [
    {
      multiple: false,
      from: 'john@example.com',
      to: {
        name: 'Mary Lou',
        email: 'donuts@example.org',
      },
      subject: 'Test mail',
      text: 'Test!',
      html: '<h1>Test!</h1>',
      attachments: [
        {
          content: 'RXhhbXBsZSBkYXRh',
          filename: 'test.dat',
          type: 'plain/text',
        },
        {
          content: {
            _id: 'resources/abc123',
          },
          filename: 'file.pdf',
          type: 'application/pdf',
        },
      ],
    },
  ],
};
 
export = schema;