replication:
  connections:
    - type: postgresql
      uri: postgresql://postgres:postgres@postgres:5432/postgres

      # SSL settings
      sslmode: disable # 'verify-full' (default) or 'verify-ca' or 'disable'

# Connection settings for sync bucket storage
storage:
  type: mongodb
  uri: mongodb://mongo:27017/powersync_datafy

# The port which the PowerSync API server will listen on
port: 8080

# Specify sync rules
sync_rules:
  # TODO use specific sync rules here
  content: |
    bucket_definitions:
      global:
        data:
          # Sync all tasks for admin view or similar
          - SELECT * FROM task
          - SELECT * FROM store
          - SELECT * FROM app_user
          - SELECT * FROM store_user_link

      user_tasks:
        parameters:
          # Get store codes for current user
          - SELECT 
              store_code
            FROM store_user_link
            WHERE user_id = request.user_id()
        data:
          # Sync only tasks with matching store codes
          - SELECT * FROM task
            WHERE store_code = bucket.store_code
            
      user_stores:
        parameters:
          # Get store codes for current user
          - SELECT 
              store_code
            FROM store_user_link
            WHERE user_id = request.user_id()
        data:
          # Sync only stores with matching store codes
          - SELECT * FROM store
            WHERE store_code = bucket.store_code

# Settings for client authentication
client_auth:
  # Enable this if using Supabase Auth
  supabase: true

  # JWKS URIs can be specified here.
  #jwks_uri: [TODO]

  # JWKS audience
  audience: ['powersync-dev', 'powersync']

  # Settings for telemetry reporting
  # See https://docs.powersync.com/self-hosting/telemetry
  #telemetry:
    # Opt out of reporting anonymized usage metrics to PowerSync telemetry service
    #disable_telemetry_sharing: false