feat: expose FSSP source APIs and exports

This commit is contained in:
Aleksandr Meshchryakov
2026-10-05 16:00:54 +02:00
parent 1884ecc546
commit 8d2c16bc24
31 changed files with 2112 additions and 44 deletions

View File

@@ -6,7 +6,7 @@ import converter from 'swagger2openapi';
import validator from 'oas-validator';
const base = fileURLToPath(new URL('../..', import.meta.url));
const input = process.argv[2] || resolve(base, 'tools/openapi/swagger.json');
const input = process.argv.slice(2).find(argument => !argument.startsWith('--')) || resolve(base, 'tools/openapi/swagger.json');
const output = resolve(base, 'src/core/openapi.json');
const check = process.argv.includes('--check');
const swagger = JSON.parse(readFileSync(input, 'utf8'));
@@ -26,6 +26,7 @@ const variants = [
['SroMembership', 'sro_membership', 'sro_membership_check', 'sro_membership', 'SroMembership'],
];
const extendedVariants = [
['FsspEnforcementProceeding', 'enforcement_proceedings', 'fssp_enforcement_proceedings', 'enforcement_proceeding', 'FsspEnforcementProceeding'],
['IntegratedStructure', 'integrated_structure_documents', 'integrated_structures', 'integrated_structure', 'IntegratedStructure'],
['FedresursCompanyProfile', 'fedresurs_company_profile', 'fedresurs_company_profile', 'company_profile', 'FedresursCompanyProfile'],
];
@@ -49,6 +50,15 @@ for (const field of schemas.SroSourceRecordOrganization.required) {
delete schemas.SroSourceRecordOrganization.properties[field].nullable;
}
schemas.FsspSourceRecordOrganization = clone(schemas.PublishedSourceRecordOrganization);
for (const field of ['name', 'inn', 'ogrn', 'okpo']) {
delete schemas.FsspSourceRecordOrganization.properties[field].nullable;
schemas.FsspSourceRecordOrganization.properties[field].minLength = 1;
}
for (const [field, length] of [['inn', 10], ['ogrn', 13], ['okpo', 8]]) {
schemas.FsspSourceRecordOrganization.properties[field].pattern = `^[0-9]{${length}}$`;
}
for (const [schemaName, kind] of [
['OrganizationSourceRecordList', 'List'],
['OrganizationSourceRecord', 'Detail'],
@@ -134,6 +144,15 @@ for (const [prefix, group, source, recordType, payloadPrefix] of extendedVariant
schema.properties.status = { type: 'string' };
schema.properties.payload = ref(payloadName);
schema.properties.organization = ref('SroSourceRecordOrganization');
if (group === 'enforcement_proceedings') {
schema.required = [...new Set([...schema.required, 'extension_uid', 'record_date', 'amount', 'url', 'legacy_model', 'legacy_pk', 'load_batch', 'financial_lines'])];
schema.properties.status = { type: 'string', enum: ['unknown', 'ended', 'terminated'] };
schema.properties.amount = { type: 'string', pattern: '^-?[0-9]+\\.[0-9]{2}$', nullable: true };
schema.properties.record_date = { type: 'string', format: 'date', nullable: true };
for (const field of ['legacy_model', 'legacy_pk']) schema.properties[field] = { type: 'string', enum: [''] };
schema.properties.financial_lines = { type: 'array', items: {}, maxItems: 0 };
schema.properties.organization = ref('FsspSourceRecordOrganization');
}
schemas[variantName] = schema;
schemas[schemaName].oneOf.push(ref(variantName));
schemas[schemaName].discriminator.mapping[group] = ref(variantName).$ref;

View File

@@ -17,7 +17,7 @@ const schemas = new Map([
]);
const requiredCases = new Set([
'mixed-list', 'empty-list', 'invalid-list', 'invalid-detail', 'missing-detail',
...['budget_ubpandnubp', 'fns_sme_support_recipients', 'sro_membership_check']
...['budget_ubpandnubp', 'fns_sme_support_recipients', 'sro_membership_check', 'fssp_enforcement_proceedings']
.flatMap(source => [`${source}-list`, `${source}-detail`]),
]);

View File

@@ -461,5 +461,515 @@
"message_details",
"lineage"
]
},
"FsspEnforcementProceedingListPayload": {
"type": "object",
"properties": {
"queried_inn": {
"type": "string",
"nullable": true
},
"debtor_name": {
"type": "string",
"nullable": true
},
"debtor_legal_address": {
"type": "string",
"nullable": true
},
"debtor_actual_address": {
"type": "string",
"nullable": true
},
"consolidated_proceeding_number": {
"type": "string",
"nullable": true
},
"document_raw": {
"type": "string",
"nullable": true
},
"document_type": {
"type": "string",
"nullable": true
},
"document_number": {
"type": "string",
"nullable": true
},
"document_issuer": {
"type": "string",
"nullable": true
},
"document_subject_raw": {
"type": "string",
"nullable": true
},
"creditor_inn": {
"type": "string",
"nullable": true
},
"termination_raw": {
"type": "string",
"nullable": true
},
"termination_reason": {
"type": "string",
"nullable": true
},
"termination_article": {
"type": "string",
"nullable": true
},
"termination_part": {
"type": "string",
"nullable": true
},
"termination_point": {
"type": "string",
"nullable": true
},
"service_text": {
"type": "string",
"nullable": true
},
"subject_raw": {
"type": "string",
"nullable": true
},
"subject": {
"type": "string",
"nullable": true
},
"debt_amount": {
"type": "string",
"nullable": true,
"pattern": "^-?[0-9]+\\.[0-9]{2}$"
},
"claim_amount": {
"type": "string",
"nullable": true,
"pattern": "^[0-9]+\\.[0-9]{2}$"
},
"debt_currency": {
"type": "string",
"nullable": true
},
"department_raw": {
"type": "string",
"nullable": true
},
"department_name": {
"type": "string",
"nullable": true
},
"department_address": {
"type": "string",
"nullable": true
},
"bailiff_raw": {
"type": "string",
"nullable": true
},
"bailiff_name": {
"type": "string",
"nullable": true
},
"debtor_raw": {
"type": "string"
},
"debtor_inn": {
"type": "string"
},
"proceeding_raw": {
"type": "string"
},
"proceeding_number": {
"type": "string"
},
"source_url": {
"type": "string"
},
"dataset": {
"type": "string"
},
"initiated_on": {
"type": "string",
"format": "date",
"nullable": true
},
"document_date": {
"type": "string",
"format": "date",
"nullable": true
},
"terminated_on": {
"type": "string",
"format": "date",
"nullable": true
},
"origin_kind": {
"type": "string",
"enum": [
"web_search",
"open_data_csv"
],
"nullable": true
},
"fetched_at": {
"type": "string",
"format": "date-time"
},
"service_links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": [
"label",
"url"
]
}
},
"bailiff_phones": {
"type": "array",
"items": {
"type": "string"
}
},
"parse_warnings": {
"type": "array",
"items": {
"type": "string"
}
},
"raw_columns": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"source_row_number": {
"type": "integer"
},
"provenance": {
"type": "object",
"additionalProperties": true
},
"observations": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
},
"required": [
"queried_inn",
"debtor_name",
"debtor_legal_address",
"debtor_actual_address",
"consolidated_proceeding_number",
"document_raw",
"document_type",
"document_number",
"document_issuer",
"document_subject_raw",
"creditor_inn",
"termination_raw",
"termination_reason",
"termination_article",
"termination_part",
"termination_point",
"service_text",
"subject_raw",
"subject",
"debt_amount",
"claim_amount",
"debt_currency",
"department_raw",
"department_name",
"department_address",
"bailiff_raw",
"bailiff_name",
"debtor_raw",
"debtor_inn",
"proceeding_raw",
"proceeding_number",
"source_url",
"dataset",
"initiated_on",
"document_date",
"terminated_on",
"origin_kind",
"fetched_at",
"service_links",
"bailiff_phones",
"parse_warnings",
"raw_columns",
"source_row_number"
]
},
"FsspEnforcementProceedingDetailPayload": {
"type": "object",
"properties": {
"queried_inn": {
"type": "string",
"nullable": true
},
"debtor_name": {
"type": "string",
"nullable": true
},
"debtor_legal_address": {
"type": "string",
"nullable": true
},
"debtor_actual_address": {
"type": "string",
"nullable": true
},
"consolidated_proceeding_number": {
"type": "string",
"nullable": true
},
"document_raw": {
"type": "string",
"nullable": true
},
"document_type": {
"type": "string",
"nullable": true
},
"document_number": {
"type": "string",
"nullable": true
},
"document_issuer": {
"type": "string",
"nullable": true
},
"document_subject_raw": {
"type": "string",
"nullable": true
},
"creditor_inn": {
"type": "string",
"nullable": true
},
"termination_raw": {
"type": "string",
"nullable": true
},
"termination_reason": {
"type": "string",
"nullable": true
},
"termination_article": {
"type": "string",
"nullable": true
},
"termination_part": {
"type": "string",
"nullable": true
},
"termination_point": {
"type": "string",
"nullable": true
},
"service_text": {
"type": "string",
"nullable": true
},
"subject_raw": {
"type": "string",
"nullable": true
},
"subject": {
"type": "string",
"nullable": true
},
"debt_amount": {
"type": "string",
"nullable": true,
"pattern": "^-?[0-9]+\\.[0-9]{2}$"
},
"claim_amount": {
"type": "string",
"nullable": true,
"pattern": "^[0-9]+\\.[0-9]{2}$"
},
"debt_currency": {
"type": "string",
"nullable": true
},
"department_raw": {
"type": "string",
"nullable": true
},
"department_name": {
"type": "string",
"nullable": true
},
"department_address": {
"type": "string",
"nullable": true
},
"bailiff_raw": {
"type": "string",
"nullable": true
},
"bailiff_name": {
"type": "string",
"nullable": true
},
"debtor_raw": {
"type": "string"
},
"debtor_inn": {
"type": "string"
},
"proceeding_raw": {
"type": "string"
},
"proceeding_number": {
"type": "string"
},
"source_url": {
"type": "string"
},
"dataset": {
"type": "string"
},
"initiated_on": {
"type": "string",
"format": "date",
"nullable": true
},
"document_date": {
"type": "string",
"format": "date",
"nullable": true
},
"terminated_on": {
"type": "string",
"format": "date",
"nullable": true
},
"origin_kind": {
"type": "string",
"enum": [
"web_search",
"open_data_csv"
],
"nullable": true
},
"fetched_at": {
"type": "string",
"format": "date-time"
},
"service_links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": [
"label",
"url"
]
}
},
"bailiff_phones": {
"type": "array",
"items": {
"type": "string"
}
},
"parse_warnings": {
"type": "array",
"items": {
"type": "string"
}
},
"raw_columns": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"source_row_number": {
"type": "integer"
},
"provenance": {
"type": "object",
"additionalProperties": true
},
"observations": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
},
"required": [
"queried_inn",
"debtor_name",
"debtor_legal_address",
"debtor_actual_address",
"consolidated_proceeding_number",
"document_raw",
"document_type",
"document_number",
"document_issuer",
"document_subject_raw",
"creditor_inn",
"termination_raw",
"termination_reason",
"termination_article",
"termination_part",
"termination_point",
"service_text",
"subject_raw",
"subject",
"debt_amount",
"claim_amount",
"debt_currency",
"department_raw",
"department_name",
"department_address",
"bailiff_raw",
"bailiff_name",
"debtor_raw",
"debtor_inn",
"proceeding_raw",
"proceeding_number",
"source_url",
"dataset",
"initiated_on",
"document_date",
"terminated_on",
"origin_kind",
"fetched_at",
"service_links",
"bailiff_phones",
"parse_warnings",
"raw_columns",
"source_row_number"
]
}
}