import { GraphQLBoolean, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLString } from 'graphql';

import { createModuleNameFromMetaUrl } from '../../../_helpers/common';

export const PAYLOAD_UPSERT_SSO_ITEM = createModuleNameFromMetaUrl(import.meta.url);

export default new GraphQLInputObjectType({
  name: PAYLOAD_UPSERT_SSO_ITEM,
  fields: {
    id: {
      type: GraphQLInt,
    },
    displayName: {
      type: GraphQLString,
    },
    allDomains: {
      type: GraphQLBoolean,
    },
    onlyExisting: {
      type: GraphQLBoolean,
    },
    allHubs: {
      type: GraphQLBoolean,
    },
    provider: {
      type: GraphQLString,
    },
    domains: {
      type: new GraphQLList(GraphQLString),
    },
    metadataURL: {
      type: GraphQLString,
    },
    ssoDefaultHubs: {
      type: new GraphQLList(
        new GraphQLInputObjectType({
          name: `${PAYLOAD_UPSERT_SSO_ITEM}_ssoDefaultHubs`,
          fields: {
            id: {
              type: GraphQLInt,
            },
            name: {
              type: GraphQLString,
            },
          },
        }),
      ),
    },
    ssoCustomAttributes: {
      type: new GraphQLList(
        new GraphQLInputObjectType({
          name: `${PAYLOAD_UPSERT_SSO_ITEM}_ssoCustomAttributes`,
          fields: {
            id: {
              type: GraphQLInt,
            },
            name: {
              type: GraphQLString,
            },
            allHubs: {
              type: GraphQLBoolean,
            },
            status: {
              type: GraphQLBoolean,
            },
            ssoCustomAttributesHubs: {
              type: new GraphQLList(
                new GraphQLInputObjectType({
                  name: `${PAYLOAD_UPSERT_SSO_ITEM}_ssoCustomAttributesHubs`,
                  fields: {
                    id: {
                      type: GraphQLInt,
                    },
                    name: {
                      type: GraphQLString,
                    },
                  },
                }),
              ),
            },
            ssoCustomAttributesKeys: {
              type: new GraphQLList(new GraphQLList(GraphQLString)),
            },
          },
        }),
      ),
    },
  },
});
