Skip to content

Commit

Permalink
Merge pull request #45 from Cyber4All/main
Browse files Browse the repository at this point in the history
Main -> Releases
  • Loading branch information
pzalep1 authored Nov 6, 2024
2 parents cb8ed9b + e397b1f commit 268ea8e
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 41 deletions.
26 changes: 17 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defaults: &defaults
- image: cimg/node:lts

orbs:
cyber4all: cyber4all/orb@1
cyber4all: cyber4all/orb@2.1.8

jobs:
build:
Expand All @@ -25,12 +25,14 @@ jobs:
- run:
name: Run tests
command: npm test
- store_test_results:
path: ./reports/junit.xml
- persist_to_workspace:
root: ./
paths:
- ./package.json
- ./lib

publish:
<<: *defaults
steps:
Expand All @@ -50,15 +52,21 @@ workflows:
filters:
branches:
ignore: /releases/

build-test-and-publish:
when:
equal: [releases, << pipeline.git.branch >>]
jobs:
- build:
filters:
branches:
only: /releases/
- build

- cyber4all/release:
requires:
- build
context: [Github]
tag: "$(jq -r '.version' package.json)"

- publish:
requires:
- build
filters:
branches:
only: /releases/
- cyber4all/release

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
/lib
/coverage
/coverage
/reports
81 changes: 79 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "competency-acl",
"version": "0.9.0",
"version": "0.10.0",
"description": "",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand All @@ -26,6 +26,7 @@
"eslint": "^8.19.0",
"husky": "^8.0.1",
"jest": "^28.1.2",
"jest-junit": "^16.0.0",
"ts-jest": "^28.0.5",
"typescript": "^4.7.4"
},
Expand Down
3 changes: 2 additions & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export const basic_user_permissions = [
competencyAcl.condition.updateChangesRequested,
competencyAcl.degree.updateChangesRequested,
competencyAcl.documentation.updateChangesRequested,
competencyAcl.notes.updateChangesRequested
competencyAcl.notes.updateChangesRequested,
competencyAcl.lifecycle.reviseDeclined
];

export const ADMIN_VIEWER = [
Expand Down
88 changes: 84 additions & 4 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,88 @@

export interface ValidationErrorOptions {
/**
* The shape ID name of the exception.
*/
readonly name: string;
/**
* Whether the client or server are at fault.
*/
readonly $fault: "client" | "server";

/**
* The error message.
*/
readonly message: string;
}

/**
* @public
*
* Base error class for the exceptions from the validation acl package.
*/
export class ValidationError extends Error{
readonly $fault: "client" | "server";
constructor(options: ValidationErrorOptions) {
super(options.message);
this.name = options.name;
this.$fault = options.$fault;
}
}

// The following example demonstrates why it is beneficial to use a custom error class
// rather than using the built-in Error class and check for the error name.
// https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/

/**
* The action did not match the REGEX pattern to validate the formatting of the ACL string.
*
* @public
*/
export class ActionMismatchError extends ValidationError {
/**
* @internal
*/
constructor(message?: string) {
super({
name: "ActionMismatchError",
$fault: "client",
message,
});
}
}

/**
* The service defined in the ACL string is not supported by the package.
*
* @public
*/
export class ServiceNotSupportedError extends ValidationError {
/**
* @internal
*/
constructor(message?: string) {
super({
name: "ServiceNotSupportedError",
$fault: "client",
message,
});
}
}

/**
* Error thrown when there is a validation issue with acls
* The action being validated is not supported by the package.
*
* @public
*/
export class ValidationError extends Error {
constructor(msg: string) {
super(msg);
export class ActionNotSupportedError extends ValidationError {
/**
* @internal
*/
constructor(message?: string) {
super({
name: "ActionNotSupportedError",
$fault: "client",
message,
});
}
}
Loading

0 comments on commit 268ea8e

Please sign in to comment.