All files / src/entities agent_skill_version.ts

44.73% Statements 17/38
0% Branches 0/3
14.28% Functions 1/7
42.85% Lines 15/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 651x     1x 1x 1x 1x   1x     1x     1x     1x     1x     1x     1x     1x     1x                                                             1x  
import { Entity } from '../entity.js';
import { RequestOptions } from '../request.js';
 
export class AgentSkillVersion extends Entity {
  protected static resourceName = 'agent_skill_versions';
  protected static singularName = 'agentSkillVersion';
  protected static pluralName = 'agentSkillVersions';
 
  @AgentSkillVersion.property()
  public id?: string;
 
  @AgentSkillVersion.property()
  public skillId?: string;
 
  @AgentSkillVersion.property()
  public versionNumber?: number;
 
  @AgentSkillVersion.property()
  public contentMd?: string;
 
  @AgentSkillVersion.property()
  public contentHash?: string;
 
  @AgentSkillVersion.property()
  public status?: string;
 
  @AgentSkillVersion.property({ type: Date })
  public requestedAt?: Date | null;
 
  @AgentSkillVersion.property({ type: Date })
  public publishedAt?: Date | null;
 
  @AgentSkillVersion.property({ type: Date })
  public disabledAt?: Date | null;
 
  public submit = (skillId: string) => {
    const resource = `/agent_skills/${skillId}/versions/${this.id}/submit/`;
    const fetchOptions: RequestOptions = { method: 'POST' };
    return this.merchi.authenticatedFetch(resource, fetchOptions).then((data: any) => {
      this.fromJson(data.agentSkillVersion);
      return this;
    });
  };
 
  public approve = (skillId: string, comment: string) => {
    const resource = `/agent_skills/${skillId}/versions/${this.id}/approve/`;
    const fetchOptions: RequestOptions = { method: 'POST', body: new FormData() };
    (fetchOptions.body as FormData).set('comment', comment);
    return this.merchi.authenticatedFetch(resource, fetchOptions).then((data: any) => {
      this.fromJson(data.agentSkillVersion);
      return this;
    });
  };
 
  public reject = (skillId: string, comment: string) => {
    const resource = `/agent_skills/${skillId}/versions/${this.id}/reject/`;
    const fetchOptions: RequestOptions = { method: 'POST', body: new FormData() };
    (fetchOptions.body as FormData).set('comment', comment);
    return this.merchi.authenticatedFetch(resource, fetchOptions).then((data: any) => {
      this.fromJson(data.agentSkillVersion);
      return this;
    });
  };
}