Skip to content

Commit 6a47cf9

Browse files
authored
Merge pull request #17 from Kucoin/dev
Add Nodejs SDK
2 parents 247a2e0 + 35ff71f commit 6a47cf9

File tree

890 files changed

+128201
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

890 files changed

+128201
-18
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Upload Nodejs SDK Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publish:
7+
description: "Publish Nodejs SDK to NPM"
8+
required: false
9+
default: "false"
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
id-token: write
15+
16+
jobs:
17+
release-build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.x'
28+
registry-url: 'https://registry.npmjs.org'
29+
cache: 'npm'
30+
cache-dependency-path: sdk/node/package-lock.json
31+
32+
- name: Install Dependencies
33+
working-directory: sdk/node
34+
run: npm ci
35+
36+
- name: Build Project
37+
working-directory: sdk/node
38+
run: npm run build
39+
40+
- name: Dry Run Package Publishing
41+
if: github.event.inputs.publish == 'false'
42+
working-directory: sdk/node
43+
run: npm publish --dry-run
44+
45+
- name: Publish Package to npm
46+
if: github.event.inputs.publish == 'true'
47+
working-directory: sdk/node
48+
run: npm publish --provenance --access public --tag latest
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,28 @@ RUN --mount=type=cache,target=/root/.m2,sharing=locked mvn -U clean package -Dsk
2222
# build tools
2323
FROM openapitools/openapi-generator-cli:v7.7.0
2424

25-
RUN apt-get update && apt-get install python3 python3-pip python3.8-venv -y
25+
RUN apt-get update && apt-get install python3 python3-pip python3.8-venv nodejs npm -y
2626
RUN pip install yapf
2727
ENV GOLANG_VERSION=1.22.2
2828
RUN curl -OL https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz && \
2929
tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz && \
3030
rm go${GOLANG_VERSION}.linux-amd64.tar.gz
3131
WORKDIR /APP
3232
COPY --from=generator-builder /build/target/sdk-openapi-generator-1.0.0.jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar
33+
34+
# node & npm
35+
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
36+
RUN apt-get install -y nodejs
37+
RUN npm install -g prettier
38+
3339
ENV CGO_ENABLED=0
3440
ENV PATH="/usr/local/go/bin:$PATH"
3541
ENV GOPATH="/go"
3642
ENV PATH="$GOPATH/bin:$PATH"
3743

3844
ENV GO_POST_PROCESS_FILE="/usr/local/go/bin/gofmt -w"
3945
ENV PYTHON_POST_PROCESS_FILE="/usr/local/bin/yapf -i"
46+
ENV TS_POST_PROCESS_FILE="/usr/bin/prettier --write --semi --single-quote --tab-width 4 --trailing-comma all --bracket-spacing --arrow-parens always --end-of-line lf --print-width 100"
4047

4148
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
4249

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ define generate-code
6464

6565
@echo "$(GREEN)lang: $(lang), clean...$(NC)"
6666
docker run --rm -v "${PWD}:/local" $(IMAGE_NAME):$(IMAGE_TAG) rm -rf $(outdir)
67-
67+
6868
@echo "$(GREEN)lang: ${lang}, copy changelog...$(NC)"
6969
docker run --rm -v "${PWD}:/local" $(IMAGE_NAME):$(IMAGE_TAG) cp /local/CHANGELOG.md /local/sdk/$(lang)
7070

71-
@make -f generate.mk generate lang=$(1) subdir=$(2)
72-
71+
@make -f generate.mk generate lang=$(1) subdir=$(2) USER_VERSION=$(3)
72+
7373
@echo "$(GREEN)lang: $(lang), clean...$(NC)"
7474
docker run --rm -v "${PWD}:/local" $(IMAGE_NAME):$(IMAGE_TAG) rm -rf $(outdir)/.openapi-generator
7575
docker run --rm -v "${PWD}:/local" $(IMAGE_NAME):$(IMAGE_TAG) rm -rf $(outdir)/.openapi-generator-ignore
@@ -97,6 +97,7 @@ generate: setup-logs
9797
$(call generate-postman)
9898
$(call generate-code,golang,/pkg/generate)
9999
$(call generate-code,python,/kucoin_universal_sdk/generate)
100+
$(call generate-code,node,/src/generate,v0.1.0-alpha)
100101

101102
.PHONY: gen-postman
102103
gen-postman: preprocessor

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ go get github.com/Kucoin/kucoin-universal-sdk/sdk/golang
4747
go mod tidy
4848
```
4949

50+
### Node.js Installation (`0.1.0-alpha`)
51+
Note: This SDK is currently in the Alpha phase. We are actively iterating and improving its features, stability, and documentation. Feedback and contributions are highly encouraged to help us refine the SDK.
52+
```bash
53+
npm install kucoin-universal-sdk
54+
```
55+
5056
### Postman Installation
5157
Visit the [KuCoin API Collection on Postman](https://www.postman.com/kucoin-api/kucoin-api/overview)
5258

@@ -124,6 +130,7 @@ For other languages, refer to the [Examples](#-examples) section.
124130
- Official Documentation: [KuCoin API Docs](https://www.kucoin.com/docs-new)
125131
- **[Python Documentation](sdk/python/README.md)**
126132
- **[Go Documentation](sdk/golang/README.md)**
133+
- **[Node.js Documentation](sdk/node/README.md)**
127134
- **[Postman Documentation](sdk/postman/README.md)**
128135

129136
## 📂 Examples
@@ -132,7 +139,8 @@ Find usage examples for your desired language by selecting the corresponding lin
132139
| Language | Example Directory |
133140
|----------|--------------------------------------------|
134141
| Python | [sdk/python/examples/](sdk/python/example/)|
135-
| Go | [sdk/go/examples/](sdk/golang/example/) |
142+
| Go | [sdk/go/examples/](sdk/golang/example/) |
143+
| Node.js | [sdk/node/examples/](sdk/node/example/) |
136144

137145
## 📋 Changelog
138146

generate.mk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
IMAGE_NAME=sdk-tools
22
IMAGE_TAG=1.0
3-
VERSION := $(shell cat VERSION)
43
DATE := $(shell date +%Y-%m-%d)
54

5+
FILE_VERSION := $(shell cat VERSION)
6+
USER_VERSION ?=
7+
VERSION := $(if $(USER_VERSION),$(USER_VERSION),$(FILE_VERSION))
8+
69
RED=\033[0;31m
710
GREEN=\033[0;32m
811
NC=\033[0m
@@ -54,7 +57,7 @@ define generate-entry
5457
-g $(2)-sdk \
5558
-o $(3) \
5659
--skip-validate-spec \
57-
--additional-properties=GEN_MODE=entry,API_VERSION=$(VERSION),API_DATE=$(DATE) > logs/$(service)-$(lang)-entry.log 2>&1 || \
60+
--additional-properties=GEN_MODE=entry,API_VERSION=$(VERSION),API_DATE=$(DATE),CSV_PATH=/local/spec > logs/$(service)-$(lang)-entry.log 2>&1 || \
5861
{ echo "$(RED)Entry Task $(service) for $(lang) failed$(NC)"; exit 1; }
5962
endef
6063

@@ -90,7 +93,7 @@ WS_FILES := $(wildcard ./spec/ws/*.json)
9093
generate-postman:
9194
$(call generate-postman-func)
9295

93-
generate: $(patsubst ./spec/rest/api/%.json,generate-rest-%, $(REST_FILES)) $(patsubst ./spec/rest/entry/%.json,generate-entry-%, $(ENTRY_FILES)) $(patsubst ./spec/ws/%.json,generate-ws-%, $(WS_FILES))
96+
generate: $(patsubst ./spec/rest/api/%.json,generate-rest-%, $(REST_FILES)) $(patsubst ./spec/ws/%.json,generate-ws-%, $(WS_FILES)) $(patsubst ./spec/rest/entry/%.json,generate-entry-%, $(ENTRY_FILES))
9497

9598
generate-rest-%: ./spec/rest/api/%.json | force
9699
$(eval service=$*)

generator/plugin/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<maven.shade.plugin.version>3.2.4</maven.shade.plugin.version>
1717
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
1818
<ascii-table.version>1.8.0</ascii-table.version>
19+
<csv.version>5.7.1</csv.version>
1920
</properties>
2021

2122
<dependencies>
@@ -36,6 +37,12 @@
3637
<version>${ascii-table.version}</version>
3738
<scope>compile</scope>
3839
</dependency>
40+
<dependency>
41+
<groupId>com.opencsv</groupId>
42+
<artifactId>opencsv</artifactId>
43+
<version>${csv.version}</version>
44+
<scope>compile</scope>
45+
</dependency>
3946
</dependencies>
4047

4148

@@ -67,6 +74,7 @@
6774
<includes>
6875
<include>org.openapitools:openapi-generator-cli</include>
6976
<include>com.github.freva:ascii-table</include>
77+
<include>com.opencsv:opencsv</include>
7078
</includes>
7179
</artifactSet>
7280
<transformers>

0 commit comments

Comments
 (0)