"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskDefinitionContributionPoint = exports.taskDefinitionSchema = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const common_1 = require("../../../common");
exports.taskDefinitionSchema = {
    type: 'object',
    additionalProperties: false,
    properties: {
        type: {
            type: 'string',
            description: (0, ide_core_browser_1.localize)('TaskDefinition.description', "The actual task type. Please note that types starting with a '$' are reserved for internal usage."),
        },
        required: {
            type: 'array',
            items: {
                type: 'string',
            },
        },
        properties: {
            type: 'object',
            description: (0, ide_core_browser_1.localize)('TaskDefinition.properties', 'Additional properties of the task type'),
            additionalProperties: {
                $ref: 'http://json-schema.org/draft-04/schema#',
            },
        },
    },
};
let TaskDefinitionContributionPoint = class TaskDefinitionContributionPoint extends common_1.VSCodeContributePoint {
    constructor() {
        super(...arguments);
        this.phase = 3 /* LifeCyclePhase.Starting */;
    }
    contribute() {
        for (const contrib of this.contributesMap) {
            const { extensionId, contributes } = contrib;
            for (const definition of contributes) {
                this.logger.verbose(`${extensionId} register taskDefinition ${JSON.stringify(definition)}`);
                this.addDispose(this.taskDefinitionRegistry.register(definition.type, {
                    ...definition,
                    taskType: definition.type,
                    extensionId,
                }));
            }
        }
    }
};
exports.TaskDefinitionContributionPoint = TaskDefinitionContributionPoint;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_common_1.ITaskDefinitionRegistry),
    tslib_1.__metadata("design:type", Object)
], TaskDefinitionContributionPoint.prototype, "taskDefinitionRegistry", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.ILogger),
    tslib_1.__metadata("design:type", Object)
], TaskDefinitionContributionPoint.prototype, "logger", void 0);
exports.TaskDefinitionContributionPoint = TaskDefinitionContributionPoint = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    (0, common_1.Contributes)('taskDefinitions'),
    (0, common_1.LifeCycle)(4 /* LifeCyclePhase.Ready */)
], TaskDefinitionContributionPoint);
//# sourceMappingURL=taskDefinition.js.map