@gent-js/gent 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/generated/packageEnv.d.ts +5 -0
- package/dist/generated/packageEnv.js +7 -0
- package/dist/generated/packageEnv.js.map +1 -0
- package/dist/src/buildDocumentFromJsonTemplate.d.ts +3 -0
- package/dist/src/buildDocumentFromJsonTemplate.js +27 -0
- package/dist/src/buildDocumentFromJsonTemplate.js.map +1 -0
- package/dist/src/buildDocumentFromTextTemplate.d.ts +3 -0
- package/dist/src/buildDocumentFromTextTemplate.js +27 -0
- package/dist/src/buildDocumentFromTextTemplate.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +103 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/cliConsts.d.ts +3 -0
- package/dist/src/cliConsts.js +3 -0
- package/dist/src/cliConsts.js.map +1 -0
- package/dist/src/cliTypes.d.ts +7 -0
- package/dist/src/cliTypes.js +2 -0
- package/dist/src/cliTypes.js.map +1 -0
- package/dist/src/command/commandManager/commandManager.d.ts +7 -0
- package/dist/src/command/commandManager/commandManager.js +83 -0
- package/dist/src/command/commandManager/commandManager.js.map +1 -0
- package/dist/src/command/commandParser/commandParser.d.ts +11 -0
- package/dist/src/command/commandParser/commandParser.js +90 -0
- package/dist/src/command/commandParser/commandParser.js.map +1 -0
- package/dist/src/command/commandParser/parseCommand.d.ts +2 -0
- package/dist/src/command/commandParser/parseCommand.js +19 -0
- package/dist/src/command/commandParser/parseCommand.js.map +1 -0
- package/dist/src/command/commandParser/types.d.ts +33 -0
- package/dist/src/command/commandParser/types.js +2 -0
- package/dist/src/command/commandParser/types.js.map +1 -0
- package/dist/src/command/commandParser/visitor.d.ts +2 -0
- package/dist/src/command/commandParser/visitor.js +160 -0
- package/dist/src/command/commandParser/visitor.js.map +1 -0
- package/dist/src/command/commands/date/anytime.d.ts +2 -0
- package/dist/src/command/commands/date/anytime.js +8 -0
- package/dist/src/command/commands/date/anytime.js.map +1 -0
- package/dist/src/command/commands/date/timestamp.d.ts +2 -0
- package/dist/src/command/commands/date/timestamp.js +71 -0
- package/dist/src/command/commands/date/timestamp.js.map +1 -0
- package/dist/src/command/commands/finance/creditCardCVV.d.ts +2 -0
- package/dist/src/command/commands/finance/creditCardCVV.js +8 -0
- package/dist/src/command/commands/finance/creditCardCVV.js.map +1 -0
- package/dist/src/command/commands/finance/creditCardIssuer.d.ts +2 -0
- package/dist/src/command/commands/finance/creditCardIssuer.js +8 -0
- package/dist/src/command/commands/finance/creditCardIssuer.js.map +1 -0
- package/dist/src/command/commands/finance/creditCardNumber.d.ts +6 -0
- package/dist/src/command/commands/finance/creditCardNumber.js +12 -0
- package/dist/src/command/commands/finance/creditCardNumber.js.map +1 -0
- package/dist/src/command/commands/hacker/hacker.noun.d.ts +2 -0
- package/dist/src/command/commands/hacker/hacker.noun.js +8 -0
- package/dist/src/command/commands/hacker/hacker.noun.js.map +1 -0
- package/dist/src/command/commands/index.d.ts +1 -0
- package/dist/src/command/commands/index.js +95 -0
- package/dist/src/command/commands/index.js.map +1 -0
- package/dist/src/command/commands/internet/domainName.d.ts +2 -0
- package/dist/src/command/commands/internet/domainName.js +8 -0
- package/dist/src/command/commands/internet/domainName.js.map +1 -0
- package/dist/src/command/commands/internet/email.d.ts +2 -0
- package/dist/src/command/commands/internet/email.js +8 -0
- package/dist/src/command/commands/internet/email.js.map +1 -0
- package/dist/src/command/commands/internet/httpMethod.d.ts +2 -0
- package/dist/src/command/commands/internet/httpMethod.js +8 -0
- package/dist/src/command/commands/internet/httpMethod.js.map +1 -0
- package/dist/src/command/commands/internet/httpStatusCode.d.ts +2 -0
- package/dist/src/command/commands/internet/httpStatusCode.js +8 -0
- package/dist/src/command/commands/internet/httpStatusCode.js.map +1 -0
- package/dist/src/command/commands/internet/ip.d.ts +2 -0
- package/dist/src/command/commands/internet/ip.js +8 -0
- package/dist/src/command/commands/internet/ip.js.map +1 -0
- package/dist/src/command/commands/internet/ipv4.d.ts +2 -0
- package/dist/src/command/commands/internet/ipv4.js +8 -0
- package/dist/src/command/commands/internet/ipv4.js.map +1 -0
- package/dist/src/command/commands/internet/ipv6.d.ts +2 -0
- package/dist/src/command/commands/internet/ipv6.js +8 -0
- package/dist/src/command/commands/internet/ipv6.js.map +1 -0
- package/dist/src/command/commands/internet/mac.d.ts +2 -0
- package/dist/src/command/commands/internet/mac.js +8 -0
- package/dist/src/command/commands/internet/mac.js.map +1 -0
- package/dist/src/command/commands/internet/password.d.ts +6 -0
- package/dist/src/command/commands/internet/password.js +12 -0
- package/dist/src/command/commands/internet/password.js.map +1 -0
- package/dist/src/command/commands/internet/pri.d.ts +2 -0
- package/dist/src/command/commands/internet/pri.js +13 -0
- package/dist/src/command/commands/internet/pri.js.map +1 -0
- package/dist/src/command/commands/internet/url.d.ts +2 -0
- package/dist/src/command/commands/internet/url.js +8 -0
- package/dist/src/command/commands/internet/url.js.map +1 -0
- package/dist/src/command/commands/internet/userAgent.d.ts +2 -0
- package/dist/src/command/commands/internet/userAgent.js +8 -0
- package/dist/src/command/commands/internet/userAgent.js.map +1 -0
- package/dist/src/command/commands/internet/username.d.ts +2 -0
- package/dist/src/command/commands/internet/username.js +8 -0
- package/dist/src/command/commands/internet/username.js.map +1 -0
- package/dist/src/command/commands/location/country.d.ts +2 -0
- package/dist/src/command/commands/location/country.js +8 -0
- package/dist/src/command/commands/location/country.js.map +1 -0
- package/dist/src/command/commands/location/countryCode.d.ts +7 -0
- package/dist/src/command/commands/location/countryCode.js +13 -0
- package/dist/src/command/commands/location/countryCode.js.map +1 -0
- package/dist/src/command/commands/location/timeZone.d.ts +2 -0
- package/dist/src/command/commands/location/timeZone.js +8 -0
- package/dist/src/command/commands/location/timeZone.js.map +1 -0
- package/dist/src/command/commands/lorem/lorem.sentences.d.ts +7 -0
- package/dist/src/command/commands/lorem/lorem.sentences.js +14 -0
- package/dist/src/command/commands/lorem/lorem.sentences.js.map +1 -0
- package/dist/src/command/commands/number/int.d.ts +7 -0
- package/dist/src/command/commands/number/int.js +13 -0
- package/dist/src/command/commands/number/int.js.map +1 -0
- package/dist/src/command/commands/number/pid.d.ts +2 -0
- package/dist/src/command/commands/number/pid.js +14 -0
- package/dist/src/command/commands/number/pid.js.map +1 -0
- package/dist/src/command/commands/others/length.d.ts +7 -0
- package/dist/src/command/commands/others/length.js +13 -0
- package/dist/src/command/commands/others/length.js.map +1 -0
- package/dist/src/command/commands/phone/imei.d.ts +2 -0
- package/dist/src/command/commands/phone/imei.js +8 -0
- package/dist/src/command/commands/phone/imei.js.map +1 -0
- package/dist/src/command/commands/phone/phone.number.d.ts +6 -0
- package/dist/src/command/commands/phone/phone.number.js +12 -0
- package/dist/src/command/commands/phone/phone.number.js.map +1 -0
- package/dist/src/command/commands/string/alpha.d.ts +7 -0
- package/dist/src/command/commands/string/alpha.js +13 -0
- package/dist/src/command/commands/string/alpha.js.map +1 -0
- package/dist/src/command/commands/string/alphanumeric.d.ts +7 -0
- package/dist/src/command/commands/string/alphanumeric.js +13 -0
- package/dist/src/command/commands/string/alphanumeric.js.map +1 -0
- package/dist/src/command/commands/string/binary.d.ts +7 -0
- package/dist/src/command/commands/string/binary.js +13 -0
- package/dist/src/command/commands/string/binary.js.map +1 -0
- package/dist/src/command/commands/string/hexadecimal.d.ts +7 -0
- package/dist/src/command/commands/string/hexadecimal.js +13 -0
- package/dist/src/command/commands/string/hexadecimal.js.map +1 -0
- package/dist/src/command/commands/string/numeric.d.ts +6 -0
- package/dist/src/command/commands/string/numeric.js +12 -0
- package/dist/src/command/commands/string/numeric.js.map +1 -0
- package/dist/src/command/commands/string/octal.d.ts +7 -0
- package/dist/src/command/commands/string/octal.js +13 -0
- package/dist/src/command/commands/string/octal.js.map +1 -0
- package/dist/src/command/commands/string/ulid.d.ts +2 -0
- package/dist/src/command/commands/string/ulid.js +8 -0
- package/dist/src/command/commands/string/ulid.js.map +1 -0
- package/dist/src/command/commands/string/uuid.d.ts +2 -0
- package/dist/src/command/commands/string/uuid.js +8 -0
- package/dist/src/command/commands/string/uuid.js.map +1 -0
- package/dist/src/command/commands/system/directoryPath.d.ts +2 -0
- package/dist/src/command/commands/system/directoryPath.js +8 -0
- package/dist/src/command/commands/system/directoryPath.js.map +1 -0
- package/dist/src/command/commands/system/filePath.d.ts +2 -0
- package/dist/src/command/commands/system/filePath.js +8 -0
- package/dist/src/command/commands/system/filePath.js.map +1 -0
- package/dist/src/command/commands/system/mimeType.d.ts +2 -0
- package/dist/src/command/commands/system/mimeType.js +8 -0
- package/dist/src/command/commands/system/mimeType.js.map +1 -0
- package/dist/src/command/commands/system/networkInterface.d.ts +2 -0
- package/dist/src/command/commands/system/networkInterface.js +8 -0
- package/dist/src/command/commands/system/networkInterface.js.map +1 -0
- package/dist/src/command/commands/system/semver.d.ts +2 -0
- package/dist/src/command/commands/system/semver.js +8 -0
- package/dist/src/command/commands/system/semver.js.map +1 -0
- package/dist/src/command/consts.d.ts +3 -0
- package/dist/src/command/consts.js +4 -0
- package/dist/src/command/consts.js.map +1 -0
- package/dist/src/command/index.d.ts +4 -0
- package/dist/src/command/index.js +3 -0
- package/dist/src/command/index.js.map +1 -0
- package/dist/src/command/type.d.ts +22 -0
- package/dist/src/command/type.js +2 -0
- package/dist/src/command/type.js.map +1 -0
- package/dist/src/command/utils.d.ts +2 -0
- package/dist/src/command/utils.js +9 -0
- package/dist/src/command/utils.js.map +1 -0
- package/dist/src/commandDocument/buildCommandDocumentFragments.d.ts +4 -0
- package/dist/src/commandDocument/buildCommandDocumentFragments.js +12 -0
- package/dist/src/commandDocument/buildCommandDocumentFragments.js.map +1 -0
- package/dist/src/commandDocument/createCommandDocumentFragment.d.ts +3 -0
- package/dist/src/commandDocument/createCommandDocumentFragment.js +14 -0
- package/dist/src/commandDocument/createCommandDocumentFragment.js.map +1 -0
- package/dist/src/commandDocument/index.d.ts +1 -0
- package/dist/src/commandDocument/index.js +2 -0
- package/dist/src/commandDocument/index.js.map +1 -0
- package/dist/src/commandTemplate/index.d.ts +2 -0
- package/dist/src/commandTemplate/index.js +3 -0
- package/dist/src/commandTemplate/index.js.map +1 -0
- package/dist/src/commandTemplate/parseAndEmbedCommandExpression.d.ts +3 -0
- package/dist/src/commandTemplate/parseAndEmbedCommandExpression.js +12 -0
- package/dist/src/commandTemplate/parseAndEmbedCommandExpression.js.map +1 -0
- package/dist/src/commandTemplate/types.d.ts +3 -0
- package/dist/src/commandTemplate/types.js +2 -0
- package/dist/src/commandTemplate/types.js.map +1 -0
- package/dist/src/common/weightedItemFeeder.d.ts +15 -0
- package/dist/src/common/weightedItemFeeder.js +67 -0
- package/dist/src/common/weightedItemFeeder.js.map +1 -0
- package/dist/src/consts.d.ts +14 -0
- package/dist/src/consts.js +17 -0
- package/dist/src/consts.js.map +1 -0
- package/dist/src/createDocumentFeeder.d.ts +5 -0
- package/dist/src/createDocumentFeeder.js +64 -0
- package/dist/src/createDocumentFeeder.js.map +1 -0
- package/dist/src/createGeneratingDocumentStream.d.ts +4 -0
- package/dist/src/createGeneratingDocumentStream.js +33 -0
- package/dist/src/createGeneratingDocumentStream.js.map +1 -0
- package/dist/src/createGeneratingLogStream.d.ts +4 -0
- package/dist/src/createGeneratingLogStream.js +21 -0
- package/dist/src/createGeneratingLogStream.js.map +1 -0
- package/dist/src/debugFileWriter.d.ts +5 -0
- package/dist/src/debugFileWriter.js +33 -0
- package/dist/src/debugFileWriter.js.map +1 -0
- package/dist/src/document/createDocumentContextIterator.d.ts +2 -0
- package/dist/src/document/createDocumentContextIterator.js +15 -0
- package/dist/src/document/createDocumentContextIterator.js.map +1 -0
- package/dist/src/document/generatingDocument.d.ts +7 -0
- package/dist/src/document/generatingDocument.js +13 -0
- package/dist/src/document/generatingDocument.js.map +1 -0
- package/dist/src/document/index.d.ts +4 -0
- package/dist/src/document/index.js +4 -0
- package/dist/src/document/index.js.map +1 -0
- package/dist/src/document/types.d.ts +20 -0
- package/dist/src/document/types.js +2 -0
- package/dist/src/document/types.js.map +1 -0
- package/dist/src/document/utils.d.ts +2 -0
- package/dist/src/document/utils.js +9 -0
- package/dist/src/document/utils.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/json/abstractJsonable.d.ts +12 -0
- package/dist/src/json/abstractJsonable.js +33 -0
- package/dist/src/json/abstractJsonable.js.map +1 -0
- package/dist/src/json/createJsonable.d.ts +3 -0
- package/dist/src/json/createJsonable.js +31 -0
- package/dist/src/json/createJsonable.js.map +1 -0
- package/dist/src/json/createJsonableTransformer.d.ts +4 -0
- package/dist/src/json/createJsonableTransformer.js +251 -0
- package/dist/src/json/createJsonableTransformer.js.map +1 -0
- package/dist/src/json/index.d.ts +6 -0
- package/dist/src/json/index.js +4 -0
- package/dist/src/json/index.js.map +1 -0
- package/dist/src/json/jsonConsts.d.ts +1 -0
- package/dist/src/json/jsonConsts.js +9 -0
- package/dist/src/json/jsonConsts.js.map +1 -0
- package/dist/src/json/jsonTypes.d.ts +8 -0
- package/dist/src/json/jsonTypes.js +2 -0
- package/dist/src/json/jsonTypes.js.map +1 -0
- package/dist/src/json/jsonableClasses/arrayJsonable.d.ts +11 -0
- package/dist/src/json/jsonableClasses/arrayJsonable.js +40 -0
- package/dist/src/json/jsonableClasses/arrayJsonable.js.map +1 -0
- package/dist/src/json/jsonableClasses/booleanJsonable.d.ts +8 -0
- package/dist/src/json/jsonableClasses/booleanJsonable.js +15 -0
- package/dist/src/json/jsonableClasses/booleanJsonable.js.map +1 -0
- package/dist/src/json/jsonableClasses/nullJsonable.d.ts +8 -0
- package/dist/src/json/jsonableClasses/nullJsonable.js +11 -0
- package/dist/src/json/jsonableClasses/nullJsonable.js.map +1 -0
- package/dist/src/json/jsonableClasses/numberJsonable.d.ts +9 -0
- package/dist/src/json/jsonableClasses/numberJsonable.js +18 -0
- package/dist/src/json/jsonableClasses/numberJsonable.js.map +1 -0
- package/dist/src/json/jsonableClasses/objectJsonable.d.ts +10 -0
- package/dist/src/json/jsonableClasses/objectJsonable.js +14 -0
- package/dist/src/json/jsonableClasses/objectJsonable.js.map +1 -0
- package/dist/src/json/jsonableClasses/stringJsonable.d.ts +9 -0
- package/dist/src/json/jsonableClasses/stringJsonable.js +15 -0
- package/dist/src/json/jsonableClasses/stringJsonable.js.map +1 -0
- package/dist/src/json/jsonableParametersConsts.d.ts +7 -0
- package/dist/src/json/jsonableParametersConsts.js +8 -0
- package/dist/src/json/jsonableParametersConsts.js.map +1 -0
- package/dist/src/json/jsonableParametersTypes.d.ts +32 -0
- package/dist/src/json/jsonableParametersTypes.js +2 -0
- package/dist/src/json/jsonableParametersTypes.js.map +1 -0
- package/dist/src/json/jsonableTypes.d.ts +11 -0
- package/dist/src/json/jsonableTypes.js +2 -0
- package/dist/src/json/jsonableTypes.js.map +1 -0
- package/dist/src/json/parseJsonable.d.ts +2 -0
- package/dist/src/json/parseJsonable.js +19 -0
- package/dist/src/json/parseJsonable.js.map +1 -0
- package/dist/src/json/stringifyJsonable.d.ts +6 -0
- package/dist/src/json/stringifyJsonable.js +43 -0
- package/dist/src/json/stringifyJsonable.js.map +1 -0
- package/dist/src/json/utils.d.ts +2 -0
- package/dist/src/json/utils.js +9 -0
- package/dist/src/json/utils.js.map +1 -0
- package/dist/src/output/createFileOutput.d.ts +2 -0
- package/dist/src/output/createFileOutput.js +28 -0
- package/dist/src/output/createFileOutput.js.map +1 -0
- package/dist/src/output/createTcpOutput.d.ts +3 -0
- package/dist/src/output/createTcpOutput.js +15 -0
- package/dist/src/output/createTcpOutput.js.map +1 -0
- package/dist/src/output/createUdpOutput.d.ts +3 -0
- package/dist/src/output/createUdpOutput.js +5 -0
- package/dist/src/output/createUdpOutput.js.map +1 -0
- package/dist/src/output/initializeOutput.d.ts +3 -0
- package/dist/src/output/initializeOutput.js +38 -0
- package/dist/src/output/initializeOutput.js.map +1 -0
- package/dist/src/output/tcpDocumentStream.d.ts +16 -0
- package/dist/src/output/tcpDocumentStream.js +107 -0
- package/dist/src/output/tcpDocumentStream.js.map +1 -0
- package/dist/src/output/throttlingDocumentStream.d.ts +21 -0
- package/dist/src/output/throttlingDocumentStream.js +69 -0
- package/dist/src/output/throttlingDocumentStream.js.map +1 -0
- package/dist/src/output/udpDocumentStream.d.ts +13 -0
- package/dist/src/output/udpDocumentStream.js +47 -0
- package/dist/src/output/udpDocumentStream.js.map +1 -0
- package/dist/src/output/updStream.d.ts +17 -0
- package/dist/src/output/updStream.js +78 -0
- package/dist/src/output/updStream.js.map +1 -0
- package/dist/src/run.d.ts +4 -0
- package/dist/src/run.js +55 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/template/consts.d.ts +2 -0
- package/dist/src/template/consts.js +3 -0
- package/dist/src/template/consts.js.map +1 -0
- package/dist/src/template/index.d.ts +4 -0
- package/dist/src/template/index.js +4 -0
- package/dist/src/template/index.js.map +1 -0
- package/dist/src/template/templateParser/parseTemplate.d.ts +2 -0
- package/dist/src/template/templateParser/parseTemplate.js +11 -0
- package/dist/src/template/templateParser/parseTemplate.js.map +1 -0
- package/dist/src/template/templateParser/templateParser.d.ts +11 -0
- package/dist/src/template/templateParser/templateParser.js +87 -0
- package/dist/src/template/templateParser/templateParser.js.map +1 -0
- package/dist/src/template/templateParser/visitor.d.ts +4 -0
- package/dist/src/template/templateParser/visitor.js +60 -0
- package/dist/src/template/templateParser/visitor.js.map +1 -0
- package/dist/src/template/types.d.ts +5 -0
- package/dist/src/template/types.js +2 -0
- package/dist/src/template/types.js.map +1 -0
- package/dist/src/template/utils.d.ts +2 -0
- package/dist/src/template/utils.js +4 -0
- package/dist/src/template/utils.js.map +1 -0
- package/dist/src/types.d.ts +68 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.js +321 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DocumentContext } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
import type { JsonableObject } from "../jsonableTypes.js";
|
|
4
|
+
import type { JsonObject } from "../jsonTypes.js";
|
|
5
|
+
export declare class ObjectJsonable extends AbstractJsonable {
|
|
6
|
+
private readonly content;
|
|
7
|
+
readonly type: "object";
|
|
8
|
+
constructor(content: JsonableObject, probability: number | undefined, weight: number | undefined);
|
|
9
|
+
protected toJSONImpl(keyOrIndex: string | number, context: DocumentContext): JsonObject | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
2
|
+
import { transformJsonableObjectIntoJsonObject } from "../stringifyJsonable.js";
|
|
3
|
+
export class ObjectJsonable extends AbstractJsonable {
|
|
4
|
+
content;
|
|
5
|
+
type = "object";
|
|
6
|
+
constructor(content, probability, weight) {
|
|
7
|
+
super(probability, weight);
|
|
8
|
+
this.content = content;
|
|
9
|
+
}
|
|
10
|
+
toJSONImpl(keyOrIndex, context) {
|
|
11
|
+
return transformJsonableObjectIntoJsonObject(this.content, keyOrIndex, context);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=objectJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectJsonable.js","sourceRoot":"","sources":["../../../../src/json/jsonableClasses/objectJsonable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAEhF,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAI/B;IAHH,IAAI,GAAG,QAAiB,CAAC;IAEzC,YACmB,OAAuB,EACxC,WAA+B,EAC/B,MAA0B;QAE1B,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAJV,YAAO,GAAP,OAAO,CAAgB;IAK1C,CAAC;IAES,UAAU,CAClB,UAA2B,EAC3B,OAAwB;QAExB,OAAO,qCAAqC,CAC1C,IAAI,CAAC,OAAO,EACZ,UAAU,EACV,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DocumentContent, type DocumentContext } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
import type { JsonString } from "../jsonTypes.js";
|
|
4
|
+
export declare class StringJsonable extends AbstractJsonable {
|
|
5
|
+
private readonly content;
|
|
6
|
+
readonly type: "string";
|
|
7
|
+
constructor(content: DocumentContent, probability: number | undefined, weight: number | undefined);
|
|
8
|
+
protected toJSONImpl(keyOrIndex: string | number, context: DocumentContext): JsonString | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { stampDocument, } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
export class StringJsonable extends AbstractJsonable {
|
|
4
|
+
content;
|
|
5
|
+
type = "string";
|
|
6
|
+
constructor(content, probability, weight) {
|
|
7
|
+
super(probability, weight);
|
|
8
|
+
this.content = content;
|
|
9
|
+
}
|
|
10
|
+
toJSONImpl(keyOrIndex, context) {
|
|
11
|
+
const output = stampDocument(this.content, context);
|
|
12
|
+
return output;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=stringJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringJsonable.js","sourceRoot":"","sources":["../../../../src/json/jsonableClasses/stringJsonable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAI/B;IAHH,IAAI,GAAG,QAAiB,CAAC;IAEzC,YACmB,OAAwB,EACzC,WAA+B,EAC/B,MAA0B;QAE1B,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAJV,YAAO,GAAP,OAAO,CAAiB;IAK3C,CAAC;IAES,UAAU,CAClB,UAA2B,EAC3B,OAAwB;QAExB,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const JsonableTypeParameterName: "type";
|
|
2
|
+
export declare const JsonableContentParameterName: "content";
|
|
3
|
+
export declare const JsonableProbabilityParameterName: "probability";
|
|
4
|
+
export declare const JsonableLengthParameterName: "length";
|
|
5
|
+
export declare const JsonableWeightParameterName: "weight";
|
|
6
|
+
export declare const MIN_PROBABILITY = 0;
|
|
7
|
+
export declare const MAX_PROBABILITY = 100;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const JsonableTypeParameterName = "type";
|
|
2
|
+
export const JsonableContentParameterName = "content";
|
|
3
|
+
export const JsonableProbabilityParameterName = "probability";
|
|
4
|
+
export const JsonableLengthParameterName = "length";
|
|
5
|
+
export const JsonableWeightParameterName = "weight";
|
|
6
|
+
export const MIN_PROBABILITY = 0;
|
|
7
|
+
export const MAX_PROBABILITY = 100;
|
|
8
|
+
//# sourceMappingURL=jsonableParametersConsts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonableParametersConsts.js","sourceRoot":"","sources":["../../../src/json/jsonableParametersConsts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAe,CAAC;AACzD,MAAM,CAAC,MAAM,4BAA4B,GAAG,SAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,gCAAgC,GAAG,aAAsB,CAAC;AACvE,MAAM,CAAC,MAAM,2BAA2B,GAAG,QAAiB,CAAC;AAC7D,MAAM,CAAC,MAAM,2BAA2B,GAAG,QAAiB,CAAC;AAE7D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DocumentContent } from "../document/index.js";
|
|
2
|
+
import type { JsonableObject, JsonableValue, JsonValueType } from "./jsonableTypes.js";
|
|
3
|
+
export interface PrimitiveJsonableParameters {
|
|
4
|
+
readonly type: JsonValueType;
|
|
5
|
+
readonly probability: number | undefined;
|
|
6
|
+
readonly weight: number | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface ObjectJsonableParameters extends PrimitiveJsonableParameters {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly content: JsonableObject;
|
|
11
|
+
}
|
|
12
|
+
export interface ArrayJsonableParameters extends PrimitiveJsonableParameters {
|
|
13
|
+
readonly type: "array";
|
|
14
|
+
readonly content: readonly JsonableValue[];
|
|
15
|
+
readonly length: DocumentContent;
|
|
16
|
+
}
|
|
17
|
+
export interface StringJsonableParameters extends PrimitiveJsonableParameters {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly content: DocumentContent;
|
|
20
|
+
}
|
|
21
|
+
export interface NumberJsonableParameters extends PrimitiveJsonableParameters {
|
|
22
|
+
readonly type: "number";
|
|
23
|
+
readonly content: DocumentContent;
|
|
24
|
+
}
|
|
25
|
+
export interface BooleanJsonableParameters extends PrimitiveJsonableParameters {
|
|
26
|
+
readonly type: "boolean";
|
|
27
|
+
readonly content: DocumentContent;
|
|
28
|
+
}
|
|
29
|
+
export interface NullJsonableParameters extends PrimitiveJsonableParameters {
|
|
30
|
+
readonly type: "null";
|
|
31
|
+
}
|
|
32
|
+
export type JsonableValueParameters = ObjectJsonableParameters | ArrayJsonableParameters | StringJsonableParameters | NumberJsonableParameters | BooleanJsonableParameters | NullJsonableParameters;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonableParametersTypes.js","sourceRoot":"","sources":["../../../src/json/jsonableParametersTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AbstractJsonable } from "./abstractJsonable.js";
|
|
2
|
+
import type { JsonValueTypes } from "./jsonConsts.js";
|
|
3
|
+
import type { JsonBoolean, JsonNull, JsonNumber, JsonString, JsonValue } from "./jsonTypes.js";
|
|
4
|
+
export type JsonValueType = (typeof JsonValueTypes)[number];
|
|
5
|
+
export type JsonableValue = AbstractJsonable | JsonableObject | JsonableValue[] | JsonString | JsonNumber | JsonBoolean | JsonNull;
|
|
6
|
+
export type JsonableObject = {
|
|
7
|
+
[key: string]: JsonableValue;
|
|
8
|
+
};
|
|
9
|
+
export interface JsonableTransformer {
|
|
10
|
+
(value: JsonValue): JsonableValue | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonableTypes.js","sourceRoot":"","sources":["../../../src/json/jsonableTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function parseJsonable(input, jsonableTransformer) {
|
|
2
|
+
let jsonValue;
|
|
3
|
+
try {
|
|
4
|
+
jsonValue = JSON.parse(input);
|
|
5
|
+
}
|
|
6
|
+
catch (error) {
|
|
7
|
+
console.error(error);
|
|
8
|
+
jsonValue = undefined;
|
|
9
|
+
}
|
|
10
|
+
if (jsonValue === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const jsonableValue = jsonableTransformer(jsonValue);
|
|
14
|
+
if (jsonableValue === undefined) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return jsonableValue;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=parseJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJsonable.js","sourceRoot":"","sources":["../../../src/json/parseJsonable.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,mBAAwC;IAExC,IAAI,SAAgC,CAAC;IACrC,IAAI,CAAC;QACH,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACrD,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DocumentContext } from "../document/index.js";
|
|
2
|
+
import type { JsonableObject, JsonableValue } from "./jsonableTypes.js";
|
|
3
|
+
import type { JsonObject, JsonValue } from "./jsonTypes.js";
|
|
4
|
+
export declare function stringifyJsonable(value: JsonableValue, keyOrIndex: string | number, context: DocumentContext): string | undefined;
|
|
5
|
+
export declare function transformJsonableIntoJsonValue(value: JsonableValue, keyOrIndex: string | number, context: DocumentContext): JsonValue | undefined;
|
|
6
|
+
export declare function transformJsonableObjectIntoJsonObject(jsonableObject: JsonableObject, keyOrIndex: string | number, context: DocumentContext): JsonObject | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AbstractJsonable } from "./abstractJsonable.js";
|
|
2
|
+
export function stringifyJsonable(value, keyOrIndex, context) {
|
|
3
|
+
const jsonValue = transformJsonableIntoJsonValue(value, keyOrIndex, context);
|
|
4
|
+
if (jsonValue === undefined) {
|
|
5
|
+
return "";
|
|
6
|
+
}
|
|
7
|
+
return JSON.stringify(jsonValue);
|
|
8
|
+
}
|
|
9
|
+
export function transformJsonableIntoJsonValue(value, keyOrIndex, context) {
|
|
10
|
+
if (value instanceof AbstractJsonable) {
|
|
11
|
+
return value.toJSON(keyOrIndex, context);
|
|
12
|
+
}
|
|
13
|
+
else if (value === null ||
|
|
14
|
+
typeof value === "boolean" ||
|
|
15
|
+
typeof value === "number" ||
|
|
16
|
+
typeof value === "string") {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
else if (Array.isArray(value)) {
|
|
20
|
+
return value
|
|
21
|
+
.map((item) => transformJsonableIntoJsonValue(item, keyOrIndex, context))
|
|
22
|
+
.filter((jsonValue) => jsonValue !== undefined);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return transformJsonableObjectIntoJsonObject(value, keyOrIndex, context);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function transformJsonableObjectIntoJsonObject(jsonableObject, keyOrIndex, context) {
|
|
29
|
+
let jsonObject = {};
|
|
30
|
+
Object.keys(jsonableObject).forEach((memberKey) => {
|
|
31
|
+
const memberValue = jsonableObject[memberKey];
|
|
32
|
+
if (memberValue === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const memberJsonValue = transformJsonableIntoJsonValue(memberValue, memberKey, context);
|
|
36
|
+
if (memberJsonValue === undefined) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
jsonObject[memberKey] = memberJsonValue;
|
|
40
|
+
});
|
|
41
|
+
return jsonObject;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=stringifyJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyJsonable.js","sourceRoot":"","sources":["../../../src/json/stringifyJsonable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,MAAM,UAAU,iBAAiB,CAC/B,KAAoB,EACpB,UAA2B,EAC3B,OAAwB;IAExB,MAAM,SAAS,GAAG,8BAA8B,CAAC,KAAK,EAAE,UAAU,EA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,8BAA8B,CACpD,WAAW,EACX,SAAS,EACT,OAAO,CACR,CAAC;QACF,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QACD,UAAU,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/json/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAsB,cAAc,CAAC;IACrD,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as rfs from "rotating-file-stream";
|
|
3
|
+
export async function createFileOutput(nonRotateOutputPath, rotateSize, rotateOutputPathGenerator) {
|
|
4
|
+
if (rotateSize === undefined) {
|
|
5
|
+
// no file rotation
|
|
6
|
+
return fs.createWriteStream(nonRotateOutputPath);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
// rotate file by size
|
|
10
|
+
return rfs.createStream((indexOrDate, indexOrUndefined) => {
|
|
11
|
+
if (indexOrDate === null) {
|
|
12
|
+
return nonRotateOutputPath;
|
|
13
|
+
}
|
|
14
|
+
let index;
|
|
15
|
+
if (typeof indexOrDate === "number") {
|
|
16
|
+
index = indexOrDate;
|
|
17
|
+
}
|
|
18
|
+
else if (typeof indexOrUndefined === "number") {
|
|
19
|
+
index = indexOrUndefined;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
index = 0;
|
|
23
|
+
}
|
|
24
|
+
return rotateOutputPathGenerator(index.toString());
|
|
25
|
+
}, { size: rotateSize });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=createFileOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileOutput.js","sourceRoot":"","sources":["../../../src/output/createFileOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,mBAA2B,EAC3B,UAA8B,EAC9B,yBAA+D;IAE/D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,mBAAmB;QACnB,OAAO,EAAE,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,sBAAsB;QACtB,OAAO,GAAG,CAAC,YAAY,CACrB,CAAC,WAAW,EAAE,gBAAgB,EAAE,EAAE;YAChC,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;gBACzB,OAAO,mBAAmB,CAAC;YAC7B,CAAC;YACD,IAAI,KAAa,CAAC;YAClB,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;gBACpC,KAAK,GAAG,WAAW,CAAC;YACtB,CAAC;iBAAM,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE,CAAC;gBAChD,KAAK,GAAG,gBAAgB,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,CAAC,CAAC;YACZ,CAAC;YACD,OAAO,yBAAyB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrD,CAAC,EACD,EAAE,IAAI,EAAE,UAAU,EAAE,CACrB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as dnsPromises from "node:dns/promises";
|
|
2
|
+
import * as net from "node:net";
|
|
3
|
+
export async function createTcpOutput(outputOptions) {
|
|
4
|
+
const lookupAddress = await dnsPromises.lookup(outputOptions.address, {
|
|
5
|
+
verbatim: true,
|
|
6
|
+
});
|
|
7
|
+
const tcpOptions = {
|
|
8
|
+
host: outputOptions.address,
|
|
9
|
+
port: outputOptions.port,
|
|
10
|
+
family: lookupAddress.family,
|
|
11
|
+
};
|
|
12
|
+
const client = net.connect(tcpOptions);
|
|
13
|
+
return client;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=createTcpOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTcpOutput.js","sourceRoot":"","sources":["../../../src/output/createTcpOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,aAA+B;IAE/B,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE;QACpE,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,MAAM,UAAU,GAA0B;QACxC,IAAI,EAAE,aAAa,CAAC,OAAO;QAC3B,IAAI,EAAE,aAAa,CAAC,IAAI;QACxB,MAAM,EAAE,aAAa,CAAC,MAAM;KAC7B,CAAC;IACF,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUdpOutput.js","sourceRoot":"","sources":["../../../src/output/createUdpOutput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,aAA+B;IAE/B,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { globIterate } from "glob";
|
|
2
|
+
import * as fsPromises from "node:fs/promises";
|
|
3
|
+
import * as nodePath from "node:path";
|
|
4
|
+
import { assertNever } from "../utils.js";
|
|
5
|
+
import { createFileOutput } from "./createFileOutput.js";
|
|
6
|
+
import { TcpDocumentStream } from "./tcpDocumentStream.js";
|
|
7
|
+
import { UdpDocumentStream } from "./udpDocumentStream.js";
|
|
8
|
+
export async function initializeOutput(outputOptions) {
|
|
9
|
+
// region clean dir
|
|
10
|
+
const nonRotateOutputPath = outputOptions.path;
|
|
11
|
+
const parsed = nodePath.parse(outputOptions.path);
|
|
12
|
+
const rotateOutputPathGenerator = (additionalPhrase) => {
|
|
13
|
+
const filename = `${parsed.name}.${additionalPhrase}${parsed.ext}`;
|
|
14
|
+
return nodePath.join(parsed.dir, filename);
|
|
15
|
+
};
|
|
16
|
+
const nonRotateOutputGlobPath = nonRotateOutputPath.replaceAll("\\", "/");
|
|
17
|
+
const rotateOutputGlobPath = rotateOutputPathGenerator("*").replaceAll("\\", "/");
|
|
18
|
+
await cleanOutputDir(nonRotateOutputGlobPath, rotateOutputGlobPath);
|
|
19
|
+
// endregion
|
|
20
|
+
if (outputOptions.type === "file") {
|
|
21
|
+
return createFileOutput(nonRotateOutputPath, outputOptions.size, rotateOutputPathGenerator);
|
|
22
|
+
}
|
|
23
|
+
else if (outputOptions.type === "udp") {
|
|
24
|
+
return new UdpDocumentStream(outputOptions);
|
|
25
|
+
}
|
|
26
|
+
else if (outputOptions.type === "tcp") {
|
|
27
|
+
return new TcpDocumentStream(outputOptions);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return assertNever(outputOptions);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function cleanOutputDir(...globPaths) {
|
|
34
|
+
for await (const path of globIterate(globPaths)) {
|
|
35
|
+
await fsPromises.rm(path);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMapp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AAE,CAAC;QAClC,OAAO,gBAAgB,CACrB,mBAAmB,EACnB,aAAa,CAAC,IAAI,EAClB,yBAAyB,CAC1B,CAAC;IACJ,CAAC;SAAM,IAAI,aAAa,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACxC,OAAO,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;SAAM,IAAI,aAAa,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACxC,OAAO,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,GAAG,SAAmB;IAClD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GeneratingDocument } from "../document/index.js";
|
|
2
|
+
import type { TcpOutputOptions } from "../types.js";
|
|
3
|
+
import { ThrottlingDocumentStream } from "./throttlingDocumentStream.js";
|
|
4
|
+
export declare class TcpDocumentStream extends ThrottlingDocumentStream {
|
|
5
|
+
private readonly address;
|
|
6
|
+
private readonly port;
|
|
7
|
+
private readonly framing;
|
|
8
|
+
private readonly trailerReplacer;
|
|
9
|
+
private family;
|
|
10
|
+
private client;
|
|
11
|
+
constructor(options: TcpOutputOptions);
|
|
12
|
+
_construct(callback: (error?: Error | null) => void): void;
|
|
13
|
+
_throttledWrite(chunk: GeneratingDocument, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
14
|
+
protected _throttledFinal(callback: (error?: Error | null) => void): void;
|
|
15
|
+
protected _throttledDestroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import * as dnsPromises from "node:dns/promises";
|
|
3
|
+
import * as net from "node:net";
|
|
4
|
+
import { TrailerMap } from "../consts.js";
|
|
5
|
+
import { ThrottlingDocumentStream } from "./throttlingDocumentStream.js";
|
|
6
|
+
const SP = " ";
|
|
7
|
+
export class TcpDocumentStream extends ThrottlingDocumentStream {
|
|
8
|
+
address;
|
|
9
|
+
port;
|
|
10
|
+
framing;
|
|
11
|
+
trailerReplacer;
|
|
12
|
+
family;
|
|
13
|
+
client;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options.eps);
|
|
16
|
+
this.address = options.address;
|
|
17
|
+
this.port = options.port;
|
|
18
|
+
if (options.framing === "octet-counting") {
|
|
19
|
+
this.framing = options.framing;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.framing = options.framing;
|
|
23
|
+
this.trailerReplacer = options.trailerReplacer;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
_construct(callback) {
|
|
27
|
+
dnsPromises
|
|
28
|
+
.lookup(this.address, {
|
|
29
|
+
verbatim: true,
|
|
30
|
+
})
|
|
31
|
+
.then((lookupAddress) => {
|
|
32
|
+
this.family = lookupAddress.family;
|
|
33
|
+
callback();
|
|
34
|
+
})
|
|
35
|
+
.catch((reason) => callback(reason));
|
|
36
|
+
}
|
|
37
|
+
_throttledWrite(chunk, encoding, callback) {
|
|
38
|
+
const family = this.family;
|
|
39
|
+
if (family === undefined) {
|
|
40
|
+
callback(new Error("called write before family has not been determined."));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let client = this.client;
|
|
44
|
+
if (client === undefined) {
|
|
45
|
+
const tcpOptions = {
|
|
46
|
+
host: this.address,
|
|
47
|
+
port: this.port,
|
|
48
|
+
family: this.family,
|
|
49
|
+
};
|
|
50
|
+
client = net.connect(tcpOptions);
|
|
51
|
+
this.client = client;
|
|
52
|
+
}
|
|
53
|
+
const outputString = chunk.stamp();
|
|
54
|
+
let output;
|
|
55
|
+
if (this.framing === "lf") {
|
|
56
|
+
const trailerReplacer = this.trailerReplacer;
|
|
57
|
+
if (trailerReplacer !== undefined) {
|
|
58
|
+
const trailer = TrailerMap[this.framing];
|
|
59
|
+
output = outputString.replaceAll(trailer, trailerReplacer) + trailer;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const trailer = TrailerMap[this.framing];
|
|
63
|
+
output = outputString + trailer;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (this.framing === "octet-counting") {
|
|
67
|
+
const messageBuf8 = Buffer.from(outputString, "utf-8");
|
|
68
|
+
const lengthCount = messageBuf8.length.toString();
|
|
69
|
+
const lengthBuf8 = Buffer.from(lengthCount + SP, "utf-8");
|
|
70
|
+
output = Buffer.concat([lengthBuf8, messageBuf8]);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
callback(new Error(`unexpected framing type ${this.framing}`));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
client.write(output, (error) => {
|
|
77
|
+
if (error !== null) {
|
|
78
|
+
callback(error);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
callback();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
_throttledFinal(callback) {
|
|
85
|
+
const client = this.client;
|
|
86
|
+
if (client === undefined) {
|
|
87
|
+
callback();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
client.end(callback);
|
|
91
|
+
}
|
|
92
|
+
_throttledDestroy(error, callback) {
|
|
93
|
+
const client = this.client;
|
|
94
|
+
if (client === undefined) {
|
|
95
|
+
callback(error);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (error !== null) {
|
|
99
|
+
client.destroy(error);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
client.destroy();
|
|
103
|
+
}
|
|
104
|
+
callback(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=tcpDocumentStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcpDocumentStream.js","sourceRoot":"","sources":["../../../src/output/tcpDocumentStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,EAAE,GAAG,GAAY,CAAC;AAExB,MAAM,OAAO,iBAAkB,SAAQ,wBAAwB;IAC5C,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,OAAO,CAAiB;IACxB,eAAe,CAAqB;IAE7C,MAAM,CAAqB;IAC3B,MAAM,CAAyB;IAEvC,YAAY,OAAyB;QACnC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,OAAO,KAAK,gBAAgB,EAAE,CAAC;YACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAC/B,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QACjD,CAAC;IACH,CAAC;IAEe,UAAU,CAAC,QAAwC;QACjE,WAAW;aACR,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;YACpB,QAAQ,EAAE,IAAI;SACf,CAAC;aACD,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE;YACtB,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YACnC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OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as stream from "node:stream";
|
|
2
|
+
import { GeneratingDocument } from "../document/index.js";
|
|
3
|
+
export declare abstract class ThrottlingDocumentStream extends stream.Writable {
|
|
4
|
+
private readonly window;
|
|
5
|
+
private readonly eventPerWindow;
|
|
6
|
+
private readonly windowInternalTimeout;
|
|
7
|
+
private eventInCurrentWindow;
|
|
8
|
+
private pendingWriteTasks;
|
|
9
|
+
private nThWindow;
|
|
10
|
+
private totalNumOfEvent;
|
|
11
|
+
protected constructor(eps: number, debug?: boolean);
|
|
12
|
+
private debugReport;
|
|
13
|
+
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
14
|
+
protected abstract _throttledWrite(chunk: GeneratingDocument, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
15
|
+
private _flushPendingWriteTasks;
|
|
16
|
+
private _clearWindowInternal;
|
|
17
|
+
_final(callback: (error?: Error | null) => void): void;
|
|
18
|
+
protected abstract _throttledFinal(callback: (error?: Error | null) => void): void;
|
|
19
|
+
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
20
|
+
protected abstract _throttledDestroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as stream from "node:stream";
|
|
2
|
+
import { GeneratingDocument } from "../document/index.js";
|
|
3
|
+
const Per1000Window = 1000;
|
|
4
|
+
const Per100Window = 100;
|
|
5
|
+
export class ThrottlingDocumentStream extends stream.Writable {
|
|
6
|
+
window;
|
|
7
|
+
eventPerWindow;
|
|
8
|
+
windowInternalTimeout;
|
|
9
|
+
eventInCurrentWindow;
|
|
10
|
+
pendingWriteTasks = [];
|
|
11
|
+
nThWindow = 0;
|
|
12
|
+
totalNumOfEvent = 0;
|
|
13
|
+
constructor(eps, debug = false) {
|
|
14
|
+
super({
|
|
15
|
+
objectMode: true,
|
|
16
|
+
});
|
|
17
|
+
if (eps < Per100Window) {
|
|
18
|
+
this.window = Per1000Window;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.window = Per100Window;
|
|
22
|
+
}
|
|
23
|
+
this.eventPerWindow = Math.ceil(eps * (this.window / 1000));
|
|
24
|
+
this.eventInCurrentWindow = 0;
|
|
25
|
+
this.windowInternalTimeout = setInterval(() => {
|
|
26
|
+
this._flushPendingWriteTasks();
|
|
27
|
+
if (debug) {
|
|
28
|
+
this.debugReport();
|
|
29
|
+
}
|
|
30
|
+
this.eventInCurrentWindow = 0;
|
|
31
|
+
}, this.window);
|
|
32
|
+
}
|
|
33
|
+
debugReport() {
|
|
34
|
+
this.totalNumOfEvent = this.totalNumOfEvent + this.eventInCurrentWindow;
|
|
35
|
+
this.nThWindow = this.nThWindow + 1;
|
|
36
|
+
console.log(`[${this.nThWindow}] => ${this.eventInCurrentWindow}/${this.totalNumOfEvent}`);
|
|
37
|
+
}
|
|
38
|
+
_write(chunk, encoding, callback) {
|
|
39
|
+
if (!(chunk instanceof GeneratingDocument)) {
|
|
40
|
+
callback(new Error(`Unexpected chunk type(${typeof chunk}). Cannot process any chunk type except Document.`));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (this.eventInCurrentWindow < this.eventPerWindow) {
|
|
44
|
+
this._throttledWrite(chunk, encoding, callback);
|
|
45
|
+
this.eventInCurrentWindow = this.eventInCurrentWindow + 1;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.pendingWriteTasks.push([chunk, encoding, callback]);
|
|
49
|
+
}
|
|
50
|
+
_flushPendingWriteTasks() {
|
|
51
|
+
const tasks = this.pendingWriteTasks;
|
|
52
|
+
this.pendingWriteTasks = [];
|
|
53
|
+
tasks.forEach(([chunk, encoding, callback]) => this._throttledWrite(chunk, encoding, callback));
|
|
54
|
+
}
|
|
55
|
+
_clearWindowInternal() {
|
|
56
|
+
clearInterval(this.windowInternalTimeout);
|
|
57
|
+
}
|
|
58
|
+
_final(callback) {
|
|
59
|
+
this._flushPendingWriteTasks();
|
|
60
|
+
this._clearWindowInternal();
|
|
61
|
+
this._throttledFinal(callback);
|
|
62
|
+
}
|
|
63
|
+
_destroy(error, callback) {
|
|
64
|
+
this._flushPendingWriteTasks();
|
|
65
|
+
this._clearWindowInternal();
|
|
66
|
+
this._throttledDestroy(error, callback);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=throttlingDocumentStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttlingDocumentStream.js","sourceRoot":"","sources":["../../../src/output/throttlingDocumentStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AASzB,MAAM,OAAgB,wBAAyB,SAAQ,MAAM,CAAC,QAAQ;IACnD,MAAM,CAAS;IACf,cAAc,CAAS;IAEvB,qBAAqB,CAAC;IAE/B,oBAAoB,CAAS;IAC7B,iBAAiB,GAAgB,EAAE,CAAC;IAEpC,SAAS,GAAG,CAAC,CAAC;IACd,eAAe,GAAG,CAAC,CAAC;IAE5B,YAAsB,GAAW,EAAE,QAAiB,KAAK;QACvD,KAAK,CAAC;YACJ,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,IAAI,GAAG,GAAG,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;QAC7B,CAAC;QACD,IAAI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KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAQO,uBAAuB;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACrC,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAC5C,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAChD,CAAC;IACJ,CAAC;IAEO,oBAAoB;QAC1B,aAAa,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC5C,CAAC;IAEe,MAAM,CAAC,QAAwC;QAC7D,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAMe,QAAQ,CACtB,KAAmB,EACnB,QAAwC;QAExC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;CAMF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GeneratingDocument } from "../document/index.js";
|
|
2
|
+
import type { UdpOutputOptions } from "../types.js";
|
|
3
|
+
import { ThrottlingDocumentStream } from "./throttlingDocumentStream.js";
|
|
4
|
+
export declare class UdpDocumentStream extends ThrottlingDocumentStream {
|
|
5
|
+
private readonly address;
|
|
6
|
+
private readonly port;
|
|
7
|
+
private socketType;
|
|
8
|
+
constructor(options: UdpOutputOptions);
|
|
9
|
+
_construct(callback: (error?: Error | null) => void): void;
|
|
10
|
+
_throttledWrite(chunk: GeneratingDocument, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
11
|
+
protected _throttledFinal(callback: (error?: Error | null) => void): void;
|
|
12
|
+
protected _throttledDestroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
13
|
+
}
|