Skip to content

Commit

Permalink
convert index file to typescript file (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmeyerink authored Feb 18, 2025
1 parent e1bfa68 commit 9b86a30
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Clone smartsheet/smartsheet-sdk-tests PUBLIC repository
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [4.2.0] - 2025-2-18
### Added
- Convert app entry to a typescript file

## [4.1.1] - 2025-2-4
### Fix
- Fix an edge case where the calcRetryBackoff function could potentially be undefined.
Expand Down
9 changes: 7 additions & 2 deletions index.js → index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CreateClient } from "./lib/types";

var _ = require('underscore');
var winston = require('winston');
var apiUrls = require('./lib/utils/apis.js');
Expand Down Expand Up @@ -71,7 +73,7 @@ function buildLoggerFromContainer(container) {
"'smartsheet' inside.");
}

exports.createClient = function(clientOptions) {
export const createClient: CreateClient = function(clientOptions) {
var requestor = buildRequestor(clientOptions);

var options = {
Expand Down Expand Up @@ -107,8 +109,11 @@ exports.createClient = function(clientOptions) {
};
};

exports.smartSheetURIs = {
export const smartSheetURIs = {
defaultBaseURI: 'https://api.smartsheet.com/2.0/',
govBaseURI: 'https://api.smartsheetgov.com/2.0/',
euBaseURI: 'https://api.smartsheet.eu/2.0/'
}


export { CreateClient, CreateClientOptions, SmartsheetClient } from "./lib/types";
37 changes: 37 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { LoggerInstance } from "winston";

export interface SmartsheetClient {
constants: any;
contacts: any;
events: any;
favorites: any;
folders: any;
groups: any;
home: any;
images: any;
reports: any;
request: any;
search: any;
server: any;
sheets: any;
sights: any;
templates: any;
tokens: any;
users: any;
webhooks: any;
workspaces: any;
}

export interface CreateClientOptions {
accessToken?: string;
userAgent?: string;
baseUrl?: string;
requestor?: any; // Custom HTTP client that will be used. TODO -> Evaluate if we want to keep this.
maxRetryDurationSeconds?: number;
calcRetryBackoff?: (retryCount: number, error?: any) => number;
logger?: LoggerInstance;
logLevel?: "error" | "warn" | "info" | "http" | "info" | "http" | "verbose" | "debug" | "silly";
loggerContainer?: any;
}

export type CreateClient = (options?: CreateClientOptions) => SmartsheetClient;
35 changes: 33 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "smartsheet",
"version": "4.1.1",
"version": "4.2.0",
"description": "Smartsheet JavaScript client SDK",
"main": "index.js",
"typings": "dist/index.d.ts",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"lint": "jshint -c .jshintrc lib/",
"test": "mocha \"test/**/*_test.js\"",
"test-functional": "mocha \"test/functional/**/*_test.js\"",
"test-mock-api": "mocha \"test/mock-api/**/*_test.js\"",
"coverage": "nyc --reporter=text --reporter=lcov mocha \"test/**/*_test.js\""
"test": "tsc && mocha \"test/**/*_test.js\"",
"test-functional": "tsc && mocha \"test/functional/**/*_test.js\"",
"test-mock-api": "tsc && mocha \"test/mock-api/**/*_test.js\"",
"coverage": "tsc && nyc --reporter=text --reporter=lcov mocha \"test/**/*_test.js\""
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,6 +41,7 @@
"winston": "^2.3.1"
},
"devDependencies": {
"@types/node": "^22.13.4",
"coveralls": "^3.1.1",
"gulp": "^4.0.2",
"gulp-jshint": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test/functional/endpoints_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var should = require('should');
var requestor = require('../../lib/utils/httpRequestor.js').create({});
var constants = require('../../lib/utils/constants.js');
var _ = require('underscore');
var smartsheet = require('../../index.js');
var smartsheet = require('../../dist/index.js');


describe('Method Unit Tests', function () {
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"outDir": "./dist",
"allowJs": true,
"target": "ES6",
"declaration": true
"declaration": true,
"moduleResolution": "node16",
"resolveJsonModule": true,
"module": "Node16"
},
"include": ["./lib/**/*", "./index.js"]
"include": ["./lib/**/*", "./index.ts", "./package.json"]
}

0 comments on commit 9b86a30

Please sign in to comment.