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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Entity } from '../entity.js';
import { RequestOptions } from '../request.js';
import { AgentSkillVersion } from './agent_skill_version.js';
import { Category } from './category.js';
import { Domain } from './domain.js';
import { Product } from './product.js';
interface CreateDraftOptions {
contentMd?: string;
}
export class AgentSkill extends Entity {
protected static resourceName = 'agent_skills';
protected static singularName = 'agentSkill';
protected static pluralName = 'agentSkills';
protected static primaryKey = 'id';
@AgentSkill.property()
public id?: string;
@AgentSkill.property()
public slug?: string;
@AgentSkill.property()
public title?: string;
@AgentSkill.property()
public scope?: 'global' | 'domain' | 'domain_category' | 'domain_product';
@AgentSkill.property({ type: Domain })
public domain?: Domain | null;
@AgentSkill.property({ type: Category })
public category?: Category | null;
@AgentSkill.property({ type: Product })
public product?: Product | null;
@AgentSkill.property()
public description?: string | null;
@AgentSkill.property()
public priority?: number;
@AgentSkill.property({ type: Date })
public createdAt?: Date | null;
@AgentSkill.property({ type: Date })
public disabledAt?: Date | null;
@AgentSkill.property()
public currentDraftVersionId?: string | null;
@AgentSkill.property()
public currentPublishedVersionId?: string | null;
@AgentSkill.property({ arrayType: 'AgentSkillVersion' })
public versions?: AgentSkillVersion[];
public createDraftVersion = (options?: CreateDraftOptions) => {
const resource = `/agent_skills/${this.id}/versions/`;
const fetchOptions: RequestOptions = { method: 'POST' };
Iif (options && options.contentMd) {
const body = new FormData();
body.set('contentMd', options.contentMd);
fetchOptions.body = body;
}
return this.merchi.authenticatedFetch(resource, fetchOptions).then((data: any) => {
const version = new this.merchi.AgentSkillVersion();
version.fromJson(data.agentSkillVersion);
this.currentDraftVersionId = version.id;
return version;
});
};
public disable = () => {
const resource = `/agent_skills/${this.id}/disable/`;
const fetchOptions: RequestOptions = { method: 'POST' };
return this.merchi.authenticatedFetch(resource, fetchOptions).then((data: any) => {
this.fromJson(data.agentSkill);
return this;
});
};
public enable = () => {
const resource = `/agent_skills/${this.id}/enable/`;
const fetchOptions: RequestOptions = { method: 'POST' };
return this.merchi.authenticatedFetch(resource, fetchOptions).then((data: any) => {
this.fromJson(data.agentSkill);
return this;
});
};
public getVersionDiff = (versionId: string) => {
const resource = `/agent_skills/${this.id}/versions/${versionId}/diff/`;
const fetchOptions: RequestOptions = { method: 'GET' };
return this.merchi.authenticatedFetch(resource, fetchOptions);
};
}
|