Skip to content

Commit 9b86a30

Browse files
authored
convert index file to typescript file (#94)
1 parent e1bfa68 commit 9b86a30

File tree

8 files changed

+98
-14
lines changed

8 files changed

+98
-14
lines changed

.github/workflows/test-build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
node-version: ${{ matrix.node-version }}
3333
- name: Install dependencies
3434
run: npm ci
35+
- name: Build
36+
run: npm run build
3537
- name: Clone smartsheet/smartsheet-sdk-tests PUBLIC repository
3638
uses: GuillaumeFalourd/clone-github-repo-action@v2
3739
with:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
9+
## [4.2.0] - 2025-2-18
10+
### Added
11+
- Convert app entry to a typescript file
12+
813
## [4.1.1] - 2025-2-4
914
### Fix
1015
- Fix an edge case where the calcRetryBackoff function could potentially be undefined.

index.js renamed to index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { CreateClient } from "./lib/types";
2+
13
var _ = require('underscore');
24
var winston = require('winston');
35
var apiUrls = require('./lib/utils/apis.js');
@@ -71,7 +73,7 @@ function buildLoggerFromContainer(container) {
7173
"'smartsheet' inside.");
7274
}
7375

74-
exports.createClient = function(clientOptions) {
76+
export const createClient: CreateClient = function(clientOptions) {
7577
var requestor = buildRequestor(clientOptions);
7678

7779
var options = {
@@ -107,8 +109,11 @@ exports.createClient = function(clientOptions) {
107109
};
108110
};
109111

110-
exports.smartSheetURIs = {
112+
export const smartSheetURIs = {
111113
defaultBaseURI: 'https://api.smartsheet.com/2.0/',
112114
govBaseURI: 'https://api.smartsheetgov.com/2.0/',
113115
euBaseURI: 'https://api.smartsheet.eu/2.0/'
114116
}
117+
118+
119+
export { CreateClient, CreateClientOptions, SmartsheetClient } from "./lib/types";

lib/types.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { LoggerInstance } from "winston";
2+
3+
export interface SmartsheetClient {
4+
constants: any;
5+
contacts: any;
6+
events: any;
7+
favorites: any;
8+
folders: any;
9+
groups: any;
10+
home: any;
11+
images: any;
12+
reports: any;
13+
request: any;
14+
search: any;
15+
server: any;
16+
sheets: any;
17+
sights: any;
18+
templates: any;
19+
tokens: any;
20+
users: any;
21+
webhooks: any;
22+
workspaces: any;
23+
}
24+
25+
export interface CreateClientOptions {
26+
accessToken?: string;
27+
userAgent?: string;
28+
baseUrl?: string;
29+
requestor?: any; // Custom HTTP client that will be used. TODO -> Evaluate if we want to keep this.
30+
maxRetryDurationSeconds?: number;
31+
calcRetryBackoff?: (retryCount: number, error?: any) => number;
32+
logger?: LoggerInstance;
33+
logLevel?: "error" | "warn" | "info" | "http" | "info" | "http" | "verbose" | "debug" | "silly";
34+
loggerContainer?: any;
35+
}
36+
37+
export type CreateClient = (options?: CreateClientOptions) => SmartsheetClient;

package-lock.json

Lines changed: 33 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "smartsheet",
3-
"version": "4.1.1",
3+
"version": "4.2.0",
44
"description": "Smartsheet JavaScript client SDK",
5-
"main": "index.js",
6-
"typings": "dist/index.d.ts",
5+
"main": "dist/index.js",
6+
"typings": "dist/index.d.ts",
77
"scripts": {
88
"build": "tsc",
99
"lint": "jshint -c .jshintrc lib/",
10-
"test": "mocha \"test/**/*_test.js\"",
11-
"test-functional": "mocha \"test/functional/**/*_test.js\"",
12-
"test-mock-api": "mocha \"test/mock-api/**/*_test.js\"",
13-
"coverage": "nyc --reporter=text --reporter=lcov mocha \"test/**/*_test.js\""
10+
"test": "tsc && mocha \"test/**/*_test.js\"",
11+
"test-functional": "tsc && mocha \"test/functional/**/*_test.js\"",
12+
"test-mock-api": "tsc && mocha \"test/mock-api/**/*_test.js\"",
13+
"coverage": "tsc && nyc --reporter=text --reporter=lcov mocha \"test/**/*_test.js\""
1414
},
1515
"repository": {
1616
"type": "git",
@@ -41,6 +41,7 @@
4141
"winston": "^2.3.1"
4242
},
4343
"devDependencies": {
44+
"@types/node": "^22.13.4",
4445
"coveralls": "^3.1.1",
4546
"gulp": "^4.0.2",
4647
"gulp-jshint": "^2.1.0",

test/functional/endpoints_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var should = require('should');
33
var requestor = require('../../lib/utils/httpRequestor.js').create({});
44
var constants = require('../../lib/utils/constants.js');
55
var _ = require('underscore');
6-
var smartsheet = require('../../index.js');
6+
var smartsheet = require('../../dist/index.js');
77

88

99
describe('Method Unit Tests', function () {

tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"outDir": "./dist",
44
"allowJs": true,
55
"target": "ES6",
6-
"declaration": true
6+
"declaration": true,
7+
"moduleResolution": "node16",
8+
"resolveJsonModule": true,
9+
"module": "Node16"
710
},
8-
"include": ["./lib/**/*", "./index.js"]
11+
"include": ["./lib/**/*", "./index.ts", "./package.json"]
912
}

0 commit comments

Comments
 (0)