fix(core): update

This commit is contained in:
Philipp Kunz 2023-07-12 19:40:41 +02:00
parent 61fcd5b992
commit a58c2881b9
21 changed files with 2181 additions and 28432 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

24
.vscode/launch.json vendored
View File

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

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "smartobject",
"shortDescription": "work with objects",
"description": "work with objects",
"npmPackagename": "@push.rocks/smartobject",
"license": "MIT",
"projectDomain": "push.rocks"

27343
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,19 +10,19 @@
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
"format": "(gitzone format)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.29",
"@gitzone/tstest": "^1.0.64",
"@pushrocks/tapbundle": "^4.0.8",
"@types/node": "^17.0.21",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.74",
"@push.rocks/tapbundle": "^5.0.8",
"@types/node": "^17.0.45"
},
"dependencies": {
"fast-deep-equal": "^3.1.3",
"minimatch": "^5.0.1"
"minimatch": "^5.1.6"
},
"browserslist": [
"last 1 chrome versions"
@ -38,5 +38,6 @@
"cli.js",
"npmextra.json",
"readme.md"
]
],
"type": "module"
}

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,26 @@
# @pushrocks/smartobject
# @push.rocks/smartobject
work with objects
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartobject)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartobject)
* [github.com (source mirror)](https://github.com/pushrocks/smartobject)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartobject/)
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartobject)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartobject)
* [github.com (source mirror)](https://github.com/push.rocks/smartobject)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartobject/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartobject/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartobject/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartobject)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartobject)](https://lossless.cloud)
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartobject/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartobject/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartobject)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartobject)](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/@pushrocks/smartobject)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartobject)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartobject)](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)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartobject)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartobject)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartobject)](https://lossless.cloud)
## 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.
> 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)
[![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 * as smartobject from '../ts/index';
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartobject from '../ts/index.js';
tap.test('first test', async () => {
const result = smartobject.compareObjects(
@ -28,7 +28,7 @@ tap.test('childObject should now be in parentObject', async () => {
tap.test('should be able to deepAdd an childParam', async () => {
const parentObject = {
hello: 'there'
hello: 'there',
};
const parentObject2 = smartobject.smartAdd(parentObject, 'wow.za', 'yes');
console.log(parentObject2);
@ -39,9 +39,9 @@ tap.test('should be able to deep get an item', async () => {
const testObject = {
hey: {
there: {
so: 'cool'
}
}
so: 'cool',
},
},
};
const item = smartobject.smartGet(testObject, 'hey.there.so');
@ -52,11 +52,11 @@ tap.test('should call properties for minimatched properties', async () => {
let testObject = {
matchedOne: 'Hey!',
matchedTwo: 'this works!',
notmatched: 'NOT!'
notmatched: 'NOT!',
};
const matchedStrings: string[] = [];
await smartobject.forEachMinimatch(testObject, 'matched*', matchedProperty => {
await smartobject.forEachMinimatch(testObject, 'matched*', (matchedProperty) => {
matchedStrings.push(matchedProperty);
console.log(matchedProperty);
});

View File

@ -1,5 +1,5 @@
import { expect, expectAsync, tap} from '@pushrocks/tapbundle';
import * as smartobject from '../ts';
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as smartobject from '../ts/index.js';
let testSmartobject: smartobject.SmartObject;
@ -10,15 +10,15 @@ tap.test('should create a smartobject', async () => {
yeah: 'so deep',
evendeeper: {
sodeep: 2,
deepArray: ['one array', 'two array']
}
}
}
deepArray: ['one array', 'two array'],
},
},
};
testSmartobject = new smartobject.SmartObject(originalObject);
testSmartobject.addValueAtFlatPathString('deep.nice', 'yeah that has been added');
console.log(testSmartobject.originalObject);
console.log(testSmartobject.toFlatObject())
console.log(testSmartobject.toFlatObject());
expect(testSmartobject.getValueAtFlatPathString('deep.yeah')).toEqual('so deep');
});
tap.start();
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartobject',
version: '1.0.11',
description: 'work with objects'
}

View File

@ -1,6 +1,6 @@
import * as plugins from './smartobject.plugins';
import * as plugins from './smartobject.plugins.js';
const fastDeepEqual = plugins.fastDeepEqual;
export { fastDeepEqual };
export * from './smartobject.classes.smartobject';
export * from './tools';
export * from './smartobject.classes.smartobject.js';
export * from './tools/index.js';

View File

@ -1,10 +1,9 @@
import * as tools from './tools';
import * as tools from './tools/index.js';
/**
* a smartobject that simplifies accessing objects
*/
export class SmartObject {
// instance
public originalObject: object;
constructor(originalObjectArg: object) {
@ -22,4 +21,4 @@ export class SmartObject {
public toFlatObject() {
return tools.toFlatObject(this.originalObject);
}
}
}

View File

@ -1,6 +1,6 @@
// thirdparty scope
// tslint:disable-next-line: no-submodule-imports
import fastDeepEqual from 'fast-deep-equal/es6';
import fastDeepEqual from 'fast-deep-equal/es6/index.js';
import minimatch from 'minimatch';
export { fastDeepEqual, minimatch };

View File

@ -1,4 +1,4 @@
import * as plugins from '../smartobject.plugins';
import * as plugins from '../smartobject.plugins.js';
export interface IObjectCompareResult {
presentInBothProperties: string[];
@ -27,41 +27,44 @@ export const compareObjects = (
const allProperties = Object.keys(referenceObjectArg).concat(Object.keys(comparisonObjectArg));
for (const currentProperty of allProperties) {
// lets find presentInBothProperties
if (referenceObjectArg[ currentProperty ] && comparisonObjectArg[ currentProperty ]) {
if (referenceObjectArg[currentProperty] && comparisonObjectArg[currentProperty]) {
returnComparisonObject.presentInBothProperties.push(currentProperty);
}
// lets find missingProperties
if (referenceObjectArg[ currentProperty ] && !comparisonObjectArg[ currentProperty ]) {
if (referenceObjectArg[currentProperty] && !comparisonObjectArg[currentProperty]) {
returnComparisonObject.missingProperties.push(currentProperty);
}
// lets find additionalProperties
if (!referenceObjectArg[ currentProperty ] && comparisonObjectArg[ currentProperty ]) {
if (!referenceObjectArg[currentProperty] && comparisonObjectArg[currentProperty]) {
returnComparisonObject.additionalProperties.push(currentProperty);
}
// lets find nulledProperties
if (comparisonObjectArg[ currentProperty ] === null) {
if (comparisonObjectArg[currentProperty] === null) {
returnComparisonObject.nulledProperties.push(currentProperty);
}
// lets find undefinedProperties
if (comparisonObjectArg[ currentProperty ] === undefined) {
if (comparisonObjectArg[currentProperty] === undefined) {
returnComparisonObject.undefinedProperties.push(currentProperty);
}
// lets find divergingProperties
if (
JSON.stringify(referenceObjectArg[ currentProperty ]) !==
JSON.stringify(comparisonObjectArg[ currentProperty ])
JSON.stringify(referenceObjectArg[currentProperty]) !==
JSON.stringify(comparisonObjectArg[currentProperty])
) {
returnComparisonObject.divergingProperties.push(currentProperty);
}
// lets find equalProperties
if (
plugins.fastDeepEqual(referenceObjectArg[ currentProperty ], comparisonObjectArg[ currentProperty ])
plugins.fastDeepEqual(
referenceObjectArg[currentProperty],
comparisonObjectArg[currentProperty]
)
) {
returnComparisonObject.equalProperties.push(currentProperty);
}
@ -71,9 +74,12 @@ export const compareObjects = (
const onlyUnique = (value: any, index: number, self: Array<any>) => {
return self.indexOf(value) === index;
};
const uniqueArray = returnComparisonObject[ currentProperty as keyof (typeof returnComparisonObject) ].filter(onlyUnique);
returnComparisonObject[ currentProperty as keyof (typeof returnComparisonObject) ] = uniqueArray;
const uniqueArray =
returnComparisonObject[currentProperty as keyof typeof returnComparisonObject].filter(
onlyUnique
);
returnComparisonObject[currentProperty as keyof typeof returnComparisonObject] = uniqueArray;
}
return returnComparisonObject;
};
};

View File

@ -1,4 +1,4 @@
import * as plugins from '../smartobject.plugins';
import * as plugins from '../smartobject.plugins.js';
/**
* checks if an object has a parameter with a given key name, returns true if yes.
@ -6,9 +6,9 @@ import * as plugins from '../smartobject.plugins';
* @param childParam
* @returns {boolean}
*/
export let exists = (parentObject: object, childParam: string): boolean => {
export let exists = (parentObject: object, childParam: string): boolean => {
if (parentObject.hasOwnProperty(childParam)) {
return true;
}
return false;
};
};

View File

@ -1,4 +1,4 @@
import * as plugins from '../smartobject.plugins';
import * as plugins from '../smartobject.plugins.js';
/**
* runs a function for all properties of an object whose key matches a regex expression
@ -6,12 +6,16 @@ import * as plugins from '../smartobject.plugins';
* @param wildcardArg the rege expression to match the property keys against
* @param callbackArg the function to run with those properties
*/
export let forEachMinimatch = async (parentObjectArg: any, wildcardArg: string, callbackArg: (matchedArg: string) => void) => {
export let forEachMinimatch = async (
parentObjectArg: any,
wildcardArg: string,
callbackArg: (matchedArg: string) => void
) => {
let propertyNames = Object.getOwnPropertyNames(parentObjectArg);
let propertyNamesMatched = propertyNames.filter(propertyNameArg => {
let propertyNamesMatched = propertyNames.filter((propertyNameArg) => {
return plugins.minimatch(propertyNameArg, wildcardArg);
});
for (let propertyNameArg of propertyNamesMatched) {
await callbackArg(parentObjectArg[propertyNameArg]);
}
};
};

View File

@ -1,5 +1,5 @@
export * from './compareobjects';
export * from './exists';
export * from './foreachminimatch';
export * from './smart_add_get';
export * from './toFlatObject';
export * from './compareobjects.js';
export * from './exists.js';
export * from './foreachminimatch.js';
export * from './smart_add_get.js';
export * from './toFlatObject.js';

View File

@ -1,4 +1,4 @@
import * as plugins from '../smartobject.plugins';
import * as plugins from '../smartobject.plugins.js';
/**
* adds an object to the parent object if it doesn't exists
@ -7,7 +7,7 @@ import * as plugins from '../smartobject.plugins';
* @param logBool
* @returns {boolean}
*/
export const smartAdd = (
export const smartAdd = (
parentObject: object,
childParam: string,
valueArg: any = {},
@ -17,7 +17,7 @@ import * as plugins from '../smartobject.plugins';
): typeof parentObject & any => {
optionsArg = {
interpretDotsAsLevel: true,
...optionsArg
...optionsArg,
};
let paramLevels: string[];
@ -70,7 +70,7 @@ export const smartGet = <T>(
): T => {
optionsArg = {
interpretDotsAsLevel: true,
...optionsArg
...optionsArg,
};
let paramLevels: string[];
@ -89,4 +89,4 @@ export const smartGet = <T>(
}
}
return referencePointer as T;
};
};

View File

@ -1,21 +1,29 @@
export const toFlatObject = (objectArg: object) => {
const returnObject: {[key: string]: any} = {};
const extractLayer = (subObject: {[key: string]: any}, pathArg: string, loopProtection: object[]) => {
const returnObject: { [key: string]: any } = {};
const extractLayer = (
subObject: { [key: string]: any },
pathArg: string,
loopProtection: object[]
) => {
if (loopProtection.indexOf(subObject) > -1) {
return;
}
if (subObject)
for (const key of Object.keys(subObject)) {
let localPathArg = pathArg;
if (typeof subObject[ key ] === 'object' && !(subObject[ key ] instanceof Array)) {
if (typeof subObject[key] === 'object' && !(subObject[key] instanceof Array)) {
const newLoopbackArray = loopProtection.slice();
newLoopbackArray.push(subObject);
extractLayer(subObject[ key ], localPathArg ? localPathArg += `.${key}` : key, newLoopbackArray);
extractLayer(
subObject[key],
localPathArg ? (localPathArg += `.${key}`) : key,
newLoopbackArray
);
} else {
returnObject[localPathArg ? localPathArg += `.${key}` : key] = subObject[key];
returnObject[localPathArg ? (localPathArg += `.${key}`) : key] = subObject[key];
}
}
}
};
extractLayer(objectArg, '', []);
return returnObject;
}
};

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,
}
}