Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: New package JSON hash added #186

Open
wants to merge 54 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
607bbac
Feat!: added support for more complex filters
Akalanka47000 Mar 25, 2024
acb7572
Merge pull request #168 from sliit-foss/feat/increase-filter-query-fi…
Akalanka47000 Mar 25, 2024
6269a04
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Mar 25, 2024
00260c1
Fix(mongoose-audit): exception when change is null
Akalanka47000 Apr 9, 2024
3f4071e
Merge pull request #171 from sliit-foss/fix/mongoose-audit-exception
Akalanka47000 Apr 9, 2024
dab0359
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Apr 9, 2024
05abfbc
Chore(git): add non-pnpm lock files to gitignore
ThulinaWickramasinghe Apr 12, 2024
d857c8a
Chore(git-hooks): remove husky
ThulinaWickramasinghe Apr 12, 2024
4684693
Chore(git-hooks): setup lefthook
ThulinaWickramasinghe Apr 12, 2024
661eeb0
Merge pull request #1 from ThulinaWickramasinghe/feat/integrate-lefthook
ThulinaWickramasinghe Apr 12, 2024
34dd036
Fix: address PR comments
ThulinaWickramasinghe Apr 12, 2024
3964d52
Fix: add cache flag for eslint
ThulinaWickramasinghe Apr 12, 2024
3b32d86
Merge pull request #2 from ThulinaWickramasinghe/feat/integrate-lefthook
ThulinaWickramasinghe Apr 12, 2024
e2f4d01
Fix(lefthook): change linting command from 'code' to 'lint'
ThulinaWickramasinghe Apr 13, 2024
b5d79d1
Chore(deps): update prettier version
ThulinaWickramasinghe Apr 13, 2024
8e7e60f
Merge pull request #3 from ThulinaWickramasinghe/feat/integrate-lefthook
ThulinaWickramasinghe Apr 13, 2024
1bd33c9
Chore: updated lockfile
Akalanka47000 Apr 14, 2024
f297337
Chore: updated lefthook scripts
Akalanka47000 Apr 14, 2024
222c131
Merge pull request #173 from ThulinaWickramasinghe/main
Akalanka47000 Apr 14, 2024
9d6d920
feat(actions-exec-wrapper): add type support
ThulinaWickramasinghe Apr 14, 2024
61566aa
Docs: update require statements for default exports
ThulinaWickramasinghe Apr 14, 2024
f86e4e5
Fix(actions-exec-wrapper): link types in package.json
ThulinaWickramasinghe Apr 14, 2024
79d2024
Merge pull request #176 from sliit-foss/fix/default-export-require-docs
Akalanka47000 Apr 14, 2024
5aaa0aa
Merge pull request #175 from sliit-foss/feat/actions-exec-type-support
Akalanka47000 Apr 14, 2024
55802c4
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Apr 14, 2024
fad5b35
Fix(filter-query): added automatic parsing of object ids
Akalanka47000 Apr 14, 2024
e948d14
Merge pull request #177 from sliit-foss/fix/filter-query-object-id-pa…
Akalanka47000 Apr 14, 2024
ab55e85
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Apr 14, 2024
44c39f2
Fix(mongoose-filter-query): incorrect parsing of regexp
Akalanka47000 Apr 16, 2024
3ad4a5b
Merge pull request #179 from sliit-foss/fix/filter-query-regexp-parsing
Akalanka47000 Apr 16, 2024
6c456fa
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Apr 16, 2024
f213613
Fix(mongoose-filter-query): default boolean parsing
Akalanka47000 Apr 20, 2024
2e53191
Fix: erroneus test
Akalanka47000 Apr 20, 2024
4371256
Merge pull request #180 from sliit-foss/fix/filter-query-default-bool…
Akalanka47000 Apr 20, 2024
8730510
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Apr 20, 2024
9878cc8
Feat(filter-query): added support for regexp modifiers
Akalanka47000 May 8, 2024
1e1c0bc
Merge pull request #181 from sliit-foss/feat/filter-query-regex-modif…
Akalanka47000 May 8, 2024
1547432
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] May 8, 2024
7338f24
Feat(service-connector): added support for retrying
Akalanka47000 May 10, 2024
c2558e6
Merge pull request #182 from sliit-foss/feat/service-connector-retry
Akalanka47000 May 10, 2024
c8651dd
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] May 10, 2024
d6efc2a
Fix(filter-query): in & nin object id parse
Akalanka47000 May 19, 2024
e067694
Merge pull request #183 from sliit-foss/fix/filter-query-object-id-pa…
Akalanka47000 May 19, 2024
5cd0edd
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] May 19, 2024
9b3d674
Feat!(filter-query): added prepaginate flag to query
Akalanka47000 Jun 22, 2024
a8f7548
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Jun 22, 2024
bdaf418
Feat!: added aggregate paginate plugin
Akalanka47000 Jun 22, 2024
af60063
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] Jun 22, 2024
042633e
Style: remove unwanted .gitkeep file
ThulinaWickramasinghe Jun 23, 2024
955db95
Fix: remove fixed pnpm version
ThulinaWickramasinghe Jun 23, 2024
e57fc53
Feat(json-hash): add new package json-hash
ThulinaWickramasinghe Jun 23, 2024
130c06f
Style(json-hash): remove commented code
ThulinaWickramasinghe Jun 23, 2024
1e35f75
Refactor(json-hash): remove redundant code
ThulinaWickramasinghe Jun 23, 2024
f0e5f8c
Test(json-hash): remove browser tests, fix async issue and add test f…
ThulinaWickramasinghe Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .github/actions/.gitkeep
Empty file.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ yarn-error.log*

.vscode

.eslintcache

packages/automatic-versioning/tmp

p*/**/dist/
Expand All @@ -51,4 +53,8 @@ p*/**/jest.config.js
p*/**/LICENSE

p*/**/node_modules/
p*/**/logs/.turbo
p*/**/logs/.turbo

#non-pnpm lock files
yarn.lock
package-lock.json
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"printWidth": 120,
"trailingComma": "none"
"trailingComma": "none",
"semi": true,
"quoteProps": "consistent"
}
14 changes: 14 additions & 0 deletions lefthook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pre-commit:
parallel: true
commands:
format:
glob: "*.{css,html,json,less,md,scss,yaml,yml,js,jsx,ts,tsx}"
run: npx prettier --write --cache {staged_files} && git add {staged_files}
lint:
glob: "*.{js,jsx,ts,tsx}"
run: npm run lint && git add {staged_files}

commit-msg:
commands:
commitlint:
run: npx commitlint --edit --color
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dev": "turbo run dev",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache",
"prepare": "husky install",
"prepare": "lefthook install",
"release": "turbo run release",
"submodules:load": "git submodule update --init",
"submodules:sync": "git submodule update --recursive --remote",
Expand All @@ -31,17 +31,17 @@
"turbo": "1.7.3"
},
"devDependencies": {
"@commitlint/cli": "17.4.2",
"@commitlint/config-conventional": "17.4.2",
"@commitlint/cli": "19.2.1",
"@commitlint/config-conventional": "19.1.0",
"@sliit-foss/eslint-config-internal": "workspace:*",
"eslint": "8.33.0",
"eslint-config-turbo": "0.0.7",
"husky": "8.0.3",
"lefthook": "1.6.10",
"nodemon": "2.0.21",
"prettier": "2.8.3"
"prettier": "3.2.5"
},
"engines": {
"node": ">=14.0.0"
},
"packageManager": "[email protected]"
"node": ">=14.0.0",
"pnpm": ">=7.5.0"
}
}
65 changes: 33 additions & 32 deletions packages/actions-exec-wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
{
"name": "@sliit-foss/actions-exec-wrapper",
"version": "1.1.1",
"description": "A wrapper around the @actions/exec module which promisifies the console output of a command",
"main": "dist/index.js",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/actions-exec-wrapper",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"dependencies": {
"@actions/exec": "1.1.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"keywords": [
"@actions/exec",
"actions-exec-wrapper",
"console-output"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/actions-exec-wrapper/readme.md"
}
{
"name": "@sliit-foss/actions-exec-wrapper",
"version": "1.1.2",
"description": "A wrapper around the @actions/exec module which promisifies the console output of a command",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/actions-exec-wrapper",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"dependencies": {
"@actions/exec": "1.1.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"keywords": [
"@actions/exec",
"actions-exec-wrapper",
"console-output"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/actions-exec-wrapper/readme.md"
}
14 changes: 14 additions & 0 deletions packages/actions-exec-wrapper/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @description Runs a given CLI command and return's it's standard output(stdout)
* @param command The command to be run
* @returns Command output wrapped around a promise
* @example
* exec("npm --version")
* .then((result) => {
* console.log(result);
* })
* .catch((error) => {
* console.log(error);
* });
*/
export default function execute(command: string): Promise<string>;
2 changes: 1 addition & 1 deletion packages/http-logger/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ yarn add @sliit-foss/http-logger

```js
# using require
const httpLogger = require("@sliit-foss/http-logger");
const httpLogger = require("@sliit-foss/http-logger").default;

# using import
import httpLogger from "@sliit-foss/http-logger";
Expand Down
35 changes: 35 additions & 0 deletions packages/json-hash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "json-hash",
"version": "1.0.0",
"description": "Hash JS objects reliablly on both Node.js and browser",
"main": "dist/index.js",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/json-hash",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"dependencies": {
"json-stable-stringify": "1.1.1"
},
"devDependencies": {
"lodash": "4.17.10"
},
"keywords": [
"json",
"hash",
"hashing",
"object-hash"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
}
}
18 changes: 18 additions & 0 deletions packages/json-hash/src/algorthms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const algos = {
"SHA-1": "sha1",
"SHA-256": "sha256",
"SHA-384": "sha384",
"SHA-512": "sha512"
};

export const getNodeJSAlgoName = (algorithm) => {
return algos[algorithm];
};

export const isAvailableAlgo = (algorithm) => {
if (Object.prototype.hasOwnProperty.call(algos, algorithm)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use algos[algorithm] here instead right, will be more readable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return true;
}

return false;
};
35 changes: 35 additions & 0 deletions packages/json-hash/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getNodeJSAlgoName, isAvailableAlgo } from "./algorithms.js";

export const computeHash = async (obj, { algorithm = "SHA-1", sort = false }) => {
if (!isAvailableAlgo(algorithm)) {
throw new Error("Provided algorithm is not available");
}

if (typeof obj !== "string") {
if (sort) {
const { default: stringify } = await import("json-stable-stringify");
obj = stringify(obj);
} else {
obj = JSON.stringify(obj);
}
}

// For browser
// eslint-disable-next-line no-undef
if (typeof window !== "undefined" && window.crypto && window.crypto.subtle) {
const msgUint8 = new TextEncoder().encode(obj); // encode as (utf-8) Uint8Array

// eslint-disable-next-line no-undef
const hashBuffer = await window.crypto.subtle.digest(algorithm, msgUint8); // hash data
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join(""); // convert bytes to hex string
return hashHex;
}

// For Node.js
if (typeof global !== "undefined" && global.crypto) {
const { createHash } = await import("crypto");
const hash = createHash(getNodeJSAlgoName(algorithm)).update(obj).digest("hex");
return hash;
}
};
Loading
Loading