fix(core): update

This commit is contained in:
Philipp Kunz 2020-08-21 15:40:04 +00:00
parent 59999a05b3
commit d379fce4a3
17 changed files with 11416 additions and 72 deletions

17
.gitignore vendored
View File

@ -1,5 +1,20 @@
.nogit/ .nogit/
node_modules/
# artifacts
coverage/ coverage/
public/ public/
pages/ pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,86 +1,137 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- mirror - security
- test - test
- release - release
- trigger - metadata
- pages
# ====================
# security stage
# ====================
mirror: mirror:
stage: mirror stage: security
script: script:
- npmci git mirror - npmci git mirror
only:
- tags
tags: tags:
- docker - lossless
- docker
- notpriv
testLEGACY: auditProductionDependencies:
stage: test image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script: script:
- npmci node install legacy - npmci npm prepare
- npmci npm install - npmci command npm install --production --ignore-scripts
- npmci npm test - npmci command npm config set registry https://registry.npmjs.org
coverage: /\d+.?\d+?\%\s*coverage/ - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true allow_failure: true
testLTS: # ====================
# test stage
# ====================
testStable:
stage: test stage: test
script: script:
- npmci node install lts - npmci npm prepare
- npmci npm install - npmci node install stable
- npmci npm test - npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
testSTABLE: testBuild:
stage: test stage: test
script: script:
- npmci node install stable - npmci npm prepare
- npmci npm install - npmci node install stable
- npmci npm test - npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
release: release:
stage: release stage: release
script: script:
- npmci npm prepare - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger: trigger:
stage: trigger stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - lossless
- docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci stage: metadata
stage: pages
script: script:
- npmci command yarn global add npmpage - npmci node install lts
- npmci command npmpage - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,4 +0,0 @@
module.name: smartmodule
module.description: a smart description
module.author: Lossless GmbH
module.license: MIT

View File

@ -1,7 +1,16 @@
{ {
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": []
"npmts" },
] "gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "mojoio",
"gitrepo": "paypal",
"shortDescription": "an unofficial paypal API package",
"npmPackagename": "@mojoio/paypal",
"license": "MIT"
}
} }
} }

11073
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,39 @@
{ {
"name": "ppal", "name": "@mojoio/paypal",
"private": "false",
"version": "1.0.1", "version": "1.0.1",
"description": "mojoio PayPal API abstraction", "description": "mojoio PayPal API abstraction",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(npmts)" "test": "(tstest test/)",
"build": "(tsbuild --web)"
}, },
"devDependencies": { "devDependencies": {
"tapbundle": "^1.0.13" "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.2.9"
}, },
"dependencies": { "dependencies": {
"typings-global": "^1.0.16" "@pushrocks/smartrequest": "^1.1.47",
} "@pushrocks/smartstring": "^3.0.18"
} },
"browserslist": [
"last 1 chrome versions"
],
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

3
qenv.yml Normal file
View File

@ -0,0 +1,3 @@
required:
- PAYPAL_CLIENT_ID
- PAYPAL_CLIENT_SECRET

40
readme.md Normal file
View File

@ -0,0 +1,40 @@
# @mojoio/paypal
an unofficial paypal API package
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/paypal)
* [gitlab.com (source)](https://gitlab.com/mojoio/paypal)
* [github.com (source mirror)](https://github.com/mojoio/paypal)
* [docs (typedoc)](https://mojoio.gitlab.io/paypal/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/paypal/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/paypal/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/paypal)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/mojoio/paypal)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@mojoio/paypal)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/paypal)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/paypal)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
Use TypeScript for best in class intellisense
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,8 +1,21 @@
import { expect, tap } from 'tapbundle' import { expect, tap } from '@pushrocks/tapbundle';
import * as ppal from '../ts/index' import * as paypal from '../ts/index';
tap.test('first test', async () => { import { Qenv } from '@pushrocks/qenv';
console.log(ppal.standardExport) const testQenv = new Qenv('./', './.nogit/');
})
tap.start() let testPayPalInstance: paypal.PayPal;
tap.test('should create a valid paypal instance', async () => {
testPayPalInstance = new paypal.PayPal({
clientId: testQenv.getEnvVarOnDemand('PAYPAL_CLIENT_ID'),
clientSecret: testQenv.getEnvVarOnDemand('PAYPAL_CLIENT_SECRET'),
});
expect(testPayPalInstance).to.be.instanceOf(paypal.PayPal);
});
tap.test('should get an access token', async () => {
await testPayPalInstance.request();
});
tap.start();

View File

@ -1,3 +1 @@
import * as plugins from './ppal.plugins' export * from './paypal.classes.paypal';
export let standardExport = 'Hi there! :) This is a exported string'

View File

@ -0,0 +1,51 @@
import * as plugins from './paypal.plugins';
export interface IPayPalOptions {
clientId: string;
clientSecret: string;
}
export class PayPal {
public apiBaseUrl: string = 'https://api.paypal.com'
public options: IPayPalOptions;
private apiToken: string;
private apiTokenExpirationTime: number;
constructor(optionsArg: IPayPalOptions) {
this.options = optionsArg;
}
public async request() {
if (!this.apiToken || this.apiTokenExpirationTime < Date.now()) {
const authHeader = `Basic ${plugins.smartstring.base64.encode(
`${this.options.clientId}:${this.options.clientSecret}`
)}`;
const response = await plugins.smartrequest.request(
`${this.apiBaseUrl}/v1/oauth2/token?grant_type=client_credentials`,
{
method: 'POST',
headers: {
Accept: 'application/json',
'Accept-Language': 'en_US',
Authorization: authHeader,
},
keepAlive: false,
}
);
this.apiToken = response.body.access_token;
this.apiTokenExpirationTime = Date.now() + response.body.expires_in * 1000 - 600000;
}
// we have a token
const response = await plugins.smartrequest.request(`${this.apiBaseUrl}/v1/reporting/transactions?start_date=2020-05-01T00:00:00Z&end_date=2020-05-30T00:00:00Z`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Accept-Language': 'en_US',
Authorization: `Bearer ${this.apiToken}`,
},
});
console.log(response.body);
}
}

View File

@ -0,0 +1 @@
import * as plugins from './paypal.plugins'

5
ts/paypal.plugins.ts Normal file
View File

@ -0,0 +1,5 @@
// pupshrocks scope
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartstring from '@pushrocks/smartstring';
export { smartrequest, smartstring };

View File

@ -1 +0,0 @@
import 'typings-global'

View File

@ -1,3 +1,17 @@
{ {
"extends": "tslint-config-standard" "extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
} }