@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,20 @@
|
|
|
1
|
+
export interface SharedDocumentOptions {
|
|
2
|
+
readonly from: Date;
|
|
3
|
+
readonly to: Date;
|
|
4
|
+
readonly total: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DocumentOptions {
|
|
7
|
+
readonly shared: SharedDocumentOptions;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
}
|
|
10
|
+
export interface DocumentContext {
|
|
11
|
+
readonly index: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ContextualStringOut {
|
|
14
|
+
(context: DocumentContext): string;
|
|
15
|
+
}
|
|
16
|
+
export interface ContextualDocumentFragment {
|
|
17
|
+
toString(context: DocumentContext): string;
|
|
18
|
+
}
|
|
19
|
+
export type DocumentFragment = string | ContextualDocumentFragment;
|
|
20
|
+
export type DocumentContent = readonly DocumentFragment[] | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/document/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/document/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAC3B,OAAwB,EACxB,OAAwB;IAExB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,OAAO;SACX,GAAG,CAAS,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SACrE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from "./run.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DocumentContext } from "../document/index.js";
|
|
2
|
+
import type { JsonValueType } from "./jsonableTypes.js";
|
|
3
|
+
import type { JsonValue } from "./jsonTypes.js";
|
|
4
|
+
export declare abstract class AbstractJsonable {
|
|
5
|
+
readonly probability: number | undefined;
|
|
6
|
+
readonly weight: number | undefined;
|
|
7
|
+
abstract readonly type: JsonValueType;
|
|
8
|
+
protected constructor(probability: number | undefined, weight: number | undefined);
|
|
9
|
+
protected testProbability(keyOrIndex: string | number, context: DocumentContext): boolean;
|
|
10
|
+
protected abstract toJSONImpl(keyOrIndex: string | number, context: DocumentContext): JsonValue | undefined;
|
|
11
|
+
toJSON(keyOrIndex: string | number, context: DocumentContext): JsonValue | undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { faker } from "@faker-js/faker";
|
|
2
|
+
import { MAX_PROBABILITY, MIN_PROBABILITY, } from "./jsonableParametersConsts.js";
|
|
3
|
+
export class AbstractJsonable {
|
|
4
|
+
probability;
|
|
5
|
+
weight;
|
|
6
|
+
constructor(probability, weight) {
|
|
7
|
+
this.probability = probability;
|
|
8
|
+
this.weight = weight;
|
|
9
|
+
}
|
|
10
|
+
testProbability(keyOrIndex, context) {
|
|
11
|
+
if (this.probability === undefined) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (this.probability <= MIN_PROBABILITY) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (this.probability >= MAX_PROBABILITY) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const diceValue = faker.number.float({
|
|
21
|
+
min: MIN_PROBABILITY,
|
|
22
|
+
max: MAX_PROBABILITY,
|
|
23
|
+
});
|
|
24
|
+
return diceValue < this.probability;
|
|
25
|
+
}
|
|
26
|
+
toJSON(keyOrIndex, context) {
|
|
27
|
+
if (!this.testProbability(keyOrIndex, context)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return this.toJSONImpl(keyOrIndex, context);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=abstractJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractJsonable.js","sourceRoot":"","sources":["../../../src/json/abstractJsonable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAIvC,MAAM,OAAgB,gBAAgB;IAIlB;IACA;IAFlB,YACkB,WAA+B,EAC/B,MAA0B;QAD1B,gBAAW,GAAX,WAAW,CAAoB;QAC/B,WAAM,GAAN,MAAM,CAAoB;IACzC,CAAC;IAEM,eAAe,CACvB,UAA2B,EAC3B,OAAwB;QAExB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,IAAI,eAAe,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,IAAI,eAAe,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YACnC,GAAG,EAAE,eAAe;YACpB,GAAG,EAAE,eAAe;SACrB,CAAC,CAAC;QACH,OAAO,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC;IACtC,CAAC;IAOM,MAAM,CACX,UAA2B,EAC3B,OAAwB;QAExB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;YAC/C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assertNever } from "../utils.js";
|
|
2
|
+
import { ArrayJsonable } from "./jsonableClasses/arrayJsonable.js";
|
|
3
|
+
import { BooleanJsonable } from "./jsonableClasses/booleanJsonable.js";
|
|
4
|
+
import { NullJsonable } from "./jsonableClasses/nullJsonable.js";
|
|
5
|
+
import { NumberJsonable } from "./jsonableClasses/numberJsonable.js";
|
|
6
|
+
import { ObjectJsonable } from "./jsonableClasses/objectJsonable.js";
|
|
7
|
+
import { StringJsonable } from "./jsonableClasses/stringJsonable.js";
|
|
8
|
+
export function createJsonable(parameters) {
|
|
9
|
+
if (parameters.type === "object") {
|
|
10
|
+
return new ObjectJsonable(parameters.content, parameters.probability, parameters.weight);
|
|
11
|
+
}
|
|
12
|
+
else if (parameters.type === "array") {
|
|
13
|
+
return new ArrayJsonable(parameters.content, parameters.length, parameters.probability, parameters.weight);
|
|
14
|
+
}
|
|
15
|
+
else if (parameters.type === "string") {
|
|
16
|
+
return new StringJsonable(parameters.content, parameters.probability, parameters.weight);
|
|
17
|
+
}
|
|
18
|
+
else if (parameters.type === "number") {
|
|
19
|
+
return new NumberJsonable(parameters.content, parameters.probability, parameters.weight);
|
|
20
|
+
}
|
|
21
|
+
else if (parameters.type === "boolean") {
|
|
22
|
+
return new BooleanJsonable(parameters.content, parameters.probability, parameters.weight);
|
|
23
|
+
}
|
|
24
|
+
else if (parameters.type === "null") {
|
|
25
|
+
return new NullJsonable(parameters.probability, parameters.weight);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return assertNever(parameters);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=createJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createJsonable.js","sourceRoot":"","sources":["../../../src/json/createJsonable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,C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UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CommandManager } from "../command/index.js";
|
|
2
|
+
import type { DocumentOptions } from "../document/index.js";
|
|
3
|
+
import type { JsonableTransformer } from "./jsonableTypes.js";
|
|
4
|
+
export declare function createJsonableTransformer(commandManager: CommandManager, documentOptions: DocumentOptions): JsonableTransformer;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { parseCommand } from "../command/index.js";
|
|
2
|
+
import { buildCommandDocumentFragments } from "../commandDocument/index.js";
|
|
3
|
+
import { parseAndEmbedCommandExpression, } from "../commandTemplate/index.js";
|
|
4
|
+
import { normalizeWeight } from "../common/weightedItemFeeder.js";
|
|
5
|
+
import { EXPRESSION_BLOCK_END, EXPRESSION_BLOCK_START, isStringOnlyTemplateFragments, parseTemplate, } from "../template/index.js";
|
|
6
|
+
import { isNonNullObject, parseNonNaNFloat, parseNonNaNInteger, } from "../utils.js";
|
|
7
|
+
import { createJsonable } from "./createJsonable.js";
|
|
8
|
+
import { JsonableContentParameterName, JsonableLengthParameterName, JsonableProbabilityParameterName, JsonableTypeParameterName, JsonableWeightParameterName, MAX_PROBABILITY, MIN_PROBABILITY, } from "./jsonableParametersConsts.js";
|
|
9
|
+
import { isJsonValueType } from "./utils.js";
|
|
10
|
+
export function createJsonableTransformer(commandManager, documentOptions) {
|
|
11
|
+
const commandDocumentFragmentsBuilder = function (parsedTemplateFragments) {
|
|
12
|
+
return buildCommandDocumentFragments(parsedTemplateFragments, commandManager, documentOptions);
|
|
13
|
+
};
|
|
14
|
+
const jsonableTransformer = function (value) {
|
|
15
|
+
if (value === null) {
|
|
16
|
+
// null
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
else if (typeof value === "boolean") {
|
|
20
|
+
// boolean
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
else if (typeof value === "number") {
|
|
24
|
+
// number
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
else if (typeof value === "string") {
|
|
28
|
+
// string
|
|
29
|
+
const documentContent = parseDocumentContent(value, commandDocumentFragmentsBuilder);
|
|
30
|
+
if (typeof documentContent === "string") {
|
|
31
|
+
return documentContent;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return createJsonable({
|
|
35
|
+
type: "string",
|
|
36
|
+
content: documentContent,
|
|
37
|
+
probability: undefined,
|
|
38
|
+
weight: undefined,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (Array.isArray(value)) {
|
|
43
|
+
// array
|
|
44
|
+
const arrayJsonableParameters = tryParseArrayJsonableParameters(value, commandDocumentFragmentsBuilder, jsonableTransformer);
|
|
45
|
+
if (arrayJsonableParameters !== undefined) {
|
|
46
|
+
return createJsonable(arrayJsonableParameters);
|
|
47
|
+
}
|
|
48
|
+
return transformIntoJsonableValueArray(value, jsonableTransformer);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// object
|
|
52
|
+
const jsonableValueParameters = tryParseJsonableParameters(value, commandDocumentFragmentsBuilder, jsonableTransformer);
|
|
53
|
+
if (jsonableValueParameters !== undefined) {
|
|
54
|
+
return createJsonable(jsonableValueParameters);
|
|
55
|
+
}
|
|
56
|
+
return transformIntoJsonableObject(value, jsonableTransformer);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return jsonableTransformer;
|
|
60
|
+
}
|
|
61
|
+
function transformIntoJsonableValueArray(content, jsonableTransformer) {
|
|
62
|
+
return content
|
|
63
|
+
.map((item) => jsonableTransformer(item))
|
|
64
|
+
.filter((jsonableValue) => jsonableValue !== undefined);
|
|
65
|
+
}
|
|
66
|
+
function transformIntoJsonableObject(jsonObject, jsonableTransformer) {
|
|
67
|
+
let jsonableObject = {};
|
|
68
|
+
Object.keys(jsonObject).forEach((memberKey) => {
|
|
69
|
+
const memberValue = jsonObject[memberKey];
|
|
70
|
+
if (memberValue === undefined) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const jsonableValue = jsonableTransformer(memberValue);
|
|
74
|
+
if (jsonableValue === undefined) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
jsonableObject[memberKey] = jsonableValue;
|
|
78
|
+
});
|
|
79
|
+
return jsonableObject;
|
|
80
|
+
}
|
|
81
|
+
function tryParseArrayJsonableParameters(array, commandDocumentFragmentsBuilder, jsonableTransformer) {
|
|
82
|
+
const items = [];
|
|
83
|
+
let lengthContent;
|
|
84
|
+
array.forEach((item) => {
|
|
85
|
+
const possibleExpression = tryExtractJsonableParameterExpression(item);
|
|
86
|
+
if (possibleExpression !== undefined) {
|
|
87
|
+
const parsedCommand = parseCommand(possibleExpression);
|
|
88
|
+
if (parsedCommand.name === JsonableLengthParameterName) {
|
|
89
|
+
lengthContent = commandDocumentFragmentsBuilder([parsedCommand]);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
items.push(item);
|
|
94
|
+
});
|
|
95
|
+
if (lengthContent === undefined) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
type: "array",
|
|
100
|
+
content: transformIntoJsonableValueArray(items, jsonableTransformer),
|
|
101
|
+
length: lengthContent,
|
|
102
|
+
probability: undefined,
|
|
103
|
+
weight: undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function tryParseJsonableParameters(jsonObject, commandDocumentFragmentsBuilder, jsonableTransformer) {
|
|
107
|
+
let jsonValueType;
|
|
108
|
+
let contentValue;
|
|
109
|
+
let lengthValue;
|
|
110
|
+
let probabilityValue;
|
|
111
|
+
let weightValue;
|
|
112
|
+
let hasShorthandObjectJsonableTrigger = false;
|
|
113
|
+
const otherMembers = {};
|
|
114
|
+
Object.keys(jsonObject).forEach((memberKey) => {
|
|
115
|
+
const memberValue = jsonObject[memberKey];
|
|
116
|
+
const possibleParameterName = tryExtractJsonableParameterExpression(memberKey);
|
|
117
|
+
if (possibleParameterName === JsonableTypeParameterName) {
|
|
118
|
+
if (!isJsonValueType(memberValue)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
jsonValueType = memberValue;
|
|
122
|
+
}
|
|
123
|
+
else if (possibleParameterName === JsonableContentParameterName) {
|
|
124
|
+
contentValue = memberValue;
|
|
125
|
+
hasShorthandObjectJsonableTrigger = true;
|
|
126
|
+
}
|
|
127
|
+
else if (possibleParameterName === JsonableProbabilityParameterName) {
|
|
128
|
+
probabilityValue = memberValue;
|
|
129
|
+
hasShorthandObjectJsonableTrigger = true;
|
|
130
|
+
}
|
|
131
|
+
else if (possibleParameterName === JsonableLengthParameterName) {
|
|
132
|
+
lengthValue = memberValue;
|
|
133
|
+
}
|
|
134
|
+
else if (possibleParameterName === JsonableWeightParameterName) {
|
|
135
|
+
weightValue = memberValue;
|
|
136
|
+
hasShorthandObjectJsonableTrigger = true;
|
|
137
|
+
}
|
|
138
|
+
else if (memberValue !== undefined) {
|
|
139
|
+
otherMembers[memberKey] = memberValue;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
let actualJsonValueType;
|
|
143
|
+
if (jsonValueType !== undefined) {
|
|
144
|
+
actualJsonValueType = jsonValueType;
|
|
145
|
+
}
|
|
146
|
+
else if (hasShorthandObjectJsonableTrigger) {
|
|
147
|
+
// shorthand object
|
|
148
|
+
actualJsonValueType = "object";
|
|
149
|
+
contentValue = contentValue ?? otherMembers;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// => return undefined
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
if (actualJsonValueType === "object") {
|
|
156
|
+
// ## object case
|
|
157
|
+
let jsonableObject;
|
|
158
|
+
if (isNonNullObject(contentValue)) {
|
|
159
|
+
jsonableObject = transformIntoJsonableObject(contentValue, jsonableTransformer);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
jsonableObject = {};
|
|
163
|
+
}
|
|
164
|
+
// => return JsonableValueParameters
|
|
165
|
+
return {
|
|
166
|
+
type: "object",
|
|
167
|
+
content: jsonableObject,
|
|
168
|
+
...createCommonJsonableParameters(probabilityValue, weightValue),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
else if (actualJsonValueType === "array") {
|
|
172
|
+
// ## array case
|
|
173
|
+
if (typeof lengthValue !== "string") {
|
|
174
|
+
// => return undefined
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const lengthContent = parseDocumentContent(lengthValue, commandDocumentFragmentsBuilder);
|
|
178
|
+
let jsonableValueArray;
|
|
179
|
+
if (Array.isArray(contentValue)) {
|
|
180
|
+
jsonableValueArray = transformIntoJsonableValueArray(contentValue, jsonableTransformer);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
jsonableValueArray = [];
|
|
184
|
+
}
|
|
185
|
+
// => return JsonableValueParameters
|
|
186
|
+
return {
|
|
187
|
+
type: actualJsonValueType,
|
|
188
|
+
content: jsonableValueArray,
|
|
189
|
+
length: lengthContent,
|
|
190
|
+
...createCommonJsonableParameters(probabilityValue, weightValue),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
else if (actualJsonValueType === "string" ||
|
|
194
|
+
actualJsonValueType === "number" ||
|
|
195
|
+
actualJsonValueType === "boolean") {
|
|
196
|
+
// ## string | number | boolean case
|
|
197
|
+
if (typeof contentValue !== "string") {
|
|
198
|
+
// => return undefined
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
const content = parseDocumentContent(contentValue, commandDocumentFragmentsBuilder);
|
|
202
|
+
// => return JsonableValueParameters
|
|
203
|
+
return {
|
|
204
|
+
type: actualJsonValueType,
|
|
205
|
+
content: content,
|
|
206
|
+
...createCommonJsonableParameters(probabilityValue, weightValue),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// ## null case
|
|
211
|
+
// => return JsonableValueParameters
|
|
212
|
+
return {
|
|
213
|
+
type: "null",
|
|
214
|
+
...createCommonJsonableParameters(probabilityValue, weightValue),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function parseDocumentContent(value, commandDocumentFragmentsBuilder) {
|
|
219
|
+
const templateFragments = parseTemplate(value);
|
|
220
|
+
if (isStringOnlyTemplateFragments(templateFragments)) {
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const documentFragments = commandDocumentFragmentsBuilder(parseAndEmbedCommandExpression(templateFragments));
|
|
225
|
+
return documentFragments;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function tryExtractJsonableParameterExpression(value) {
|
|
229
|
+
if (typeof value !== "string") {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
if (!value.startsWith(EXPRESSION_BLOCK_START) ||
|
|
233
|
+
!value.endsWith(EXPRESSION_BLOCK_END)) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
return value.substring(EXPRESSION_BLOCK_START.length, value.length - EXPRESSION_BLOCK_END.length);
|
|
237
|
+
}
|
|
238
|
+
function createCommonJsonableParameters(probabilityValue, weightValue) {
|
|
239
|
+
const probability = parseNonNaNFloat(probabilityValue);
|
|
240
|
+
const normalizedProbability = probability !== undefined ? normalizeProbability(probability) : undefined;
|
|
241
|
+
const weight = parseNonNaNInteger(weightValue);
|
|
242
|
+
const normalizedWeight = weight !== undefined ? normalizeWeight(weight) : undefined;
|
|
243
|
+
return {
|
|
244
|
+
probability: normalizedProbability,
|
|
245
|
+
weight: normalizedWeight,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function normalizeProbability(value) {
|
|
249
|
+
return Math.min(Math.max(value, MIN_PROBABILITY), MAX_PROBABILITY);
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=createJsonableTransformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createJsonableTransformer.js","sourceRoot":"","sources":["../../../src/json/createJsonableTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAEL,8BAA8B,GAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAMlE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,yBAAyB,EACzB,2BAA2B,EAC3B,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAavC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ7C,MAAM,UAAU,yBAAyB,CACvC,cAA8B,EAC9B,eAAgC;IAEhC,MAAM,+BAA+B,GACnC,UACE,uBAAiE;QAEjE,OAAO,6BAA6B,CAClC,uBAAuB,EACvB,cAAc,EACd,eAAe,CAChB,CAAC;IACJ,CAAC,CAAC;IAEJ,MAAM,mBAAmB,GAAwB,UAC/C,KAAgB;QAEhB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO;YACP,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YACtC,UAAU;YACV,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC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OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,qCAAqC,CAC5C,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IACE,CAAC,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC;QACzC,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EACrC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,CACpB,sBAAsB,CAAC,MAAM,EAC7B,KAAK,CAAC,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAC3C,CAAC;AACJ,CAAC;AAID,SAAS,8BAA8B,CACrC,gBAAuC,EACvC,WAAkC;IAElC,MAAM,WAAW,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACvD,MAAM,qBAAqB,GACzB,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE5E,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,gBAAgB,GACpB,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,OAAO;QACL,WAAW,EAAE,qBAAqB;QAClC,MAAM,EAAE,gBAAgB;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type * from "./jsonTypes.js";
|
|
2
|
+
export type * from "./jsonableTypes.js";
|
|
3
|
+
export type { JsonableValueParameters } from "./jsonableParametersTypes.js";
|
|
4
|
+
export { parseJsonable } from "./parseJsonable.js";
|
|
5
|
+
export { stringifyJsonable } from "./stringifyJsonable.js";
|
|
6
|
+
export { createJsonableTransformer } from "./createJsonableTransformer.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/json/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const JsonValueTypes: readonly ["object", "array", "string", "number", "boolean", "null"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonConsts.js","sourceRoot":"","sources":["../../../src/json/jsonConsts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;CACE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type JsonValue = JsonObject | JsonValue[] | JsonString | JsonNumber | JsonBoolean | JsonNull;
|
|
2
|
+
export type JsonObject = {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type JsonString = string;
|
|
6
|
+
export type JsonNumber = number;
|
|
7
|
+
export type JsonBoolean = boolean;
|
|
8
|
+
export type JsonNull = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonTypes.js","sourceRoot":"","sources":["../../../src/json/jsonTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DocumentContent, type DocumentContext } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
import type { JsonableValue } from "../jsonableTypes.js";
|
|
4
|
+
import type { JsonValue } from "../jsonTypes.js";
|
|
5
|
+
export declare class ArrayJsonable extends AbstractJsonable {
|
|
6
|
+
private readonly lengthContent;
|
|
7
|
+
readonly type: "array";
|
|
8
|
+
private readonly weightedItemFeeder;
|
|
9
|
+
constructor(items: readonly JsonableValue[], lengthContent: DocumentContent, probability: number | undefined, weight: number | undefined);
|
|
10
|
+
protected toJSONImpl(keyOrIndex: string | number, context: DocumentContext): JsonValue[] | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { WeightedItemFeeder } from "../../common/weightedItemFeeder.js";
|
|
2
|
+
import { stampDocument, } from "../../document/index.js";
|
|
3
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
4
|
+
import { transformJsonableIntoJsonValue } from "../stringifyJsonable.js";
|
|
5
|
+
export class ArrayJsonable extends AbstractJsonable {
|
|
6
|
+
lengthContent;
|
|
7
|
+
type = "array";
|
|
8
|
+
weightedItemFeeder;
|
|
9
|
+
constructor(items, lengthContent, probability, weight) {
|
|
10
|
+
super(probability, weight);
|
|
11
|
+
this.lengthContent = lengthContent;
|
|
12
|
+
const weightedItemFeeder = new WeightedItemFeeder();
|
|
13
|
+
items.forEach((item) => {
|
|
14
|
+
if (item instanceof AbstractJsonable) {
|
|
15
|
+
weightedItemFeeder.addItem(item, item.weight);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
weightedItemFeeder.addItem(item);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
this.weightedItemFeeder = weightedItemFeeder;
|
|
22
|
+
}
|
|
23
|
+
toJSONImpl(keyOrIndex, context) {
|
|
24
|
+
const jsonValues = [];
|
|
25
|
+
const length = Number.parseInt(stampDocument(this.lengthContent, context));
|
|
26
|
+
if (!Number.isNaN(length) && length > 0) {
|
|
27
|
+
for (let i = 0; i < length; i++) {
|
|
28
|
+
const item = this.weightedItemFeeder.getItem();
|
|
29
|
+
if (item !== undefined) {
|
|
30
|
+
const jsonValue = transformJsonableIntoJsonValue(item, i, context);
|
|
31
|
+
if (jsonValue !== undefined) {
|
|
32
|
+
jsonValues.push(jsonValue);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return jsonValues;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=arrayJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayJsonable.js","sourceRoot":"","sources":["../../../../src/json/jsonableClasses/arrayJsonable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAGL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAEzE,MAAM,OAAO,aAAc,SAAQ,gBAAgB;IAM9B;IALH,IAAI,GAAG,OAAgB,CAAC;IACvB,kBAAkB,CAAoC;IAEvE,YACE,KAA+B,EACd,aAA8B,EAC/C,WAA+B,EAC/B,MAA0B;QAE1B,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAJV,kBAAa,GAAb,aAAa,CAAiB;QAK/C,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAiB,CAAC;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,IAAI,YAAY,gBAAgB,EAAE,CAAC;gBACrC,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAChD,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAES,UAAU,CAClB,UAA2B,EAC3B,OAAwB;QAExB,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAChC,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;gBAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;oBACvB,MAAM,SAAS,GAAG,8BAA8B,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;oBACnE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;wBAC5B,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC7B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DocumentContent, type DocumentContext } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
export declare class BooleanJsonable extends AbstractJsonable {
|
|
4
|
+
private readonly content;
|
|
5
|
+
readonly type: "boolean";
|
|
6
|
+
constructor(content: DocumentContent, probability: number | undefined, weight: number | undefined);
|
|
7
|
+
protected toJSONImpl(keyOrIndex: string | number, context: DocumentContext): string | undefined;
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { stampDocument, } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
export class BooleanJsonable extends AbstractJsonable {
|
|
4
|
+
content;
|
|
5
|
+
type = "boolean";
|
|
6
|
+
constructor(content, probability, weight) {
|
|
7
|
+
super(probability, weight);
|
|
8
|
+
this.content = content;
|
|
9
|
+
}
|
|
10
|
+
toJSONImpl(keyOrIndex, context) {
|
|
11
|
+
const output = Boolean(stampDocument(this.content, context));
|
|
12
|
+
return output ? "true" : "false";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=booleanJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booleanJsonable.js","sourceRoot":"","sources":["../../../../src/json/jsonableClasses/booleanJsonable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,OAAO,eAAgB,SAAQ,gBAAgB;IAIhC;IAHH,IAAI,GAAG,SAAkB,CAAC;IAE1C,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,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DocumentContext } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
import type { JsonNull } from "../jsonTypes.js";
|
|
4
|
+
export declare class NullJsonable extends AbstractJsonable {
|
|
5
|
+
readonly type: "null";
|
|
6
|
+
constructor(probability: number | undefined, weight: number | undefined);
|
|
7
|
+
protected toJSONImpl(keyOrIndex: string | number, context: DocumentContext): JsonNull | undefined;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
2
|
+
export class NullJsonable extends AbstractJsonable {
|
|
3
|
+
type = "null";
|
|
4
|
+
constructor(probability, weight) {
|
|
5
|
+
super(probability, weight);
|
|
6
|
+
}
|
|
7
|
+
toJSONImpl(keyOrIndex, context) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=nullJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullJsonable.js","sourceRoot":"","sources":["../../../../src/json/jsonableClasses/nullJsonable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,OAAO,YAAa,SAAQ,gBAAgB;IAChC,IAAI,GAAG,MAAe,CAAC;IAEvC,YAAY,WAA+B,EAAE,MAA0B;QACrE,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;IAES,UAAU,CAClB,UAA2B,EAC3B,OAAwB;QAExB,OAAO,IAAI,CAAC;IACd,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 { JsonNumber } from "../jsonTypes.js";
|
|
4
|
+
export declare class NumberJsonable extends AbstractJsonable {
|
|
5
|
+
private readonly content;
|
|
6
|
+
readonly type: "number";
|
|
7
|
+
constructor(content: DocumentContent, probability: number | undefined, weight: number | undefined);
|
|
8
|
+
protected toJSONImpl(keyOrIndex: string | number, context: DocumentContext): JsonNumber | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { stampDocument, } from "../../document/index.js";
|
|
2
|
+
import { AbstractJsonable } from "../abstractJsonable.js";
|
|
3
|
+
export class NumberJsonable extends AbstractJsonable {
|
|
4
|
+
content;
|
|
5
|
+
type = "number";
|
|
6
|
+
constructor(content, probability, weight) {
|
|
7
|
+
super(probability, weight);
|
|
8
|
+
this.content = content;
|
|
9
|
+
}
|
|
10
|
+
toJSONImpl(keyOrIndex, context) {
|
|
11
|
+
const output = Number(stampDocument(this.content, context));
|
|
12
|
+
if (Number.isNaN(output)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return output;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=numberJsonable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberJsonable.js","sourceRoot":"","sources":["../../../../src/json/jsonableClasses/numberJsonable.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,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC5D,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|