Add shape or element to diagram programmaticaly

How to add shape or element from javascript programmatically? (ex : add task element to diagram and create connection between one element to another element)