Skip to content

Commit

Permalink
feat(rules): Introduced the capability to import and export rules usi…
Browse files Browse the repository at this point in the history
…ng YAML. Additionally, included a rule glossary in the documentation.

* fix: Add toast notification with yaml import/export status

* refactor: Use the media type in encode & decode

* feat: add a rule glossary & delete duplicate radarr.filedate from constants
  • Loading branch information
jorenn92 authored Jan 12, 2024
1 parent 1e812f7 commit 97c52d4
Show file tree
Hide file tree
Showing 13 changed files with 1,245 additions and 93 deletions.
462 changes: 462 additions & 0 deletions docs/3-using-maintainerr/1-rules/Glossary.md

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"migration:generate": "ts-node node_modules/typeorm/cli.js migration:generate --dataSource ./datasource-config.ts -p"
},
"dependencies": {
"@headlessui/react": "1.7.12",
"@heroicons/react": "^1.0.6",
"@monaco-editor/react": "^4.6.0",
"@nestjs/common": "^10.2.7",
"@nestjs/core": "^10.3.0",
"@nestjs/platform-express": "^10.3.0",
Expand All @@ -50,6 +52,7 @@
"plex-api": "^5.3.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-toast-notifications": "^2.5.1",
"react-transition-group": "^4.4.5",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.5",
Expand All @@ -58,7 +61,8 @@
"swr": "^2.2.4",
"typeorm": "^0.3.17",
"web-push": "^3.6.6",
"xml2js": "^0.6.2"
"xml2js": "^0.6.2",
"yaml": "^2.3.4"
},
"devDependencies": {
"@automock/jest": "^1.4.0",
Expand Down Expand Up @@ -94,6 +98,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-next": "14.0.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"jsdoc": "^4.0.2",
Expand Down
8 changes: 8 additions & 0 deletions server/src/modules/api/plex-api/enums/plex-data-type-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ export enum EPlexDataType {
SEASONS = 3,
EPISODES = 4,
}

// EPlexDataType values as strings
export const PlexDataTypeStrings: string[] = [
'MOVIES',
'SHOWS',
'SEASONS',
'EPISODES',
];
84 changes: 46 additions & 38 deletions server/src/modules/rules/constants/rules.constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EPlexDataType } from '../../api/plex-api/enums/plex-data-type-enum';

export const enum RulePossibility {
export enum RulePossibility {
BIGGER,
SMALLER,
EQUALS,
Expand All @@ -15,7 +15,7 @@ export const enum RulePossibility {
NOT_CONTAINS_PARTIAL,
}

export const enum RuleOperators {
export enum RuleOperators {
AND,
OR,
}
Expand All @@ -41,37 +41,51 @@ export const enum MediaType {
}

export class RuleType {
static readonly NUMBER = new RuleType('0', [
RulePossibility.BIGGER,
RulePossibility.SMALLER,
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
RulePossibility.CONTAINS,
RulePossibility.NOT_CONTAINS,
]);
static readonly DATE = new RuleType('1', [
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
RulePossibility.BEFORE,
RulePossibility.AFTER,
RulePossibility.IN_LAST,
RulePossibility.IN_NEXT,
]);
static readonly TEXT = new RuleType('2', [
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
RulePossibility.CONTAINS,
RulePossibility.NOT_CONTAINS,
RulePossibility.CONTAINS_PARTIAL,
RulePossibility.NOT_CONTAINS_PARTIAL,
]);
static readonly BOOL = new RuleType('3', [
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
]);
private constructor(
static readonly NUMBER = new RuleType(
'0',
[
RulePossibility.BIGGER,
RulePossibility.SMALLER,
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
RulePossibility.CONTAINS,
RulePossibility.NOT_CONTAINS,
],
'number',
);
static readonly DATE = new RuleType(
'1',
[
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
RulePossibility.BEFORE,
RulePossibility.AFTER,
RulePossibility.IN_LAST,
RulePossibility.IN_NEXT,
],
'date',
);
static readonly TEXT = new RuleType(
'2',
[
RulePossibility.EQUALS,
RulePossibility.NOT_EQUALS,
RulePossibility.CONTAINS,
RulePossibility.NOT_CONTAINS,
RulePossibility.CONTAINS_PARTIAL,
RulePossibility.NOT_CONTAINS_PARTIAL,
],
'text',
);
static readonly BOOL = new RuleType(
'3',
[RulePossibility.EQUALS, RulePossibility.NOT_EQUALS],
'boolean',
);
public constructor(
private readonly key: string,
public readonly possibilities: number[],
public readonly humanName: string,
) {}
toString() {
return this.key;
Expand Down Expand Up @@ -300,13 +314,7 @@ export class RuleConstants {
mediaType: MediaType.MOVIE,
type: RuleType.DATE,
} as Property,
{
id: 1,
name: 'fileDate',
humanName: 'Date file downloaded',
mediaType: MediaType.MOVIE,
type: RuleType.DATE,
} as Property,
// Don't use ID 1, It was once used for an old rule value. Changing the id's messes up existing rules.
{
id: 2,
name: 'tags',
Expand Down
1 change: 1 addition & 0 deletions server/src/modules/rules/dtos/rule.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export class RuleDto {
firstVal: [number, number];
lastVal?: [number, number];
customVal?: { ruleTypeId: number; value: string };
section: number;
}
Loading

0 comments on commit 97c52d4

Please sign in to comment.