π NOTE: This is still a work in progress.
A project template that allows the development of Thingworx models in a TypeScript IDE like Visual Studio Code.
This template is primarily aimed at Thingworx developer who are already very familiar with the composer but are also used to working in a regular IDE. To be able to succesfully use this, you should at least have an understanding of how the modelling environment works in Thingworx and some basic knowledge of TypeScript.
There are many advantages to this, and here are some of them:
ThingworxVSCodeDebugger
visual studio code extension and the BMDebugServer
thingworx extension, developers can also debug their thingworx typescript projects directly from visual studio code. The debugger supports most common features including setting breakpoints, exception breakpoints, stepping, evaluating expressions and changing variable values. For more information about setting up debugging, see Usage Guide.BMProfiler
thingworx extension, developers can also profile their thingworx typescript projects to quickly identify performance bottlenecks. The profiler is a simple tracing profiler that shows the amount of time spent executing each service or function within a service. The profiler generates reports that can be viewed in the chrome performance inspector. For more information about setting up profiling, see BMProfiler.METHOD_NAME
, giving developers the ability to declare and use global functions, writing inline SQL queries on Database things and extending data shapes.The following software is required:
PATH
. You should use the LTS version (v14+).The following software is recommended:
In order to develop with this project you need to do the following:
.env.sample
to .env
and configure the THINGWORX_SERVER
and either THINGWORX_USER
and THINGWORX_PASSWORD
or THINGWORX_APP_KEY
and other fields as needed.package.json
and twconfig.json
and change the fields as needed.npm install
. This will install the development dependencies for the project.npm run watch:declarations
. This will start a background process that is needed for generating certain files.By default, the project contains the declarations for all the out of the box entities available in a fresh installation of Thingworx, however there may be the case that you need to use some entities that had been previously created on the Thingworx instance using the composer. To handle this, it is possible to define entity dependencies in twconfig.json
. There are two types of dependencies that can be specified there:
projectDependencies
: An array where you specify the Thingworx project names on which your local projects depends. This will download the declaration for all of the entities that are included in the project.entityDependencies
: An array where you specify entity types and names (e.g. "Things/MyThing"
). This can be used to download specific entities, such as extension templates.Whenever you change twconfig.json
, run npx twc install
to pull the declarations from the Thingworx server specified in package.json
.
Whenever entities are downloaded in this way, all other dependencies are downloaded as well, so if your MyThing
thing depends on the MyDataShape
data shape, you don't need to specify both in twconfig.json
.
ThingworxVSCodeProject
β README.md // This file
β package.json // Standard npm package details; the package name is also used as the extension name
β tsconfig.json // Standard typescript configuration file
β twconfig.json // Thingworx-specific configuration
β metadata.xml // Thingworx metadata file for this extension; This is automatically updated based on your package.json and build settings
β LICENSE // License file
β .env // Contains environment variables and thingworx connection details
ββββsrc // Main folder where your development will take place
β ββββfile1.ts // Thingworx entity file
β β ...
β ββββ[Project1] // In multi-project mode, each subfolder represents a thingworx project
β β ββββsrc // Project's source folder
β β β ββββfile2.ts // Thingworx entity file
β β β ...
β β ββββtsconfig.json // Project's typescript configuration file; Project dependencies are extracted from this
ββββstatic // Supporting files required for compilation; Don't change these
ββββtw_imports // Entity dependencies downloaded from a Thingworx server
ββββbuild // Temporary folder used during compilation
ββββzip // Location of the built extension
Any TypeScript file you add to the src
folder will be compiled into a Thingworx entity. There are some restrictions on what is allowed to be included in these files, namely:
const
since these are erased at runtimestring
, number
. To build the extension, run npm run build
in the root of the project. This will generate an extension .zip file in the zip folder in the root of the project.
To build the extension and upload it to Thingworx, run npm run upload
in the root of the project. The details of the Thingworx server to which the script will upload the extension are declared in the project's environment or package.json
file. These are:
thingworxServer
- The server to which the extension will be uploaded.thingworxAppKey
or thingworxUser
and thingworxPassword
- The credentials used for uploading. This should be a user that has permission to install extensions.To create a debug build that can be used for debugging, add the --debug
argument to any task. For example, to create and upload a debug build, run npx twc upload --debug
. For more information about debugging and debug builds, see BMDebugServer and ThingworxVSCodeDebugger.
Deployment to Thingworx is part of the build process as explained above. Alternatively, you can manually install the extension that is generated in the zip folder in the root of the project.
For a complete changelog see CHANGELOG.md.
fieldDefinitions
exportsoverride
keywordPetrisor Lacatus - had the original idea for this, inferred property types and bug fixes, support for method helpers, API generation, data shape inheritance, declare
on class members.
Bogdan Mihaiciuc - main developer.
thomas-thomas-tfs - deployment using app keys.
carlo-quinonez - bug fixes and documentation improvements.
dwil618 - support for min/max aspects and date initializers.
kklorenzotesta - thingworx API typing updates
The Thingworx VSCode Project is not an official Thingworx product. It is something developed to improve the life of a Thingworx developer and they need to understand that it is not supported and any issues encountered are their own responsibility.