varias alteracoes
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-06 14:50:12 +02:00
parent 4f35313d06
commit e65cb26901
333 changed files with 54656 additions and 2058 deletions
+13 -5
View File
@@ -10,7 +10,7 @@ const relation = {association_type: {type: 'string', enum: ['official','influenc
const relationRequired=['association_type','role','source_reference','justification','valid_from'];
const schemas = {
Version: object({version_no:version},['version_no']),
Zone: object({version_no:version,code:{type:'string',maxLength:80},category:{type:'string',enum:['zee','zfi','industrial_park','pending']},name:{type:'string',maxLength:255},name_en:nullable(string),description:nullable(string),description_en:nullable(string),province:nullable(string),district:nullable(string),operator_id:nullable(uuid),legal_source_id:nullable(uuid)},['code','category','name']),
Zone: object({version_no:version,code:{type:'string',maxLength:80},category:{type:'string',enum:['zee','zfi','industrial_park','pending']},physical_category:{type:'string',enum:['economic_zone','industrial_park','agro_industrial_park','industrial_logistics_park','industrial_free_zone','integrated_tourism_area','other','unknown']},legal_regime:{type:'string',enum:['zee','zfi','general','pending','not_applicable']},development_status:{type:'string',enum:['announced','planned','in_development','partially_operational','operational','suspended','unknown']},availability_status:{type:'string',enum:['confirmed','unavailable','reported_unverified','not_informed']},area_components:{type:'array',items:{type:'object'}},source_evidence:{type:'array',items:{type:'object'}},name:{type:'string',maxLength:255},name_en:nullable(string),description:nullable(string),description_en:nullable(string),province:nullable(string),district:nullable(string),operator_id:nullable(uuid),legal_source_id:nullable(uuid)},['code','category','name']),
LegalSource: object({title:string,url:{type:'string',format:'uri',description:'HTTPS reference only; no remote download.'},diploma:string,article:string,competent_entity:string,valid_from:date,valid_until:nullable(date)},['title','url','diploma','article','competent_entity','valid_from']),
Link: object({opportunity_id:{type:'integer',minimum:1},...relation},['opportunity_id',...relationRequired]),
Relation: object({cluster_id:nullable(uuid),corridor_id:nullable(uuid),project_id:nullable(uuid),...relation},relationRequired),
@@ -23,14 +23,22 @@ schemas.Geometry.description='GeoJSON geometry in EPSG:4326, 2D, valid, nonempty
const paths={}; let operations=0;
for(const route of routes){
const path='/'+route.uri; const method=route.method.split('|')[0].toLowerCase(); const admin=path.includes('/admin/');
const parameters=[...path.matchAll(/\{([^}]+)\}/g)].map(match=>({name:match[1],in:'path',required:true,schema:match[1]==='action'?{type:'string',enum:path.includes('/admin/zones/')?['publish','suspend']:['validate','revoke']}:uuid}));
if(method==='get' && path.endsWith('/zones')) parameters.push({name:'q',in:'query',schema:{type:'string',maxLength:120}},{name:'category',in:'query',schema:{type:'string',enum:['zee','zfi','industrial_park']}},{name:'page',in:'query',schema:version});
const parameters=[...path.matchAll(/\{([^}]+)\}/g)].map(match=>({name:match[1],in:'path',required:true,schema:match[1]==='action'?{type:'string',enum:path.includes('zone-attachments')?['review','select-public','withdraw-public']:path.includes('/admin/zones/')?['publish','suspend']:['validate','revoke']}:uuid}));
if(method==='get' && (path.endsWith('/zones') || path.endsWith('/zones/export.csv'))) parameters.push({name:'q',in:'query',schema:{type:'string',maxLength:120}},{name:'category',in:'query',schema:{type:'string',enum:['zee','zfi','industrial_park']}},{name:'physical_category',in:'query',schema:string},{name:'legal_regime',in:'query',schema:string},{name:'development_status',in:'query',schema:string},{name:'availability_status',in:'query',schema:string},{name:'activity',in:'query',schema:string},{name:'province_id',in:'query',schema:uuid},{name:'district_id',in:'query',schema:uuid},{name:'admin_post_id',in:'query',schema:uuid},{name:'locality_id',in:'query',schema:uuid},{name:'page',in:'query',schema:version});
if(path.endsWith('/zone-map')) parameters.push({name:'zone_id',in:'query',schema:uuid},{name:'bbox[]',in:'query',style:'form',explode:true,schema:{type:'array',minItems:4,maxItems:4,items:{type:'number'}},description:'west,south,east,north; no antimeridian wrap.'});
const creates=method==='post'&&!path.includes('{action}');
const operation={operationId:route.action.split('\\').at(-1).replace('@','_')+'_'+operations++,summary:route.action.split('\\').at(-1),parameters,security:admin?[{laravelSession:[]}]:[],responses:{[creates?'201':'200']:{description:'Success. JSON; paginated lists. Private management responses use Cache-Control: private, no-store.',content:{'application/json':{schema:{type:'object'}}}},'403':{description:'Missing manager/MFA/designated role or self-review.'},'404':{description:'Not found or not publicly visible.'},'409':{description:'Stale version or duplicate relation.'},'419':{description:'Session/CSRF validation failed.'},'422':{description:'Invalid data, source, geometry, overlap or workflow.'},'429':{description:'Rate limit exceeded.'}}};
const privateRoute=admin||path.includes('/management/');
const operation={operationId:route.action.split('\\').at(-1).replace('@','_')+'_'+operations++,summary:route.action.split('\\').at(-1),parameters,security:privateRoute?[{laravelSession:[]}]:[],responses:{[creates?'201':'200']:{description:'Success. JSON; paginated lists. Private management responses use Cache-Control: private, no-store.',content:{'application/json':{schema:{type:'object'}}}},'403':{description:'Missing manager/MFA/designated role or self-review.'},'404':{description:'Not found or not publicly visible.'},'409':{description:'Stale version or duplicate relation.'},'419':{description:'Session/CSRF validation failed.'},'422':{description:'Invalid data, source, geometry, overlap or workflow.'},'429':{description:'Rate limit exceeded.'}}};
if(path.endsWith('/zones/export.csv')) operation.responses['200']={description:'CSV filtered with the same server-side criteria as the public zone list.',content:{'text/csv':{schema:{type:'string',format:'binary'}}}};
if(method!=='get'){
const schema=path.includes('{action}')?'Version':path.endsWith('/legal-sources')?'LegalSource':path.endsWith('/links')?'Link':path.endsWith('/relations')?'Relation':path.endsWith('/geometries')?'Geometry':'Zone';
operation.requestBody={required:true,content:{'application/json':{schema:{$ref:'#/components/schemas/'+schema}}}};
if(path.endsWith('/attachments')){
operation.requestBody={required:true,content:{'multipart/form-data':{schema:object({file:{type:'string',format:'binary'},kind:{type:'string',enum:['legal_instrument','map','photo','study','other']},caption:{type:'string',maxLength:255},source_reference:{type:'string',minLength:5,maxLength:2000},source_date:nullable(date),rights_status:{type:'string',enum:['pending','confirmed','restricted']},rights_basis:nullable(string)},['file','kind','caption','source_reference','rights_status'])}}};
} else if(path.includes('zone-attachments/{id}/{action}')){
operation.requestBody={required:true,content:{'application/json':{schema:object({version_no:version,decision:{type:'string',enum:['reviewed','rejected']},rights_status:{type:'string',enum:['pending','confirmed','restricted']},rights_basis:nullable(string),personal_data_status:{type:'string',enum:['none','present','unknown']}},path.endsWith('/review')?['version_no','decision','rights_status','personal_data_status']:['version_no'])}}};
} else {
operation.requestBody={required:true,content:{'application/json':{schema:{$ref:'#/components/schemas/'+schema}}}};
}
}
(paths[path]??={})[method]=operation;
}