Skip to content

Commit

Permalink
fix(square): remove revoked acces token from env example
Browse files Browse the repository at this point in the history
Former-commit-id: 1c22e3a
Former-commit-id: 64a5d8946df0182f17c8e4d99a84d57a0af1bf33
  • Loading branch information
tudormd committed Mar 7, 2023
1 parent c5fa182 commit b6812cc
Show file tree
Hide file tree
Showing 37 changed files with 2,220 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# These variables are used for integration tests #
##################################################
SQUARE_BASE_URL=https://connect.squareup.com
SQUARE_SANDBOX_BASE_URL=https://connect.squareupsandbox.com
# https://developer.squareup.com/docs/oauth-api/overview
SQUARE_ACCESS_TOKEN=EAAAE
###########################
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: 🐞 Bug Report
about: Report a reproducible bug
title: ''
labels: ''
assignees: ''
---

<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/goparrot/square-connect-plus/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/goparrot/square-connect-plus/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Square Connect Plus or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/goparrot-square-connect-plus).
- Ensure it isn't already fixed in the latest Square Connect Plus version.
⚠️👆 Feel free to these instructions before submitting the issue 👆⚠️
-->

## Describe the bug

<!-- A clear and concise description of what the bug is. If your problem is not a bug, please file under Question -->

## To Reproduce

<!-- Code snippet to reproduce, ideally that will work by pasting into something like <https://npm.runkit.com/goparrot/square-connect-plus>, a hosted solution, or a repository that illustrates the issue. **If your problem is not reproducible, please file under Question** -->

```typescript
// Example code here
```

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment:

- Square Connect Plus Version: x.y.z
- Node version: x.y.z

## Additional context/Screenshots

<!-- Add any other context about the problem here. If applicable, add screenshots to help explain. -->
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/1-bug-report.md.REMOVED.git-id

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI

on: [ "push", "pull_request" ]

jobs:
commitlint:
runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Clone repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Lints Pull Request commits
uses: wagoid/commitlint-github-action@v2

build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 14.x, 16.x ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Git Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- run: node --version
- run: npm --version

- name: Install npm dependencies
run: npm install --progress=false --loglevel=warn --ignore-scripts

- name: Lint code
run: npm run lint

- name: Check publish sdk
run: npm run publish:dev:dry

- name: Type check
run: npm run typecheck

- name: Run tests and covarage
run: npm run coverage:ci
env:
SQUARE_BASE_URL: ${{ secrets.SQUARE_BASE_URL }}
SQUARE_SANDBOX_BASE_URL: ${{ secrets.SQUARE_SANDBOX_BASE_URL }}
SQUARE_ACCESS_TOKEN: ${{ secrets.SQUARE_ACCESS_TOKEN }}

- name: Run Coveralls
uses: coverallsapp/github-action@master
if: startsWith(matrix.node-version, '14.')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/ci.yml.REMOVED.git-id

This file was deleted.

117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
[![Build Status](https://github.com/goparrot/square-connect-plus/workflows/CI/badge.svg?branch=master)](https://github.com/goparrot/square-connect-plus/actions?query=branch%3Amaster+event%3Apush+workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/goparrot/square-connect-plus/badge.svg?branch=master)](https://coveralls.io/github/goparrot/square-connect-plus?branch=master)
[![NPM version](https://img.shields.io/npm/v/@goparrot/square-connect-plus)](https://www.npmjs.com/package/@goparrot/square-connect-plus)
[![Greenkeeper badge](https://badges.greenkeeper.io/goparrot/square-connect-plus.svg)](https://greenkeeper.io/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)

# Square Connect Plus

**Square Connect Plus** is a Typescript library which extends the official Square Node.js SDK library with additional functionality.
The library does not modify request and response payload.

- [Installation](#installation)
- [Usage](#usage)
- [Versioning](#versioning)
- [Contributing](#contributing)
- [Unit Tests](#unit-tests)
- [Background](#background)
- [License](#license)

## Installation

$ npm i @goparrot/square-connect-plus [email protected]

## Usage

### Simple example

```typescript
import { SquareClient } from '@goparrot/square-connect-plus';
import { ListLocationsResponse } from 'square';

const accessToken: string = `${process.env.SQUARE_ACCESS_TOKEN}`;
const squareClient: SquareClient = new SquareClient(accessToken);

(async () => {
try {
const listLocationsResponse: ListLocationsResponse = await squareClient.getLocationsApi().listLocations();
if (listLocationsResponse.errors.length) {
throw new Error(`cant fetch locations`);
}

console.info('locations', listLocationsResponse.locations);
} catch (error) {
console.error(error);
// or error as string with stack + request and response payload
// console.error(`${error.stack}\npayload: ${error.toString()}`);
}
})();
```

### Advanced example

```typescript
import { SquareClient, exponentialDelay, retryCondition } from '@goparrot/square-connect-plus';

const accessToken: string = `${process.env.SQUARE_ACCESS_TOKEN}`;
const squareClient: SquareClient = new SquareClient(accessToken, {
retry: {
maxRetries: 10,
},
configuration: {
timeout: 60_000,
},
logger: console,
});
```

## Available Options

### `retry` Options

| Name | Type | Default | Description |
| -------------- | ---------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| maxRetries | `Number` | `6` | The number of times to retry before failing. |
| retryCondition | `Function` | `retryCondition` | A callback to further control if a request should be retried. By default, the built-in `retryCondition` function is used. |
| retryDelay | `Function` | `exponentialDelay` | A callback to further control the delay between retried requests. By default, the built-in `exponentialDelay` function is used ([Exponential Backoff](https://developers.google.com/analytics/devguides/reporting/core/v3/errors#backoff)). |

### `originClient` Options

A set of possible settings for the original library.

| Name | Type | Default | Description |
| ----------------- | -------- | ------------------------------ | ------------------------------------------------------------------------- |
| customUrl | `String` | `https://connect.squareup.com` | The custom URL against which to resolve every API call's (relative) path. |
| additionalHeaders | `Object` | `{}` | Record<string, string> |
| timeout | `Number` | `60_000` | The default HTTP timeout for all API calls. |
| squareVersion | `String` | `2021-12-15` | The default square api version for all API calls. |
| environment | `Enum` | `Environment.Production` | The default square enviroment for all API calls. |
| accessToken | `String` | `''` | Scoped access token. |

### `logger` Option

By default, the built-in `NullLogger` class is used.
You can use any logger that fits the built-in `ILogger` interface

## Versioning

Square Connect Plus follows [Semantic Versioning](http://semver.org/).

## Contributing

See [`CONTRIBUTING`](https://github.com/goparrot/square-connect-plus/blob/master/CONTRIBUTING.md#contributing) file.

## Unit Tests

In order to run the test suite, install the development dependencies:

$ npm i

Then, run the following command:

$ npm run coverage

## License

Square Connect Plus is [MIT licensed](LICENSE).
1 change: 0 additions & 1 deletion README.md.REMOVED.git-id

This file was deleted.

122 changes: 122 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"name": "@goparrot/square-connect-plus",
"version": "1.7.0",
"private": false,
"description": "Extends the official Square Node.js SDK library with additional functionality",
"keywords": [
"node",
"typescript",
"square",
"retry"
],
"bugs": {
"url": "https://github.com/goparrot/square-connect-plus/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/goparrot/square-connect-plus.git"
},
"license": "MIT",
"author": "Coroliov Oleg",
"main": "src/index.ts",
"scripts": {
"commit": "git-cz",
"prepare": "husky install",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "mocha --config=.mocharc.json 'test/**/*spec.ts'",
"test:unit": "mocha --config=.mocharc.json 'test/unit/**/*.spec.ts'",
"test:e2e": "mocha 'test/e2e/**/*.spec.ts'",
"test:ci": "mocha --config=.mocharc.json 'test/**/*.spec.ts' 'test/e2e/**/*.spec.ts'",
"test:integration": "mocha --timeout 15000 'test/integration/**/*.spec.ts'",
"coverage": "nyc npm run test",
"coverage:ci": "nyc npm run test:ci -- --reporter mocha-junit-reporter --reporter-options mochaFile=./coverage/junit.xml",
"prettier": "npm run prettier:base -- '**/**.+(md)'",
"prettier:base": "prettier --ignore-path .eslintignore --write",
"pre-commit": "git add . && run-p typecheck format:staged && run-p lint coverage publish:dev:dry",
"format": "npm run prettier && npm run lint -- --fix",
"format:base": "npm run lint:base -- --fix",
"format:staged": "git add . && lint-staged --allow-empty -q",
"lint": "npm run lint:base -- './**/**.{ts,js,json}'",
"lint:base": "npm run lint:config:check && eslint",
"lint:config:check": "eslint-config-prettier src/index.ts",
"build": "rimraf dist && tsc -p tsconfig.build.json",
"remark": "remark README.md CHANGELOG.md CONTRIBUTING.md CODE_OF_CONDUCT.md .github/ -o -f -q && git add .",
"prepublishOnly": "echo \"use 'npm run publish'\" && exit 1",
"publish": "npm run build && ts-node -T bin/prepublish.ts && npm publish ./dist",
"publish:dev": "npm run publish --tag dev",
"publish:dev:dry": "npm run publish:dev --dry-run",
"version": "echo \"use 'npm run release'\" && exit 1",
"release": "standard-version && git push && git push --tags && npm run publish && npm run github-release",
"release:dry": "npm run publish:dev:dry && standard-version --dry-run",
"github-release": "env-cmd conventional-github-releaser -p angular"
},
"lint-staged": {
"*.{ts,tsx,js,json}": [
"npm run format:base"
],
"*.md": [
"npm run prettier:base"
]
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"lodash.upperfirst": "^4.3.1"
},
"devDependencies": {
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@goparrot/eslint-config": "^1.0.3",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.5",
"@types/lodash.camelcase": "^4.3.6",
"@types/lodash.snakecase": "^4.1.6",
"@types/lodash.upperfirst": "^4.3.7",
"@types/mocha": "^9.1.0",
"@types/node": "^16.11.24",
"@types/sinon": "^10.0.11",
"@types/square-connect": "^4.20201028.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"commitizen": "^4.2.4",
"conventional-github-releaser": "^3.1.5",
"cz-conventional-changelog": "^3.3.0",
"dotenv-safe": "^8.2.0",
"env-cmd": "^10.1.0",
"husky": "^7.0.4",
"lint-staged": "^12.3.4",
"lodash.camelcase": "4.3.0",
"lodash.snakecase": "4.1.1",
"mocha": "^9.2.0",
"mocha-junit-reporter": "^2.0.2",
"nock": "^13.2.4",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^2.5.1",
"remark-cli": "^10.0.1",
"remark-frontmatter": "^4.0.1",
"remark-github": "^11.2.2",
"remark-lint-emphasis-marker": "^3.1.1",
"remark-lint-strong-marker": "^3.1.1",
"rimraf": "^3.0.2",
"sinon": "^13.0.1",
"square": "^21.1.0",
"standard-version": "^9.3.2",
"ts-node": "^10.5.0",
"typescript": "^4.5.5",
"utility-types": "^3.10.0",
"uuid": "^8.3.2"
},
"peerDependencies": {
"lodash.camelcase": "^4.3.0",
"lodash.snakecase": "^4.1.1",
"square": ">=21.1.0",
"uuid": "^8.3.2"
},
"engines": {
"node": ">=14"
}
}
1 change: 0 additions & 1 deletion package.json.REMOVED.git-id

This file was deleted.

Loading

0 comments on commit b6812cc

Please sign in to comment.