Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
32265e83f3 | |||
e2df11cea2 | |||
2719ba28f6 | |||
6d78a7ba0c | |||
5897c6e7de | |||
20369614a2 | |||
7ceaf694fe | |||
391c6bd45d | |||
1a702071c6 | |||
0fe2f6a4ae | |||
20d04413c9 | |||
e56439e9f4 | |||
c9a9434cd9 | |||
5d98dd9089 | |||
2d635fdf7c | |||
1dbf3724d0 | |||
cc7eb8c139 | |||
0e01ecbd1a | |||
2d21b40a76 | |||
2d1a5cdc50 | |||
20a41d3381 | |||
b2019b33f8 | |||
1ab582db51 | |||
9c87f5ee5e | |||
ef9cb193d5 | |||
9f706e0a70 | |||
b2d4b82532 | |||
63713f4cd2 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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
|
17
.gitignore
vendored
17
.gitignore
vendored
@ -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
|
104
.gitlab-ci.yml
104
.gitlab-ci.yml
@ -1,87 +1,80 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- pnpm install -g pnpm
|
||||||
|
- pnpm install -g @shipzone/npmci
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command pnpm audit --audit-level=high --prod
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
snyk:
|
auditDevDependencies:
|
||||||
|
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 -g snyk
|
- npmci command pnpm audit --audit-level=high --dev
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@ -90,20 +83,15 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
only:
|
||||||
- docker:stable-dind
|
- tags
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
@ -114,18 +102,18 @@ trigger:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci node install stable
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -135,13 +123,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
||||||
|
4
.snyk
4
.snyk
@ -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
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -2,5 +2,16 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "mojoio",
|
||||||
|
"gitrepo": "elasticsearch",
|
||||||
|
"description": "log to elasticsearch in a kibana compatible format",
|
||||||
|
"npmPackagename": "@mojoio/elasticsearch",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1148
package-lock.json
generated
1148
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
57
package.json
57
package.json
@ -1,34 +1,49 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/elasticsearch",
|
"name": "@apiclient.xyz/elasticsearch",
|
||||||
"version": "1.0.22",
|
"version": "1.0.36",
|
||||||
"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 --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.1.13",
|
"@gitzone/tsrun": "^1.2.42",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/qenv": "^2.0.2",
|
"@pushrocks/qenv": "^5.0.2",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^5.0.8",
|
||||||
"@types/node": "^10.12.2",
|
"@types/node": "^20.3.3"
|
||||||
"tslint": "^5.11.0",
|
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.1",
|
"@pushrocks/lik": "^6.0.2",
|
||||||
"@pushrocks/smartdelay": "^2.0.2",
|
"@pushrocks/smartdelay": "^3.0.1",
|
||||||
"@pushrocks/smartlog-interfaces": "^2.0.2",
|
"@pushrocks/smartlog-interfaces": "^3.0.0",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^4.0.2",
|
||||||
"@pushrocks/smarttime": "^3.0.2",
|
"@pushrocks/smarttime": "^4.0.1",
|
||||||
"@types/elasticsearch": "^5.0.28",
|
"@types/elasticsearch": "^5.0.40",
|
||||||
"elasticsearch": "^15.2.0"
|
"elasticsearch": "^16.7.3"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"type": "module",
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
4609
pnpm-lock.yaml
generated
Normal file
4609
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
2
qenv.yml
2
qenv.yml
@ -1,4 +1,4 @@
|
|||||||
vars:
|
required:
|
||||||
- ELK_DOMAIN
|
- ELK_DOMAIN
|
||||||
- ELK_PORT
|
- ELK_PORT
|
||||||
- ELK_USER
|
- ELK_USER
|
||||||
|
50
readme.md
50
readme.md
@ -1,26 +1,26 @@
|
|||||||
# elasticlog
|
# @mojoio/elasticsearch
|
||||||
|
|
||||||
log to elasticsearch in a kibana compatible format
|
log to elasticsearch in a kibana compatible format
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/elasticsearch)
|
||||||
[](https://www.npmjs.com/package/elasticlog)
|
* [gitlab.com (source)](https://gitlab.com/mojoio/elasticsearch)
|
||||||
[](https://GitLab.com/pushrocks/elasticlog)
|
* [github.com (source mirror)](https://github.com/mojoio/elasticsearch)
|
||||||
[](https://github.com/pushrocks/elasticlog)
|
* [docs (typedoc)](https://mojoio.gitlab.io/elasticsearch/)
|
||||||
[](https://pushrocks.gitlab.io/elasticlog/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
[](https://GitLab.com/pushrocks/elasticlog/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://GitLab.com/pushrocks/elasticlog/commits/master)
|
-- | --
|
||||||
[](https://www.npmjs.com/package/elasticlog)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://david-dm.org/pushrocks/elasticlog)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://www.bithound.io/github/pushrocks/elasticlog/master/dependencies/npm)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://www.bithound.io/github/pushrocks/elasticlog)
|
Snyk | [](https://lossless.cloud)
|
||||||
[](https://snyk.io/test/npm/elasticlog)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
Code Style | [](https://lossless.cloud)
|
||||||
[](http://standardjs.com/)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -32,3 +32,17 @@ For further information read the linked docs at the top of this README.
|
|||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://push.rocks)
|
[](https://push.rocks)
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
@ -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/');
|
||||||
|
|
||||||
@ -10,13 +10,11 @@ tap.test('first test', async () => {
|
|||||||
testElasticLog = new elasticsearch.ElasticSearch({
|
testElasticLog = new elasticsearch.ElasticSearch({
|
||||||
indexPrefix: 'smartlog',
|
indexPrefix: 'smartlog',
|
||||||
indexRetention: 7,
|
indexRetention: 7,
|
||||||
domain: process.env.ELK_DOMAIN,
|
domain: testQenv.getEnvVarOnDemand('ELK_DOMAIN'),
|
||||||
port: parseInt(process.env.ELK_PORT, 10),
|
port: parseInt(testQenv.getEnvVarOnDemand('ELK_PORT'), 10),
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: process.env.ELK_USER,
|
|
||||||
pass: process.env.ELK_PASS
|
|
||||||
});
|
});
|
||||||
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 () => {
|
||||||
@ -30,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: 'hi, this is a testMessage'
|
message: 'GET https://myroute.to.a.cool.destination/sorare?hello=there',
|
||||||
|
correlation: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@apiclient.xyz/elasticsearch',
|
||||||
|
version: '1.0.36',
|
||||||
|
description: 'log to elasticsearch in a kibana compatible format'
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './elasticsearch.plugins';
|
import * as plugins from './elasticsearch.plugins.js';
|
||||||
import { ElasticSearch } from './elasticsearch.classes.elasticsearch';
|
import { ElasticSearch } from './elasticsearch.classes.elasticsearch.js';
|
||||||
import { ILogPackage } from '@pushrocks/smartlog-interfaces';
|
import { type ILogPackage } from '@pushrocks/smartlog-interfaces';
|
||||||
|
|
||||||
import { Stringmap } from '@pushrocks/lik';
|
import { Stringmap } from '@pushrocks/lik';
|
||||||
|
|
||||||
@ -15,55 +15,45 @@ export class ElasticIndex {
|
|||||||
public async ensureIndex(indexArg: string) {
|
public async ensureIndex(indexArg: string) {
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
if (this.stringmap.checkString(indexArg)) {
|
if (this.stringmap.checkString(indexArg)) {
|
||||||
|
done.resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.elasticSearchRef.client.cat.indices(
|
this.elasticSearchRef.client.cat.indices(
|
||||||
{
|
{
|
||||||
format: 'json',
|
format: 'json',
|
||||||
bytes: 'm'
|
bytes: 'm',
|
||||||
},
|
},
|
||||||
async (err, response: any[]) => {
|
async (err, responseArg: any[]) => {
|
||||||
// lets delete indexes that violate the retention
|
if (err) {
|
||||||
const filteredIndices = response.filter(indexObjectArg => {
|
console.log(err);
|
||||||
return indexObjectArg.index.startsWith('smartlog');
|
return;
|
||||||
});
|
|
||||||
const filteredIndexNames = filteredIndices.map(indexObjectArg => {
|
|
||||||
return indexObjectArg.name;
|
|
||||||
});
|
|
||||||
const todayAsUnix: number = Date.now();
|
|
||||||
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
|
|
||||||
this.elasticSearchRef.indexRetention
|
|
||||||
);
|
|
||||||
for (const indexName of filteredIndexNames) {
|
|
||||||
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/;
|
|
||||||
const dateAsUnix: number = new Date(
|
|
||||||
`${regexResult[1]}-${regexResult[2]}-${regexResult[3]}`
|
|
||||||
).getTime();
|
|
||||||
if (todayAsUnix - rententionPeriodAsUnix > dateAsUnix) {
|
|
||||||
const done2 = plugins.smartpromise.defer();
|
|
||||||
this.elasticSearchRef.client.indices.delete({
|
|
||||||
index: indexName
|
|
||||||
}, (err2, response2) => {
|
|
||||||
if(err2) {
|
|
||||||
console.log(err2);
|
|
||||||
}
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
await done2.promise;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(response);
|
// lets delete indexes that violate the retention
|
||||||
const index = response.find(indexObject => {
|
if (Array.isArray(responseArg)) {
|
||||||
|
const filteredIndices = responseArg.filter((indexObjectArg) => {
|
||||||
|
return indexObjectArg.index.startsWith('smartlog');
|
||||||
|
});
|
||||||
|
const filteredIndexNames = filteredIndices.map((indexObjectArg) => {
|
||||||
|
return indexObjectArg.index;
|
||||||
|
});
|
||||||
|
this.deleteOldIndices(filteredIndexNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
let index = null;
|
||||||
|
|
||||||
|
if (Array.isArray(responseArg)) {
|
||||||
|
index = responseArg.find((indexObject) => {
|
||||||
return indexObject.index === indexArg;
|
return indexObject.index === indexArg;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!index) {
|
if (!index) {
|
||||||
const done2 = plugins.smartpromise.defer();
|
const done2 = plugins.smartpromise.defer();
|
||||||
this.elasticSearchRef.client.indices.create(
|
this.elasticSearchRef.client.indices.create(
|
||||||
{
|
{
|
||||||
waitForActiveShards: '2',
|
waitForActiveShards: '1',
|
||||||
index: indexArg
|
index: indexArg,
|
||||||
},
|
},
|
||||||
(error, response) => {
|
(error, response) => {
|
||||||
// console.lof(response)
|
// console.lof(response)
|
||||||
@ -78,4 +68,36 @@ export class ElasticIndex {
|
|||||||
);
|
);
|
||||||
await done.promise;
|
await done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createNewIndex(indexNameArg: string) {}
|
||||||
|
|
||||||
|
public async deleteOldIndices(indicesArray: string[]) {
|
||||||
|
const todayAsUnix: number = Date.now();
|
||||||
|
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
|
||||||
|
this.elasticSearchRef.indexRetention
|
||||||
|
);
|
||||||
|
for (const indexName of indicesArray) {
|
||||||
|
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName);
|
||||||
|
const dateAsUnix: number = new Date(
|
||||||
|
`${regexResult[1]}-${regexResult[2]}-${regexResult[3]}`
|
||||||
|
).getTime();
|
||||||
|
if (todayAsUnix - rententionPeriodAsUnix > dateAsUnix) {
|
||||||
|
console.log(`found old index ${indexName}`);
|
||||||
|
const done2 = plugins.smartpromise.defer();
|
||||||
|
this.elasticSearchRef.client.indices.delete(
|
||||||
|
{
|
||||||
|
index: indexName,
|
||||||
|
},
|
||||||
|
(err2, response2) => {
|
||||||
|
if (err2) {
|
||||||
|
console.log(err2);
|
||||||
|
}
|
||||||
|
console.log(`deleted ${indexName}`);
|
||||||
|
done2.resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await done2.promise;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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>;
|
||||||
|
@ -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;
|
||||||
@ -56,15 +56,16 @@ export class ElasticSearch<T> {
|
|||||||
} else {
|
} else {
|
||||||
hostString = `http://${hostString}`;
|
hostString = `http://${hostString}`;
|
||||||
}
|
}
|
||||||
|
console.log(hostString);
|
||||||
return hostString;
|
return hostString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async log(logPackageArg: ILogPackage, scheduleOverwrite = false) {
|
public async log(logPackageArg: ILogPackage, scheduleOverwrite = false) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const indexToUse = `${this.indexPrefix}-${now.getFullYear()}.${('0' + (now.getMonth() + 1)).slice(-2)}.${(
|
const indexToUse = `${this.indexPrefix}-${now.getFullYear()}.${(
|
||||||
'0' + now.getDate()
|
'0' +
|
||||||
).slice(-2)}`;
|
(now.getMonth() + 1)
|
||||||
|
).slice(-2)}.${('0' + now.getDate()).slice(-2)}`;
|
||||||
|
|
||||||
if (this.elasticScheduler.docsScheduled && !scheduleOverwrite) {
|
if (this.elasticScheduler.docsScheduled && !scheduleOverwrite) {
|
||||||
this.elasticScheduler.scheduleDoc(logPackageArg);
|
this.elasticScheduler.scheduleDoc(logPackageArg);
|
||||||
@ -79,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) {
|
||||||
@ -94,11 +95,11 @@ 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);
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import * as elasticsearch from 'elasticsearch';
|
import * as elasticsearch from 'elasticsearch';
|
||||||
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smarttime from '@pushrocks/smarttime';
|
import * as smarttime from '@pushrocks/smarttime';
|
||||||
|
|
||||||
export { elasticsearch, smartdelay, smartlogInterfaces, smartpromise, smarttime };
|
export { elasticsearch, lik, smartdelay, smartlogInterfaces, smartpromise, smarttime };
|
||||||
|
@ -1 +1 @@
|
|||||||
export * from './elasticsearch.classes.elasticsearch';
|
export * from './elasticsearch.classes.elasticsearch.js';
|
||||||
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -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"
|
|
||||||
}
|
|
Reference in New Issue
Block a user