@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
68 lines • 2.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
const AbstractStore_1 = __importDefault(require("../../../stores/AbstractStore"));
class OrganizationStore extends AbstractStore_1.default {
name = 'organization';
async isSkillInstalledAtOrg(skillId, orgId) {
const client = await this.connectToApi();
const results = await client.emit('is-skill-installed::v2020_12_25', {
target: {
organizationId: orgId,
},
payload: {
skillId,
},
});
const { isInstalled } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
return isInstalled;
}
async installSkillAtOrganization(skillId, orgId) {
const client = await this.connectToApi();
const results = await client.emit('install-skill::v2020_12_25', {
target: {
organizationId: orgId,
},
payload: {
skillId,
},
});
spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
}
async fetchMyOrganizations() {
const client = await this.connectToApi();
const results = await client.emit('list-organizations::v2020_12_25', {
payload: {
shouldOnlyShowMine: true,
},
});
const { organizations } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
return organizations;
}
async create(values) {
const { name, slug } = values;
const client = await this.connectToApi();
const results = await client.emit('create-organization::v2020_12_25', {
payload: {
name,
slug,
},
});
const { organization } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
return organization;
}
async deleteOrganization(orgId) {
const client = await this.connectToApi();
const results = await client.emit('delete-organization::v2020_12_25', {
target: {
organizationId: orgId,
},
});
spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
}
}
exports.default = OrganizationStore;
//# sourceMappingURL=OrganizationStore.js.map