Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

VersionSupported
2

(tick)

4

(tick)

5

(tick)

6

(tick)

7

(tick)

8(tick)
9(tick)
10(tick)
11(tick)
12(tick)
13(tick)

React

VersionSupported
15.x

(tick)

16.x

(tick)

...

  • (tick) indicates that the framework is currently supported.
  • (error) indicates that the framework is not yet supported.

Library

Comment

Data Access

Web Service

Supported versions

ExpressNode.js application framework
(tick)4.x
MongooseMongoDB access(tick)
5.x
SequelizeNode.js application framework(tick)
5.x; 6.x
TypeORMORM(tick)
0.2.x
FastifyNode.js server
(tick)3.x
AxiosPromise based HTTP client
(tick)0.x
Node-mongodb-nativeMongoDB access(tick)
3.x
nestjsNode.js application framework
(tick)6.x; 7.x
httpsNode.js web service
(tick)
fetchJavaScript builtin web service
(tick)
requestHTTP request client 'request'
(tick)2.x

request-promise

HTTP request client 'request'
(tick)4.x
request-promise-nativeHTTP request client 'request'
(tick)1.x
request-promise-anyHTTP request client 'request'
(tick)1.x
Mongo-clientMongoDB access(error)

CouchdbCouchdb access(error)

Node-couchdbCouchdb access(error)

Couchdb-nanoCouchdb access(error)

MarklogicMarklogic access(error)

my_connectionMySQL access(tick)
0.x
pgPostgreSQL access(tick)
7.x; 8.x
oracledbOracle Database access(tick)
4.x; 5.x

node-sqlserver

MsnodeSQL access(tick)
0.x

mssql

MsSQL access(tick) 
5.x; 6.x
HapiNode.js application framework(error)

SailsNode.js application framework(error)(error)
LoopbackNode.js application framework

(error)

(error)
KoaNode.js application framework(error)

KnexNode.js SQL query builder (error)

MemcachedStorage framework(error)

AWS.S3Amazon storage service(tick)
SDK 2.x
AWS.LambdaAmazon routing solution
(tick)Cloudformation, Serverless framework, SAM
AWS.SQSAmazon Simple Queue Service
(tick)SDK 2.x

Supported Emailing frameworks: @sendgrid/mail, nodemailer

...

Image Removed S3 Region S3 Bucket
IconMetamodel nameCode Reference (example)

Typescript Module


Typescript Namespace


Code Block
languagejs
namespace A {
     
    // not exported
    function a() {
    }
}


Typescript Class


Code Block
languagejs
export class TodoStorage implements ... {


...     
}


Class Initializer


Code Block
languagejs
export class TodoStorage implements ... {

field = new Todo();

...     
}


Typescript Method


Code Block
languagejs
export class TodoStorage implements ... {

	// Standard method
	getTodos(): Observable<Todo[]> {
	}


	// Arrow method
	m1 = () => {alert("m1 is called")}     
}


Typescript Interface


Code Block
languagejs
export interface ITodoScope extends... {


...     
}


Typescript Function


Code Block
languagejs
// Named function
function add(x, y) {
    return x + y;
}

// Anonymous function
function(x, y) { return x + y; };


// Arrow function
var f = (x,y) => { return x + y };


// Anonymous arrow function
(x,y) => x+y;

// Generator function
function* infiniteSequence() {
    var i = 0;
    while(true) {
        yield i++;
    }
}


Angular Component

Angular Directive

Angular GET http service

TypeScript GET http service


Angular POST http service

TypeScript POST http service


Angular PUT http service

TypeScript PUT http service


Angular DELETE http service

TypeScript DELETE http service


HTML5 HTML fragment


ReactJS Application

ReactJS Component

ReactJS Form

Node.js Delete Operation Service
Node.js Get Operation Service
Node.js Post Operation Service
Node.js Put Operation Service

Node.js MongoDB connection

Node.js MongoDB collection

TypeScript SQL query

Node.js AWS SQS Publisher

Node.js AWS SQS Receiver

Node.js AWS SQS Unknown Publisher

Node.js AWS SQS Unknown Receiver

Image Added

Node.js AWS SNS Publisher

Image Added

Node.js Image RemovedAWS SNS Subscriber

Image Added

Node.js Image RemovedAWS SNS Unknown Publisher

Image Added

Node.js AWS Lambda Get Operation ServiceSNS Unknown Subscriber

Node.js AWS Lambda Post Operation Service

Node.js AWS Lambda Put Operation Service

Node.js AWS Lambda Delete Operation Service

Node.js AWS Lambda Any Operation Service

Node.js AWS Lambda Function

Image Added

Node.js Call to Lambda

Image Added

Node.js Call to unknown Lambda

Image Added

Node.js S3 Bucket

Image Added

Node.js S3 Unknown Bucket

More about Typescript analysis 

Expand

Support of arrow functions and methods

Arrow 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 functions

For 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 Services

XMLHttpRequest

The 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 :

function my_func(){

  var xhttp = new XMLHttpRequest();
  xhttp.open("GET", "foo/url", false);
  xhttp.send();

}

 

fetch

The 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 :

Code Block
function my_func(){
  const response = await fetch('foo/path', {
    method: 'POST'
  })
}

Window variable

The 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:

Code Block
languagejs
titlemodule1.pyts
window.myurl = "foo/url/"


Code Block
languagejs
titlemodule2.pyts
function my_func(){

  var xhttp = new XMLHttpRequest();
  xhttp.open("GET", window['myurl'], false);
  xhttp.send();

}

a webservice object is created with the url set through the window variable: 

...

Expand

Behavior explanation

Serverless framework, Serverless Application Model (SAM), and Cloudformation are supported. These are frameworks using *.yml or *.json file to set up AWS environment. 
Whenever the runtime set in these files is nodejs, the com.castsoftware.nodejs extension is responsible for creating the corresponding NodeJS AWS Lambda Function, NodeJS AWS Lambda Operation (which represent AWS APIGateway events), and NodeJS AWS Simple Queue objects (see com.castsoftware.nodejs documentation for source codes and example). 

Warning

Since the com.castsoftware.nodejs extension is responsible for analyzing AWS deployment framework *.yml and *.json files the results of an analysis will depend on the version of com.castsoftware.nodjes used.

The typescript extension is responsible for linking these objects to the handler function whenever this handler function is a TypeScript function.

What results can you expect?

When analyzing the following source code with a recent enough version of com.castsoftware.nodejs ( 2.6.0.beta1):

Code Block
provider:
  name: aws
  runtime: nodejs12.x

functions:
  mylambda:
    handler: handler.apilambda
    events:
      - http:
          path: test
          method: get
      - sqs:
          arn:
            Fn::GetAtt:
              - MyQueue
              - Arn     	  
    environment:
      stage: ${opt:stage}
resources:
  Resources:
    MyQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "MyQueue"

Assuming that the handler function is a TypeScript function, once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten)Lambda services allow executing some source code on the cloud and define when this source code should be executed. 

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 CloudConfiguration), 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 method matching the handler fullname a link to that TypeScript method will be added from the lambda function, the SQS queue and the API Gateway objects:

Click to enlarge


Anchor
AWSS3
AWSS3
AWS S3 framework analysis

Expand

Links

Link TypeFunction
No Link
  • createBucket
callLink
  • createMultipartUpload

  • createPresignedPost

  • abortMultipartUpload

  • completeMultipartUpload

  • deleteBucketAnalyticsConfiguration

  • deleteBucketCors

  • deleteBucketEncryption

  • deleteBucketInventoryConfiguration

  • deleteBucketLifecycle

  • deleteBucketMetricsConfiguration

  • deleteBucketPolicy

  • deleteBucketReplication

  • deleteBucketTagging

  • deleteBucketWebsite

  • deleteObjectTagging

  • deletePublicAccessBlock

  • getBucketAccelerateConfiguration

  • getBucketAcl

  • getBucketAnalyticsConfiguration

  • getBucketCors

  • getBucketEncryption

  • getBucketInventoryConfiguration

  • getBucketLifecycle

  • getBucketLifecycleConfiguration

  • getBucketLocation

  • getBucketLogging

  • getBucketMetricsConfiguration

  • getBucketNotification

  • getBucketNotificationConfiguration

  • getBucketPolicy

  • getBucketPolicyStatus

  • getBucketReplication

  • getBucketTagging

  • getBucketVersioning

  • getBucketWebsite

  • getObjectAcl

  • getObjectLegalHold

  • getObjectLockConfiguration

  • getObjectRetention

  • getObjectTagging

  • getPublicAccessBlock

  • getSignedUrl

  • listBuckets
  • listBucketAnalyticsConfigurations

  • listBucketInventoryConfigurations

  • listBucketMetricsConfigurations

  • listMultipartUploads

  • listObjectVersions

  • listParts

  • putBucketLogging
  • putBucketAnalyticsConfiguration
  • putBucketLifecycleConfiguration

  • putBucketMetricsConfiguration

  • putBucketNotification

  • putBucketNotificationConfiguration

  • putBucketPolicy

  • putBucketReplication

  • putBucketRequestPayment

  • putBucketTagging

  • putBucketVersioning

  • putObjectAcl

  • putObjectLegalHold

  • putObjectLockConfiguration

  • putObjectRetention

  • putObjectTagging

  • putPublicAccessBlock

  • putBucketAccelerateConfiguration

  • putBucketAcl

  • putBucketCors

  • putBucketEncryption

  • putBucketInventoryConfiguration

  • putBucketLifecycle

  • upload

  • uploadPart

  • uploadPartCopy

useInsertLink
  • putObject
useDeleteLink
  • deleteBucket
  • deleteObject

  • deleteObjects

useSelectLink
  • getObject
  • getObjectTorrent
  • listObjects

  • listObjectsV2

useUpdateLink
  • putBucketLogging
  • putBucketAnalyticsConfiguration

Code samples

This code will create an S3 Bucket named "MyBucket" on an AWS server in region "REGION" and puts an object in it

Code Block
languagejs
linenumberstrue
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'REGION'});

// Create S3 service object
s3 = new AWS.S3({apiVersion: '2006-03-01'});

// Create the parameters for calling createBucket
var bucketParams = {
  Bucket : "MyBucket",
  ACL : 'public-read'
};

// call S3 to create the bucket
s3.createBucket(bucketParams, function(err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data.Location);
  }
});

params = {
	// ...
    Bucket: "MyBucket"
};
s3.putObject(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
});

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


...

Expand
Links
Link TypeFunction
callLink
  • sendMessage

  • sendMessageBatch
  • receiveMessage
Support for SDK

This code will publish a message into the "SQS_QUEUE_URL" queue:

Code Block
languagejs
linenumberstrue
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,
};


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
languagejs
linenumberstrue
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 following rules are shipped with this extension:

...

  • 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.