"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLIntegrationPlugin = exports.GraphQLIntegrationPluginMergedFieldNames = void 0;
const index_js_1 = require("../../types/index.js");
const constants_js_1 = require("./constants.js");
const graphql_js_1 = require("./graphql.js");
const index_js_2 = require("./shared/index.js");
const GraphQLIntegrationPluginVersions = graphql_js_1.GraphQLPluginVersions;
var GraphQLIntegrationPluginMergedFieldNames;
(function (GraphQLIntegrationPluginMergedFieldNames) {
    GraphQLIntegrationPluginMergedFieldNames["HEADERS"] = "headers";
    // potentially variables too if converted to FieldList component
    // VARIABLES = 'custom.variables.value'
})(GraphQLIntegrationPluginMergedFieldNames || (exports.GraphQLIntegrationPluginMergedFieldNames = GraphQLIntegrationPluginMergedFieldNames = {}));
exports.GraphQLIntegrationPlugin = {
    id: index_js_1.ExtendedIntegrationPluginId.GRAPHQL,
    name: 'GraphQL',
    moduleName: 'GraphQLPlugin',
    modulePath: 'plugins/graphql/GraphQLPlugin',
    iconLocation: `${constants_js_1.PUBLIC_INTEGRATIONS_LOGO_URL}/graphql.png`,
    type: index_js_1.PluginType.API,
    responseType: index_js_1.PluginResponseType.JSON,
    hasRawRequest: true,
    rawRequestName: 'Executed request',
    hasTest: false,
    datasourceTemplate: {
        sections: [
            {
                name: 'main',
                items: [
                    {
                        label: 'Display name',
                        name: 'name',
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        placeholder: 'Example API',
                        rules: [{ required: true, message: 'Display name is required' }]
                    },
                    {
                        label: 'URL',
                        name: 'path',
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.DYNAMIC_INPUT_TEXT,
                        placeholder: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
                        rules: [{ required: true, message: 'URL is required' }]
                    }
                ]
            },
            ...(0, index_js_2.authSections)({
                startVersion: GraphQLIntegrationPluginVersions.V8,
                pluginId: index_js_1.ExtendedIntegrationPluginId.GRAPHQL,
                pluginName: 'GraphQL',
                enabledMethods: {
                    basic: true,
                    oauth: true,
                    bearer: true,
                    apiKey: true
                }
            }),
            {
                name: 'tabs',
                layout: index_js_1.FormSectionLayout.TABS,
                items: [
                    {
                        label: 'Headers',
                        name: GraphQLIntegrationPluginMergedFieldNames.HEADERS,
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.FIELD_LIST,
                        secretsNames: ['Authorization']
                    }
                ]
            }
        ]
    },
    actionTemplate: {
        sections: [
            {
                name: 'main',
                items: [
                    {
                        label: 'URL',
                        name: 'path',
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.INPUT_TEXT,
                        disabled: true
                    }
                ]
            },
            {
                name: 'tabs',
                layout: index_js_1.FormSectionLayout.TABS,
                items: [
                    {
                        label: 'Query',
                        name: 'body',
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.CODE_EDITOR,
                        language: index_js_1.EditorLanguage.JSON
                    },
                    {
                        label: 'Variables',
                        name: 'custom.variables.value',
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.CODE_EDITOR,
                        language: index_js_1.EditorLanguage.JSON
                    },
                    {
                        label: 'Headers',
                        name: GraphQLIntegrationPluginMergedFieldNames.HEADERS,
                        startVersion: GraphQLIntegrationPluginVersions.V1,
                        componentType: index_js_1.FormComponentType.FIELD_LIST
                    }
                ]
            },
            {
                name: 'additionalSettings',
                sectionHeader: 'Additional Settings',
                isCollapsible: true,
                defaultCollapsed: true,
                asTitle: false,
                items: [
                    {
                        name: 'verboseHttpOutput',
                        label: 'Include full request response in step output',
                        lightLabelText: true,
                        startVersion: GraphQLIntegrationPluginVersions.V9,
                        componentType: index_js_1.FormComponentType.SWITCH,
                        initialValue: false,
                        showConfirm: false,
                        renderIconFirst: true
                    },
                    {
                        name: 'failOnGraphqlErrors',
                        label: 'Fail when request includes errors',
                        lightLabelText: true,
                        startVersion: GraphQLIntegrationPluginVersions.V10,
                        componentType: index_js_1.FormComponentType.SWITCH,
                        initialValue: false,
                        showConfirm: false,
                        renderIconFirst: true
                    }
                ]
            }
        ]
    }
};
//# sourceMappingURL=graphqlintegration.js.map