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

feat: add protocol generator #278

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/constants/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export enum DataTypeCategory {
}

export enum DataType {
PROTOCOL = "protocol",
MACADDRESS = "macaddress",
IPADDRESS = "ipaddress",
BIRTHDAY = "birthday",
Expand Down
19 changes: 19 additions & 0 deletions src/core/generators/Protocol/Protocol.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {GenerateResult} from "@/types/generator";
import {faker} from "@faker-js/faker";
// -------------------------------------------------------------------------------------------------------------
// types

// no types for now

// -------------------------------------------------------------------------------------------------------------
// generate method
export const generate = (options: any): GenerateResult => {
const value = faker.internet.protocol();
return {
value: value,
stringValue: value,
};
}

// -------------------------------------------------------------------------------------------------------------
// no options component
12 changes: 12 additions & 0 deletions src/core/generators/Protocol/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Generator} from "@/types/generator";
import {DataType, DataTypeCategory, ValueType} from "@/constants/enums";
import { generate} from "./Protocol";

export const ProtocolGenerator: Generator = {
type: DataType.PROTOCOL,
category: DataTypeCategory.NETWORK,
generate: generate,
defaultValueType: ValueType.STRING,
exampleLines: ["http", "https", "https"]
}

2 changes: 2 additions & 0 deletions src/core/generators/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {ProtocolGenerator} from "@/core/generators/Protocol";
import {MacAddressGenerator} from "@/core/generators/MacAddress";
import {IpAddressGenerator} from "@/core/generators/IpAddress";
import {BirthdayGenerator} from "@/core/generators/Birthday";
Expand Down Expand Up @@ -25,6 +26,7 @@ import {CompanyNameGenerator} from "@/core/generators/CompanyName";
import {DataType} from "@/constants/enums";

export const generators = {
[DataType.PROTOCOL]: ProtocolGenerator,
[DataType.MACADDRESS]: MacAddressGenerator,
[DataType.IPADDRESS]: IpAddressGenerator,
[DataType.BIRTHDAY]: BirthdayGenerator,
Expand Down
5 changes: 5 additions & 0 deletions src/locale/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export const en = {
// data types



// protocol
"dataType.protocol": "Internet Protocol",


// macaddress
"dataType.macaddress": "Mac Address",
"dataType.macaddress.format": "Separator",
Expand Down
4 changes: 4 additions & 0 deletions src/locale/translations/jaJP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export const jaJP = {
// data types



// protocol
"dataType.protocol": "Protocol",

// macaddress
"dataType.macaddress": "MacAddress",

Expand Down
5 changes: 5 additions & 0 deletions src/locale/translations/zhCN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export const zhCN = {
// data types



// protocol
"dataType.protocol": "网络协议",


// macaddress
"dataType.macaddress": "Mac地址",
"dataType.macaddress.format": "分隔符",
Expand Down