HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/agentcloud/airbyte/docs/integrations/sources/e2e-test.js
import React, {useState} from 'react';
import CodeBlock from '@theme/CodeBlock';

function simpleProperty(name, type) {
  return [name, { type }];
}

function dateProperty(name, format, airbyteType) {
  const definition = {
    type: ['null', 'string'],
    format,
  };
  if (airbyteType !== null) {
    definition.airbyte_type = airbyteType;
  }
  return [name, definition];
}

const allSupportedColumnTypePropertyGenerators = [
  (i) => simpleProperty(`string_${i}`, 'string'),
  (i) => simpleProperty(`boolean_${i}`, 'boolean'),
  (i) => dateProperty(`date_${i}`, 'date', null),
  (i) => dateProperty(`timestamp_wo_tz_${i}`, 'date-time', 'timestamp_without_timezone'),
  (i) => dateProperty(`timestamp_w_tz_${i}`, 'date-time', 'timestamp_with_timezone'),
  (i) => dateProperty(`time_wo_tz_${i}`, 'time', 'time_without_timezone'),
  (i) => dateProperty(`time_w_tz_${i}`, 'time', 'time_with_timezone'),
  (i) => simpleProperty(`integer_${i}`, 'integer'),
  (i) => simpleProperty(`number_${i}`, 'number'),
  (i) => simpleProperty(`array_${i}`, 'array'),
  (i) => simpleProperty(`object_${i}`, 'object'),
];

function generateWideSchema(columns) {

  const fullSchema = { type: 'object' };
  const properties = {};

  // Special case id and updated_at column
  const id = simpleProperty('id', 'integer');
  properties[id[0]] = id[1];
  properties['updated_at'] = { type: 'string', format: 'date-time', airbyte_type: 'timestamp_with_timezone' };

  let columnCount = 2;
  let propertyGeneratorIndex = 0;

  while (columnCount < columns) {
    const propertyInfo = allSupportedColumnTypePropertyGenerators[propertyGeneratorIndex](columnCount);
    properties[propertyInfo[0]] = propertyInfo[1];

    propertyGeneratorIndex += 1;
    if (propertyGeneratorIndex === allSupportedColumnTypePropertyGenerators.length) {
      propertyGeneratorIndex = 0;
    }

    columnCount += 1;
  }

  fullSchema.properties = properties;

  return fullSchema;
}




export const SchemaGenerator = () => {

  const [generatedSchema, updateGeneratedSchema] = useState({
    'schema' : JSON.stringify(generateWideSchema(10))
  })
  function updateSchema(event) {
    const columns = parseInt(document.getElementById("schema-generator-column-count").value)
    const schema = JSON.stringify(generateWideSchema(columns))
    updateGeneratedSchema({'schema': schema})
  }

  return (
      <div>
        <label for="schema-generator-column-count">Desired Number of Columns:</label>
        <input type="number" id="schema-generator-column-count" name="schema-generator-column-count" onChange={updateSchema}/>
        <p>Generated Schema:</p>
        <CodeBlock id={"generated_e2e_test_schema"} language={"javascript"}>
          { generatedSchema['schema'] }
        </CodeBlock>
      </div>
  )
}