id: '**Entity_NotSyncedNotification_Puller_Id**'
name: '**Entity_NotSyncedNotification_Puller_Name**'
description: '**Entity_NotSyncedNotification_Puller_Description**'
options: []
beforePullSteps: []
pullSteps:
  - key: PULL_DATA
    rootStep: true
    name: Pull Data
    displayType: SQL
    connectorId: '**SelfConnectorId**'
    arguments:
      created_at: |-
        {{
          if puller.lastToken && puller.lastToken.PULL_DATA && puller.lastToken.PULL_DATA.created_at
            puller.lastToken.PULL_DATA.created_at
          else
            0
          end
        }}
      delayed: 15
      from_date: '2025-01-01'
    data:
      timeout: '60'
      sql: |-
        SELECT 
          __id as hss_id,
          **Entity_ID_Field** as id, 
          __pushed_notes as pushed_notes -- TODO: trim the push notes if needed
        FROM **Entity_Table_Name** v
        WHERE 
            ( -- this is only check new items
              v.__destination_id IS NULL
              AND v.__created_at BETWEEN 
                GREATEST(@created_at::int8, EXTRACT(EPOCH FROM TIMESTAMP @from_date) * 1000)
                AND ((EXTRACT(EPOCH FROM NOW()) * 1000) - (@delayed::int*60000)) 
            ) -- TODO: check for updated items: https://applink.larksuite.com/client/todo/detail?guid=7449e4ce-28f6-4f70-8867-c7bc80ce63b8&suite_entity_num=t103628
            AND v.__status & (2 | 4) = 0
            -- TODO: add more filters here
        ORDER BY v.__created_at ASC
        LIMIT 100;
      responseFilters:
        - key: items
          type: List
          fields: # for CLI only
            - id
            - hss_id
            - pushed_notes
afterPullSteps: []
responseFilters:
  items: $.PULL_DATA.items
