version: 1
send_anonymous_usage_stats: false
project_id: 14a3eb75-9bc1-4886-bfab-54691b989a95
auto_install: false

environments:
  - name: experimental
    env:
      ENVIRONMENT: experimental
      TAP_DB_HOST: $EXPERIMENTAL_TAP_DB_HOST
      TAP_DB_PORT: $EXPERIMENTAL_TAP_DB_PORT
      TAP_DB_USER: $EXPERIMENTAL_TAP_DB_USER
      TAP_DB_PASSWORD: $EXPERIMENTAL_TAP_DB_PASSWORD
      TAP_DB_HAMILTON_DBNAME: $EXPERIMENTAL_TAP_DB_HAMILTON_DBNAME
      TAP_DB_CLYDE_DBNAME: $EXPERIMENTAL_TAP_DB_CLYDE_DBNAME
      TAP_DB_AGNODICE_DBNAME: $EXPERIMENTAL_TAP_DB_AGNODICE_DBNAME
      TAP_DB_ROCKEFELLER_DBNAME: $EXPERIMENTAL_TAP_DB_ROCKEFELLER_DBNAME
      TAP_DB_PLUGINS_DBNAME: $EXPERIMENTAL_TAP_DB_PLUGINS_DBNAME
      TAP_CHARGIFY_SUBDOMAIN: $EXPERIMENTAL_TAP_CHARGIFY_SUBDOMAIN
      TAP_CHARGIFY_API_KEY: $EXPERIMENTAL_TAP_CHARGIFY_API_KEY
      TAP_EDGAR_MONGODB_MONGO_HOST: $EXPERIMENTAL_TAP_EDGAR_MONGODB_MONGO_HOST
      TAP_EDGAR_MONGODB_MONGO_DBNAME: $EXPERIMENTAL_TAP_EDGAR_MONGODB_MONGO_DBNAME
      TAP_EDGAR_MONGODB_MONGO_USERNAME: $EXPERIMENTAL_TAP_EDGAR_MONGODB_MONGO_USERNAME
      TAP_EDGAR_MONGODB_MONGO_PASSWORD: $EXPERIMENTAL_TAP_EDGAR_MONGODB_MONGO_PASSWORD

  - name: staging
    env:
      ENVIRONMENT: staging
      TAP_DB_HOST: $STAGING_TAP_DB_HOST
      TAP_DB_PORT: $STAGING_TAP_DB_PORT
      TAP_DB_USER: $STAGING_TAP_DB_USER
      TAP_DB_PASSWORD: $STAGING_TAP_DB_PASSWORD
      TAP_DB_HAMILTON_DBNAME: $STAGING_TAP_DB_HAMILTON_DBNAME
      TAP_DB_CLYDE_DBNAME: $STAGING_TAP_DB_CLYDE_DBNAME
      TAP_DB_AGNODICE_DBNAME: $STAGING_TAP_DB_AGNODICE_DBNAME
      TAP_DB_ROCKEFELLER_DBNAME: $STAGING_TAP_DB_ROCKEFELLER_DBNAME
      TAP_DB_PLUGINS_DBNAME: $STAGING_TAP_DB_PLUGINS_DBNAME
      TAP_CHARGIFY_SUBDOMAIN: $STAGING_TAP_CHARGIFY_SUBDOMAIN
      TAP_CHARGIFY_API_KEY: $STAGING_TAP_CHARGIFY_API_KEY
      TAP_EDGAR_MONGODB_MONGO_HOST: $STAGING_TAP_EDGAR_MONGODB_MONGO_HOST
      TAP_EDGAR_MONGODB_MONGO_DBNAME: $STAGING_TAP_EDGAR_MONGODB_MONGO_DBNAME
      TAP_EDGAR_MONGODB_MONGO_USERNAME: $STAGING_TAP_EDGAR_MONGODB_MONGO_USERNAME
      TAP_EDGAR_MONGODB_MONGO_PASSWORD: $STAGING_TAP_EDGAR_MONGODB_MONGO_PASSWORD
  - name: us
    env:
      ENVIRONMENT: us
      TAP_DB_HOST: $US_TAP_DB_HOST
      TAP_DB_PORT: $US_TAP_DB_PORT
      TAP_DB_USER: $US_TAP_DB_USER
      TAP_DB_PASSWORD: $US_TAP_DB_PASSWORD
      TAP_DB_HAMILTON_DBNAME: $US_TAP_DB_HAMILTON_DBNAME
      TAP_DB_CLYDE_DBNAME: $US_TAP_DB_CLYDE_DBNAME
      TAP_DB_AGNODICE_DBNAME: $US_TAP_DB_AGNODICE_DBNAME
      TAP_DB_ROCKEFELLER_DBNAME: $US_TAP_DB_ROCKEFELLER_DBNAME
      TAP_DB_PLUGINS_DBNAME: $US_TAP_DB_PLUGINS_DBNAME
      TAP_CHARGIFY_SUBDOMAIN: $US_TAP_CHARGIFY_SUBDOMAIN
      TAP_CHARGIFY_API_KEY: $US_TAP_CHARGIFY_API_KEY
      TAP_EDGAR_MONGODB_MONGO_HOST: $US_TAP_EDGAR_MONGODB_MONGO_HOST
      TAP_EDGAR_MONGODB_MONGO_DBNAME: $US_TAP_EDGAR_MONGODB_MONGO_DBNAME
      TAP_EDGAR_MONGODB_MONGO_USERNAME: $US_TAP_EDGAR_MONGODB_MONGO_USERNAME
      TAP_EDGAR_MONGODB_MONGO_PASSWORD: $US_TAP_EDGAR_MONGODB_MONGO_PASSWORD
  - name: au
    env:
      ENVIRONMENT: au
      TAP_DB_HOST: $AU_TAP_DB_HOST
      TAP_DB_PORT: $AU_TAP_DB_PORT
      TAP_DB_USER: $AU_TAP_DB_USER
      TAP_DB_PASSWORD: $AU_TAP_DB_PASSWORD
      TAP_DB_HAMILTON_DBNAME: $AU_TAP_DB_HAMILTON_DBNAME
      TAP_DB_CLYDE_DBNAME: $AU_TAP_DB_CLYDE_DBNAME
      TAP_DB_AGNODICE_DBNAME: $AU_TAP_DB_AGNODICE_DBNAME
      TAP_DB_ROCKEFELLER_DBNAME: $AU_TAP_DB_ROCKEFELLER_DBNAME
      TAP_DB_PLUGINS_DBNAME: $AU_TAP_DB_PLUGINS_DBNAME
      TAP_CHARGIFY_SUBDOMAIN: $AU_TAP_CHARGIFY_SUBDOMAIN
      TAP_CHARGIFY_API_KEY: $AU_TAP_CHARGIFY_API_KEY
      TAP_EDGAR_MONGODB_MONGO_HOST: $AU_TAP_EDGAR_MONGODB_MONGO_HOST
      TAP_EDGAR_MONGODB_MONGO_DBNAME: $AU_TAP_EDGAR_MONGODB_MONGO_DBNAME
      TAP_EDGAR_MONGODB_MONGO_USERNAME: $AU_TAP_EDGAR_MONGODB_MONGO_USERNAME
      TAP_EDGAR_MONGODB_MONGO_PASSWORD: $AU_TAP_EDGAR_MONGODB_MONGO_PASSWORD
  - name: hd
    env:
      ENVIRONMENT: hd
      TAP_DB_HOST: $HD_TAP_DB_HOST
      TAP_DB_PORT: $HD_TAP_DB_PORT
      TAP_DB_USER: $HD_TAP_DB_USER
      TAP_DB_PASSWORD: $HD_TAP_DB_PASSWORD
      TAP_DB_HAMILTON_DBNAME: $HD_TAP_DB_HAMILTON_DBNAME
      TAP_DB_CLYDE_DBNAME: $HD_TAP_DB_CLYDE_DBNAME
      TAP_DB_AGNODICE_DBNAME: $HD_TAP_DB_AGNODICE_DBNAME
      TAP_DB_ROCKEFELLER_DBNAME: $HD_TAP_DB_ROCKEFELLER_DBNAME
      TAP_DB_PLUGINS_DBNAME: $HD_TAP_DB_PLUGINS_DBNAME

plugins:
  # extractor name format: tap-NAME-vX
  # load_schema format: raw_${ENVIRONMENT}_name_vX
  #
  # v is for version.
  # The version lets us add a new extractor for the same data source
  # and gradually switch over to it.

  extractors:
  - name: tap-chargify-v3
    namespace: tap_coviu_chargify
    executable: ./extract/tap-coviu-chargify/bin/tap-coviu-chargify
    load_schema: raw_${ENVIRONMENT}_chargify_v3
    capabilities:
    - discover
    - catalog
    - state
    settings:
    - name: regions_domain
      tooltip: Chargify domain (https://developers.chargify.com/docs/developer-docs/158e3be5cbdc8-sites-subdomains#site-api-subdomain)
      kind: string
    - name: api_key
      tooltip: Chargify API Key (https://developers.chargify.com/docs/developer-docs/472b76237be93-authentication#api)
      kind: string
    - name: sleep_interval_millis
      tooltip: >
        Determines how long to sleep between calls to Chargify. This is not
        an exact measure - we just have a call to setTimeout in the loop that
        waits this many millis. A rate-limiting mitigation measure.
      kind: integer
    - name: iterations_per_run
      tooltip: >
        Determines the max amount of times Chargify will be called in a given run.
        If we run out of records before that, we stop.
        If we get to that point and there are still more to go, we stop too.
      kind: integer
    - name: page_size
      tooltip: How many rows of data to get from Chargify at a time. Maximum of 200.
      kind: integer
    - name: enabled
      tooltip: >
        By default, this tap does nothing. This flag must be set to have the tap run.
        This is to smooth deployment to higher environments.
      kind: boolean
      value: false

    config:
      regions_domain: $TAP_CHARGIFY_SUBDOMAIN
      api_key: $TAP_CHARGIFY_API_KEY
      sleep_interval_millis: 100
      page_size: 200

    select:
      - customers.*
      - components.*
      - subscriptions.*
      - products.*
      - events.*
      - subscriptions_components.*
      - components_price_points.*
      - products_price_points.*
      - mrr_movements.*
      - coupons.*

    metadata:
      customers:
        replication-method: INCREMENTAL
      components:
        replication-method: FULL_TABLE
      subscriptions:
        replication-method: INCREMENTAL
      products:
        replication-method: FULL_TABLE
      events:
        replication-method: INCREMENTAL
      mrr_movements:
        replication-method: INCREMENTAL
      coupons:
        replication-method: FULL_TABLE

  - name: tap-postgres--meltanolabs
    inherit_from: tap-postgres
    variant: meltanolabs
    pip_url: meltanolabs-tap-postgres==0.0.14

  - name: tap-hamilton-v3
    inherit_from: tap-postgres--meltanolabs
    load_schema: raw_${ENVIRONMENT}_hamilton_v3
    config:
      database: $TAP_DB_HAMILTON_DBNAME
      host: $TAP_DB_HOST
      port: $TAP_DB_PORT
      user: $TAP_DB_USER
      password: $TAP_DB_PASSWORD
      filter_schemas:
        - public

    select:
      - public-organisation.organisation_id
      - public-organisation.platform_id
      - public-organisation.status
      - public-organisation.name
      - public-organisation.created
      - public-organisation.last_modified
      - public-organisation_member.organisation_id
      - public-organisation_member.user_id
      - public-organisation_member.role
      - public-organisation_member.created
      - public-organisation_member.deleted
      - public-organisation_member.last_modified
      - public-phone_call.phone_call_id
      - public-phone_call.team_id
      - public-phone_call.direction
      - public-phone_call.status
      - public-phone_call.finished_at
      - public-phone_call.created_at
      - public-phone_call.updated_at
      - public-platform.platform_id
      - public-platform.name
      - public-platform.status
      - public-platform.description
      - public-platform.created
      - public-platform.platform_type
      - public-platform_member.platform_id
      - public-platform_member.user_id
      - public-platform_member.role
      - public-platform_member.created
      - public-platform_member.deleted
      - public-platform_member.last_modified
      - public-queued_call.call_id
      - public-queued_call.team_id
      - public-queued_call.session_id
      - public-queued_call.joined_at
      - public-queued_call.left_queue_at
      - public-queued_call.answered_at
      - public-queued_call.finished_at
      - public-queued_call.cleaned_at
      - public-queued_call.last_activity_at
      - public-queued_call.transferred_at
      - public-queued_call.previous_call_id
      - public-queued_call.transferred_to
      - public-queued_call.on_hold_at
      - public-queued_call.transferred_to_team
      - public-queued_call.phone_call_id
      - public-queued_call.started_at
      - public-queued_call.last_modified
      - public-queued_call.call_type
      - public-reportable_event.event_id
      - public-reportable_event.action_name
      - public-reportable_event.user_id
      - public-reportable_event.team_id
      - public-reportable_event.organisation_id
      - public-reportable_event.platform_id
      - public-reportable_event.correlation_id
      - public-reportable_event.created
      - public-tag_definition.tag_definition_id
      - public-tag_definition.platform_id
      - public-tag_definition.tag_definition_name
      - public-tag_definition.tag_definition_type
      - public-tag_definition.type_meta_data
      - public-tag_definition.tag_for
      - public-tag_definition.last_modified
      - public-tag_value.tag_id
      - public-tag_value.platform_id
      - public-tag_value.tag_definition_id
      - public-tag_value.tag_value
      - public-tag_value.tag_target
      - public-tag_value.last_modified
      - public-team.team_id
      - public-team.subdomain
      - public-team.name
      - public-team.active
      - public-team.created
      - public-team.deleted
      - public-team.organisation_id
      - public-team.platform_id
      - public-team.short_description
      - public-team.deleted
      - public-team.hubspot_id
      - public-team.hubspot_deal_id
      - public-team.synced_with_bartik_at
      - public-team.last_modified
      - public-team_member.team_id
      - public-team_member.user_id
      - public-team_member.role
      - public-team_member.last_active
      - public-team_member.last_call_at
      - public-team_member.enable_permissions
      - public-team_member.created
      - public-team_member.deleted
      - public-team_member.last_modified
      - public-team_member.display_name
      - public-team_insight.team_id
      - public-team_insight.user_id
      - public-team_insight.role
      - public-team_insight.team_type
      - public-user.user_id
      - public-user.role
      - public-user.first_name
      - public-user.last_name
      - public-user.active
      - public-user.creating_platform_id
      - public-user.created
      - public-user.hubspot_id
      - public-user.speciality
      - public-user.last_modified
      - public-user.email
      - public-phone_number.phone_number_id
      - public-phone_number.team_id
      - public-phone_number.status
      - public-phone_number.created_at
      - public-phone_number.updated_at
      - public-phone_number.regulatory_bundle_id
      - public-phone_number.waiting_queue_id

    #     team_setting has some sensitive, long, and optionally-json fields. We shouldn't ingest it. We may be able to ingest a restricted view of it.
    metadata:
      public-organisation:
        replication-method: INCREMENTAL
        replication-key: last_modified

      # source table is missing a primary key: see mappers below for primary key fix
      public-organisation_member:
        replication-method: INCREMENTAL
        replication-key: last_modified

      public-organisation_setting:
        replication-method: INCREMENTAL
        replication-key: created

      public-phone_call:
        replication-method: INCREMENTAL
        replication-key: updated_at

      # The biggest source table is about 30 rows, so full table is fine.
      public-platform:
        replication-method: FULL_TABLE

      # The source table is missing a primary key: see mappers below for primary key fix.
      # The biggest source table is about 500 rows, so full table is fine.
      public-platform_member:
        replication-method: FULL_TABLE

      # The biggest source table is about 80 rows, so full table is fine.
      public-platform_setting:
        replication-method: FULL_TABLE

      public-subdomain:
        replication-method: INCREMENTAL
        replication-key: last_modified

      # The biggest source table is 44 rows, so full table is fine.
      public-tag_definition:
        replication-method: FULL_TABLE

      public-tag_value:
        replication-method: INCREMENTAL
        replication-key: last_modified

      public-team:
        replication-method: INCREMENTAL
        replication-key: last_modified

      # source table is missing a primary key: see mappers below for primary key fix
      public-team_member:
        replication-method: INCREMENTAL
        replication-key: last_modified

      public-team_insight:
        replication-method: FULL_TABLE

      public-queued_call:
        replication-method: INCREMENTAL
        replication-key: last_modified

      public-user:
        replication-method: FULL_TABLE

      # small table
      public-phone_number:
        replication-method: FULL_TABLE

      public-reportable_event:
        replication-method: INCREMENTAL
        replication-key: created

  - name: tap-clyde-v3
    inherit_from: tap-postgres--meltanolabs
    load_schema: raw_${ENVIRONMENT}_clyde_v3
    config:
      database: $TAP_DB_CLYDE_DBNAME
      host: $TAP_DB_HOST
      port: $TAP_DB_PORT
      user: $TAP_DB_USER
      password: $TAP_DB_PASSWORD
      filter_schemas:
        - public
    select:
      - public-call_record.call_record_id
      - public-call_record.platform_id
      - public-call_record.organisation_id
      - public-call_record.team_id
      - public-call_record.session_reference
      - public-call_record.session_type
      - public-call_record.created_at
      - public-call_record.last_active_at
      - public-call_record.processed_at
      - public-call_record.transfer_target
      - public-call_record.transfer_type
      - public-call_record.session_subtype
      - public-call_record.last_modified
      - public-event.event_id
      - public-event.client_id
      - public-event.event_type
      - public-event.created
      - public-event.content
      - public-event.call_record_id
      - public-event.participant_reference
      - public-event.json_data
      - public-participant.participant_id
      - public-participant.session_id
      - public-participant.client_id
      - public-participant.role
      - public-participant.created
      - public-participant.coviu_user_id
      - public-participant.state
      - public-participant.removed
      - public-participant.fee
      - public-participant.clean_required
      - public-participant.cleaned_at
      - public-participant.forms
      - public-participant.last_modified
      - public-participant_record.participant_reference
      - public-participant_record.platform_id
      - public-participant_record.organisation_id
      - public-participant_record.team_id
      - public-participant_record.call_record_id
      - public-participant_record.participant_type
      - public-participant_record.coviu_user_id
      - public-participant_record.entered_at
      - public-participant_record.left_at
      - public-participant_record.left_reason
      - public-participant_record.transfer_target
      - public-participant_record.transfer_type
      - public-participant_record.last_modified
      - public-session.session_id
      - public-session.team_id
      - public-session.client_id
      - public-session.start_time
      - public-session.end_time
      - public-session.feature_flags
      - public-session.created
      - public-session.canceled
      - public-session.billable
      - public-session.last_modified
      - public-session.actual_end_time
      - public-session_entry.peer_id
      - public-session_entry.participant_id
      - public-session_entry.session_id
      - public-session_entry.team_id
      - public-session_entry.role
      - public-session_entry.created

    schema:
      public-event:
        # This stops the postgres target turning this field into jsonb[]
        json_data:
          type: [ "null","object" ]
    metadata:
      public-participant:
        replication-method: INCREMENTAL
        replication-key: last_modified
      public-call_record:
        replication-method: INCREMENTAL
        replication-key: last_modified
      public-event:
        replication-method: INCREMENTAL
        replication-key: created
      public-participant_record:
        replication-method: INCREMENTAL
        replication-key: last_modified
      public-session:
        replication-method: INCREMENTAL
        replication-key: last_modified
      public-session_entry:
        replication-method: INCREMENTAL
        replication-key: created

  - name: tap-plugins-v1
    inherit_from: tap-postgres--meltanolabs
    load_schema: raw_${ENVIRONMENT}_plugins_v1
    config:
      database: $TAP_DB_PLUGINS_DBNAME
      host: $TAP_DB_HOST
      port: $TAP_DB_PORT
      user: $TAP_DB_USER
      password: $TAP_DB_PASSWORD
      filter_schemas:
        - public
    select:
      - public-plugin.plugin_id
      - public-plugin.plugin_version
      - public-plugin.plugin_url
        # Not taking plugin_init for now
        #  - public-plugin.plugin_init
      - public-plugin.plugin_product_code
      - public-plugin.plugin_access_control
      - public-plugin.updated_at
      - public-plugin.created_at
      - public-plugin.deleted_at
      - public-team_plugin_setting.team_id
      - public-team_plugin_setting.plugin_id
      - public-team_plugin_setting.enabled
      - public-team_plugin_setting.updated_at
      - public-team_plugin_setting.created_at
    # Don't need a schema override for plugin_init for now
#    schema:
#      public-plugin:
#        plugin_init:
#          type: [ "null", "string", "object" ]
    metadata:
      public-plugin:
        replication-method: FULL_TABLE
      public-team_plugin_setting:
        replication-method: FULL_TABLE

  - name: tap-rockefeller-v3
    inherit_from: tap-postgres--meltanolabs
    load_schema: raw_${ENVIRONMENT}_rockefeller_v3
    config:
      database: $TAP_DB_ROCKEFELLER_DBNAME
      host: $TAP_DB_HOST
      port: $TAP_DB_PORT
      user: $TAP_DB_USER
      password: $TAP_DB_PASSWORD
      filter_schemas:
        - public
    select:
      - public-customers.customer_id
      - public-customers.chargify_id
      - public-customers.customer_type
      - public-customers.email
      - public-plan_features.product_handle
      - public-plan_features.feature
      - public-plan_features.description
      - public-plan_features.quantity
      - public-plan_features.metadata
      - public-product_features.product_type
      - public-product_features.feature
      - public-product_features.description
      - public-product_features.quantity
      - public-product_features.metadata
      - public-subscriptions.subscription_id
      - public-subscriptions.customer_id
      - public-subscriptions.product_id
      - public-subscriptions.product_handle
      - public-subscriptions.product_type
      - public-subscriptions.region
      - public-subscriptions.status
      - public-subscriptions.subscription_type
      - public-subscriptions.subscription_for
      - public-subscriptions.description
      - public-subscriptions.next_billing_manifest
      - public-subscriptions.amount_in_cents
      - public-subscriptions.currency
      - public-subscriptions.trial_started_at
      - public-subscriptions.trial_ended_at
      - public-subscriptions.current_period_started
      - public-subscriptions.current_period_ended
      - public-subscriptions.created_at
      - public-subscriptions.expires_at
      - public-subscriptions.updated_at
      - public-subscriptions.referral_code
      - public-subscriptions.verified_at
      - public-subscriptions.delayed_cancel_at
      - public-subscriptions.cancel_at_end_of_period
      - public-subscriptions.synced_with_hubspot_at
      - public-subscription_user_licenses.subscription_type
      - public-subscription_user_licenses.subscription_for
      - public-subscription_user_licenses.user_id
      - public-subscription_user_licenses.license_feature
      - public-subscription_user_licenses.created_at
      - public-subscription_user_licenses.deleted_at
      - public-usage_events.event_id
      - public-usage_events.team_id
      - public-usage_events.user_id
      - public-usage_events.plugin_id
      - public-usage_events.category
      - public-usage_events.session_reference
      - public-usage_events.idempotency_key
      - public-usage_events.metadata
      - public-usage_events.created_at
      - public-usage_events.action

    metadata:
      public-customers:
        replication-method: FULL_TABLE
      public-plan_features:
        replication-method: FULL_TABLE
      public-product_features:
        replication-method: FULL_TABLE
      public-subscriptions:
        replication-method: FULL_TABLE
      public-usage_events:
        replication-method: INCREMENTAL
        replication-key: created_at
      public-subscription_user_licenses:
        replication-method: FULL_TABLE

  - name: tap-agnodice-v3
    inherit_from: tap-postgres--meltanolabs
    load_schema: raw_${ENVIRONMENT}_agnodice_v3
    config:
      database: $TAP_DB_AGNODICE_DBNAME
      host: $TAP_DB_HOST
      port: $TAP_DB_PORT
      user: $TAP_DB_USER
      password: $TAP_DB_PASSWORD
      filter_schemas:
        - public
    select:
      - public-forms.id
      - public-forms.name
      - public-forms.published
      - public-forms.save_to_datacollections
      - public-forms.available_incall
      - public-forms.available_precall
      - public-forms.available_presession
      - public-forms.available_postcall
      - public-forms.available_to_guests
      - public-forms.platform_id
      - public-forms.organisation_id
      - public-forms.team_id
      - public-forms.creation_level
      - public-forms.created_user_id
      - public-forms.last_modified_user_id
      - public-forms.exportable
      - public-forms.public_id
      - public-forms.created_at
      - public-forms.updated_at
      - public-forms.deleted_at
      - public-forms.deleted_by
      - public-forms.app_id
      - public-practitioners.id
      - public-practitioners.user_id
      - public-practitioners.team_id
      - public-practitioners.position
      - public-practitioners.specialty
      - public-practitioners.created_at
      - public-practitioners.updated_at
      - public-practitioners.active

    metadata:
      public-forms:
        replication-method: INCREMENTAL
        replication-key: updated_at

      public-practitioners:
        replication-method: FULL_TABLE

  - name: tap-mongodb
    variant: z3z1ma
    # pip_url: git+https://github.com/z3z1ma/tap-mongodb.git
    # currently using fork due to https://github.com/z3z1ma/tap-mongodb/issues/8
    # overriding singer_sdk as 0.45 breaks it
    pip_url: 'git+https://github.com/edsoncezar16/tap-mongodb.git singer_sdk==0.44.3'
  - name: tap-edgar-mongodb-v1
    inherit_from: tap-mongodb
    config:
      # This will infer the postgres schema from the mongo collection.
      strategy: infer
      mongo:
        appname: meltano
        host: $TAP_EDGAR_MONGODB_MONGO_HOST
        # Hardcoded default port, tap python client throw on string env var.
        port: 27017
        username: $TAP_EDGAR_MONGODB_MONGO_USERNAME
        password: $TAP_EDGAR_MONGODB_MONGO_PASSWORD
        authSource: $TAP_EDGAR_MONGODB_MONGO_DBNAME
        # See Dockerfile
        tlsCAFile: $TAP_EDGAR_MONGODB_MONGO_TLS_CA_FILE
        tls: true
        tlsAllowInvalidHostnames: true
        retryWrites: true

      # Currently only supported on edsoncezar16 fork, and is a bit weird
      # It means ALL replication keys are treated as timestamps.
      # See https://github.com/z3z1ma/tap-mongodb/issues/8
      is_timestamp_replication_key: true
    database_includes:
      - edgar
    load_schema: raw_${ENVIRONMENT}_edgar_mongodb_v1
    select:
    - edgar_event_aggregates.*
    - edgar_applications._id
    - edgar_applications.name
    - edgar_applications.slug
    metadata:
      edgar_event_aggregates:
        replication-method: INCREMENTAL
        replication-key: last_updated
      edgar_applications:
        replication-method: FULL_TABLE
    schema:
      edgar_event_aggregates:
        type:
          type: [ "null", "string" ]


  loaders:
  - name: target-postgres
    variant: meltanolabs
    pip_url: meltanolabs-target-postgres==0.2.0

  - name: target-redshift
    variant: ticketswap
    pip_url: git+https://github.com/TicketSwap/target-redshift

  - name: target-warehouse-postgres
    inherit_from: target-postgres
    config:
      host: $WAREHOUSE_HOST
      database: $WAREHOUSE_DBNAME
      port: $WAREHOUSE_PORT
      user: $WAREHOUSE_MELTANO_USER
      password: $WAREHOUSE_MELTANO_PASSWORD

  - name: target-warehouse-redshift
    inherit_from: target-redshift
    config:
      host: $WAREHOUSE_HOST
      dbname: $WAREHOUSE_DBNAME
      port: $WAREHOUSE_PORT
      user: $WAREHOUSE_MELTANO_USER
      password: $WAREHOUSE_MELTANO_PASSWORD
      aws_redshift_copy_role_arn: $WAREHOUSE_COPY_ROLE_ARN
      s3_bucket: $WAREHOUSE_COPY_BUCKET
      remove_s3_files: true

  utilities:
  - name: dbt-postgres
    variant: dbt-labs
    pip_url: dbt-core dbt-postgres meltano-dbt-ext~=0.3.2
  - name: dbt-redshift
    variant: dbt-labs
    pip_url: dbt-core dbt-redshift meltano-dbt-ext~=0.3.2

  mappers:
  - name: meltano-map-transformer
    variant: meltano
    pip_url: git+https://github.com/MeltanoLabs/meltano-map-transform.git@v0.9.1
    # Note: mappers in here need to be explicitly specified when running meltano. See eltCore.ts
    # table-key-properties doesn't seem to work with tap-postgres, but we can set keys here
    #
    # TODO: The taps that are based on meltano sdk can have their mappings set in the tap config.
    mappings:
    - name: mapper-hamilton
      config:
        stream_maps:
          public-team_member:
            __key_properties__:
              - team_id
              - user_id
              - created
          public-organisation_member:
            __key_properties__:
              - organisation_id
              - user_id
              - created
          public-platform_member:
            __key_properties__:
              - platform_id
              - user_id
              - created
          public-organisation:
            image_url:
          public-platform:
            image_url:
            email_sender:
          public-team:
            image_url:
            logo_url:
          public-user:
            email:
            email_domain: email.split('@')[-1] if email else None
            phone_number:
            synced_with_bartik_at:
          public-phone_call:
            from_number:
            to_number:
          public-queued_call:
            details:
          public-reportable_event:
            metadata:
            action_target:
    - name: mapper-rockefeller
      config:
        stream_maps:
          public-customers:
            email:
            email_domain: email.split('@')[-1] if email else None
            user_id:
            team_id:
            first_name:
            last_name:
            organization:
            address:
            address_2:
            city:
            state:
            country:
            zip:
          public-subscriptions:
            payment_profile_id:
            current_vault:
            masked_card_number:
            card_type:
            card_expiration_month:
            card_expiration_year:
            card_first_name:
            card_last_name:
            payment_type:
          public-plan_features:
            updated_at:
            created_at:
            __key_properties__: [product_handle, feature]
          public-product_features:
            updated_at:
            created_at:
            __key_properties__: [product_type, feature]
          public-subscription_user_licenses:
            transform:
            __key_properties__: [subscription_for, subscription_type, user_id, license_feature, created_at]

    - name: mapper-agnodice
      config:
        stream_maps:
          public-forms:
            form_data:

    - name: mapper-clyde
      config:
        stream_maps:
          public-participant:
            display_name:
            phone:
            picture:
          public-session:
            session_name:
            picture:
          public-session_entry:
            token:

    - name: mapper-chargify
      config:
        stream_maps:
          customers:
            address:
            address_2:
            first_name:
            last_name:
            locale:
            phone:
            email:
            email_domain: email.split('@')[-1] if email else None
          subscriptions:
            cancellation_message:
            cancellation_method:
            payment_type:
            stored_credential_transaction_id:
            payment_collection_method:
