commit melhorias sgf

This commit is contained in:
2026-11-11 09:00:17 +02:00
parent 0b05a1192c
commit 1d11a5e57b
736 changed files with 40746 additions and 210 deletions
+16
View File
@@ -0,0 +1,16 @@
export class WorkshopStockOperation {
constructor(api){this.api=api;this.pending=false;this.uncertain=false;this.operation=null;}
async send(path,body,key){
if(this.pending||this.uncertain)throw new Error('Recupere primeiro a operação pendente.');
this.operation={path,body:JSON.parse(JSON.stringify(body)),key};return this.execute();
}
async retry(){if(!this.uncertain||this.pending)throw new Error('Não existe uma operação incerta para recuperar.');return this.execute();}
async execute(){
this.pending=true;const op=this.operation;
try{const result=await this.api(op.path,'POST',op.body,undefined,op.key);
if(!result||!Number.isInteger(result.id??result.movement_id??result.claim_id))throw new Error('Resposta incompleta; conserve a decisão para recuperação.');
this.uncertain=false;return result;
}catch(e){this.uncertain=!Number.isInteger(e.status)||e.status>=500||e.status===429;throw e;}
finally{this.pending=false;}
}
}