├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── __mocks__ └── axios.ts ├── jest.config.js ├── package.json ├── src ├── index.ts ├── v1.ts └── v1_types.ts ├── test └── v1 │ ├── board.spec.ts │ └── user.spec.ts ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | # Webstorm 64 | .idea/ 65 | 66 | \.DS_Store 67 | 68 | dist 69 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "10" 4 | - "12" 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 James Quigley 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitKraken Glo JavaScript SDK 2 | 3 | ![](https://img.shields.io/github/license/Axosoft/glo-sdk.svg?style=flat) 4 | [![Build Status](https://travis-ci.org/Axosoft/glo-sdk.svg?branch=master)](https://travis-ci.org/Axosoft/glo-sdk) 5 | ![](https://img.shields.io/bundlephobia/min/@axosoft/glo-sdk.svg?label=size&style=flat) 6 | ![](https://img.shields.io/npm/dt/@axosoft/glo-sdk.svg?style=flat) 7 | 8 | GitKraken Glo API [documentation](https://gloapi.gitkraken.com/v1/docs) 9 | 10 | ## How to Use 11 | 12 | ### Install 13 | 14 | npm: 15 | ``` 16 | npm install -S @axosoft/glo-sdk 17 | ``` 18 | yarn 19 | ``` 20 | yarn add @axosoft/glo-sdk 21 | ``` 22 | 23 | ### Example Usage 24 | 25 | You must pass in an auth token. All method calls return a promise, so you should properly handle errors with a .catch or a try/catch block if using async/await. 26 | 27 | ```javascript 28 | // Import options 29 | const GloSDK = require('@axosoft/glo-sdk'); 30 | import GloSDK from '@axosoft/glo-sdk'; 31 | 32 | 33 | // Usage 34 | GloSDK(authToken).boards.getAll() 35 | .then(boards => console.log(boards)) 36 | .catch(error => console.error(error)); 37 | 38 | try { 39 | const boards = await GloSDK(authToken).boards.getAll(); 40 | } catch (error) { 41 | console.log(error); 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /__mocks__/axios.ts: -------------------------------------------------------------------------------- 1 | export const getMock = jest.fn().mockImplementation((url: string) => new Promise(function (resolve, reject) { resolve({ data: 'data' }) })) 2 | export const postMock = jest.fn().mockImplementation((url: string, body: any) => new Promise(function (resolve, reject) { resolve({ data: 'data' }) })) 3 | export const deleteMock = jest.fn().mockImplementation((url: string, body: any) => new Promise(function (resolve, reject) { resolve({ data: 'data' }) })) 4 | 5 | export default { 6 | create: jest.fn().mockImplementation((options: { 7 | baseURL: string, 8 | headers: { 9 | Authorization: string 10 | } 11 | }) => ({ 12 | get: getMock, 13 | post: postMock, 14 | delete: deleteMock 15 | })) 16 | }; 17 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | transform: { 5 | "^.+\\.tsx?$": "ts-jest", 6 | } 7 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@axosoft/glo-sdk", 3 | "version": "2.0.0", 4 | "description": "JavaScript SDK for GitKraken Glo APIs", 5 | "repository": { 6 | "url": "https://github.com/Axosoft/glo-sdk" 7 | }, 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "scripts": { 11 | "build": "tsc", 12 | "build:watch": "tsc --watch", 13 | "test": "jest", 14 | "test:watch": "jest --watch", 15 | "prepublishOnly": "yarn build" 16 | }, 17 | "author": "James Quigley", 18 | "contributors": [ 19 | "Chuck Dries " 20 | ], 21 | "license": "MIT", 22 | "dependencies": { 23 | "axios": "^0.18.1" 24 | }, 25 | "devDependencies": { 26 | "@types/jest": "^23.3.2", 27 | "@types/node": "^11.9.3", 28 | "jest": "^25.1.0", 29 | "ts-jest": "^23.10.1", 30 | "typescript": "^3.0.3" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import v1 from "./v1"; 2 | 3 | 4 | const GloSDK = (token: string) => { 5 | return v1(token); 6 | }; 7 | 8 | export = GloSDK; 9 | -------------------------------------------------------------------------------- /src/v1.ts: -------------------------------------------------------------------------------- 1 | import a from 'axios'; 2 | import { Attachment, BatchError, Board, Card, Column, Comment, GetAttachmentOptions, GetAllBoardOptions, GetBoardOptions, GetCardOptions, GetCommentOptions, GetUserOptions, Label, NewColumn, NewLabel, PageOptions, User} from './v1_types'; 3 | 4 | export default v1; 5 | 6 | function v1(token: string) { 7 | const axios = a.create({ 8 | baseURL: `https://gloapi.gitkraken.com/v1/`, 9 | headers: { 10 | 'Authorization': token 11 | } 12 | }); 13 | 14 | const defaultGetAllBoardOptions = { 15 | archived: false, 16 | page: 1, 17 | per_page: 50, 18 | sort: 'asc', 19 | fields: ['name'], 20 | }; 21 | 22 | const getAllBoards = async (options?: GetAllBoardOptions): Promise<[Board]> => { 23 | const mergedOptions = { 24 | ...defaultGetAllBoardOptions, 25 | ...options 26 | }; 27 | return ( 28 | await axios.get(`/glo/boards?page=${mergedOptions.page}&per_page=${mergedOptions.per_page}&archived=${mergedOptions.archived}&sort=${mergedOptions.sort}&fields=${mergedOptions.fields.join('%2C')}`) 29 | ).data; 30 | }; 31 | 32 | const boards = { 33 | getAll: getAllBoards, 34 | get: async (board_id: string, options?: GetBoardOptions): Promise => { 35 | return ( 36 | await axios.get(`/glo/boards/${board_id}?fields=${ ((options && options.fields) || ['name']).join('%2C')}` 37 | ) 38 | ).data; 39 | }, 40 | create: async (board_name: string): Promise => { 41 | return (await axios.post(`/glo/boards`, { name: board_name })).data; 42 | }, 43 | delete: async (board_id: string): Promise => { 44 | return (await axios.delete(`/glo/boards/${board_id}`)).data; 45 | }, 46 | labels: { 47 | create: async (board_id: string, label: NewLabel): Promise