chore: Update copyright year from 2025 to 2026 across core files

- Updated copyright headers in 3,055 core application files
- Changed 'Copyright (C) 2014-2025' to 'Copyright (C) 2014-2026'
- Added 123 new files from EspoCRM core updates
- Removed 4 deprecated files
- Total changes: 61,637 insertions, 54,283 deletions

This is a routine maintenance update for the new year 2026.
This commit is contained in:
2026-02-07 16:05:21 +01:00
parent 6a8a4a2882
commit 127fa6503b
6468 changed files with 564781 additions and 31179 deletions

View File

@@ -0,0 +1,55 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class AutoincrementType implements FieldSchemaBuilder
{
public function __construct(
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$schema = (object) [
'type' => Type::INTEGER,
'readOnly' => true,
'description' => 'An auto-increment number.',
];
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class BoolType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [
'type' => Type::BOOLEAN,
'readOnly' => $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false,
];
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class CurrencyConvertedType implements FieldSchemaBuilder
{
public function __construct(
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$schema = (object) [];
$schema->type = Type::NUMBER;
$schema->readOnly = true;
$schema->description = 'A currency amount converted to the default currency.';
$schema->type = [
$schema->type,
Type::NULL,
];
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
);
}
}

View File

@@ -0,0 +1,107 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\Core\Currency\ConfigDataProvider;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class CurrencyType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
private ConfigDataProvider $configDataProvider,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if ($fieldDefs->getParam(FieldParam::DECIMAL)) {
$schema->type = Type::STRING;
$schema->pattern = '^-?\d+(\.\d+)?$';
$schema->description = 'A numeric string';
} else {
$schema->type = Type::NUMBER;
if ($fieldDefs->getParam(FieldParam::MIN) !== null) {
$schema->minimum = $fieldDefs->getParam(FieldParam::MIN);
}
if ($fieldDefs->getParam(FieldParam::MAX) !== null) {
$schema->maximum = $fieldDefs->getParam(FieldParam::MAX);
}
}
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->description = 'A currency amount.';
$codeSchema = (object) [];
$codeSchema->type = Type::STRING;
$codeSchema->enum = $this->configDataProvider->getCurrencyList();
$codeSchema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$codeSchema->type = [
$codeSchema->type,
Type::NULL,
];
}
$codeSchema->description = 'A code.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field;
$required[] = $field . 'Currency';
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
$field . 'Currency' => get_object_vars($codeSchema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,75 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class DateType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$schema->format = 'date';
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->description = 'A date.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,89 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class DatetimeOptionalType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->pattern = '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$';
$schema->examples = ['2026-11-29 12:34:56'];
$schema->description = 'A timestamp in UTC.';
$schemaDate = (object) [];
$schemaDate->type = Type::STRING;
$schemaDate->format = 'date';
$schemaDate->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$schemaDate->type = [
$schemaDate->type,
Type::NULL,
];
$schema->description = "Specified if the '$field' field is all-day.";
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
$field . 'Date' => get_object_vars($schemaDate),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,76 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class DatetimeType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->pattern = '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$';
$schema->examples = ['2026-11-29 12:34:56'];
$schema->description = 'A timestamp in UTC.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,75 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class DecimalType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$schema->pattern = '^-?\d+(\.\d+)?$';
$schema->description = 'A numeric string.';
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,113 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class EmailType implements FieldSchemaBuilder
{
const int DEFAULT_MAX_LENGTH = 255;
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->maxLength = self::DEFAULT_MAX_LENGTH;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->description = 'A primary email address.';
$itemSchema = (object) [];
$itemSchema->type = Type::OBJECT;
$itemSchema->properties = [
'emailAddress' => [
'type' => Type::STRING,
],
'primary' => [
'type' => Type::BOOLEAN,
],
'optOut' => [
'type' => Type::BOOLEAN,
],
'invalid' => [
'type' => Type::BOOLEAN,
],
'lower' => [
'type' => Type::STRING,
'readOnly' => true,
],
];
$itemSchema->required = [
'emailAddress',
'primary',
];
$dataSchema = (object) [];
$dataSchema->type = Type::ARRAY;
$dataSchema->items = get_object_vars($itemSchema);
$dataSchema->description = 'Multiple email addresses';
$dataSchema->type = [
$dataSchema->type,
Type::NULL,
];
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
$field . 'Data' => get_object_vars($dataSchema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,83 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
use Espo\Tools\OpenApi\Util\EnumOptionsProvider;
class EnumType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
private EnumOptionsProvider $optionsProvider,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$optionList = $this->optionsProvider->get($fieldDefs);
if ($optionList) {
if (in_array('', $optionList) && !$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
Type::STRING,
Type::NULL,
];
}
$optionList = array_filter($optionList, fn ($it) => $it !== '');
$optionList = array_values($optionList);
$schema->enum = $optionList;
}
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,80 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class FloatType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::NUMBER;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if ($fieldDefs->getParam(FieldParam::MIN) !== null) {
$schema->minimum = $fieldDefs->getParam(FieldParam::MIN);
}
if ($fieldDefs->getParam(FieldParam::MAX) !== null) {
$schema->maximum = $fieldDefs->getParam(FieldParam::MAX);
}
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,110 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\Core\ORM\Type\FieldType;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class ForeignType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$schema = (object) [];
$schema->readOnly = true;
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$link = $fieldDefs->getParam(FieldParam::LINK);
$foreignField = $fieldDefs->getParam(FieldParam::FIELD);
$foreignEntityType = $this->defs
->getEntity($entityType)
->tryGetRelation($link)
?->tryGetForeignEntityType();
if (!$foreignEntityType) {
return new FieldSchemaResult([]);
}
$foreignFieldDefs = $this->defs
->getEntity($foreignEntityType)
->tryGetField($foreignField);
if (!$foreignFieldDefs) {
return new FieldSchemaResult([]);
}
$fieldType = $foreignFieldDefs->getType();
if (
$fieldType === FieldType::ENUM ||
$fieldType === FieldType::VARCHAR ||
$fieldType === FieldType::TEXT ||
$fieldType === FieldType::DATE ||
$fieldType === FieldType::DATETIME ||
$fieldType === FieldType::EMAIL ||
$fieldType === FieldType::PHONE ||
$fieldType === FieldType::WYSIWYG ||
$fieldType === FieldType::DECIMAL
) {
$schema->type = Type::STRING;
} else if (
$foreignEntityType === FieldType::INT
) {
$schema->type = Type::INTEGER;
} else if (
$foreignEntityType === FieldType::FLOAT
) {
$schema->type = Type::NUMBER;
} else {
return new FieldSchemaResult([]);
}
$schema->type = [
$schema->type,
Type::NULL,
];
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Doctrine\DBAL\Types\Types;
use Espo\ORM\Defs;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class IdType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->tryGetField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = true;
$dbType = $fieldDefs?->getParam(Defs\Params\FieldParam::DB_TYPE);
if ($dbType === Types::BIGINT || $dbType === Types::INTEGER) {
$schema->type = Type::INTEGER;
}
$schema->description = 'An ID.';
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
);
}
}

View File

@@ -0,0 +1,80 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class IntType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::INTEGER;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if ($fieldDefs->getParam(FieldParam::MIN) !== null) {
$schema->minimum = $fieldDefs->getParam(FieldParam::MIN);
}
if ($fieldDefs->getParam(FieldParam::MAX) !== null) {
$schema->maximum = $fieldDefs->getParam(FieldParam::MAX);
}
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,185 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\Core\ORM\Type\FieldType;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
use Espo\Tools\OpenApi\Util\EnumOptionsProvider;
class LinkMultipleType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
private EnumOptionsProvider $enumOptionsProvider,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$linkDefs = $this->defs->getEntity($entityType)->tryGetRelation($field);
$idsSchema = (object) [
'type' => Type::ARRAY,
'items' => [
'type' => Type::STRING,
],
];
$idsSchema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$foreignEntityType = null;
if ($linkDefs && $linkDefs->tryGetForeignEntityType()) {
$foreignEntityType = $linkDefs->tryGetForeignEntityType();
$idsSchema->description = "IDs of records of the $foreignEntityType type.";
}
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$idsSchema->type = [
$idsSchema->type,
Type::NULL,
];
}
$namesSchema = (object) [];
$namesSchema->type = Type::OBJECT;
$namesSchema->additionalProperties = [
'type' => Type::STRING,
];
$namesSchema->readOnly = true;
$namesSchema->description = 'An {ID => record name} map.';
$namesSchema->type = [
$namesSchema->type,
Type::NULL,
];
$output = [
$field . 'Ids' => get_object_vars($idsSchema),
$field . 'Names' => get_object_vars($namesSchema),
];
/** @var ?array<string, string> $columns */
$columns = $fieldDefs->getParam('columns');
if (is_array($columns) && $foreignEntityType) {
$columnsSchema = (object) [];
$columnsSchema->type = Type::OBJECT;
$columnsSchema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$columnsSchema->description = 'An {ID => object} map. Relationship column values.';
$columnsSchema->type = [
$columnsSchema->type,
Type::NULL,
];
$properties = array_map(function ($columnField) use ($entityType, $foreignEntityType) {
return $this->prepareColumnSchema($entityType, $foreignEntityType, $columnField);
}, $columns);
$columnsSchema->additionalProperties = [
'type' => Type::OBJECT,
'properties' => $properties,
];
$output[$field . 'Columns'] = get_object_vars($columnsSchema);
}
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field . 'Ids';
}
return new FieldSchemaResult(
properties: $output,
required: $required,
);
}
/**
* @return array<string, mixed>
*/
private function prepareColumnSchema(string $entityType, string $foreignEntityType, string $columnField): array
{
$colSchema = (object) [];
$fieldDefs = $this->defs->getEntity($foreignEntityType)->tryGetField($columnField);
if (!$fieldDefs) {
$fieldDefs = $this->defs->getEntity($entityType)->tryGetField($columnField);
}
if (!$fieldDefs) {
return get_object_vars($colSchema);
}
$optionList = $this->enumOptionsProvider->get($fieldDefs);
if ($optionList) {
$colSchema->type = Type::STRING;
if (in_array('', $optionList)) {
$colSchema->type = [
$colSchema->type,
Type::NULL,
];
}
$optionList = array_filter($optionList, fn($it) => $it !== '');
$optionList = array_values($optionList);
$colSchema->enum = $optionList;
return get_object_vars($colSchema);
}
if ($fieldDefs->getType() === FieldType::BOOL) {
$colSchema->type = Type::BOOLEAN;
} else if ($fieldDefs->getType() === FieldType::INT) {
$colSchema->type = Type::INTEGER;
} else if ($fieldDefs->getType() === FieldType::FLOAT) {
$colSchema->type = Type::NUMBER;
} else if ($fieldDefs->getType() === FieldType::VARCHAR) {
$colSchema->type = Type::STRING;
if ($fieldDefs->getParam(FieldParam::MAX_LENGTH)) {
$colSchema->maxLength = $fieldDefs->getParam(FieldParam::MAX_LENGTH);
}
}
return get_object_vars($colSchema);
}
}

View File

@@ -0,0 +1,105 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class LinkParentType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$idSchema = (object) [];
$idSchema->type = Type::STRING;
$idSchema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$idSchema->description = "A foreign record ID.";
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$idSchema->type = [
$idSchema->type,
Type::NULL,
];
}
$typeSchema = (object) [];
$typeSchema->type = Type::STRING;
$typeSchema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$typeSchema->type = [
$typeSchema->type,
Type::NULL,
];
}
if ($fieldDefs->getParam('entityList')) {
$typeSchema->enum = $fieldDefs->getParam('entityList');
}
$typeSchema->description = "An entity type.";
$nameSchema = (object) [];
$nameSchema->type = Type::STRING;
$nameSchema->readOnly = true;
$nameSchema->type = [
$nameSchema->type,
Type::NULL,
];
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field . 'Id';
$required[] = $field . 'Type';
}
$nameSchema->description = 'A foreign record name.';
return new FieldSchemaResult(
properties: [
$field . 'Id' => get_object_vars($idSchema),
$field . 'Type' => get_object_vars($typeSchema),
$field . 'Name' => get_object_vars($nameSchema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,90 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class LinkType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$linkDefs = $this->defs->getEntity($entityType)->tryGetRelation($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if ($linkDefs && $linkDefs->tryGetForeignEntityType()) {
$foreignEntityType = $linkDefs->tryGetForeignEntityType();
$schema->description = "An ID of the record of the $foreignEntityType type.";
}
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$nameSchema = (object) [];
$nameSchema->type = Type::STRING;
$nameSchema->readOnly = true;
$nameSchema->type = [
$nameSchema->type,
Type::NULL,
];
$nameSchema->description = 'A foreign record name.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field . 'Id';
}
return new FieldSchemaResult(
properties: [
$field . 'Id' => get_object_vars($schema),
$field . 'Name' => get_object_vars($nameSchema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,81 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
use Espo\Tools\OpenApi\Util\EnumOptionsProvider;
class MultiEnumType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
private EnumOptionsProvider $optionsProvider,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::ARRAY;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
$optionList = $this->optionsProvider->get($fieldDefs);
$itemSchema = (object) [
'type' => Type::STRING,
];
if ($optionList) {
$itemSchema->enum = $optionList;
}
$schema->items = get_object_vars($itemSchema);
$schema->description = 'A multi-enum.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class NoSupport implements FieldSchemaBuilder
{
public function build(string $entityType, string $field): FieldSchemaResult
{
return new FieldSchemaResult(
properties: [],
);
}
}

View File

@@ -0,0 +1,55 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class NumberType implements FieldSchemaBuilder
{
public function __construct(
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$schema = (object) [];
$schema->type = Type::STRING;
$schema->readOnly = true;
$schema->description = 'A number. Auto-incrementing with a prefix.';
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
);
}
}

View File

@@ -0,0 +1,112 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class PhoneType implements FieldSchemaBuilder
{
const int DEFAULT_MAX_LENGTH = 36;
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->maxLength = self::DEFAULT_MAX_LENGTH;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->description = 'A primary phone number.';
$itemSchema = (object) [];
$itemSchema->type = Type::OBJECT;
$itemSchema->properties = [
'phoneNumber' => [
'type' => Type::STRING,
],
'primary' => [
'type' => Type::BOOLEAN,
],
'optOut' => [
'type' => Type::BOOLEAN,
],
'invalid' => [
'type' => Type::BOOLEAN,
],
'type' => [
'type' => Type::STRING,
'enum' => $fieldDefs->getParam('typeList'),
],
];
$itemSchema->required = [
'phoneNumber',
'primary',
];
$dataSchema = (object) [];
$dataSchema->type = Type::ARRAY;
$dataSchema->items = get_object_vars($itemSchema);
$dataSchema->type = [
$dataSchema->type,
Type::NULL,
];
$dataSchema->description = 'Multiple phone numbers.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
$field . 'Data' => get_object_vars($dataSchema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,79 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class TextType implements FieldSchemaBuilder
{
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
if ($fieldDefs->getParam(FieldParam::MAX_LENGTH)) {
$schema->maxLength = $fieldDefs->getParam(FieldParam::MAX_LENGTH);
}
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->description = 'A multi-line text.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}

View File

@@ -0,0 +1,77 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Tools\OpenApi\FieldSchemaBuilders;
use Espo\Tools\OpenApi\Type;
use Espo\ORM\Defs;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\Tools\OpenApi\FieldSchemaBuilder;
use Espo\Tools\OpenApi\FieldSchemaResult;
class VarcharType implements FieldSchemaBuilder
{
const int DEFAULT_MAX_LENGTH = 255;
public function __construct(
private Defs $defs,
) {}
public function build(string $entityType, string $field): FieldSchemaResult
{
$fieldDefs = $this->defs->getEntity($entityType)->getField($field);
$schema = (object) [];
$schema->type = Type::STRING;
$schema->maxLength = $fieldDefs->getParam(FieldParam::MAX_LENGTH) ?? self::DEFAULT_MAX_LENGTH;
$schema->readOnly = $fieldDefs->getParam(FieldParam::READ_ONLY) ?? false;
if (!$fieldDefs->getParam(FieldParam::REQUIRED)) {
$schema->type = [
$schema->type,
Type::NULL,
];
}
$schema->description = 'A one-line string.';
$required = [];
if ($fieldDefs->getParam(FieldParam::REQUIRED) && !$fieldDefs->getParam(FieldParam::DEFAULT)) {
$required[] = $field;
}
return new FieldSchemaResult(
properties: [
$field => get_object_vars($schema),
],
required: $required,
);
}
}