Add function to a class(TSNode) of an imported module lua

I’m basically trying to have a finale end use like:
node:myPrint()
Similar to Treesitter’s
node:named_child_count()

I guess it has something to do with self but doing that for an imported module that “is not accessable” or “legacy” complicates things a bit here’s what I tryed so far but failed:

-- local ts = require "nvim-treesitter"
-- local TSNode = ts('TSNode')
-- local TSNode = {}
function self:getSmallestDescendant()
  -- node = node or {}
  -- setmetatable(node, self)
  -- self.__index = self
  local child_count = self:named_child_count() 
  print("Node chilndren count: " .. child_count)
  return child_count
end

was I close? :rofl:

Any tips?(sound’s like that on the philosophy of lua that’s something that should be easy to get done)