Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

7.9 KB
Raw Blame
// Generated by `pnpm openapi:contracts`. Do not edit directly.

import type { ZodOpenApiOperationObject } from 'zod-openapi';
import { defineOperation } from '@/openapi/operation';

const operation1 = defineOperation({
  method: 'post',
  path: '/api/record',
  audience: 'collect',
  auth: 'none',
  operation: {
    operationId: 'record',
    summary: 'Create or update record',
    tags: ['Collection'],
    requestBody: {
      required: true,
      content: {
        'application/json': {
          schema: {
            anyOf: [
              {
                type: 'object',
                properties: {
                  type: {
                    const: 'record',
                  },
                  payload: {
                    type: 'object',
                    properties: {
                      website: {
                        type: 'string',
                        format: 'uuid',
                      },
                      events: {
                        type: 'array',
                        items: {},
                        maxItems: 200,
                      },
                      timestamp: {
                        type: 'integer',
                      },
                    },
                    required: ['website', 'events'],
                  },
                },
                required: ['type', 'payload'],
              },
              {
                type: 'object',
                properties: {
                  type: {
                    const: 'heatmap',
                  },
                  payload: {
                    type: 'object',
                    properties: {
                      website: {
                        type: 'string',
                        format: 'uuid',
                      },
                      events: {
                        type: 'array',
                        items: {
                          anyOf: [
                            {
                              type: 'object',
                              properties: {
                                type: {
                                  const: 'click',
                                },
                                url: {
                                  type: 'string',
                                },
                                x: {
                                  type: 'number',
                                },
                                y: {
                                  type: 'number',
                                },
                                pageX: {
                                  type: 'number',
                                },
                                pageY: {
                                  type: 'number',
                                },
                                pageW: {
                                  type: 'number',
                                },
                                pageH: {
                                  type: 'number',
                                },
                                viewportW: {
                                  type: 'number',
                                },
                                viewportH: {
                                  type: 'number',
                                },
                                timestamp: {
                                  type: 'integer',
                                },
                              },
                              required: ['type', 'url'],
                            },
                            {
                              type: 'object',
                              properties: {
                                type: {
                                  const: 'scroll',
                                },
                                url: {
                                  type: 'string',
                                },
                                scrollPct: {
                                  type: 'number',
                                },
                                pageW: {
                                  type: 'number',
                                },
                                pageH: {
                                  type: 'number',
                                },
                                viewportW: {
                                  type: 'number',
                                },
                                viewportH: {
                                  type: 'number',
                                },
                                timestamp: {
                                  type: 'integer',
                                },
                              },
                              required: ['type', 'url'],
                            },
                          ],
                        },
                        maxItems: 200,
                      },
                      timestamp: {
                        type: 'integer',
                      },
                    },
                    required: ['website', 'events'],
                  },
                },
                required: ['type', 'payload'],
              },
            ],
          },
        },
      },
    },
    responses: {
      '200': {
        description: 'The operation completed successfully.',
        content: {
          'application/json': {
            schema: {
              anyOf: [
                {
                  type: 'object',
                  properties: {
                    ok: {
                      type: 'boolean',
                    },
                  },
                  required: ['ok'],
                },
                {
                  type: 'object',
                  properties: {
                    ok: {
                      type: 'boolean',
                    },
                    reason: {
                      type: 'string',
                    },
                  },
                  required: ['ok', 'reason'],
                },
                {
                  type: 'object',
                  properties: {
                    beep: {
                      type: 'string',
                    },
                  },
                  required: ['beep'],
                },
              ],
            },
          },
        },
      },
      '400': {
        description: 'Bad request.',
        content: {
          'application/json': {
            example: {
              error: {
                message: 'Bad request.',
                code: 'bad-request',
                status: 400,
              },
            },
            schema: {
              $ref: '#/components/schemas/ApiError',
            },
          },
        },
      },
      '403': {
        description: 'Forbidden.',
        content: {
          'application/json': {
            example: {
              error: {
                message: 'Forbidden.',
                code: 'forbidden',
                status: 403,
              },
            },
            schema: {
              $ref: '#/components/schemas/ApiError',
            },
          },
        },
      },
      '413': {
        description: 'Payload too large.',
        content: {
          'application/json': {
            example: {
              error: {
                message: 'Payload too large.',
                code: 'payload-too-large',
                status: 413,
              },
            },
            schema: {
              $ref: '#/components/schemas/ApiError',
            },
          },
        },
      },
      '500': {
        description: 'Server error.',
        content: {
          'application/json': {
            example: {
              error: {
                message: 'Server error.',
                code: 'server-error',
                status: 500,
              },
            },
            schema: {
              $ref: '#/components/schemas/ApiError',
            },
          },
        },
      },
    },
  } as ZodOpenApiOperationObject,
});

export const operations = [operation1] as const;