36 Commits

Author SHA1 Message Date
9fa3165304 2.0.0 2023-03-20 14:23:33 +01:00
069d61ccf7 BREAKING CHANGE(core): update 2023-03-20 14:23:33 +01:00
0b56464a5f 1.0.27 2020-10-20 20:31:28 +00:00
4805687305 fix(core): update 2020-10-20 20:31:28 +00:00
c387a633bb 1.0.26 2020-10-20 20:28:34 +00:00
99efc2d5fe fix(core): update 2020-10-20 20:28:33 +00:00
e146b7741d 1.0.25 2020-09-24 00:59:02 +00:00
02866cbe8d fix(core): update 2020-09-24 00:59:01 +00:00
7a320d27a3 1.0.24 2020-09-24 00:45:24 +00:00
7910f9a856 fix(core): update 2020-09-24 00:45:23 +00:00
05194609fe 1.0.23 2020-09-24 00:32:54 +00:00
eb0ec04199 fix(core): update 2020-09-24 00:32:54 +00:00
ffd5eb2e52 1.0.22 2020-09-23 23:54:46 +00:00
c432079a70 fix(core): update 2020-09-23 23:54:46 +00:00
e2cab0bb59 1.0.21 2020-09-23 23:30:55 +00:00
aaaa8b3ee4 fix(core): update 2020-09-23 23:30:54 +00:00
4cc149069e 1.0.20 2020-07-28 17:24:53 +00:00
6c106a4f22 fix(core): update 2020-07-28 17:24:53 +00:00
85fca378ff 1.0.19 2020-07-28 17:14:17 +00:00
d096a08e42 fix(core): update 2020-07-28 17:14:16 +00:00
a715dd9e8c 1.0.18 2020-07-26 15:02:25 +00:00
ef8bf0a0d8 fix(core): update 2020-07-26 15:02:24 +00:00
f6d8910c45 1.0.17 2020-07-26 14:34:48 +00:00
0917b9dd06 fix(core): update 2020-07-26 14:34:47 +00:00
0455c34cfa 1.0.16 2020-07-26 14:01:17 +00:00
a69fee7985 fix(core): update 2020-07-26 14:01:17 +00:00
3e0d01520e 1.0.15 2020-07-26 13:54:47 +00:00
7c4db19825 fix(core): update 2020-07-26 13:54:46 +00:00
f7205e2f29 1.0.14 2020-07-25 16:58:07 +00:00
0caf4becbe fix(core): update 2020-07-25 16:58:06 +00:00
42af79a271 1.0.13 2020-07-25 16:34:11 +00:00
4dad23896c fix(core): update 2020-07-25 16:34:10 +00:00
03ae15b10d 1.0.12 2020-07-25 15:53:45 +00:00
f66a5a80e1 fix(core): update 2020-07-25 15:53:45 +00:00
4bd3c65588 1.0.11 2020-07-25 15:48:24 +00:00
f29dd9bf1c fix(core): update 2020-07-25 15:48:24 +00:00
15 changed files with 4358 additions and 5075 deletions

View File

@@ -12,30 +12,38 @@ stages:
- release - release
- metadata - metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
mirror: # ====================
stage: security # security stage
script: # ====================
- npmci git mirror auditProductionDependencies:
tags:
- lossless
- docker
- notpriv
audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm install --ignore-scripts - npmci command pnpm audit --audit-level=high --prod
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
tags: tags:
- lossless - lossless
- docker - docker
- notpriv allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --dev
tags:
- lossless
- docker
allow_failure: true
# ==================== # ====================
# test stage # test stage
@@ -44,28 +52,22 @@ audit:
testStable: testStable:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- priv
testBuild: testBuild:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- notpriv
release: release:
stage: release stage: release
@@ -85,11 +87,12 @@ release:
codequality: codequality:
stage: metadata stage: metadata
allow_failure: true allow_failure: true
only:
- tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker
@@ -109,11 +112,9 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install lts - npmci node install stable
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command npm run buildDocs
tags: tags:
- lossless - lossless
- docker - docker

24
.vscode/launch.json vendored
View File

@@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${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"
} }
] ]
} }

View File

@@ -15,7 +15,7 @@
"properties": { "properties": {
"projectType": { "projectType": {
"type": "string", "type": "string",
"enum": ["website", "element", "service", "npm"] "enum": ["website", "element", "service", "npm", "wcc"]
} }
} }
} }

View File

@@ -5,7 +5,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "apiglobal", "gitscope": "apiglobal",
"gitrepo": "test-sdk", "gitrepo": "test-sdk",
"shortDescription": "an sdk for testing ag handlers", "description": "an sdk for testing ag handlers",
"npmPackagename": "@apiglobal/test-sdk", "npmPackagename": "@apiglobal/test-sdk",
"license": "MIT", "license": "MIT",
"projectDomain": "api.global" "projectDomain": "api.global"

4969
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@apiglobal/test-sdk", "name": "@apiglobal/test-sdk",
"version": "1.0.10", "version": "2.0.0",
"private": false, "private": false,
"description": "an sdk for testing ag handlers", "description": "an sdk for testing ag handlers",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@@ -9,22 +9,22 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web)" "build": "(tsbuild --web)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^14.0.14", "@types/node": "^18.15.3"
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@apiglobal/sdk": "^1.0.9", "@apiglobal/sdk": "^2.0.1",
"@apiglobal/typedrequest": "^1.0.40", "@apiglobal/typedrequest": "^2.0.12",
"@apiglobal/typedrequest-interfaces": "^1.0.15", "@apiglobal/typedrequest-interfaces": "^2.0.1",
"@pushrocks/smartexpress": "^3.0.73", "@pushrocks/qenv": "^5.0.2",
"@pushrocks/smartobject": "^1.0.3" "@pushrocks/smartexpress": "^4.0.28",
"@pushrocks/smartobject": "^1.0.4"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@@ -37,5 +37,9 @@
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ],
"browserslist": [
"last 1 chrome versions"
],
"type": "module"
} }

4230
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@apiglobal/test-sdk)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@apiglobal/test-sdk)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@apiglobal/test-sdk)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@apiglobal/test-sdk)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@apiglobal/test-sdk)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@apiglobal/test-sdk)](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 ## Usage
@@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | 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,5 +1,5 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as testSdk from '../ts/index'; import * as testSdk from '../ts/index.js';
let testServer: testSdk.AgTestServer; let testServer: testSdk.AgTestServer;

8
ts/00_commitinfo_data.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@apiglobal/test-sdk',
version: '2.0.0',
description: 'an sdk for testing ag handlers'
}

View File

@@ -1,13 +1,24 @@
import * as plugins from './test-sdk.plugins'; import * as plugins from './test-sdk.plugins.js';
import { AgTestServer } from './test-sdk.classes.testserver'; import { AgTestServer } from './test-sdk.classes.testserver.js';
import { AAgHandler } from '@apiglobal/sdk';
export { export { AgTestServer };
AgTestServer
};
let testServer: AgTestServer; let testServer: AgTestServer;
export const createTestServer = async (handlerArg: plugins.agSdk.AAgHandler<any>) => { let handler: AAgHandler<any>;
testServer = new AgTestServer(handlerArg); export const createTestServer = async (handlerArg: {
new (envManagerArg: plugins.agSdk.AgEnvironment): plugins.agSdk.AAgHandler<any>;
}) => {
class AgEnvironement extends plugins.agSdk.AgEnvironment {
public qenv = new plugins.qenv.Qenv('./', './.nogit');
public async getEnvVar(nameArg: string) {
return this.qenv.getEnvVarOnDemand(nameArg);
}
}
handler = new handlerArg(new AgEnvironement());
console.log(`now checking requirements for handler with slug ${handler.slug}...`);
await handler.checkRequirements();
testServer = new AgTestServer(handler);
await testServer.start(); await testServer.start();
return testServer; return testServer;
}; };
@@ -16,7 +27,7 @@ export const testFire = <
A extends plugins.agSdk.AAgHandler<any>, A extends plugins.agSdk.AAgHandler<any>,
T extends plugins.typedrequestInterfaces.ITypedRequest T extends plugins.typedrequestInterfaces.ITypedRequest
>( >(
slug: A['slug'], slugArg: A['slug'],
methodArg: T['method'], methodArg: T['method'],
requestArg: T['request'] requestArg: T['request']
) => { ) => {
@@ -27,18 +38,27 @@ export const testFire = <
throw new Error('you need to start the testServer first!'); throw new Error('you need to start the testServer first!');
} }
const typedRequest = new plugins.typedrequest.TypedRequest<T>( const typedRequest = new plugins.typedrequest.TypedRequest<T>(
`https://localhost:${testServer.server.options.port}`, `http://localhost:${testServer.server.options.port}/${slugArg}`,
methodArg methodArg
); );
const responsePromise = typedRequest.fire(requestArg); const responsePromise = typedRequest.fire(requestArg);
const expect = async (expectedResponseArg: T['response']) => { const expect = async (expectedResponseArg: T['response']) => {
const actualResponse = await responsePromise; const actualResponse = await responsePromise;
const comparisonResult = plugins.smartobject.compareObjects(expectedResponseArg, actualResponse); const comparisonResult = plugins.smartobject.compareObjects(
expectedResponseArg,
actualResponse
);
let throwErrorBool = false; let throwErrorBool = false;
if (comparisonResult.divergingProperties.length > 0) { if (comparisonResult.divergingProperties.length > 0) {
console.log(`The following properties diverged:`); console.log(`The following properties diverged:`);
console.log(comparisonResult.divergingProperties); console.log(comparisonResult.divergingProperties);
throwErrorBool = true; for (const divProperty of comparisonResult.divergingProperties) {
if (expectedResponseArg[divProperty] !== 'maydiverge') {
throwErrorBool = true;
} else {
console.log(`${divProperty} may diverge, not throwing for this one`);
}
}
} }
if (comparisonResult.missingProperties.length > 0) { if (comparisonResult.missingProperties.length > 0) {
console.log(`The following properties diverged:`); console.log(`The following properties diverged:`);
@@ -46,16 +66,23 @@ export const testFire = <
throwErrorBool = true; throwErrorBool = true;
} }
if (throwErrorBool) { if (throwErrorBool) {
console.log('Result: response did not comply');
console.log('-> expected:');
console.log(expectedResponseArg);
console.log('-> but actually received:');
console.log(actualResponse);
throw new Error('response did not comply'); throw new Error('response did not comply');
} }
return actualResponse;
}; };
return { return {
expect expect,
}; };
}; };
export const stopTestServer = async () => { export const stopTestServer = async () => {
if (testServer) { if (testServer) {
await testServer.stop(); await testServer.stop();
await handler.stop();
} }
}; };

View File

@@ -1,4 +1,4 @@
import * as plugins from './test-sdk.plugins'; import * as plugins from './test-sdk.plugins.js';
export class AgTestServer { export class AgTestServer {
public handlers: Array<plugins.agSdk.AAgHandler<any>> = []; public handlers: Array<plugins.agSdk.AAgHandler<any>> = [];
@@ -6,29 +6,37 @@ export class AgTestServer {
constructor(handlerArg?: plugins.agSdk.AAgHandler<any>) { constructor(handlerArg?: plugins.agSdk.AAgHandler<any>) {
if (handlerArg) { if (handlerArg) {
this.handlers.push(handlerArg); this.addAgHandler(handlerArg);
} }
} }
public async addAgHandler(handlerArg: plugins.agSdk.AAgHandler<any>) { public async addAgHandler(handlerArg: plugins.agSdk.AAgHandler<any>) {
this.handlers.push(handlerArg); this.handlers.push(handlerArg);
await this.stop(); console.log(`added handler with slug ${handlerArg.slug}`);
await this.start(); if (this.server && this.server.serverStatus === 'running') {
await this.stop();
await this.start();
}
} }
public async start() { public async start() {
this.server = new plugins.smartexpress.Server({ this.server = new plugins.smartexpress.Server({
cors: true, cors: true,
forceSsl: false,
defaultAnswer: async () => 'apiglobal testserver', defaultAnswer: async () => 'apiglobal testserver',
domain: 'localhost', domain: 'localhost',
port: 3000, port: 3000,
forceSsl: false,
}); });
for (const handlerArg of this.handlers) { for (const handlerArg of this.handlers) {
console.log(`found handler with slug ${handlerArg.slug}`);
await handlerArg.start();
console.log(`started handler with slug ${handlerArg.slug}`);
const slugroute = `/${handlerArg.slug}`;
this.server.addRoute( this.server.addRoute(
`/${handlerArg.slug}`, slugroute,
new plugins.smartexpress.HandlerTypedRouter(handlerArg.typedrouter) new plugins.smartexpress.HandlerTypedRouter(handlerArg.typedrouter)
); );
console.log(`added slugroute ${slugroute}`);
} }
await this.server.start(); await this.server.start();
} }

View File

@@ -6,7 +6,8 @@ import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
export { agSdk, typedrequest, typedrequestInterfaces }; export { agSdk, typedrequest, typedrequestInterfaces };
// pushrocks scope // pushrocks scope
import * as qenv from '@pushrocks/qenv';
import * as smartexpress from '@pushrocks/smartexpress'; import * as smartexpress from '@pushrocks/smartexpress';
import * as smartobject from '@pushrocks/smartobject'; import * as smartobject from '@pushrocks/smartobject';
export { smartexpress, smartobject }; export { qenv, smartexpress, smartobject };

10
tsconfig.json Normal file
View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

View File

@@ -1,17 +0,0 @@
{
"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"
}