Coding Week 1: GSoC’ 22 with SCoRe Lab

Pranjal Walia
Leopards Lab
Published in
4 min readJun 30, 2022
Let’s get started.

The coding period of Google Summer of Code 2022 officially started on the 12th of June 2022. There are 12 weeks of coding time for a medium-sized project. In this post, I’ll be talking about how the first week of coding went. You can read my community bonding experience blog posts here as well.

My Project 🛠

In the previous post, I gave a brief introduction on what exactly is the aim of building NodeCloud and what it aims to achieve, now let’s move on further. We saw that it consumes TypeScript type-definition files of modules in order to leverage code-generation of the TypeScript compiler backend.

This is all good, but what if there are no type-definition files!😿 this is the first issue which is to be rectified when building the module for Alibaba Cloud. The official SDK present here is currently a crude implementation but it has all the necessary mechanisms for communicating with the Alibaba Cloud API 😌, but what is missing is that it has not been transpiled into a module ready for consumption. Usually, in a TypeScript module there always exists a directory that is usually named as build or dist , this contains the minified JavaScript code obtained after transpiling all of the TypeScript along with the type-definition files. These files are the ones that facilitate the fancy intellisense of vscode in TypeScript projects and when talking about the build procedure of NodeCloud modules, type-definition files are absolutely necessary to leverage the code-generation of the compiler backend.

Since this is missing, my GSoC task is now split into two, one is to implement the actual plugin but in order to achieve that the type-definition files are needed, so my other task is to consume the different modules already published by Alibaba Cloud, package them as a seperate SDK that exposes type-definition files and is ready for consumption. This was my work in the first week. Another reason that further reinforces the need to build out the SDK is that AliCloud is expected to migrate to V2 of it’s cloud API in the next few months and with no official SDK out, it will render the current official V1 SDK as obsolete, so it made sense release atleast a well typed/tested and consumable version of the SDK for now.

We’ll look further into how exactly the type-definition files are being used in upcoming posts, for now just bear in mind that these are absolutely necessary and let’s proceed further.

Design of the SDK 🏗️

The design of the aliyun-v2-typescript-sdk is heavily inspired from the design patterns of infamous AWS SDK , more specifically we leverage the factory pattern of object oriented design to expose services of the SDK.

import AliCloud from 'aliyun-v2-typescript-sdk';const instance = new AliCloud('accessKeyId', 'accessKeySecret');

Then we proceed to select the service we want to invoke simply as:

instance.oss.<method_name>

And this is where the advantage of type-definition files prevails, we immediately see method completions, type definitions of various parameters and even few lines left by the authors (me in this case..) describing the behaviour of various methods.

Intellisense paired with vscode

Over the course of the week, I went on to implement the following modules into the SDK:

  1. Object Storage (OSS)
  2. Databases (Relational and NoSql)
  3. Server Load Balancers (SLB)

This constitutes the version 0.0.1 release of the SDK! 🎉

What remains for the SDK currently is the modules for compute services, namely the Elastic Compute Service (ECS), Elastic Container Instance (ECI) and Alibaba Cloud Container Service for Kubernetes (ACK). I will be implementing this further into the coding period.

As for the AliCloud package for NodeCloud, now that an initial SDK is out, I will be focusing on writing out the complex logic for consuming, parsing and extracting relevant method implementations of the SDK by using these type-definition files to start building out the plugin. Additionally, in parallel I will be creating/testing the remaining modules for the SDK as well.

Epilogue 🔚

Well this week was fun and a great learning experience, going forward into the next week, expect the posts to become slightly more complex because of the heavy jargon of compilers involved, but it is my job to help you in understanding all of it.

Well this is the end of the line for now, till next time! Follow me on my socials in case of any questions, tips and guidance pertaining to GSoC or anything in general.

Connect with me: Linkedin, Github, Twitter 😀

--

--