<commit_before>import ClarifaiAPI = require('clarifai');

export class Config {
  /**
   * Enable or disable HTTP.
   */
  static httpEnabled: boolean = process.env.IR_HTTP_ENABLED === 'true' || true;

  /**
   * HTTP Port where the app runs
   */
  static httpPort: string = process.env.IR_HTTP_PORT || '9090';

  /**
   * Enable or disable HTTPS. When enabled, all HTTP traffic is redirected to HTTPS.
   */
  static httpsEnabled: boolean = process.env.IR_HTTPS_ENABLED === 'true' || true;

  /**
   * HTTPS Port where the app runs
   */
  static httpsPort: string = process.env.IR_HTTPS_PORT || '9443';

  /**
   * SSL private key
   */
  static httpsKeyFile: string = process.env.IR_HTTPS_KEY_FILE || './https/server.key';

  /**
   * SSL certificate
   */
  static httpsCertFile: string = process.env.IR_HTTPS_CERT_FILE || './https/server.crt';

  /**
   * Temporary directory used for downloading images.
   */
  static tempDir: string = process.env.IR_TEMP_DIR || './temp';

  /**
   * Elvis server url
   */
  static elvisUrl: string = process.env.IR_ELVIS_URL || 'http://localhost:8080';

  /**
   * Elvis username. 
   * 
   * The user should be able to access the preview of the image in Elvis.
   */
  static elvisUsername: string = process.env.IR_ELVIS_USER || 'admin';

  /**
   * Elvis password.
   */
  static elvisPassword: string = process.env.IR_ELVIS_PASSWORD || '<PASSWORD>';

  /**
   * Recognize images right after they are imported in Elvis.
   * 
   * This depends on webhooks, make sure to also configure the elvisToken correctly when this setting is enabled.
   */
  static recognizeOnImport: boolean = process.env.IR_RECOGNIZE_ON_IMPORT === 'true' || true;

  /**
   * Enable or disable the REST API.
   * 
   * Web client plugins like the Auto Tag Images plugin depend on this API to be enabled.
   * 
   * BETA NOTE: This API is currently in BETA stage. All API calls are fully functional, authentication is however not yet implemented. 
   * Therefore, ensure on network level that the recognition server can only be accessed by your integration.
   */
  static restAPIEnabled: boolean = process.env.IR_REST_API_ENABLED === 'true' || false;

  /**
   * Elvis webhook token. Create a webhook that listens for "asset_update_metadata" events and that returns the "assetDomain" metadata field.
   * 
   * More info on creating a webhook: https://helpcenter.woodwing.com/hc/en-us/articles/115001884346
   */
  static elvisToken: string = process.env.IR_ELVIS_TOKEN || '<PASSWORD>';

  /**
   * Elvis metadata field where the unique tags from all services are stored.
   * 
   * Default value is "tagsFromAI" which holds all tags generated by image recognition services. 
   * Note that this metadata field was introduced with Elvis 5.26
   */
  static elvisTagsField: string = process.env.IR_ELVIS_TAGS_FIELD || 'tagsFromAI';

  /**
   * Elvis metadata field that holds a timestamp of the last AI metadata update.
   *
   * This can be useful to determine which files need to be processed or re-processed after a certain period (new services, better AI models)
   */
  static aiMetadataModifiedField: string = process.env.IR_ELVIS_AI_METADATA_MODIFIED_FIELD || 'cf_aiMetadataModified'

  /**
   * Enable or disable Clarifai image recognition.
   */
  static clarifaiEnabled: boolean = process.env.IR_CLARIFAI_ENABLED === 'true' || true;

  /**
   * Clarifai CLIENT ID.
   *
   * Can be obtained by creating a Clarifai account: https://www.clarifai.com/
   */
  static clarifaiClientId: string = process.env.IR_CLARIFAI_CLIENT_ID || 'my-clarifai-client-id';

  /**
   * Clarifai CLIENT SECRET.
   *
   * Can be obtained by creating a Clarifai account: https://www.clarifai.com/
   */
  static clarifaiClientSecret: string = process.env.IR_CLARIFAI_CLIENT_SECRET || 'my-clarifai-client-secret';

  /**
   * Elvis metadata field where Clarifai tags are stored, set to null to skip saving tags in a specific Clarifai field.
   */
  static clarifaiTagsField: string = process.env.IR_CLARIFAI_TAGS_FIELD || 'cf_tagsClarifai';

  /**
   * Possible model values:
   * - ClarifaiAPI.GENERAL_MODEL
   * - ClarifaiAPI.FOOD_MODEL
   * - ClarifaiAPI.TRAVEL_MODEL
   * - ClarifaiAPI.WEDDING_MODEL
   * - ClarifaiAPI.APPAREL_MODEL
   * - 'e466caa0619f444ab97497640cefc4dc' (Celebrity model)
   * - ClarifaiAPI.DEMOGRAPHICS_MODEL
   * - ClarifaiAPI.MODERATION_MODEL
   * - ClarifaiAPI.NSFW_MODEL
   */
  static clarifaiFolderToModelMapping: any[] = [
    {
      folder: '/Demo Zone/Images/Food',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.FOOD_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Travel',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.TRAVEL_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Wedding',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.WEDDING_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Apparel',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.APPAREL_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Celebrity',
      models: [ClarifaiAPI.GENERAL_MODEL, 'e466caa0619f444ab97497640cefc4dc']
    }
  ];
   * Enable or disable Google image recognition.
   */
  static googleEnabled: boolean = process.env.IR_GOOGLE_ENABLED === 'true' || true;

  /**
   * Full path to the Google Service account keyfile (JSON).  
   *
   * Can be obtained by creating a Google Cloud account: https://cloud.google.com/vision/
   * 
   * Steps when starting from scratch with Google Vision:
   * - Create a new project.
   * - Enable the Cloud Vision API (API Manager -> Library -> Vision API).
   * - Create a service account key (API Manager -> Credentials -> Create Credentials - Service account key).
   * - Specify the full path to the JSON keyfile in this setting.
   */
  static googleKeyFilename: string = process.env.IR_GOOGLE_KEY_FILENAME || '/Users/username/keyfile.json';

  /**
   * Elvis metadata field where Google tags are stored, set to null to skip saving tags in a specific Google field.
   */
  static googleTagsField: string = process.env.IR_GOOGLE_TAGS_FIELD || 'cf_tagsGoogle';

  /**
   * Enable or disable AWS image recognition.
   */
  static awsEnabled: boolean = process.env.IR_AWS_ENABLED === 'true' || true;

  /**
   * AWS access key<commit_msg>Tidy up config file<commit_after>import ClarifaiAPI = require('clarifai');

export class Config {
  /**
   * Enable or disable HTTP.
   */
  static httpEnabled: boolean = process.env.IR_HTTP_ENABLED === 'true' || true;

  /**
   * HTTP Port where the app runs.
   */
  static httpPort: string = process.env.IR_HTTP_PORT || '9090';

  /**
   * Enable or disable HTTPS. When enabled, all HTTP traffic is redirected to HTTPS.
   */
  static httpsEnabled: boolean = process.env.IR_HTTPS_ENABLED === 'true' || false;

  /**
   * HTTPS Port where the app runs.
   */
  static httpsPort: string = process.env.IR_HTTPS_PORT || '9443';

  /**
   * SSL private key.
   */
  static httpsKeyFile: string = process.env.IR_HTTPS_KEY_FILE || './https/server.key';

  /**
   * SSL certificate.
   */
  static httpsCertFile: string = process.env.IR_HTTPS_CERT_FILE || './https/server.crt';

  /**
   * Temporary directory used for downloading images.
   */
  static tempDir: string = process.env.IR_TEMP_DIR || './temp';

  /**
   * Elvis server url.
   */
  static elvisUrl: string = process.env.IR_ELVIS_URL || 'http://localhost:8080';

  /**
   * Elvis username. 
   * 
   * Permission configuration:
   * - This user should be licensed as an API user.
   * - Ensure that the user can access the preview of all images imported in Elvis.
   */
  static elvisUsername: string = process.env.IR_ELVIS_USER || 'admin';

  /**
   * Elvis password.
   */
  static elvisPassword: string = process.env.IR_ELVIS_PASSWORD || '<PASSWORD>';


  /**
   * Recognize images right after they are imported in Elvis.
   * 
   * This depends on webhooks, make sure to also configure the elvisToken correctly when this setting is enabled.
   */
  static recognizeOnImport: boolean = process.env.IR_RECOGNIZE_ON_IMPORT === 'true' || true;

  /**
   * Enable or disable the REST API.
   * 
   * Web client plugins like the Auto Tag Images plugin depend on this API to be enabled.
   * 
   * BETA NOTE: This API is currently in BETA stage. All API calls are fully functional, authentication is however not yet implemented. 
   * Therefore, ensure on network level that the recognition server can only be accessed by your integration.
   */
  static restAPIEnabled: boolean = process.env.IR_REST_API_ENABLED === 'true' || false;

  /**
   * Elvis webhook token. Create a webhook that listens for "asset_update_metadata" events and that returns the "assetDomain" metadata field.
   * 
   * More info on creating a webhook: https://helpcenter.woodwing.com/hc/en-us/articles/115001884346
   */
  static elvisToken: string = process.env.IR_ELVIS_TOKEN || 'my-webhook-token';

  /**
   * Elvis metadata field where the unique tags from all services are stored.
   * 
   * Default value is "tagsFromAI" which holds all tags generated by image recognition services. 
   * Note that this metadata field was introduced with Elvis 5.26
   */
  static elvisTagsField: string = process.env.IR_ELVIS_TAGS_FIELD || 'tagsFromAI';

  /**
   * Elvis metadata field that holds a timestamp of the last AI metadata update.
   *
   * This can be useful to determine which files need to be processed or re-processed after a certain period (new services, better AI models)
   */
  static aiMetadataModifiedField: string = process.env.IR_ELVIS_AI_METADATA_MODIFIED_FIELD || 'cf_aiMetadataModified'

  /**
   * Enable or disable Clarifai image recognition.
   */
  static clarifaiEnabled: boolean = process.env.IR_CLARIFAI_ENABLED === 'true' || true;

  /**
   * Clarifai CLIENT ID.
   *
   * Can be obtained by creating a Clarifai account: https://www.clarifai.com/
   */
  static clarifaiClientId: string = process.env.IR_CLARIFAI_CLIENT_ID || 'my-clarifai-client-id';

  /**
   * Clarifai CLIENT SECRET.
   *
   * Can be obtained by creating a Clarifai account: https://www.clarifai.com/
   */
  static clarifaiClientSecret: string = process.env.IR_CLARIFAI_CLIENT_SECRET || 'my-clarifai-client-secret';

  /**
   * Elvis metadata field where Clarifai tags are stored, set to null to skip saving tags in a specific Clarifai field.
   */
  static clarifaiTagsField: string = process.env.IR_CLARIFAI_TAGS_FIELD || 'cf_tagsClarifai';

  /**
   * Mapping between a folder in Elvis and one or multiple Clarifai models.
   * 
   * When recognizeOnImport=true, this mapping is used to tag images using on import one or multiple models.
   * More info on Clarifai models: https://clarifai.com/models/
   * 
   * Possible model values:
   * - ClarifaiAPI.GENERAL_MODEL
   * - ClarifaiAPI.FOOD_MODEL
   * - ClarifaiAPI.TRAVEL_MODEL
   * - ClarifaiAPI.WEDDING_MODEL
   * - ClarifaiAPI.APPAREL_MODEL
   * - 'e466caa0619f444ab97497640cefc4dc' (Celebrity model)
   */
  static clarifaiFolderToModelMapping: any[] = [
    {
      folder: '/Demo Zone/Images/Food',
      models: [ClarifaiAPI.FOOD_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Travel',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.TRAVEL_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Wedding',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.WEDDING_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Apparel',
      models: [ClarifaiAPI.GENERAL_MODEL, ClarifaiAPI.APPAREL_MODEL]
    },
    {
      folder: '/Demo Zone/Images/Celebrity',
      models: [ClarifaiAPI.GENERAL_MODEL, 'e466caa0619f444ab97497640cefc4dc']
    }
  ];

  /**
   * Enable or disable Google image recognition.
   */
  static googleEnabled: boolean = process.env.IR_GOOGLE_ENABLED === 'true' || true;

  /**
   * Full path to the Google Service account keyfile (JSON).  
   *
   * Can be obtained by creating a Google Cloud account: https://cloud.google.com/vision/
   * 
   * Steps when starting from scratch with Google Vision:
   * - Create a new project.
   * - Enable the Cloud Vision API (API Manager -> Library -> Vision API).
   * - Create a service account key (API Manager -> Credentials -> Create Credentials - Service account key).
   * - Specify the full path to the JSON keyfile in this setting.
   */
  static googleKeyFilename: string = process.env.IR_GOOGLE_KEY_FILENAME || '/Users/username/keyfile.json';

  /**
   * Elvis metadata field where Google tags are stored, set to null to skip saving tags in a specific Google field.
   */
  static googleTagsField: string = process.env.IR_GOOGLE_TAGS_FIELD || 'cf_tagsGoogle';

  /**
   * Enable or disable AWS image recognition.
   */
  static awsEnabled: boolean = process.env.IR_AWS_ENABLED === 'true' || true;

  /**
   * AWS access key
{'fraction_non_alphanumeric': 0.10477984459618554, 'fraction_numerical': 0.010203280747194099, 'mean_word_length': 3.199736321687541, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 14, 'https://': 9, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1622042', 'n_tokens_mistral': 4202, 'n_tokens_neox': 4013, 'n_words': 1177}