fix(core): update

This commit is contained in:
Philipp Kunz 2023-07-04 09:13:14 +02:00
parent c9a9434cd9
commit e56439e9f4
19 changed files with 4926 additions and 1883 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

4
.snyk
View File

@ -1,4 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
ignore: {}
patch: {}

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

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

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

@ -4,11 +4,12 @@
"npmAccessLevel": "public" "npmAccessLevel": "public"
}, },
"gitzone": { "gitzone": {
"projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "mojoio", "gitscope": "mojoio",
"gitrepo": "elasticsearch", "gitrepo": "elasticsearch",
"shortDescription": "log to elasticsearch in a kibana compatible format", "description": "log to elasticsearch in a kibana compatible format",
"npmPackagename": "@mojoio/elasticsearch", "npmPackagename": "@mojoio/elasticsearch",
"license": "MIT" "license": "MIT"
} }

1805
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,43 +3,47 @@
"version": "1.0.30", "version": "1.0.30",
"private": false, "private": false,
"description": "log to elasticsearch in a kibana compatible format", "description": "log to elasticsearch in a kibana compatible format",
"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": "(tstest test/)", "test": "(tstest test/)",
"format": "(gitzone format)", "format": "(gitzone format)",
"build": "(tsbuild)" "build": "(tsbuild)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.74",
"@pushrocks/qenv": "^4.0.6", "@pushrocks/qenv": "^5.0.2",
"@pushrocks/tapbundle": "^3.0.13", "@pushrocks/tapbundle": "^5.0.8",
"@types/node": "^12.12.5", "@types/node": "^20.3.3"
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.11", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartdelay": "^3.0.1",
"@pushrocks/smartlog-interfaces": "^2.0.9", "@pushrocks/smartlog-interfaces": "^3.0.0",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^4.0.2",
"@pushrocks/smarttime": "^3.0.12", "@pushrocks/smarttime": "^4.0.1",
"@types/elasticsearch": "^5.0.35", "@types/elasticsearch": "^5.0.40",
"elasticsearch": "^16.5.0" "elasticsearch": "^16.7.3"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
] ]
} }

4609
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,19 @@ log to elasticsearch in a kibana compatible format
* [docs (typedoc)](https://mojoio.gitlab.io/elasticsearch/) * [docs (typedoc)](https://mojoio.gitlab.io/elasticsearch/)
## Status for master ## Status for master
[![build status](https://gitlab.com/mojoio/elasticsearch/badges/master/build.svg)](https://gitlab.com/mojoio/elasticsearch/commits/master)
[![coverage report](https://gitlab.com/mojoio/elasticsearch/badges/master/coverage.svg)](https://gitlab.com/mojoio/elasticsearch/commits/master) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/elasticsearch.svg)](https://www.npmjs.com/package/@mojoio/elasticsearch) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/elasticsearch/badge.svg)](https://snyk.io/test/npm/@mojoio/elasticsearch) GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/elasticsearch/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/elasticsearch/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/elasticsearch)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/mojoio/elasticsearch)](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/elasticsearch)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/elasticsearch)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/elasticsearch)](https://lossless.cloud)
## Usage ## Usage
@ -27,13 +33,17 @@ For further information read the linked docs at the top of this README.
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks) [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribute ## Contribute
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: [Contribute monthly :)](https://lossless.link/contribute) 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: [Contribute monthly :)](https://lossless.link/contribute)
## 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. 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,6 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import { Qenv } from '@pushrocks/qenv'; import { Qenv } from '@pushrocks/qenv';
import * as elasticsearch from '../ts/index'; import * as elasticsearch from '../ts/index.js';
const testQenv = new Qenv('./', './.nogit/'); const testQenv = new Qenv('./', './.nogit/');
@ -12,9 +12,9 @@ tap.test('first test', async () => {
indexRetention: 7, indexRetention: 7,
domain: testQenv.getEnvVarOnDemand('ELK_DOMAIN'), domain: testQenv.getEnvVarOnDemand('ELK_DOMAIN'),
port: parseInt(testQenv.getEnvVarOnDemand('ELK_PORT'), 10), port: parseInt(testQenv.getEnvVarOnDemand('ELK_PORT'), 10),
ssl: true ssl: true,
}); });
expect(testElasticLog).to.be.instanceOf(elasticsearch.ElasticSearch); expect(testElasticLog).toBeInstanceOf(elasticsearch.ElasticSearch);
}); });
tap.test('should send a message to Elasticsearch', async () => { tap.test('should send a message to Elasticsearch', async () => {
@ -28,9 +28,10 @@ tap.test('should send a message to Elasticsearch', async () => {
containerName: 'testcontainer', containerName: 'testcontainer',
environment: 'test', environment: 'test',
runtime: 'node', runtime: 'node',
zone: 'ship.zone' zone: 'ship.zone',
}, },
message: 'GET https://myroute.to.a.cool.destination/sorare?hello=there' message: 'GET https://myroute.to.a.cool.destination/sorare?hello=there',
correlation: null,
}); });
}); });

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@mojoio/elasticsearch',
version: '1.0.31',
description: 'log to elasticsearch in a kibana compatible format'
}

View File

@ -21,7 +21,7 @@ export class ElasticIndex {
this.elasticSearchRef.client.cat.indices( this.elasticSearchRef.client.cat.indices(
{ {
format: 'json', format: 'json',
bytes: 'm' bytes: 'm',
}, },
async (err, responseArg: any[]) => { async (err, responseArg: any[]) => {
if (err) { if (err) {
@ -31,10 +31,10 @@ export class ElasticIndex {
// lets delete indexes that violate the retention // lets delete indexes that violate the retention
if (Array.isArray(responseArg)) { if (Array.isArray(responseArg)) {
const filteredIndices = responseArg.filter(indexObjectArg => { const filteredIndices = responseArg.filter((indexObjectArg) => {
return indexObjectArg.index.startsWith('smartlog'); return indexObjectArg.index.startsWith('smartlog');
}); });
const filteredIndexNames = filteredIndices.map(indexObjectArg => { const filteredIndexNames = filteredIndices.map((indexObjectArg) => {
return indexObjectArg.index; return indexObjectArg.index;
}); });
this.deleteOldIndices(filteredIndexNames); this.deleteOldIndices(filteredIndexNames);
@ -43,7 +43,7 @@ export class ElasticIndex {
let index = null; let index = null;
if (Array.isArray(responseArg)) { if (Array.isArray(responseArg)) {
index = responseArg.find(indexObject => { index = responseArg.find((indexObject) => {
return indexObject.index === indexArg; return indexObject.index === indexArg;
}); });
} }
@ -53,7 +53,7 @@ export class ElasticIndex {
this.elasticSearchRef.client.indices.create( this.elasticSearchRef.client.indices.create(
{ {
waitForActiveShards: '1', waitForActiveShards: '1',
index: indexArg index: indexArg,
}, },
(error, response) => { (error, response) => {
// console.lof(response) // console.lof(response)
@ -86,7 +86,7 @@ export class ElasticIndex {
const done2 = plugins.smartpromise.defer(); const done2 = plugins.smartpromise.defer();
this.elasticSearchRef.client.indices.delete( this.elasticSearchRef.client.indices.delete(
{ {
index: indexName index: indexName,
}, },
(err2, response2) => { (err2, response2) => {
if (err2) { if (err2) {

View File

@ -1,4 +1,4 @@
import { ElasticSearch, IStandardLogParams } from './elasticsearch.classes.elasticsearch'; import { ElasticSearch, type IStandardLogParams } from './elasticsearch.classes.elasticsearch.js';
export class ElasticScheduler { export class ElasticScheduler {
elasticSearchRef: ElasticSearch<any>; elasticSearchRef: ElasticSearch<any>;

View File

@ -1,10 +1,10 @@
// interfaces // interfaces
import { Client as ElasticClient } from 'elasticsearch'; import { Client as ElasticClient } from 'elasticsearch';
import { ILogContext, ILogPackage, ILogDestination } from '@pushrocks/smartlog-interfaces'; import type { ILogContext, ILogPackage, ILogDestination } from '@pushrocks/smartlog-interfaces';
// other classes // other classes
import { ElasticScheduler } from './elasticsearch.classes.elasticscheduler'; import { ElasticScheduler } from './elasticsearch.classes.elasticscheduler.js';
import { ElasticIndex } from './elasticsearch.classes.elasticindex'; import { ElasticIndex } from './elasticsearch.classes.elasticindex.js';
export interface IStandardLogParams { export interface IStandardLogParams {
message: string; message: string;
@ -35,7 +35,7 @@ export class ElasticSearch<T> {
*/ */
constructor(optionsArg: IElasticSearchConstructorOptions) { constructor(optionsArg: IElasticSearchConstructorOptions) {
this.client = new ElasticClient({ this.client = new ElasticClient({
host: this.computeHostString(optionsArg) host: this.computeHostString(optionsArg),
// log: 'trace' // log: 'trace'
}); });
this.indexPrefix = optionsArg.indexPrefix; this.indexPrefix = optionsArg.indexPrefix;
@ -80,8 +80,8 @@ export class ElasticSearch<T> {
type: 'log', type: 'log',
body: { body: {
'@timestamp': new Date(logPackageArg.timestamp).toISOString(), '@timestamp': new Date(logPackageArg.timestamp).toISOString(),
...logPackageArg ...logPackageArg,
} },
}, },
(error, response) => { (error, response) => {
if (error) { if (error) {
@ -97,9 +97,9 @@ export class ElasticSearch<T> {
get logDestination(): ILogDestination { get logDestination(): ILogDestination {
return { return {
handleLog: (smartlogPackageArg: ILogPackage) => { handleLog: async (smartlogPackageArg: ILogPackage) => {
this.log(smartlogPackageArg); this.log(smartlogPackageArg);
} },
}; };
} }
} }

View File

@ -1 +1 @@
export * from './elasticsearch.classes.elasticsearch'; export * from './elasticsearch.classes.elasticsearch.js';

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": 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"
}