Info |
---|
This extension was previously (in version 1.0, 1.1, and 1.2) known as TypeScript and Angular. |
Panel | ||||
---|---|---|---|---|
|
Info |
---|
This extension was previously (in version 1.0, 1.1, and 1.2) known as TypeScript and Angular. |
Info |
---|
Summary: This document provides information about the extension providing TypeScript, Angular, React and Node support for Web applications. |
...
Version | Supported |
---|---|
2 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 |
React
Version | Supported |
---|---|
15.x | |
16.x |
...
Library | Comment | Data Access | Web Service or communication | Supported versions |
---|---|---|---|---|
Express | Node.js application framework | 4.x | ||
Mongoose | MongoDB access | 5.x | ||
Sequelize | Node.js application framework | 5.x; 6.x | ||
TypeORM | ORM | 0.2.x | ||
Fastify | Node.js server | 3.x | ||
Axios | Promise based HTTP client | 0.x | ||
Node-mongodb-native | MongoDB access | 3.x | ||
nestjs | Node.js application framework | 6.x; 7.x | ||
https | Node.js web service | |||
fetch | JavaScript builtin web service | |||
request | HTTP request client 'request' | 2.x | ||
request-promise | HTTP request client 'request' | 4.x | ||
request-promise-native | HTTP request client 'request' | 1.x | ||
request-promise-any | HTTP request client 'request' | 1.x | ||
Mongo-client | MongoDB access | |||
Couchdb | Couchdb access | |||
Node-couchdb | Couchdb access | |||
Couchdb-nano | Couchdb access | |||
Marklogic | Marklogic access | |||
my_connection | MySQL access | 0.x | ||
pg | PostgreSQL access | 7.x; 8.x | ||
oracledb | Oracle Database access | 4.x; 5.x | ||
node-sqlserver | MsnodeSQL access | 0.x | ||
mssql | MsSQL access | 5.x; 6.x | ||
Hapi | Node.js application framework | |||
Sails | Node.js application framework | |||
Loopback | Node.js application framework | |||
Koa | Node.js application framework | |||
Knex | Node.js SQL query builder | |||
Memcached | Storage framework | |||
AWS.DynamoDB | Amazon database access | SDK 2.x; SDK 3.x | ||
AWS.S3 | Amazon storage service | SDK 2.x; SDK 3.x | ||
AWS.Lambda | Amazon routing solution | Cloudformation, Serverless framework, SAM (requires com.castsoftware.cloudconfig) | ||
AWS.SNS | Amazon Simple Notification Service | SDK 2.x; SDK 3.x | ||
AWS.SQS | Amazon Simple Queue Service | SDK 2.x; SDK 3.x |
...
Expand | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Support of arrow functions and methodsArrow functions which have been introduced in typescript following ES6 standard (also known as ES2015) are supported. Since arrow functions are equivalent to standard functions, the same function objects are created by the analyzer for both standard functions and arrow functions. Arrow functions can also define methods in which case method objects are created by the analyzer. Examples of arrow functions and methods are provided in the Objects section of this documentation. Support of anonymous functionsFor anonymous functions, the analyzer creates function objects named <Anonymous$i> where $i is incremented such that each anonymous function object has a unique fullname. Web ServicesXMLHttpRequestThe analysis of the following code will create a TypeScript GET http service named "foo/url" and a callLink between my_func function and that service :
fetchThe analysis of the following code will create a TypeScript POST http service named "foo/url" and a callLink between my_func function and that service :
Window variableThe JavaScript window variable can be used to pass values such as urls. The windows variable is accessible from all modules. So when analyzing the following modules:
a webservice object is created with the url set through the window variable: |
...
Expand | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. In sequelize, the user defines Models for data storage. The models are modelized as tables. The following links are added for these API calls:
The query API is also supported . A and a Query object is created as a result. Example In the following code:
...the User class defines a model which is linked with the table named 'users' (through the User.init() call). The name of the table is defined by the tableName value which if not defined is set to the pluralized (if freezeTableName is not set to true) value of modelName which is itself set to the class name when it is not explicitly defined. The User.findAll() call then selects elements from that table 'users'. In this example, this extension creates a useSelect link to the table 'users': Note that a model can also be defined using method sequelize.define().
|
Anchor | ||||
---|---|---|---|---|
|
...
Expand | |||||
---|---|---|---|---|---|
Lambda services allow executing some source code on the cloud. The execution can be set to be triggered by some AWS events. Lambda functions can be deployed using several deployment frameworks. The supported deployment frameworks are listed on this page. When a lambda function is created and its runtime is nodejs, the current extension is responsible for linking the lambda objects and their triggers with the TypeScript handler functions. Example Let us consider a source code defining a lambda function that has two triggers: an SQS queue and an API Gateway. The lambda function has a nodejs runtime and the handler function is given by the handler function fullname. If the lambda function is deployed using a supported deployment framework (such as CloudFormation) and the extension responsible for analyzing this deployment framework is used (com.castsoftware.cloudconfig for CloudFormation), the analysis will create a lambda function, an SQS receiver, and an API Gateway objects. Each of these objects has a runtime property (nodejs) and a handler property with the function fullname. If the current extension finds a TypeScript function matching the handler fullname a link to that function will be added from the lambda function, the SQS queue, and the API Gateway objects. Click to enlarge Lambda invocation using SDKThe SDK provides APIs to execute (i.e. invoke) lambda function. The following APIs are supported:
ExampleWhen analyzing the following source code:
a call to AWS lambda function object named mylambda is created. com.castsoftware.wbslinker links that call to lambda object to AWS Lambda Function objects having the same name: |
...
Anchor | ||||
---|---|---|---|---|
|
Expand | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Warning | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Links
Code samplesThis code will create an S3 Bucket named "MyBucket" on an AWS server in region "REGION" and puts an object in it and a useInsert link to that bucket
What results can you expect?Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten): Analysis of the code sample |
AnchorSQSTypeScript SQSTypeScript
AWS SQS analysis
SQSTypeScript | |
SQSTypeScript |
Expand | ||||
---|---|---|---|---|
Links | ||||
Link Type | Function |
Methods from SDK V2 sqs client | Commands from SDK V3 imported from '@aws-sdk/client-sqs' | |
---|---|---|
Publish |
|
|
Receive |
|
|
Support for SDK
This code will publish a message into the "SQS_QUEUE_URL" queue:
Code Block | ||||
---|---|---|---|---|
| ||||
import * as AWS from "aws-sdk"; AWS.config.update({ region: 'REGION' }); const sqs = new AWS.SQS({apiVersion: '2012-11-05'}); const queueUrl = "SQS_QUEUE_URL" const params = { MessageBody: "This is a message", QueueUrl: queueUrl, MaxNumberOfMessages: 1, VisibilityTimeout: 0, }; class Foo { sendMessage(){ sqs.sendMessage(params, function (err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.MessageId); } }); } } |
This code will receive a message from the queue "SQS_QUEUE_URL"
Code Block | ||||
---|---|---|---|---|
| ||||
import * as AWS from "aws-sdk"; AWS.config.update({ region: 'REGION' }); const sqs = new AWS.SQS({apiVersion: '2012-11-05'}); const queueUrl = "SQS_QUEUE_URL" const params = { QueueUrl: queueUrl, MaxNumberOfMessages: 1, VisibilityTimeout: 0, }; export class SqsReciver { constructor() { this.reciver(); } private reciver(): void { sqs.receiveMessage(params, (err, data) => { // do something }); } } |
What results can you expect?
Once the analysis/snapshot generation has been completed, you can view the results in the standard manner (for example via CAST Enlighten):
Click to enlarge
When the evaluation of the queue name fails, a Node.js AWS SQS Unknown Publisher (or Receiver) will be created.
...
The use of AWS.SQS with promises is not supported. For instance, no link would be created between the receiver and the handler function defined in .then() call in the following source code:
Code Block language xml this.sqs.receiveMessage(params).promise().then( () => {})
- If the queueName is set using the createQueue API, the evaluation of the queue name will fail.will fail.
- Use of access points is not supported
SQL Database Access
This extension supports some libraries offering access to SQL databases. The SQL frameworks analysis is based on the evaluation of the first argument of the "query()" and "execute()" method calls. The first argument is evaluated and if it corresponds to an SQL query, a CAST_TS_Query object is created. In the case where the first argument does not correspond to a SQL query, we evaluate the second argument if is exists. Text only and parameterized SQL queries are supported. This heuristic allows us to support a large number of SQL database frameworks.
...
Expand | ||
---|---|---|
In the following code:
In this example, a TypeScript query object is created and a callLink between the anonymous function and that query is added. The sql analyzer can then link that query with the corresponding table if the table exists. In the present case, this extension creates a useSelect link to the table 'titles': |
Links
Analysis of the TypeScript application will result in the following links:
...
The following rules are shipped with this extension:
...
Info |
---|
The rule "Avoid too many copy-pasted artifacts" depends on com.castsoftware.html5 extension. It will be activated automatically for TypeScript source code when using a version of com.castsoftware.html5 >= 2.0.15-funcrel. |
Limitations
- Limitations for support of the following frameworks are given in their own section:
- Calls between JavaScript and TypeScript source codes are not supported.
- The use of setters and getters is not supported.
- Passing the URL strings directly (or string variables referring to URLs) as arguments to web-service calls is supported for many use cases. However, passing them through http.RequestOptions (containing metadata) is work in progress.
- String concatenations using the operator '+' inside loops do not raise violations currently.
- The cyclomatic complexity number might appear underestimated in callables containing loops with complex conditional expressions.
- A single production environment file is supported (see corresponding section above).
- The use of bind method is not supported and would lead to missing callLinks.
- The use of Object.freeze method is not supported.
- React Without JSX is not supported.
- The spread operator "..." is not supported.