feat: expose unified exchange activity APIs and exports

This commit is contained in:
Aleksandr Meshchryakov
2026-10-05 17:33:33 +02:00
parent d69ba600d4
commit 3ce9898c0e
30 changed files with 1324 additions and 85 deletions

View File

@@ -7,7 +7,7 @@ The source is the actual DRF serializers and view annotations. `build.mjs` conve
Swagger 2 to OpenAPI 3, adds the source-record discriminated variants and the named
ordering enum with comma-separated ordering, then validates the resulting document.
Do not edit `src/core/openapi.json` or generated TypeScript by hand.
The public-UI Fedresurs and integrated-structure DTOs live in
The FSSP, Checko sections, combined exchange, public-UI Fedresurs and integrated-structure DTOs live in
`source-record-extensions.json`; `build.mjs` adds their discriminated list/detail
variants and typed upload/attachment errors to the generated contract.

View File

@@ -26,6 +26,7 @@ const variants = [
['SroMembership', 'sro_membership', 'sro_membership_check', 'sro_membership', 'SroMembership'],
];
const extendedVariants = [
['ExchangeInstrument', 'stock_exchange_activity', 'stock_exchange_activity', 'exchange_instrument', 'ExchangeInstrument'],
['CheckoLeasing', 'leasing', 'checko_leasing', 'leasing_contract', 'CheckoLeasing'],
['CheckoMessage', 'company_messages', 'checko_messages', 'company_message', 'CheckoMessage'],
['CheckoLicense', 'company_licenses', 'checko_licenses', 'company_license', 'CheckoLicense'],
@@ -123,6 +124,12 @@ for (const name of ['OrganizationSourceRecordListResponse', 'SourceRecordMeta',
}
schemas.OrganizationSourceRecordListResponse.properties.errors = { type: 'object', nullable: true, enum: [null] };
// Source refresh validation details are arbitrary structured JSON from the actual
// exception envelope; they must survive generated validators unchanged.
if (schemas.SourceRefreshErrorItem?.properties?.details) {
schemas.SourceRefreshErrorItem.properties.details = { type: 'object', additionalProperties: true };
}
// The two richer source payloads have stable public DTOs in addition to the
// generic DRF JSONField. Keep these schemas beside the canonical converter so
// both backend /openapi.json and the frontend client come from one contract.
@@ -147,7 +154,7 @@ 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 (['leasing', 'company_messages', 'company_licenses'].includes(group)) {
if (['leasing', 'company_messages', 'company_licenses', 'stock_exchange_activity'].includes(group)) {
schema.properties.organization = ref('FsspSourceRecordOrganization');
}
if (group === 'enforcement_proceedings') {

View File

@@ -6,9 +6,19 @@ import {
ApiV2OrganizationSourceRecordsRead404Response,
V2OrganizationSourceRecordsList200Response,
V2OrganizationSourceRecordsList400Response,
ApiV1SourcesRefreshCreate202Response,
ApiV1SourcesRefreshCreate400Response,
ApiV1SourcesRefreshCreate403Response,
ApiV1SourcesRefreshCreate404Response,
ApiV1SourcesRefreshCreate409Response,
} from './generated-zod/contract.ts';
const schemas = new Map([
['refresh:202', ApiV1SourcesRefreshCreate202Response],
['refresh:400', ApiV1SourcesRefreshCreate400Response],
['refresh:403', ApiV1SourcesRefreshCreate403Response],
['refresh:404', ApiV1SourcesRefreshCreate404Response],
['refresh:409', ApiV1SourcesRefreshCreate409Response],
['list:200', V2OrganizationSourceRecordsList200Response],
['list:400', V2OrganizationSourceRecordsList400Response],
['detail:200', ApiV2OrganizationSourceRecordsRead200Response],
@@ -17,7 +27,10 @@ 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', 'fssp_enforcement_proceedings', 'checko_leasing', 'checko_messages', 'checko_licenses']
'stock_exchange_activity-spb-detail', 'missing-refresh',
...['fssp_enforcement_proceedings', 'checko_leasing', 'checko_messages', 'checko_licenses', 'stock_exchange_activity']
.flatMap(source => ['forbidden', 'invalid', 'accepted', 'conflict'].map(kind => `${source}-refresh-${kind}`)),
...['budget_ubpandnubp', 'fns_sme_support_recipients', 'sro_membership_check', 'fssp_enforcement_proceedings', 'checko_leasing', 'checko_messages', 'checko_licenses', 'stock_exchange_activity']
.flatMap(source => [`${source}-list`, `${source}-detail`]),
]);

View File

@@ -6,6 +6,12 @@ import type {
} from './generated/schemas';
export function recordLabel(record: OrganizationSourceRecordList): string {
if (record.source_group === 'stock_exchange_activity') {
const type: 'exchange_instrument' = record.record_type;
const duration: string | null | undefined = record.payload.duration?.value;
const yieldValue: string | null | undefined = record.payload.yield?.value;
return type + record.payload.exchange + (duration || '') + (yieldValue || '');
}
if (record.source_group === 'budget_process_registry') {
const type: 'budget_registry_organization' = record.record_type;
return type + record.payload.registry.code;

View File

@@ -1163,5 +1163,152 @@
"$ref": "#/components/schemas/CheckoLicenseListPayload"
}
]
},
"ExchangeMetric": {
"type": "object",
"properties": {
"value": {
"type": "string",
"nullable": true
},
"unit": {
"type": "string",
"nullable": true
},
"calculated_on": {
"type": "string",
"format": "date",
"nullable": true
}
},
"required": [
"value",
"unit",
"calculated_on"
]
},
"ExchangeTrading": {
"type": "object",
"properties": {
"traded_on": {
"type": "string",
"format": "date"
},
"board_id": {
"type": "string"
},
"upstream": {
"type": "object",
"additionalProperties": true
}
},
"required": [
"traded_on",
"board_id",
"upstream"
]
},
"ExchangeInstrumentListPayload": {
"type": "object",
"properties": {
"exchange": {
"type": "string",
"enum": [
"moex",
"spb"
]
},
"instrument_id": {
"type": "string"
},
"issuer_inn": {
"type": "string",
"pattern": "^[0-9]{10}$"
},
"issuer_provider_id": {
"type": "string",
"nullable": true
},
"isin": {
"type": "string",
"nullable": true
},
"instrument_kind": {
"type": "string"
},
"listing_date": {
"type": "string",
"format": "date",
"nullable": true
},
"nominal_value": {
"type": "string",
"nullable": true
},
"nominal_currency": {
"type": "string",
"nullable": true
},
"parameters": {
"type": "object",
"additionalProperties": true
},
"trading": {
"allOf": [
{
"$ref": "#/components/schemas/ExchangeTrading"
}
],
"nullable": true
},
"duration": {
"allOf": [
{
"$ref": "#/components/schemas/ExchangeMetric"
}
],
"nullable": true
},
"yield": {
"allOf": [
{
"$ref": "#/components/schemas/ExchangeMetric"
}
],
"nullable": true
},
"provenance": {
"type": "object",
"additionalProperties": true
},
"upstream": {
"type": "object",
"additionalProperties": true
}
},
"required": [
"exchange",
"instrument_id",
"issuer_inn",
"issuer_provider_id",
"isin",
"instrument_kind",
"listing_date",
"nominal_value",
"nominal_currency",
"parameters",
"trading",
"duration",
"yield",
"provenance",
"upstream"
]
},
"ExchangeInstrumentDetailPayload": {
"allOf": [
{
"$ref": "#/components/schemas/ExchangeInstrumentListPayload"
}
]
}
}