Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

2.9 KB
Raw Blame
import type {
  GetSystemFeaturesLicenseResponse,
  GetSystemFeaturesResponse,
} from '@dify/contracts/api/console/system-features/types.gen'
import {
  zLicenseStatus,
  zPluginInstallationScope,
} from '@dify/contracts/api/console/system-features/zod.gen'

export type DeepPartial<T> =
  T extends Array<infer U>
    ? Array<U>
    : T extends object
      ? { [K in keyof T]?: DeepPartial<T[K]> }
      : T

const baseSystemFeatures = {
  agent_tracing_api_collection_enabled: false,
  deployment_edition: 'COMMUNITY',
  enable_app_deploy: false,
  sso_enforced_for_signin: false,
  sso_enforced_for_signin_protocol: null,
  enable_marketplace: false,
  enable_email_code_login: false,
  enable_email_password_login: true,
  enable_social_oauth_login: false,
  is_allow_register: false,
  is_email_setup: false,
  enable_change_email: true,
  license: {
    status: zLicenseStatus.enum.none,
  },
  branding: {
    enabled: false,
    login_page_logo: '',
    workspace_logo: '',
    favicon: '',
    application_title: '',
  },
  webapp_auth: {
    enabled: false,
    allow_sso: false,
    sso_config: {
      protocol: null,
    },
    allow_email_code_login: false,
    allow_email_password_login: false,
    allow_public_access: true,
  },
  plugin_installation_permission: {
    plugin_installation_scope: zPluginInstallationScope.enum.all,
    restrict_to_marketplace_only: false,
  },
  rbac_enabled: false,
  enable_creators_platform: false,
  enable_explore_banner: false,
  enable_learn_app: true,
  enable_step_by_step_tour: false,
} satisfies GetSystemFeaturesResponse

const baseSystemFeaturesLicense = {
  status: zLicenseStatus.enum.none,
  license_expiry_notice_enabled: false,
  expired_at: '',
  workspaces: {
    enabled: false,
    size: 0,
    limit: 0,
  },
  seats: {
    enabled: false,
    size: 0,
    limit: 0,
  },
} satisfies GetSystemFeaturesLicenseResponse

export const createSystemFeaturesFixture = (
  overrides: DeepPartial<GetSystemFeaturesResponse> = {},
): GetSystemFeaturesResponse => ({
  ...baseSystemFeatures,
  ...overrides,
  branding: {
    ...baseSystemFeatures.branding,
    ...overrides.branding,
  },
  webapp_auth: {
    ...baseSystemFeatures.webapp_auth,
    ...overrides.webapp_auth,
    sso_config: {
      ...baseSystemFeatures.webapp_auth.sso_config,
      ...overrides.webapp_auth?.sso_config,
    },
  },
  plugin_installation_permission: {
    ...baseSystemFeatures.plugin_installation_permission,
    ...overrides.plugin_installation_permission,
  },
  license: {
    ...baseSystemFeatures.license,
    ...overrides.license,
  },
})

export const createSystemFeaturesLicenseFixture = (
  overrides: DeepPartial<GetSystemFeaturesLicenseResponse> = {},
): GetSystemFeaturesLicenseResponse => ({
  ...baseSystemFeaturesLicense,
  ...overrides,
  workspaces: {
    ...baseSystemFeaturesLicense.workspaces,
    ...overrides.workspaces,
  },
  seats: {
    ...baseSystemFeaturesLicense.seats,
    ...overrides.seats,
  },
})