From 59c349b5951d12a6fae345483c2f6fa55d92df4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Tue, 12 Mar 2024 19:55:48 +0100 Subject: [PATCH] refactor: making xk6-faker more maintainable --- .github/workflows/build.yml | 19 + .github/workflows/docs.yml | 40 + .github/workflows/lint.yml | 32 + .github/workflows/release.yml | 58 + .github/workflows/test.yml | 41 + .gitignore | 7 +- .golangci.yml | 165 +- .vscode/settings.json | 3 +- LICENSE | 682 ++++- Taskfile.yml | 62 - docs/README.md | 48 - docs/classes/faker.md | 2212 -------------- docs/interfaces/address.md | 64 - docs/interfaces/car.md | 50 - docs/interfaces/contact.md | 22 - docs/interfaces/creditcard.md | 36 - docs/interfaces/creditcardoptions.md | 29 - docs/interfaces/currency.md | 22 - docs/interfaces/job.md | 36 - docs/interfaces/person.md | 64 - faker.go | 64 - faker/faker.go | 191 ++ faker/faker_internal_test.go | 136 + faker/faker_test.go | 122 + faker/fumctions_test.go | 89 + faker/functions.go | 69 + faker/lookup.go | 127 + faker/lookup_test.go | 32 + functions.json | 4021 ++++++++++++++++++++++++++ functions_test.go | 52 + go.mod | 47 +- go.sum | 131 +- module.go | 105 - module/module.go | 65 + module/module_internal_test.go | 34 + module/module_test.go | 50 + package-lock.json | 812 ------ package.json | 8 - register.go | 16 + register_internal_test.go | 15 + script.js | 7 + test/expect.js | 258 -- test/faker.test.js | 276 -- test/testdata/sample.csv | 6 - tools/codegen/genjson.go | 16 + tools/codegen/gentest.go | 9 + tools/codegen/gents.go | 9 + tools/codegen/lookup.go | 82 + tools/codegen/main.go | 59 + tsconfig.json | 25 +- typedoc.json | 8 - 51 files changed, 6328 insertions(+), 4305 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml delete mode 100644 Taskfile.yml delete mode 100644 docs/README.md delete mode 100644 docs/classes/faker.md delete mode 100644 docs/interfaces/address.md delete mode 100644 docs/interfaces/car.md delete mode 100644 docs/interfaces/contact.md delete mode 100644 docs/interfaces/creditcard.md delete mode 100644 docs/interfaces/creditcardoptions.md delete mode 100644 docs/interfaces/currency.md delete mode 100644 docs/interfaces/job.md delete mode 100644 docs/interfaces/person.md delete mode 100644 faker.go create mode 100644 faker/faker.go create mode 100644 faker/faker_internal_test.go create mode 100644 faker/faker_test.go create mode 100644 faker/fumctions_test.go create mode 100644 faker/functions.go create mode 100644 faker/lookup.go create mode 100644 faker/lookup_test.go create mode 100644 functions.json create mode 100644 functions_test.go delete mode 100644 module.go create mode 100644 module/module.go create mode 100644 module/module_internal_test.go create mode 100644 module/module_test.go delete mode 100644 package-lock.json delete mode 100644 package.json create mode 100644 register.go create mode 100644 register_internal_test.go create mode 100644 script.js delete mode 100644 test/expect.js delete mode 100644 test/faker.test.js delete mode 100644 test/testdata/sample.csv create mode 100644 tools/codegen/genjson.go create mode 100644 tools/codegen/gentest.go create mode 100644 tools/codegen/gents.go create mode 100644 tools/codegen/lookup.go create mode 100644 tools/codegen/main.go delete mode 100644 typedoc.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a24dd89 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +name: Build +on: [pull_request] + +jobs: + build: + name: Bundle xk6 extensions + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build + id: build + uses: szkiba/xk6bundler@v0 + with: + with: github.com/szkiba/xk6-faker=/github/workspace diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..79bf618 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,40 @@ +name: Docs +on: + push: + branches: [master, feature/simplifa-api] + paths: + - .github/workflows/docs.yml + - index.js + - index.d.ts + - tsconfig.json + +jobs: + docs: + name: Docs + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install bun + uses: oven-sh/setup-bun@v1 + - name: Generate API doc + run: bun x typedoc + - name: Copy index.d.ts + run: cp index.d.ts build/docs/ + + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: "build/docs" + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..25f6264 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +name: lint + +on: + pull_request: + workflow_dispatch: + push: + paths-ignore: + - "docs/**" + - README.md + - "releases/**" + +permissions: + contents: read + +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + cache: false + - name: Go linter + uses: golangci/golangci-lint-action@v3 + with: + version: v1.55 + args: --timeout=30m + install-mode: binary diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..780da03 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release +on: + push: + tags: + - "v*" + +jobs: + release: + name: Bundle xk6 extensions + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build + id: build + uses: szkiba/xk6bundler@v0 + with: + with: github.com/szkiba/xk6-faker=/github/workspace + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: dist/*.tar.gz + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + context: ./${{ steps.build.outputs.dockerdir }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c7dadbb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: test + +on: + pull_request: + workflow_dispatch: + push: + paths-ignore: + - "docs/**" + - README.md + - "releases/**" + +jobs: + test: + name: Test + strategy: + matrix: + platform: + - ubuntu-latest + - macos-latest + - windows-latest + runs-on: ${{matrix.platform}} + steps: + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + - name: Checkout code + uses: actions/checkout@v4 + + - name: Test + run: go test -count 1 -race -coverprofile=coverage.txt ./... + + - name: Upload Coverage + if: ${{ matrix.platform == 'ubuntu-latest' && github.ref_name == 'master' }} + uses: codecov/codecov-action@v3 + with: + directory: build + + - name: Generate Go Report Card + if: ${{ matrix.platform == 'ubuntu-latest' && github.ref_name == 'master' }} + uses: creekorful/goreportcard-action@v1.0 diff --git a/.gitignore b/.gitignore index ebb2368..695a2d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /k6 -.task -node_modules -vendor/ \ No newline at end of file +*_skeleton.go +/build +/node_modules +yarn.lock \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index de13757..cdd1054 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,42 +1,135 @@ -# MIT License -# -# Copyright (c) 2021 Iván Szkiba -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# v1.55.2 +# Please don't remove the first line. It uses in CI to determine the golangci version +run: + deadline: 5m + +issues: + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 + + # We want to try and improve the comments in the k6 codebase, so individual + # non-golint items from the default exclusion list will gradually be added + # to the exclude-rules below + exclude-use-default: false + + exclude-rules: + # Exclude duplicate code and function length and complexity checking in test + # files (due to common repeats and long functions in test code) + - path: _(test|gen)\.go + linters: + - cyclop + - dupl + - gocognit + - funlen + - lll + - path: js\/modules\/k6\/http\/.*_test\.go + linters: + # k6/http module's tests are quite complex because they often have several nested levels. + # The module is in maintainance mode, so we don't intend to port the tests to a parallel version. + - paralleltest + - tparallel + - linters: + - staticcheck # Tracked in https://github.com/grafana/xk6-grpc/issues/14 + text: "The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated." + - linters: + - forbidigo + text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden' + +linters-settings: + nolintlint: + # Disable to ensure that nolint directives don't have a leading space. Default is true. + allow-leading-space: false + exhaustive: + default-signifies-exhaustive: true + govet: + check-shadowing: true + cyclop: + max-complexity: 25 + maligned: + suggest-new: true + dupl: + threshold: 150 + goconst: + min-len: 10 + min-occurrences: 4 + funlen: + lines: 80 + statements: 60 + forbidigo: + forbid: + - '^(fmt\\.Print(|f|ln)|print|println)$' + # Forbid everything in os, except os.Signal and os.SyscalError + - '^os\.(.*)$(# Using anything except Signal and SyscallError from the os package is forbidden )?' + # Forbid everything in syscall except the uppercase constants + - '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?' + - '^logrus\.Logger$' linters: - presets: - - bugs - - style - - unused - - complexity - - format - - performance + disable-all: true enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - contextcheck + - cyclop + - dogsled + - dupl + - durationcheck + - errcheck + - errchkjson + - errname + - errorlint + - exhaustive - exportloopref - disable: - - nolintlint - - exhaustivestruct + - forbidigo + - forcetypeassert + - funlen + - gocheckcompilerdirectives - gochecknoglobals - - gochecknoinits + - gocognit + - goconst + - gocritic + - gofmt + - gofumpt + - goimports + - gomoddirectives + - goprintffuncname + - gosec + - gosimple + - govet + - importas + - ineffassign + - interfacebloat - lll - - maligned - - interfacer - - scopelint - - wrapcheck + - makezero + - misspell + - nakedret + - nestif + - nilerr + - nilnil + - noctx + - nolintlint + - nosprintfhostport + - paralleltest + - prealloc + - predeclared + - promlinter + - revive + - reassign + - rowserrcheck + - sqlclosecheck + - staticcheck + - stylecheck + - tenv + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - wastedassign + - whitespace + fast: false diff --git a/.vscode/settings.json b/.vscode/settings.json index 6e380ce..cb6adc1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "go.lintTool": "golangci-lint", - "go.lintFlags": ["--fast"] + "go.lintFlags": ["--fast"], + "go.buildTags": "codegen" } diff --git a/LICENSE b/LICENSE index 9df0146..be3f7b2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,661 @@ -MIT License - -Copyright (c) 2021 Iván Szkiba - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/Taskfile.yml b/Taskfile.yml deleted file mode 100644 index 71c9e4d..0000000 --- a/Taskfile.yml +++ /dev/null @@ -1,62 +0,0 @@ -# MIT License -# -# Copyright (c) 2021 Iván Szkiba -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -version: "3" - -env: - K6_VERSION: v0.43.1 - -silent: true - -tasks: - default: - cmds: - - task: test - - clean: - desc: Clean up working directory - cmds: - - rm -rf k6 .task node_modules - - build: - sources: - - "**/*.go" - generates: - - k6 - cmds: - - xk6 build --with github.com/szkiba/xk6-faker=$(pwd) - - test: - deps: [build] - cmds: - - ./k6 run --no-usage-report test/faker.test.js - - npm:install: - cmds: - - npm ci - status: - - test -d node_modules - - docs: - deps: [npm:install] - cmds: - - npx typedoc diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 2153d7b..0000000 --- a/docs/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# xk6-faker - -xk6-faker random fake data generator - -The main generator class is [Faker](classes/faker.md). - -```js -import { Faker } from "k6/x/faker" - -let f = new Faker(); -console.log(f.name()); -``` - -Pass a random seed number to [Faker constructor](classes/faker.md#constructor) if you want to get deterministic random values. - -```js -import { Faker } from "k6/x/faker" - -let f = new Faker(1234); -console.log(f.name()); -``` - -For easier usage, the module's default export is a Faker instance too, so you can use generator functions without instantiating the [Faker](classes/faker.md) class: - -```js -import faker from "k6/x/faker" - -console.log(faker.name()) -``` - -You can pass random seed value in `XK6_FAKER_SEED` env if you want deterministic generated random values. - -## Table of contents - -### Classes - -- [Faker](classes/faker.md) - -### Interfaces - -- [Address](interfaces/address.md) -- [Car](interfaces/car.md) -- [Contact](interfaces/contact.md) -- [CreditCard](interfaces/creditcard.md) -- [CreditCardOptions](interfaces/creditcardoptions.md) -- [Currency](interfaces/currency.md) -- [Job](interfaces/job.md) -- [Person](interfaces/person.md) diff --git a/docs/classes/faker.md b/docs/classes/faker.md deleted file mode 100644 index 4af1eac..0000000 --- a/docs/classes/faker.md +++ /dev/null @@ -1,2212 +0,0 @@ -# Class: Faker - -## Table of contents - -### Constructors - -- [constructor](faker.md#constructor) - -### Methods - -- [achAccount](faker.md#achaccount) -- [achRouting](faker.md#achrouting) -- [address](faker.md#address) -- [adjective](faker.md#adjective) -- [adverb](faker.md#adverb) -- [animal](faker.md#animal) -- [animalType](faker.md#animaltype) -- [appAuthor](faker.md#appauthor) -- [appName](faker.md#appname) -- [appVersion](faker.md#appversion) -- [beerAlcohol](faker.md#beeralcohol) -- [beerBlg](faker.md#beerblg) -- [beerHop](faker.md#beerhop) -- [beerIbu](faker.md#beeribu) -- [beerMalt](faker.md#beermalt) -- [beerName](faker.md#beername) -- [beerStyle](faker.md#beerstyle) -- [beerYeast](faker.md#beeryeast) -- [bitcoinAddress](faker.md#bitcoinaddress) -- [bitcoinPrivateKey](faker.md#bitcoinprivatekey) -- [bool](faker.md#bool) -- [breakfast](faker.md#breakfast) -- [bs](faker.md#bs) -- [buzzWord](faker.md#buzzword) -- [car](faker.md#car) -- [carFuelType](faker.md#carfueltype) -- [carMaker](faker.md#carmaker) -- [carModel](faker.md#carmodel) -- [carTransmissionType](faker.md#cartransmissiontype) -- [carType](faker.md#cartype) -- [cat](faker.md#cat) -- [chromeUserAgent](faker.md#chromeuseragent) -- [city](faker.md#city) -- [color](faker.md#color) -- [company](faker.md#company) -- [companySuffix](faker.md#companysuffix) -- [contact](faker.md#contact) -- [country](faker.md#country) -- [countryAbr](faker.md#countryabr) -- [creditCard](faker.md#creditcard) -- [creditCardCvv](faker.md#creditcardcvv) -- [creditCardExp](faker.md#creditcardexp) -- [creditCardNumber](faker.md#creditcardnumber) -- [creditCardType](faker.md#creditcardtype) -- [currency](faker.md#currency) -- [currencyLong](faker.md#currencylong) -- [currencyShort](faker.md#currencyshort) -- [date](faker.md#date) -- [dateRange](faker.md#daterange) -- [day](faker.md#day) -- [dessert](faker.md#dessert) -- [digit](faker.md#digit) -- [digitN](faker.md#digitn) -- [dinner](faker.md#dinner) -- [dog](faker.md#dog) -- [domainName](faker.md#domainname) -- [domainSuffix](faker.md#domainsuffix) -- [email](faker.md#email) -- [emoji](faker.md#emoji) -- [emojiAlias](faker.md#emojialias) -- [emojiCategory](faker.md#emojicategory) -- [emojiDescription](faker.md#emojidescription) -- [emojiTag](faker.md#emojitag) -- [farmAnimal](faker.md#farmanimal) -- [fileExtension](faker.md#fileextension) -- [fileMimeType](faker.md#filemimetype) -- [firefoxUserAgent](faker.md#firefoxuseragent) -- [firstName](faker.md#firstname) -- [flipACoin](faker.md#flipacoin) -- [float32](faker.md#float32) -- [float32Range](faker.md#float32range) -- [float64](faker.md#float64) -- [float64Range](faker.md#float64range) -- [fruit](faker.md#fruit) -- [gamertag](faker.md#gamertag) -- [gender](faker.md#gender) -- [generate](faker.md#generate) -- [hackerAbbreviation](faker.md#hackerabbreviation) -- [hackerAdjective](faker.md#hackeradjective) -- [hackerNoun](faker.md#hackernoun) -- [hackerPhrase](faker.md#hackerphrase) -- [hackerVerb](faker.md#hackerverb) -- [hackeringVerb](faker.md#hackeringverb) -- [hexColor](faker.md#hexcolor) -- [hipsterParagraph](faker.md#hipsterparagraph) -- [hipsterSentence](faker.md#hipstersentence) -- [hipsterWord](faker.md#hipsterword) -- [hour](faker.md#hour) -- [httpMethod](faker.md#httpmethod) -- [httpStatusCode](faker.md#httpstatuscode) -- [httpStatusCodeSimple](faker.md#httpstatuscodesimple) -- [imageJpeg](faker.md#imagejpeg) -- [imagePng](faker.md#imagepng) -- [imageURL](faker.md#imageurl) -- [int16](faker.md#int16) -- [int32](faker.md#int32) -- [int64](faker.md#int64) -- [int8](faker.md#int8) -- [ipv4Address](faker.md#ipv4address) -- [ipv6Address](faker.md#ipv6address) -- [job](faker.md#job) -- [jobDescriptor](faker.md#jobdescriptor) -- [jobLevel](faker.md#joblevel) -- [jobTitle](faker.md#jobtitle) -- [language](faker.md#language) -- [languageAbbreviation](faker.md#languageabbreviation) -- [lastName](faker.md#lastname) -- [latitude](faker.md#latitude) -- [latitudeInRange](faker.md#latitudeinrange) -- [letter](faker.md#letter) -- [letterN](faker.md#lettern) -- [lexify](faker.md#lexify) -- [logLevel](faker.md#loglevel) -- [longitude](faker.md#longitude) -- [longitudeInRange](faker.md#longitudeinrange) -- [loremIpsumParagraph](faker.md#loremipsumparagraph) -- [loremIpsumSentence](faker.md#loremipsumsentence) -- [loremIpsumWord](faker.md#loremipsumword) -- [lunch](faker.md#lunch) -- [macAddress](faker.md#macaddress) -- [minute](faker.md#minute) -- [month](faker.md#month) -- [monthString](faker.md#monthstring) -- [name](faker.md#name) -- [namePrefix](faker.md#nameprefix) -- [nameSuffix](faker.md#namesuffix) -- [nanoSecond](faker.md#nanosecond) -- [noun](faker.md#noun) -- [number](faker.md#number) -- [numerify](faker.md#numerify) -- [operaUserAgent](faker.md#operauseragent) -- [paragraph](faker.md#paragraph) -- [password](faker.md#password) -- [person](faker.md#person) -- [petName](faker.md#petname) -- [phone](faker.md#phone) -- [phoneFormatted](faker.md#phoneformatted) -- [phrase](faker.md#phrase) -- [preposition](faker.md#preposition) -- [price](faker.md#price) -- [programmingLanguage](faker.md#programminglanguage) -- [programmingLanguageBest](faker.md#programminglanguagebest) -- [question](faker.md#question) -- [quote](faker.md#quote) -- [randomInt](faker.md#randomint) -- [randomString](faker.md#randomstring) -- [randomUint](faker.md#randomuint) -- [regex](faker.md#regex) -- [rgbColor](faker.md#rgbcolor) -- [safariUserAgent](faker.md#safariuseragent) -- [safeColor](faker.md#safecolor) -- [second](faker.md#second) -- [sentence](faker.md#sentence) -- [snack](faker.md#snack) -- [ssn](faker.md#ssn) -- [state](faker.md#state) -- [stateAbr](faker.md#stateabr) -- [street](faker.md#street) -- [streetName](faker.md#streetname) -- [streetNumber](faker.md#streetnumber) -- [streetPrefix](faker.md#streetprefix) -- [streetSuffix](faker.md#streetsuffix) -- [timeZone](faker.md#timezone) -- [timeZoneAbv](faker.md#timezoneabv) -- [timeZoneFull](faker.md#timezonefull) -- [timeZoneOffset](faker.md#timezoneoffset) -- [timeZoneRegion](faker.md#timezoneregion) -- [uint16](faker.md#uint16) -- [uint32](faker.md#uint32) -- [uint64](faker.md#uint64) -- [uint8](faker.md#uint8) -- [url](faker.md#url) -- [userAgent](faker.md#useragent) -- [username](faker.md#username) -- [uuid](faker.md#uuid) -- [vegetable](faker.md#vegetable) -- [verb](faker.md#verb) -- [weekDay](faker.md#weekday) -- [word](faker.md#word) -- [year](faker.md#year) -- [zip](faker.md#zip) - -## Constructors - -### constructor - -\+ **new Faker**(`seed?`: *number*): [*Faker*](faker.md) - -Create new Faker instance. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `seed?` | *number* | random seed value for deterministic generator | - -**Returns:** [*Faker*](faker.md) - -## Methods - -### achAccount - -▸ **achAccount**(): *string* - -achAccount will generate a 12 digit account number - -**Returns:** *string* - -___ - -### achRouting - -▸ **achRouting**(): *string* - -achRouting will generate a 9 digit routing number - -**Returns:** *string* - -___ - -### address - -▸ **address**(): [*Address*](../interfaces/address.md) - -address will generate a struct of address information - -**Returns:** [*Address*](../interfaces/address.md) - -___ - -### adjective - -▸ **adjective**(): *string* - -adjective will generate a random adjective - -**Returns:** *string* - -___ - -### adverb - -▸ **adverb**(): *string* - -adverb will generate a random adverb - -**Returns:** *string* - -___ - -### animal - -▸ **animal**(): *string* - -animal will return a random animal - -**Returns:** *string* - -___ - -### animalType - -▸ **animalType**(): *string* - -animalType will return a random animal type - -**Returns:** *string* - -___ - -### appAuthor - -▸ **appAuthor**(): *string* - -appAuthor will generate a random company or person name - -**Returns:** *string* - -___ - -### appName - -▸ **appName**(): *string* - -appName will generate a random app name - -**Returns:** *string* - -___ - -### appVersion - -▸ **appVersion**(): *string* - -appVersion will generate a random app version - -**Returns:** *string* - -___ - -### beerAlcohol - -▸ **beerAlcohol**(): *string* - -beerAlcohol will return a random beer alcohol level between 2.0 and 10.0 - -**Returns:** *string* - -___ - -### beerBlg - -▸ **beerBlg**(): *string* - -beerBlg will return a random beer blg between 5.0 and 20.0 - -**Returns:** *string* - -___ - -### beerHop - -▸ **beerHop**(): *string* - -beerHop will return a random beer hop - -**Returns:** *string* - -___ - -### beerIbu - -▸ **beerIbu**(): *string* - -beerIbu will return a random beer ibu value between 10 and 100 - -**Returns:** *string* - -___ - -### beerMalt - -▸ **beerMalt**(): *string* - -beerMalt will return a random beer malt - -**Returns:** *string* - -___ - -### beerName - -▸ **beerName**(): *string* - -beerName will return a random beer name - -**Returns:** *string* - -___ - -### beerStyle - -▸ **beerStyle**(): *string* - -beerStyle will return a random beer style - -**Returns:** *string* - -___ - -### beerYeast - -▸ **beerYeast**(): *string* - -beerYeast will return a random beer yeast - -**Returns:** *string* - -___ - -### bitcoinAddress - -▸ **bitcoinAddress**(): *string* - -bitcoinAddress will generate a random bitcoin address consisting of numbers, upper and lower characters - -**Returns:** *string* - -___ - -### bitcoinPrivateKey - -▸ **bitcoinPrivateKey**(): *string* - -bitcoinPrivateKey will generate a random bitcoin private key base58 consisting of numbers, upper and lower characters - -**Returns:** *string* - -___ - -### bool - -▸ **bool**(): *boolean* - -bool will generate a random boolean value - -**Returns:** *boolean* - -___ - -### breakfast - -▸ **breakfast**(): *string* - -breakfast will return a random breakfast name - -**Returns:** *string* - -___ - -### bs - -▸ **bs**(): *string* - -bs will generate a random company bs string - -**Returns:** *string* - -___ - -### buzzWord - -▸ **buzzWord**(): *string* - -buzzWord will generate a random company buzz word string - -**Returns:** *string* - -___ - -### car - -▸ **car**(): [*Car*](../interfaces/car.md) - -car will generate a struct with car information - -**Returns:** [*Car*](../interfaces/car.md) - -___ - -### carFuelType - -▸ **carFuelType**(): *string* - -carFuelType will return a random fuel type - -**Returns:** *string* - -___ - -### carMaker - -▸ **carMaker**(): *string* - -carMaker will return a random car maker - -**Returns:** *string* - -___ - -### carModel - -▸ **carModel**(): *string* - -carModel will return a random car model - -**Returns:** *string* - -___ - -### carTransmissionType - -▸ **carTransmissionType**(): *string* - -carTransmissionType will return a random transmission type - -**Returns:** *string* - -___ - -### carType - -▸ **carType**(): *string* - -carType will generate a random car type string - -**Returns:** *string* - -___ - -### cat - -▸ **cat**(): *string* - -cat will return a random cat breed - -**Returns:** *string* - -___ - -### chromeUserAgent - -▸ **chromeUserAgent**(): *string* - -chromeUserAgent will generate a random chrome browser user agent string - -**Returns:** *string* - -___ - -### city - -▸ **city**(): *string* - -city will generate a random city string - -**Returns:** *string* - -___ - -### color - -▸ **color**(): *string* - -color will generate a random color string - -**Returns:** *string* - -___ - -### company - -▸ **company**(): *string* - -company will generate a random company name string - -**Returns:** *string* - -___ - -### companySuffix - -▸ **companySuffix**(): *string* - -companySuffix will generate a random company suffix string - -**Returns:** *string* - -___ - -### contact - -▸ **contact**(): [*Contact*](../interfaces/contact.md) - -contact will generate a struct with information randomly populated contact information - -**Returns:** [*Contact*](../interfaces/contact.md) - -___ - -### country - -▸ **country**(): *string* - -country will generate a random country string - -**Returns:** *string* - -___ - -### countryAbr - -▸ **countryAbr**(): *string* - -countryAbr will generate a random abbreviated country string - -**Returns:** *string* - -___ - -### creditCard - -▸ **creditCard**(): [*CreditCard*](../interfaces/creditcard.md) - -creditCard will generate a struct full of credit card information - -**Returns:** [*CreditCard*](../interfaces/creditcard.md) - -___ - -### creditCardCvv - -▸ **creditCardCvv**(): *string* - -creditCardCvv will generate a random CVV number Its a string because you could have 017 as an exp date - -**Returns:** *string* - -___ - -### creditCardExp - -▸ **creditCardExp**(): *string* - -creditCardExp will generate a random credit card expiration date string Exp date will always be a future date - -**Returns:** *string* - -___ - -### creditCardNumber - -▸ **creditCardNumber**(`opts?`: [*CreditCardOptions*](../interfaces/creditcardoptions.md)): *string* - -creditCardNumber will generate a random luhn credit card number - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | [*CreditCardOptions*](../interfaces/creditcardoptions.md) | - -**Returns:** *string* - -___ - -### creditCardType - -▸ **creditCardType**(): *string* - -creditCardType will generate a random credit card type string - -**Returns:** *string* - -___ - -### currency - -▸ **currency**(): [*Currency*](../interfaces/currency.md) - -currency will generate a struct with random currency information - -**Returns:** [*Currency*](../interfaces/currency.md) - -___ - -### currencyLong - -▸ **currencyLong**(): *string* - -currencyLong will generate a random long currency name - -**Returns:** *string* - -___ - -### currencyShort - -▸ **currencyShort**(): *string* - -currencyShort will generate a random short currency value - -**Returns:** *string* - -___ - -### date - -▸ **date**(): Date - -date will generate a random time.Time struct - -**Returns:** Date - -___ - -### dateRange - -▸ **dateRange**(`start`: Date, `end`: Date): Date - -dateRange will generate a random time.Time struct between a start and end date - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `start` | Date | -| `end` | Date | - -**Returns:** Date - -___ - -### day - -▸ **day**(): *number* - -day will generate a random day between 1 - 31 - -**Returns:** *number* - -___ - -### dessert - -▸ **dessert**(): *string* - -dessert will return a random dessert name - -**Returns:** *string* - -___ - -### digit - -▸ **digit**(): *string* - -digit will generate a single ASCII digit - -**Returns:** *string* - -___ - -### digitN - -▸ **digitN**(`m`: *number*): *string* - -digitN will generate a random string of length N consists of ASCII digits (note it can start with 0). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `m` | *number* | - -**Returns:** *string* - -___ - -### dinner - -▸ **dinner**(): *string* - -dinner will return a random dinner name - -**Returns:** *string* - -___ - -### dog - -▸ **dog**(): *string* - -dog will return a random dog breed - -**Returns:** *string* - -___ - -### domainName - -▸ **domainName**(): *string* - -domainName will generate a random url domain name - -**Returns:** *string* - -___ - -### domainSuffix - -▸ **domainSuffix**(): *string* - -domainSuffix will generate a random domain suffix - -**Returns:** *string* - -___ - -### email - -▸ **email**(): *string* - -email will generate a random email string - -**Returns:** *string* - -___ - -### emoji - -▸ **emoji**(): *string* - -emoji will return a random fun emoji - -**Returns:** *string* - -___ - -### emojiAlias - -▸ **emojiAlias**(): *string* - -emojiAlias will return a random fun emoji alias - -**Returns:** *string* - -___ - -### emojiCategory - -▸ **emojiCategory**(): *string* - -emojiCategory will return a random fun emoji category - -**Returns:** *string* - -___ - -### emojiDescription - -▸ **emojiDescription**(): *string* - -emojiDescription will return a random fun emoji description - -**Returns:** *string* - -___ - -### emojiTag - -▸ **emojiTag**(): *string* - -emojiTag will return a random fun emoji tag - -**Returns:** *string* - -___ - -### farmAnimal - -▸ **farmAnimal**(): *string* - -farmAnimal will return a random animal that usually lives on a farm - -**Returns:** *string* - -___ - -### fileExtension - -▸ **fileExtension**(): *string* - -fileExtension will generate a random file extension - -**Returns:** *string* - -___ - -### fileMimeType - -▸ **fileMimeType**(): *string* - -fileMimeType will generate a random mime file type - -**Returns:** *string* - -___ - -### firefoxUserAgent - -▸ **firefoxUserAgent**(): *string* - -firefoxUserAgent will generate a random firefox broswer user agent string - -**Returns:** *string* - -___ - -### firstName - -▸ **firstName**(): *string* - -firstName will generate a random first name - -**Returns:** *string* - -___ - -### flipACoin - -▸ **flipACoin**(): *string* - -flipACoin will return a random value of Heads or Tails - -**Returns:** *string* - -___ - -### float32 - -▸ **float32**(): *number* - -float32 will generate a random float32 value - -**Returns:** *number* - -___ - -### float32Range - -▸ **float32Range**(`min`: *number*, `max`: *number*): *number* - -float32Range will generate a random float32 value between min and max - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `min` | *number* | -| `max` | *number* | - -**Returns:** *number* - -___ - -### float64 - -▸ **float64**(): *number* - -float64 will generate a random float64 value - -**Returns:** *number* - -___ - -### float64Range - -▸ **float64Range**(`min`: *number*, `max`: *number*): *number* - -float64Range will generate a random float64 value between min and max - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `min` | *number* | -| `max` | *number* | - -**Returns:** *number* - -___ - -### fruit - -▸ **fruit**(): *string* - -fruit will return a random fruit name - -**Returns:** *string* - -___ - -### gamertag - -▸ **gamertag**(): *string* - -gamertag will generate a random video game username - -**Returns:** *string* - -___ - -### gender - -▸ **gender**(): *string* - -gender will generate a random gender string - -**Returns:** *string* - -___ - -### generate - -▸ **generate**(`dataVal`: *string*): *string* - -Generate fake information from given string. Replaceable values should be within {} - -**Functions** -- `{firstname}` - `billy` -- `{sentence:3}` - `Record river mind.` -- `{number:1,10}` - `4` -- `{uuid}` - `590c1440-9888-45b0-bd51-a817ee07c3f2` - -**Letters/Numbers** -- random numbers: `###` - `481` -- random letters: `???` - `fda` - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `dataVal` | *string* | template string | - -**Returns:** *string* - -___ - -### hackerAbbreviation - -▸ **hackerAbbreviation**(): *string* - -hackerAbbreviation will return a random hacker abbreviation - -**Returns:** *string* - -___ - -### hackerAdjective - -▸ **hackerAdjective**(): *string* - -hackerAdjective will return a random hacker adjective - -**Returns:** *string* - -___ - -### hackerNoun - -▸ **hackerNoun**(): *string* - -hackerNoun will return a random hacker noun - -**Returns:** *string* - -___ - -### hackerPhrase - -▸ **hackerPhrase**(): *string* - -hackerPhrase will return a random hacker sentence - -**Returns:** *string* - -___ - -### hackerVerb - -▸ **hackerVerb**(): *string* - -hackerVerb will return a random hacker verb - -**Returns:** *string* - -___ - -### hackeringVerb - -▸ **hackeringVerb**(): *string* - -hackeringVerb will return a random hacker ingverb - -**Returns:** *string* - -___ - -### hexColor - -▸ **hexColor**(): *string* - -hexColor will generate a random hexadecimal color string - -**Returns:** *string* - -___ - -### hipsterParagraph - -▸ **hipsterParagraph**(`paragraphCount`: *number*, `sentenceCount`: *number*, `wordCount`: *number*, `separator`: *string*): *string* - -hipsterParagraph will generate a random paragraphGenerator Set Paragraph Count Set Sentence Count Set Word Count Set Paragraph Separator - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `paragraphCount` | *number* | -| `sentenceCount` | *number* | -| `wordCount` | *number* | -| `separator` | *string* | - -**Returns:** *string* - -___ - -### hipsterSentence - -▸ **hipsterSentence**(`wordCount`: *number*): *string* - -hipsterSentence will generate a random sentence - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `wordCount` | *number* | - -**Returns:** *string* - -___ - -### hipsterWord - -▸ **hipsterWord**(): *string* - -hipsterWord will return a single hipster word - -**Returns:** *string* - -___ - -### hour - -▸ **hour**(): *number* - -hour will generate a random hour - in military time - -**Returns:** *number* - -___ - -### httpMethod - -▸ **httpMethod**(): *string* - -httpMethod will generate a random http method - -**Returns:** *string* - -___ - -### httpStatusCode - -▸ **httpStatusCode**(): *number* - -httpStatusCode will generate a random status code - -**Returns:** *number* - -___ - -### httpStatusCodeSimple - -▸ **httpStatusCodeSimple**(): *number* - -httpStatusCodeSimple will generate a random simple status code - -**Returns:** *number* - -___ - -### imageJpeg - -▸ **imageJpeg**(`width`: *number*, `height`: *number*): ArrayBuffer - -imageJpeg generates a random rgba jpeg image - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `width` | *number* | -| `height` | *number* | - -**Returns:** ArrayBuffer - -___ - -### imagePng - -▸ **imagePng**(`width`: *number*, `height`: *number*): ArrayBuffer - -imagePng generates a random rgba png image - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `width` | *number* | -| `height` | *number* | - -**Returns:** ArrayBuffer - -___ - -### imageURL - -▸ **imageURL**(`width`: *number*, `height`: *number*): *string* - -imageURL will generate a random Image Based Upon Height And Width. https://picsum.photos/ - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `width` | *number* | -| `height` | *number* | - -**Returns:** *string* - -___ - -### int16 - -▸ **int16**(): *number* - -int16 will generate a random int16 value - -**Returns:** *number* - -___ - -### int32 - -▸ **int32**(): *number* - -int32 will generate a random int32 value - -**Returns:** *number* - -___ - -### int64 - -▸ **int64**(): *number* - -int64 will generate a random int64 value - -**Returns:** *number* - -___ - -### int8 - -▸ **int8**(): *number* - -int8 will generate a random Int8 value - -**Returns:** *number* - -___ - -### ipv4Address - -▸ **ipv4Address**(): *string* - -ipv4Address will generate a random version 4 ip address - -**Returns:** *string* - -___ - -### ipv6Address - -▸ **ipv6Address**(): *string* - -ipv6Address will generate a random version 6 ip address - -**Returns:** *string* - -___ - -### job - -▸ **job**(): [*Job*](../interfaces/job.md) - -job will generate a struct with random job information - -**Returns:** [*Job*](../interfaces/job.md) - -___ - -### jobDescriptor - -▸ **jobDescriptor**(): *string* - -jobDescriptor will generate a random job descriptor string - -**Returns:** *string* - -___ - -### jobLevel - -▸ **jobLevel**(): *string* - -jobLevel will generate a random job level string - -**Returns:** *string* - -___ - -### jobTitle - -▸ **jobTitle**(): *string* - -jobTitle will generate a random job title string - -**Returns:** *string* - -___ - -### language - -▸ **language**(): *string* - -language will return a random language - -**Returns:** *string* - -___ - -### languageAbbreviation - -▸ **languageAbbreviation**(): *string* - -languageAbbreviation will return a random language abbreviation - -**Returns:** *string* - -___ - -### lastName - -▸ **lastName**(): *string* - -lastName will generate a random last name - -**Returns:** *string* - -___ - -### latitude - -▸ **latitude**(): *number* - -latitude will generate a random latitude float64 - -**Returns:** *number* - -___ - -### latitudeInRange - -▸ **latitudeInRange**(`min`: *number*, `max`: *number*): *number* - -latitudeInRange will generate a random latitude within the input range - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `min` | *number* | -| `max` | *number* | - -**Returns:** *number* - -___ - -### letter - -▸ **letter**(): *string* - -letter will generate a single random lower case ASCII letter - -**Returns:** *string* - -___ - -### letterN - -▸ **letterN**(`n`: *number*): *string* - -letterN will generate a random ASCII string with length N - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `n` | *number* | number of letters to generate | - -**Returns:** *string* - -___ - -### lexify - -▸ **lexify**(`str`: *string*): *string* - -lexify will replace ? with random generated letters - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `str` | *string* | - -**Returns:** *string* - -___ - -### logLevel - -▸ **logLevel**(): *string* - -logLevel will generate a random log level See data/LogLevels for list of available levels - -**Returns:** *string* - -___ - -### longitude - -▸ **longitude**(): *number* - -longitude will generate a random longitude float64 - -**Returns:** *number* - -___ - -### longitudeInRange - -▸ **longitudeInRange**(`min`: *number*, `max`: *number*): *number* - -longitudeInRange will generate a random longitude within the input range - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `min` | *number* | -| `max` | *number* | - -**Returns:** *number* - -___ - -### loremIpsumParagraph - -▸ **loremIpsumParagraph**(`paragraphCount`: *number*, `sentenceCount`: *number*, `wordCount`: *number*, `separator`: *string*): *string* - -loremIpsumParagraph will generate a random paragraphGenerator - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `paragraphCount` | *number* | -| `sentenceCount` | *number* | -| `wordCount` | *number* | -| `separator` | *string* | - -**Returns:** *string* - -___ - -### loremIpsumSentence - -▸ **loremIpsumSentence**(`wordCount`: *number*): *string* - -loremIpsumSentence will generate a random sentence - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `wordCount` | *number* | - -**Returns:** *string* - -___ - -### loremIpsumWord - -▸ **loremIpsumWord**(): *string* - -loremIpsumWord will generate a random word - -**Returns:** *string* - -___ - -### lunch - -▸ **lunch**(): *string* - -lunch will return a random lunch name - -**Returns:** *string* - -___ - -### macAddress - -▸ **macAddress**(): *string* - -macAddress will generate a random mac address - -**Returns:** *string* - -___ - -### minute - -▸ **minute**(): *number* - -minute will generate a random minute - -**Returns:** *number* - -___ - -### month - -▸ **month**(): *number* - -month will generate a random month int - -**Returns:** *number* - -___ - -### monthString - -▸ **monthString**(): *string* - -monthString will generate a random month string - -**Returns:** *string* - -___ - -### name - -▸ **name**(): *string* - -name will generate a random First and Last Name - -**Returns:** *string* - -___ - -### namePrefix - -▸ **namePrefix**(): *string* - -namePrefix will generate a random name prefix - -**Returns:** *string* - -___ - -### nameSuffix - -▸ **nameSuffix**(): *string* - -nameSuffix will generate a random name suffix - -**Returns:** *string* - -___ - -### nanoSecond - -▸ **nanoSecond**(): *number* - -nanoSecond will generate a random nano second - -**Returns:** *number* - -___ - -### noun - -▸ **noun**(): *string* - -noun will generate a random noun - -**Returns:** *string* - -___ - -### number - -▸ **number**(`min`: *number*, `max`: *number*): *number* - -number will generate a random number between given min And max - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `min` | *number* | -| `max` | *number* | - -**Returns:** *number* - -___ - -### numerify - -▸ **numerify**(`str`: *string*): *string* - -numerify will replace # with random numerical values - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `str` | *string* | - -**Returns:** *string* - -___ - -### operaUserAgent - -▸ **operaUserAgent**(): *string* - -operaUserAgent will generate a random opera browser user agent string - -**Returns:** *string* - -___ - -### paragraph - -▸ **paragraph**(`paragraphCount`: *number*, `sentenceCount`: *number*, `wordCount`: *number*, `separator`: *string*): *string* - -paragraph will generate a random paragraphGenerator - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `paragraphCount` | *number* | -| `sentenceCount` | *number* | -| `wordCount` | *number* | -| `separator` | *string* | - -**Returns:** *string* - -___ - -### password - -▸ **password**(`lower`: *boolean*, `upper`: *boolean*, `numeric`: *boolean*, `special`: *boolean*, `num`: *number*): *string* - -password will generate a random password. Minimum number length of 5 if less than. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `lower` | *boolean* | -| `upper` | *boolean* | -| `numeric` | *boolean* | -| `special` | *boolean* | -| `num` | *number* | - -**Returns:** *string* - -___ - -### person - -▸ **person**(): *string* - -person will generate a struct with person information - -**Returns:** *string* - -___ - -### petName - -▸ **petName**(): *string* - -petName will return a random fun pet name - -**Returns:** *string* - -___ - -### phone - -▸ **phone**(): *string* - -phone will generate a random phone number string - -**Returns:** *string* - -___ - -### phoneFormatted - -▸ **phoneFormatted**(): *string* - -phoneFormatted will generate a random phone number string - -**Returns:** *string* - -___ - -### phrase - -▸ **phrase**(): *string* - -phrase will return a random dictionary phrase - -**Returns:** *string* - -___ - -### preposition - -▸ **preposition**(): *string* - -preposition will generate a random preposition - -**Returns:** *string* - -___ - -### price - -▸ **price**(`min`: *number*, `max`: *number*): *number* - -price will take in a min and max value and return a formatted price - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `min` | *number* | -| `max` | *number* | - -**Returns:** *number* - -___ - -### programmingLanguage - -▸ **programmingLanguage**(): *string* - -programmingLanguage will return a random programming language - -**Returns:** *string* - -___ - -### programmingLanguageBest - -▸ **programmingLanguageBest**(): *string* - -programmingLanguageBest will return a random programming language - -**Returns:** *string* - -___ - -### question - -▸ **question**(): *string* - -question will return a random question - -**Returns:** *string* - -___ - -### quote - -▸ **quote**(): *string* - -quote will return a random quote from a random person - -**Returns:** *string* - -___ - -### randomInt - -▸ **randomInt**(`all`: *number*[]): *number* - -randomInt will take in a slice of int and return a randomly selected value - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `all` | *number*[] | - -**Returns:** *number* - -___ - -### randomString - -▸ **randomString**(`all`: *string*[]): *string* - -randomString will take in a slice of string and return a randomly selected value - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `all` | *string*[] | - -**Returns:** *string* - -___ - -### randomUint - -▸ **randomUint**(`all`: *number*[]): *number* - -randomUint will take in a slice of uint and return a randomly selected value - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `all` | *number*[] | - -**Returns:** *number* - -___ - -### regex - -▸ **regex**(`regexStr`: *string*): *string* - -regex will generate a string based upon a RE2 syntax - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `regexStr` | *string* | - -**Returns:** *string* - -___ - -### rgbColor - -▸ **rgbColor**(): *number*[] - -rgbColor will generate a random int slice color - -**Returns:** *number*[] - -___ - -### safariUserAgent - -▸ **safariUserAgent**(): *string* - -safariUserAgent will generate a random safari browser user agent string - -**Returns:** *string* - -___ - -### safeColor - -▸ **safeColor**(): *string* - -safeColor will generate a random safe color string - -**Returns:** *string* - -___ - -### second - -▸ **second**(): *number* - -second will generate a random second - -**Returns:** *number* - -___ - -### sentence - -▸ **sentence**(`wordCount`: *number*): *string* - -sentence will generate a random sentence - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `wordCount` | *number* | - -**Returns:** *string* - -___ - -### snack - -▸ **snack**(): *string* - -snack will return a random snack name - -**Returns:** *string* - -___ - -### ssn - -▸ **ssn**(): *string* - -SSN will generate a random Social Security Number - -**Returns:** *string* - -___ - -### state - -▸ **state**(): *string* - -state will generate a random state string - -**Returns:** *string* - -___ - -### stateAbr - -▸ **stateAbr**(): *string* - -stateAbr will generate a random abbreviated state string - -**Returns:** *string* - -___ - -### street - -▸ **street**(): *string* - -street will generate a random address street string - -**Returns:** *string* - -___ - -### streetName - -▸ **streetName**(): *string* - -streetName will generate a random address street name string - -**Returns:** *string* - -___ - -### streetNumber - -▸ **streetNumber**(): *string* - -streetNumber will generate a random address street number string - -**Returns:** *string* - -___ - -### streetPrefix - -▸ **streetPrefix**(): *string* - -streetPrefix will generate a random address street prefix string - -**Returns:** *string* - -___ - -### streetSuffix - -▸ **streetSuffix**(): *string* - -streetSuffix will generate a random address street suffix string - -**Returns:** *string* - -___ - -### timeZone - -▸ **timeZone**(): *string* - -timeZone will select a random timezone string - -**Returns:** *string* - -___ - -### timeZoneAbv - -▸ **timeZoneAbv**(): *string* - -timeZoneAbv will select a random timezone abbreviation string - -**Returns:** *string* - -___ - -### timeZoneFull - -▸ **timeZoneFull**(): *string* - -timeZoneFull will select a random full timezone string - -**Returns:** *string* - -___ - -### timeZoneOffset - -▸ **timeZoneOffset**(): *number* - -timeZoneOffset will select a random timezone offset - -**Returns:** *number* - -___ - -### timeZoneRegion - -▸ **timeZoneRegion**(): *string* - -timeZoneRegion will select a random region style timezone string, e.g. "America/Chicago" - -**Returns:** *string* - -___ - -### uint16 - -▸ **uint16**(): *number* - -uint16 will generate a random uint16 value - -**Returns:** *number* - -___ - -### uint32 - -▸ **uint32**(): *number* - -uint32 will generate a random uint32 value - -**Returns:** *number* - -___ - -### uint64 - -▸ **uint64**(): *number* - -uint64 will generate a random uint64 value - -**Returns:** *number* - -___ - -### uint8 - -▸ **uint8**(): *number* - -uint8 will generate a random uint8 value - -**Returns:** *number* - -___ - -### url - -▸ **url**(): *string* - -url will generate a random url string - -**Returns:** *string* - -___ - -### userAgent - -▸ **userAgent**(): *string* - -userAgent will generate a random broswer user agent - -**Returns:** *string* - -___ - -### username - -▸ **username**(): *string* - -username will generate a random username based upon picking a random lastname and random numbers at the end - -**Returns:** *string* - -___ - -### uuid - -▸ **uuid**(): *string* - -uuid (version 4) will generate a random unique identifier based upon random numbers Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - -**Returns:** *string* - -___ - -### vegetable - -▸ **vegetable**(): *string* - -vegetable will return a random vegetable name - -**Returns:** *string* - -___ - -### verb - -▸ **verb**(): *string* - -verb will generate a random verb - -**Returns:** *string* - -___ - -### weekDay - -▸ **weekDay**(): *string* - -weekDay will generate a random weekday string (Monday-Sunday) - -**Returns:** *string* - -___ - -### word - -▸ **word**(): *string* - -word will generate a random word - -**Returns:** *string* - -___ - -### year - -▸ **year**(): *number* - -year will generate a random year between 1900 - current year - -**Returns:** *number* - -___ - -### zip - -▸ **zip**(): *string* - -zip will generate a random Zip code string - -**Returns:** *string* diff --git a/docs/interfaces/address.md b/docs/interfaces/address.md deleted file mode 100644 index 16e0b24..0000000 --- a/docs/interfaces/address.md +++ /dev/null @@ -1,64 +0,0 @@ -# Interface: Address - -Address is a struct full of address information - -## Table of contents - -### Properties - -- [address](address.md#address) -- [city](address.md#city) -- [country](address.md#country) -- [latitude](address.md#latitude) -- [longitude](address.md#longitude) -- [state](address.md#state) -- [street](address.md#street) -- [zip](address.md#zip) - -## Properties - -### address - -• **address**: *string* - -___ - -### city - -• **city**: *string* - -___ - -### country - -• **country**: *string* - -___ - -### latitude - -• **latitude**: *number* - -___ - -### longitude - -• **longitude**: *number* - -___ - -### state - -• **state**: *string* - -___ - -### street - -• **street**: *string* - -___ - -### zip - -• **zip**: *string* diff --git a/docs/interfaces/car.md b/docs/interfaces/car.md deleted file mode 100644 index 7000c5e..0000000 --- a/docs/interfaces/car.md +++ /dev/null @@ -1,50 +0,0 @@ -# Interface: Car - -Car is a struct dataset of all car information - -## Table of contents - -### Properties - -- [brand](car.md#brand) -- [fuel](car.md#fuel) -- [model](car.md#model) -- [transmission](car.md#transmission) -- [type](car.md#type) -- [year](car.md#year) - -## Properties - -### brand - -• **brand**: *string* - -___ - -### fuel - -• **fuel**: *string* - -___ - -### model - -• **model**: *string* - -___ - -### transmission - -• **transmission**: *string* - -___ - -### type - -• **type**: *string* - -___ - -### year - -• **year**: *number* diff --git a/docs/interfaces/contact.md b/docs/interfaces/contact.md deleted file mode 100644 index 3a42378..0000000 --- a/docs/interfaces/contact.md +++ /dev/null @@ -1,22 +0,0 @@ -# Interface: Contact - -Contact struct full of contact info - -## Table of contents - -### Properties - -- [email](contact.md#email) -- [phone](contact.md#phone) - -## Properties - -### email - -• **email**: *string* - -___ - -### phone - -• **phone**: *string* diff --git a/docs/interfaces/creditcard.md b/docs/interfaces/creditcard.md deleted file mode 100644 index d4b1c4d..0000000 --- a/docs/interfaces/creditcard.md +++ /dev/null @@ -1,36 +0,0 @@ -# Interface: CreditCard - -CreditCard is a struct containing credit variables - -## Table of contents - -### Properties - -- [cvv](creditcard.md#cvv) -- [exp](creditcard.md#exp) -- [number](creditcard.md#number) -- [type](creditcard.md#type) - -## Properties - -### cvv - -• **cvv**: *string* - -___ - -### exp - -• **exp**: *string* - -___ - -### number - -• **number**: *string* - -___ - -### type - -• **type**: *string* diff --git a/docs/interfaces/creditcardoptions.md b/docs/interfaces/creditcardoptions.md deleted file mode 100644 index 439c93b..0000000 --- a/docs/interfaces/creditcardoptions.md +++ /dev/null @@ -1,29 +0,0 @@ -# Interface: CreditCardOptions - -CreditCardOptions is the options for credit card number - -## Table of contents - -### Properties - -- [bins](creditcardoptions.md#bins) -- [gaps](creditcardoptions.md#gaps) -- [types](creditcardoptions.md#types) - -## Properties - -### bins - -• **bins**: *string*[] - -___ - -### gaps - -• **gaps**: *boolean* - -___ - -### types - -• **types**: *string*[] diff --git a/docs/interfaces/currency.md b/docs/interfaces/currency.md deleted file mode 100644 index aaef834..0000000 --- a/docs/interfaces/currency.md +++ /dev/null @@ -1,22 +0,0 @@ -# Interface: Currency - -Currency is a struct of currency information - -## Table of contents - -### Properties - -- [long](currency.md#long) -- [short](currency.md#short) - -## Properties - -### long - -• **long**: *string* - -___ - -### short - -• **short**: *string* diff --git a/docs/interfaces/job.md b/docs/interfaces/job.md deleted file mode 100644 index ba43d77..0000000 --- a/docs/interfaces/job.md +++ /dev/null @@ -1,36 +0,0 @@ -# Interface: Job - -Job is a struct of job information - -## Table of contents - -### Properties - -- [company](job.md#company) -- [descriptor](job.md#descriptor) -- [level](job.md#level) -- [title](job.md#title) - -## Properties - -### company - -• **company**: *string* - -___ - -### descriptor - -• **descriptor**: *string* - -___ - -### level - -• **level**: *string* - -___ - -### title - -• **title**: *string* diff --git a/docs/interfaces/person.md b/docs/interfaces/person.md deleted file mode 100644 index 8295f43..0000000 --- a/docs/interfaces/person.md +++ /dev/null @@ -1,64 +0,0 @@ -# Interface: Person - -Person is a struct of person information - -## Table of contents - -### Properties - -- [address](person.md#address) -- [contact](person.md#contact) -- [creditCard](person.md#creditcard) -- [firstName](person.md#firstname) -- [gender](person.md#gender) -- [image](person.md#image) -- [job](person.md#job) -- [lastName](person.md#lastname) - -## Properties - -### address - -• **address**: [*Address*](address.md) - -___ - -### contact - -• **contact**: [*Contact*](contact.md) - -___ - -### creditCard - -• **creditCard**: [*CreditCard*](creditcard.md) - -___ - -### firstName - -• **firstName**: *string* - -___ - -### gender - -• **gender**: *string* - -___ - -### image - -• **image**: *string* - -___ - -### job - -• **job**: [*Job*](job.md) - -___ - -### lastName - -• **lastName**: *string* diff --git a/faker.go b/faker.go deleted file mode 100644 index 4c488c0..0000000 --- a/faker.go +++ /dev/null @@ -1,64 +0,0 @@ -package faker - -import ( - "github.com/brianvoe/gofakeit/v6" - "github.com/dop251/goja" - "go.k6.io/k6/js/modules" - "lukechampine.com/frand" -) - -type Faker struct { - vu modules.VU - - *gofakeit.Faker -} - -func newFaker(vu modules.VU, seed int64) *Faker { //nolint:varnamelen - src := frand.NewSource() - - if seed != 0 { - src.Seed(seed) - } - - return &Faker{vu: vu, Faker: gofakeit.NewCustom(src)} -} - -func (f *Faker) Ipv4Address() string { - return f.IPv4Address() -} - -func (f *Faker) Ipv6Address() string { - return f.IPv6Address() -} - -func (f *Faker) HttpStatusCodeSimple() int { //nolint:golint,revive,stylecheck - return f.HTTPStatusCodeSimple() -} - -func (f *Faker) HttpStatusCode() int { //nolint:golint,revive,stylecheck - return f.HTTPStatusCode() -} - -func (f *Faker) HttpMethod() string { //nolint:golint,revive,stylecheck - return f.HTTPMethod() -} - -func (f *Faker) Bs() string { - return f.BS() -} - -func (f *Faker) Uuid() string { //nolint:golint,revive,stylecheck - return f.UUID() -} - -func (f *Faker) RgbColor() []int { - return f.RGBColor() -} - -func (f *Faker) ImageJpeg(width int, height int) goja.ArrayBuffer { - return f.vu.Runtime().NewArrayBuffer(f.Faker.ImageJpeg(width, height)) -} - -func (f *Faker) ImagePng(width int, height int) goja.ArrayBuffer { - return f.vu.Runtime().NewArrayBuffer(f.Faker.ImagePng(width, height)) -} diff --git a/faker/faker.go b/faker/faker.go new file mode 100644 index 0000000..4872f92 --- /dev/null +++ b/faker/faker.go @@ -0,0 +1,191 @@ +// Package faker contains Faker class implementation for goja. +package faker + +import ( + "math/rand" + + "github.com/brianvoe/gofakeit/v6" + "github.com/dop251/goja" + "lukechampine.com/frand" +) + +// Constructor is a Faker class constructor. +func Constructor(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object { + seed := call.Argument(0).ToInteger() + + return runtime.NewDynamicObject(newFaker(seed, runtime)) +} + +// New calls Faker constructor and returns new Faker object. +func New(seed int64, runtime *goja.Runtime) *goja.Object { + return Constructor( + goja.ConstructorCall{ + This: runtime.NewObject(), + Arguments: []goja.Value{runtime.ToValue(seed)}, + }, + runtime, + ) +} + +// faker represents JavaScript Faker class. +type faker struct { + rand *rand.Rand + runtime *goja.Runtime +} + +// newFaker creates new Faker instance. +func newFaker(seed int64, runtime *goja.Runtime) *faker { + src := frand.NewSource() + + if seed != 0 { + src.Seed(seed) + } + + return &faker{rand: rand.New(src), runtime: runtime} //nolint:gosec +} + +// Delete implements goja.DynamicObject. +func (f *faker) Delete(_ string) bool { + return false +} + +// Get implements goja.DynamicObject. +func (f *faker) Get(key string) goja.Value { + if key == "call" { + return f.runtime.ToValue(f.call) + } + + category := newCategory(f, key) + if category == nil { + return goja.Undefined() + } + + return f.runtime.NewDynamicObject(category) +} + +// Has implements goja.DynamicObject. +func (f *faker) Has(_ string) bool { + return false +} + +// Keys implements goja.DynamicObject. +func (f *faker) Keys() []string { + return getCategoryNames() +} + +// Set implements goja.DynamicObject. +func (f *faker) Set(_ string, _ goja.Value) bool { + return false +} + +// call invokes faker function by name. +// The faker function name is the first parameter, the rest of parameters passed to function. +func (f *faker) call(call goja.FunctionCall) goja.Value { + function := call.Argument(0) + + if goja.IsUndefined(function) { + panic(f.runtime.NewTypeError(function)) + } + + info, found := lookupFunc(function.ToString().String()) + if !found { + panic(f.runtime.NewTypeError(function)) + } + + call.Arguments = call.Arguments[1:] + + return f.invoke(info, call) +} + +func (f *faker) toMapParams(info *gofakeit.Info, call goja.FunctionCall) *gofakeit.MapParams { + if len(info.Params) == 0 { + return nil + } + + params := gofakeit.NewMapParams() + + for idx, param := range info.Params { + val := call.Argument(idx) + if goja.IsUndefined(val) { + if len(param.Default) != 0 { + params.Add(param.Field, param.Default) + continue + } + + if param.Optional { + continue + } + + panic(f.runtime.NewTypeError("missing parameter: %s", param.Field)) + } + + var arr []string + + if f.runtime.ExportTo(val, &arr) == nil { + (*params)[param.Field] = arr + } else { + params.Add(param.Field, val.String()) + } + } + + return params +} + +func (f *faker) invoke(info *gofakeit.Info, call goja.FunctionCall) goja.Value { + params := f.toMapParams(info, call) + + val, err := info.Generate(f.rand, params, info) + if err != nil { + panic(f.runtime.NewGoError(err)) + } + + return f.runtime.ToValue(val) +} + +type category struct { + faker *faker + funcs map[string]*gofakeit.Info +} + +func newCategory(faker *faker, name string) *category { + funcs, ok := lookupCategory(name) + if !ok { + return nil + } + + return &category{faker: faker, funcs: funcs} +} + +// Delete implements goja.DynamicObject. +func (c *category) Delete(_ string) bool { + return false +} + +// Get implements goja.DynamicObject. +func (c *category) Get(key string) goja.Value { + info, ok := c.funcs[key] + if !ok { + return goja.Undefined() + } + + return c.faker.runtime.ToValue(func(call goja.FunctionCall) goja.Value { + return c.faker.invoke(info, call) + }) +} + +// Has implements goja.DynamicObject. +func (c *category) Has(_ string) bool { + return false +} + +// Keys implements goja.DynamicObject. +func (c *category) Keys() []string { + return []string{} +} + +// Set implements goja.DynamicObject. +func (c *category) Set(_ string, _ goja.Value) bool { + return false +} + +//go:generate go run -tags codegen ../tools/codegen json ../functions.json diff --git a/faker/faker_internal_test.go b/faker/faker_internal_test.go new file mode 100644 index 0000000..c57e0fc --- /dev/null +++ b/faker/faker_internal_test.go @@ -0,0 +1,136 @@ +package faker + +import ( + "errors" + "math/rand" + "testing" + + "github.com/brianvoe/gofakeit/v6" + "github.com/dop251/goja" + "github.com/stretchr/testify/require" +) + +func Test_faker_dynamic(t *testing.T) { + t.Parallel() + + faker := newFaker(11, goja.New()) + + // Delete + require.False(t, faker.Delete("foo")) + + // Get + require.False(t, goja.IsUndefined(faker.Get("call"))) + require.True(t, goja.IsUndefined(faker.Get("no such category"))) + require.False(t, goja.IsUndefined(faker.Get("zen"))) + + // Has + require.False(t, faker.Has("zen")) + + // Keys + require.NotEmpty(t, faker.Keys()) + + // Set + require.False(t, faker.Set("foo", faker.runtime.ToValue(42))) +} + +func Test_faker_invoke(t *testing.T) { + t.Parallel() + + faker := newFaker(11, goja.New()) + + info, ok := lookupFunc("username") + + require.True(t, ok) + + val := faker.invoke(info, goja.FunctionCall{This: goja.Undefined()}) + + require.False(t, goja.IsUndefined(val)) + + clone := *info + info = &clone + + info.Generate = func(_ *rand.Rand, _ *gofakeit.MapParams, _ *gofakeit.Info) (any, error) { + return nil, errors.ErrUnsupported + } + + require.Panics(t, func() { + faker.invoke(info, goja.FunctionCall{This: goja.Undefined()}) + }) +} + +func Test_newCategory(t *testing.T) { + t.Parallel() + + faker := newFaker(11, goja.New()) + + require.Nil(t, newCategory(faker, "no such category")) + require.NotNil(t, newCategory(faker, "zen")) +} + +func Test_category_dynamic(t *testing.T) { + t.Parallel() + + category := newCategory(newFaker(11, goja.New()), "zen") + + // Delete + require.False(t, category.Delete("foo")) + + // Get + require.False(t, goja.IsUndefined(category.Get("username"))) + require.True(t, goja.IsUndefined(category.Get("no such function"))) + + // Has + require.False(t, category.Has("username")) + + // Keys + require.Empty(t, category.Keys()) + + // Set + require.False(t, category.Set("foo", category.faker.runtime.ToValue(42))) +} + +func Test_faker_toMapParams(t *testing.T) { + t.Parallel() + + runtime := goja.New() + faker := newFaker(11, runtime) + + info, ok := lookupFunc("intRange") + + require.True(t, ok) + + var call goja.FunctionCall + + require.Panics(t, func() { + faker.toMapParams(info, call) + }) + + call.Arguments = append(call.Arguments, runtime.ToValue(1), runtime.ToValue(42)) + + mparams := faker.toMapParams(info, call) + + require.NotNil(t, mparams) + require.Equal(t, &gofakeit.MapParams{"min": []string{"1"}, "max": []string{"42"}}, mparams) + + clone := *info + clone.Params = nil + clone.Params = append(clone.Params, info.Params...) + info = &clone + + info.Params[1].Default = "24" + + call.Arguments = []goja.Value{runtime.ToValue(1)} + + mparams = faker.toMapParams(info, call) + + require.NotNil(t, mparams) + require.Equal(t, &gofakeit.MapParams{"min": []string{"1"}, "max": []string{"24"}}, mparams) + + info.Params[0].Optional = true + call.Arguments = nil + + mparams = faker.toMapParams(info, call) + + require.NotNil(t, mparams) + require.Equal(t, &gofakeit.MapParams{"max": []string{"24"}}, mparams) +} diff --git a/faker/faker_test.go b/faker/faker_test.go new file mode 100644 index 0000000..4c21c37 --- /dev/null +++ b/faker/faker_test.go @@ -0,0 +1,122 @@ +package faker_test + +import ( + "testing" + + "github.com/dop251/goja" + "github.com/stretchr/testify/require" + "github.com/szkiba/xk6-faker/faker" +) + +func Test_Constructor(t *testing.T) { + t.Parallel() + + vm := goja.New() + + require.NoError(t, vm.Set("Faker", faker.Constructor)) + + val, err := vm.RunString("new Faker()") + + require.NoError(t, err) + + _, ok := goja.AssertFunction(val.ToObject(vm).Get("call")) + + require.True(t, ok, "has call() method") + + val, err = vm.RunString("new Faker(11)") + + require.NoError(t, err) + + _, ok = goja.AssertFunction(val.ToObject(vm).Get("call")) + + require.True(t, ok, "has call() method") +} + +func Test_New(t *testing.T) { + t.Parallel() + + vm := goja.New() + + var val *goja.Object + + require.NotPanics(t, func() { + val = faker.New(0, vm) + }) + + _, ok := goja.AssertFunction(val.ToObject(vm).Get("call")) + + require.True(t, ok, "has call() method") +} + +func Test_Faker_call(t *testing.T) { + t.Parallel() + + vm := goja.New() + + require.NoError(t, vm.Set("Faker", faker.Constructor)) + + val, err := vm.RunString("new Faker(11).call('username')") + + require.NoError(t, err) + require.Equal(t, "Abshire5538", val.String()) + + _, err = vm.RunString("new Faker(11).call('no such function')") + + require.Error(t, err) + + _, err = vm.RunString("new Faker(11).call()") + + require.Error(t, err) +} + +func Test_Faker_no_parameter(t *testing.T) { + t.Parallel() + + vm := goja.New() + + require.NoError(t, vm.Set("Faker", faker.Constructor)) + + val, err := vm.RunString("new Faker(11).zen.username()") + + require.NoError(t, err) + require.Equal(t, "Abshire5538", val.String()) +} + +func Test_Faker_int_parameters(t *testing.T) { + t.Parallel() + + vm := goja.New() + + require.NoError(t, vm.Set("Faker", faker.Constructor)) + + val, err := vm.RunString("new Faker(11).zen.intRange(2,19)") + + require.NoError(t, err) + require.Equal(t, int64(5), val.ToInteger()) +} + +func Test_Faker_string_array_parameter(t *testing.T) { + t.Parallel() + + vm := goja.New() + + require.NoError(t, vm.Set("Faker", faker.Constructor)) + + val, err := vm.RunString("new Faker(11).zen.randomString(['foo', 'bar', 'dummy'])") + + require.NoError(t, err) + require.Equal(t, "foo", val.String()) +} + +func Test_Faker_int_array_parameter(t *testing.T) { + t.Parallel() + + vm := goja.New() + + require.NoError(t, vm.Set("Faker", faker.Constructor)) + + val, err := vm.RunString("new Faker(11).zen.randomInt([1,4,2,6])") + + require.NoError(t, err) + require.Equal(t, int64(2), val.ToInteger()) +} diff --git a/faker/fumctions_test.go b/faker/fumctions_test.go new file mode 100644 index 0000000..74fcf4f --- /dev/null +++ b/faker/fumctions_test.go @@ -0,0 +1,89 @@ +package faker_test + +import ( + "math/rand" + "strconv" + "testing" + "time" + + "github.com/brianvoe/gofakeit/v6" + "github.com/stretchr/testify/require" + "lukechampine.com/frand" +) + +func Test_lookup(t *testing.T) { + t.Parallel() + + funcs := []string{"creditcardstring", "creditcardexpmonth", "creditcardexpyear"} + + for _, fun := range funcs { + fun := fun + t.Run(fun, func(t *testing.T) { + t.Parallel() + info := gofakeit.GetFuncLookup(fun) + + require.NotNil(t, info) + }) + } +} + +func testRand(t *testing.T) *rand.Rand { + t.Helper() + + src := frand.NewSource() + src.Seed(11) + + return rand.New(src) //nolint:gosec +} + +func Test_creditcardexpyear(t *testing.T) { + t.Parallel() + + info := gofakeit.GetFuncLookup("creditcardexpyear") + + require.NotNil(t, info) + + val, err := info.Generate(testRand(t), nil, info) + + require.NoError(t, err) + require.Len(t, val, 2) + + year, err := strconv.Atoi(val.(string)) + + require.NoError(t, err) + + require.Greater(t, year, time.Now().Year()-2000) +} + +func Test_creditcardexpmonth(t *testing.T) { + t.Parallel() + + info := gofakeit.GetFuncLookup("creditcardexpmonth") + + require.NotNil(t, info) + + val, err := info.Generate(testRand(t), nil, info) + + require.NoError(t, err) + require.Len(t, val, 2) + + month, err := strconv.Atoi(val.(string)) + + require.NoError(t, err) + + require.Greater(t, month, 0) + require.Less(t, month, 13) +} + +func Test_creditcardstring(t *testing.T) { + t.Parallel() + + info := gofakeit.GetFuncLookup("creditcardstring") + + require.NotNil(t, info) + + val, err := info.Generate(testRand(t), nil, info) + + require.NoError(t, err) + require.Equal(t, "4111-1111-1111-1111", val) +} diff --git a/faker/functions.go b/faker/functions.go new file mode 100644 index 0000000..023428c --- /dev/null +++ b/faker/functions.go @@ -0,0 +1,69 @@ +package faker + +import ( + "math/rand" + "strconv" + "time" + + "github.com/brianvoe/gofakeit/v6" +) + +func init() { + gofakeit.AddFuncLookup("creditcardstring", gofakeit.Info{ + Display: "Credit Card Number Formatted", + Category: "payment", + Description: "Unique numerical identifier on a credit card used for making electronic payments and transactions", + Example: "4136-4599-4899-5369", + Output: "string", + Params: nil, + Generate: creditcardstring, + }) + + gofakeit.AddFuncLookup("creditcardexpmonth", gofakeit.Info{ + Display: "Credit Card Exp Month", + Category: "payment", + Description: "Month of the date when a credit card becomes invalid and cannot be used for transactions", + Example: "11", + Output: "string", + Params: nil, + Generate: creditcardexpmonth, + }) + + gofakeit.AddFuncLookup("creditcardexpyear", gofakeit.Info{ + Display: "Credit Card Exp Year", + Category: "payment", + Description: "Year of the date when a credit card becomes invalid and cannot be used for transactions", + Example: "28", + Output: "string", + Params: nil, + Generate: creditcardexpyear, + }) +} + +var testcards = []string{ //nolint:gochecknoglobals + "4111-1111-1111-1111", + "4242-4242-4242-4242", + "4000-0566-5566-5556", + "5555-5555-5555-4444", + "5200-8282-8282-8210", + "5105-1051-0510-5100", +} + +func creditcardstring(r *rand.Rand, _ *gofakeit.MapParams, _ *gofakeit.Info) (any, error) { + return testcards[r.Intn(len(testcards))], nil +} + +func creditcardexpmonth(r *rand.Rand, _ *gofakeit.MapParams, _ *gofakeit.Info) (any, error) { + month := strconv.Itoa(1 + r.Intn(12)) + if len(month) == 1 { + month = "0" + month + } + + return month, nil +} + +func creditcardexpyear(r *rand.Rand, _ *gofakeit.MapParams, _ *gofakeit.Info) (any, error) { + current := time.Now().Year() - 2000 + + return strconv.Itoa(current + 1 + r.Intn(10)), nil +} diff --git a/faker/lookup.go b/faker/lookup.go new file mode 100644 index 0000000..c8197e3 --- /dev/null +++ b/faker/lookup.go @@ -0,0 +1,127 @@ +package faker + +import ( + "sort" + "sync" + + "github.com/brianvoe/gofakeit/v6" + "github.com/iancoleman/strcase" +) + +// GetFuncLookups returns fake functions lookup table. +func GetFuncLookups() map[string]*gofakeit.Info { + requireFuncLookups() + + return _funcLookups +} + +func getCategoryNames() []string { + requireFuncLookups() + + return _categoryNames +} + +// GetCategoryFuncs returns fake functions by category. +func GetCategoryFuncs() map[string]map[string]*gofakeit.Info { + requireFuncLookups() + + return _categoryFuncs +} + +func lookupCategory(name string) (map[string]*gofakeit.Info, bool) { + requireFuncLookups() + + funcs, ok := _categoryFuncs[name] + return funcs, ok +} + +func lookupFunc(name string) (*gofakeit.Info, bool) { + requireFuncLookups() + + fun, ok := _funcLookups[name] + return fun, ok +} + +//nolint:gochecknoglobals +var ( + convertLookupsOnce sync.Once + + _funcLookups map[string]*gofakeit.Info + _categoryNames []string + _categoryFuncs map[string]map[string]*gofakeit.Info +) + +func requireFuncLookups() { + convertLookupsOnce.Do(convertFuncLookups) +} + +//nolint:gochecknoglobals +var ( + funcToSkip = map[string]struct{}{ + "template": {}, + "generate": {}, + "weighted": {}, + } + + addPrefix = map[string]string{ + "booktitle": "Book", + "bookauthor": "Book", + "bookgenre": "Book", + "moviegenre": "Movie", + } + + funcRename = map[string]string{ + "imageSvg": "imageSVG", + "gRpcError": "gRPCError", + } +) + +func fixLookup(name string, info *gofakeit.Info) string { + if prefix, need := addPrefix[name]; need { + info.Display = prefix + " " + info.Display + } + + key := strcase.ToLowerCamel(info.Display) + + if fixed, need := funcRename[key]; need { + key = fixed + } + + return key +} + +func convertFuncLookups() { + _funcLookups = make(map[string]*gofakeit.Info) + _categoryFuncs = make(map[string]map[string]*gofakeit.Info) + zen := make(map[string]*gofakeit.Info) + + for key, info := range gofakeit.FuncLookups { + if _, skip := funcToSkip[key]; skip { + continue + } + + info := info + info.Any = key + key = fixLookup(key, &info) + _funcLookups[key] = &info + + category, ok := _categoryFuncs[info.Category] + if !ok { + category = make(map[string]*gofakeit.Info) + _categoryFuncs[info.Category] = category + } + + category[key] = &info + zen[key] = &info + } + + _categoryFuncs["zen"] = zen + + _categoryNames = make([]string, 0, len(_categoryFuncs)) + + for name := range _categoryFuncs { + _categoryNames = append(_categoryNames, name) + } + + sort.Strings(_categoryNames) +} diff --git a/faker/lookup_test.go b/faker/lookup_test.go new file mode 100644 index 0000000..8a5a0b2 --- /dev/null +++ b/faker/lookup_test.go @@ -0,0 +1,32 @@ +package faker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/szkiba/xk6-faker/faker" +) + +func TestGetFuncLookups(t *testing.T) { + t.Parallel() + + funcs := faker.GetFuncLookups() + + require.Len(t, funcs, 317) + require.Contains(t, funcs, "intRange") + require.Contains(t, funcs, "randomString") +} + +func TestGetCategoryFuncs(t *testing.T) { + t.Parallel() + + categories := faker.GetCategoryFuncs() + + require.Len(t, categories, 37) + require.Contains(t, categories, "zen") + require.Contains(t, categories, "number") + + require.Contains(t, categories["zen"], "intRange") + require.Contains(t, categories["number"], "intRange") + require.Same(t, categories["zen"]["intRange"], categories["number"]["intRange"]) +} diff --git a/functions.json b/functions.json new file mode 100644 index 0000000..a5ea33f --- /dev/null +++ b/functions.json @@ -0,0 +1,4021 @@ +{ + "achAccountNumber": { + "display": "ACH Account Number", + "category": "payment", + "description": "A bank account number used for Automated Clearing House transactions and electronic transfers", + "example": "491527954328", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "achaccount" + }, + "achRoutingNumber": { + "display": "ACH Routing Number", + "category": "payment", + "description": "Unique nine-digit code used in the U.S. for identifying the bank and processing electronic transactions", + "example": "513715684", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "achrouting" + }, + "actionVerb": { + "display": "Action Verb", + "category": "word", + "description": "Verb Indicating a physical or mental action", + "example": "close", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "verbaction" + }, + "address": { + "display": "Address", + "category": "address", + "description": "Residential location including street, city, state, country and postal code", + "example": "{\n\t\"address\": \"364 Unionsville, Norfolk, Ohio 99536\",\n\t\"street\": \"364 Unionsville\",\n\t\"city\": \"Norfolk\",\n\t\"state\": \"Ohio\",\n\t\"zip\": \"99536\",\n\t\"country\": \"Lesotho\",\n\t\"latitude\": 88.792592,\n\t\"longitude\": 174.504681\n}", + "output": "Record\u003cstring,unknown\u003e", + "content_type": "application/json", + "params": null, + "any": "address" + }, + "adjective": { + "display": "Adjective", + "category": "word", + "description": "Word describing or modifying a noun", + "example": "genuine", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjective" + }, + "adverb": { + "display": "Adverb", + "category": "word", + "description": "Word that modifies verbs, adjectives, or other adverbs", + "example": "smoothly", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverb" + }, + "adverbDegree": { + "display": "Adverb Degree", + "category": "word", + "description": "Adverb that indicates the degree or intensity of an action or adjective", + "example": "intensely", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbdegree" + }, + "adverbFrequencyDefinite": { + "display": "Adverb Frequency Definite", + "category": "word", + "description": "Adverb that specifies how often an action occurs with a clear frequency", + "example": "hourly", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbfrequencydefinite" + }, + "adverbFrequencyIndefinite": { + "display": "Adverb Frequency Indefinite", + "category": "word", + "description": "Adverb that specifies how often an action occurs without specifying a particular frequency", + "example": "occasionally", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbfrequencyindefinite" + }, + "adverbManner": { + "display": "Adverb Manner", + "category": "word", + "description": "Adverb that describes how an action is performed", + "example": "stupidly", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbmanner" + }, + "adverbPhrase": { + "display": "Adverb Phrase", + "category": "word", + "description": "Phrase that modifies a verb, adjective, or another adverb, providing additional information.", + "example": "fully gladly", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phraseadverb" + }, + "adverbPlace": { + "display": "Adverb Place", + "category": "word", + "description": "Adverb that indicates the location or direction of an action", + "example": "east", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbplace" + }, + "adverbTimeDefinite": { + "display": "Adverb Time Definite", + "category": "word", + "description": "Adverb that specifies the exact time an action occurs", + "example": "now", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbtimedefinite" + }, + "adverbTimeIndefinite": { + "display": "Adverb Time Indefinite", + "category": "word", + "description": "Adverb that gives a general or unspecified time frame", + "example": "already", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adverbtimeindefinite" + }, + "animal": { + "display": "Animal", + "category": "animal", + "description": "Living creature with the ability to move, eat, and interact with its environment", + "example": "elk", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "animal" + }, + "animalType": { + "display": "Animal Type", + "category": "animal", + "description": "Type of animal, such as mammals, birds, reptiles, etc.", + "example": "amphibians", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "animaltype" + }, + "appAuthor": { + "display": "App Author", + "category": "app", + "description": "Person or group creating and developing an application", + "example": "Qado Energy, Inc.", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "appauthor" + }, + "appName": { + "display": "App Name", + "category": "app", + "description": "Software program designed for a specific purpose or task on a computer or mobile device", + "example": "Parkrespond", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "appname" + }, + "appVersion": { + "display": "App Version", + "category": "app", + "description": "Particular release of an application in Semantic Versioning format", + "example": "1.12.14", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "appversion" + }, + "beerAlcohol": { + "display": "Beer Alcohol", + "category": "beer", + "description": "Measures the alcohol content in beer", + "example": "2.7%", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beeralcohol" + }, + "beerBlg": { + "display": "Beer BLG", + "category": "beer", + "description": "Scale indicating the concentration of extract in worts", + "example": "6.4°Blg", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beerblg" + }, + "beerHop": { + "display": "Beer Hop", + "category": "beer", + "description": "The flower used in brewing to add flavor, aroma, and bitterness to beer", + "example": "Glacier", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beerhop" + }, + "beerIbu": { + "display": "Beer IBU", + "category": "beer", + "description": "Scale measuring bitterness of beer from hops", + "example": "29 IBU", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beeribu" + }, + "beerMalt": { + "display": "Beer Malt", + "category": "beer", + "description": "Processed barley or other grains, provides sugars for fermentation and flavor to beer", + "example": "Munich", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beermalt" + }, + "beerName": { + "display": "Beer Name", + "category": "beer", + "description": "Specific brand or variety of beer", + "example": "Duvel", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beername" + }, + "beerStyle": { + "display": "Beer Style", + "category": "beer", + "description": "Distinct characteristics and flavors of beer", + "example": "European Amber Lager", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beerstyle" + }, + "beerYeast": { + "display": "Beer Yeast", + "category": "beer", + "description": "Microorganism used in brewing to ferment sugars, producing alcohol and carbonation in beer", + "example": "1388 - Belgian Strong Ale", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "beeryeast" + }, + "bird": { + "display": "Bird", + "category": "animal", + "description": "Distinct species of birds", + "example": "goose", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "bird" + }, + "bitcoinAddress": { + "display": "Bitcoin Address", + "category": "payment", + "description": "Cryptographic identifier used to receive, store, and send Bitcoin cryptocurrency in a peer-to-peer network", + "example": "1lWLbxojXq6BqWX7X60VkcDIvYA", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "bitcoinaddress" + }, + "bitcoinPrivateKey": { + "display": "Bitcoin Private Key", + "category": "payment", + "description": "Secret, secure code that allows the owner to access and control their Bitcoin holdings", + "example": "5vrbXTADWJ6sQBSYd6lLkG97jljNc0X9VPBvbVqsIH9lWOLcoqg", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "bitcoinprivatekey" + }, + "blurb": { + "display": "Blurb", + "category": "company", + "description": "Brief description or summary of a company's purpose, products, or services", + "example": "word", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "blurb" + }, + "book": { + "display": "Book", + "category": "book", + "description": "Written or printed work consisting of pages bound together, covering various subjects or stories", + "example": "{\n\t\"title\": \"Anna Karenina\",\n\t\"author\": \"Toni Morrison\",\n\t\"genre\": \"Thriller\"\n}", + "output": "Record\u003cstring,string\u003e", + "content_type": "application/json", + "params": null, + "any": "book" + }, + "bookAuthor": { + "display": "Book Author", + "category": "book", + "description": "The individual who wrote or created the content of a book", + "example": "Mark Twain", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "bookauthor" + }, + "bookGenre": { + "display": "Book Genre", + "category": "book", + "description": "Category or type of book defined by its content, style, or form", + "example": "Adventure", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "bookgenre" + }, + "bookTitle": { + "display": "Book Title", + "category": "book", + "description": "The specific name given to a book", + "example": "Hamlet", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "booktitle" + }, + "boolean": { + "display": "Boolean", + "category": "misc", + "description": "Data type that represents one of two possible values, typically true or false", + "example": "true", + "output": "boolean", + "content_type": "text/plain", + "params": null, + "any": "bool" + }, + "breakfast": { + "display": "Breakfast", + "category": "food", + "description": "First meal of the day, typically eaten in the morning", + "example": "Blueberry banana happy face pancakes", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "breakfast" + }, + "bs": { + "display": "BS", + "category": "company", + "description": "Random bs company word", + "example": "front-end", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "bs" + }, + "buzzword": { + "display": "Buzzword", + "category": "company", + "description": "Trendy or overused term often used in business to sound impressive", + "example": "disintermediate", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "buzzword" + }, + "car": { + "display": "Car", + "category": "car", + "description": "Wheeled motor vehicle used for transportation", + "example": "{\n\t\"type\": \"Passenger car mini\",\n\t\"fuel\": \"Gasoline\",\n\t\"transmission\": \"Automatic\",\n\t\"brand\": \"Fiat\",\n\t\"model\": \"Freestyle Fwd\",\n\t\"year\": 1991\n}", + "output": "Record\u003cstring,unknown\u003e", + "content_type": "application/json", + "params": null, + "any": "car" + }, + "carFuelType": { + "display": "Car Fuel Type", + "category": "car", + "description": "Type of energy source a car uses", + "example": "CNG", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "carfueltype" + }, + "carMaker": { + "display": "Car Maker", + "category": "car", + "description": "Company or brand that manufactures and designs cars", + "example": "Nissan", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "carmaker" + }, + "carModel": { + "display": "Car Model", + "category": "car", + "description": "Specific design or version of a car produced by a manufacturer", + "example": "Aveo", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "carmodel" + }, + "carTransmissionType": { + "display": "Car Transmission Type", + "category": "car", + "description": "Mechanism a car uses to transmit power from the engine to the wheels", + "example": "Manual", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "cartransmissiontype" + }, + "carType": { + "display": "Car Type", + "category": "car", + "description": "Classification of cars based on size, use, or body style", + "example": "Passenger car mini", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "cartype" + }, + "cat": { + "display": "Cat", + "category": "animal", + "description": "Various breeds that define different cats", + "example": "Chausie", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "cat" + }, + "celebrityActor": { + "display": "Celebrity Actor", + "category": "celebrity", + "description": "Famous person known for acting in films, television, or theater", + "example": "Brad Pitt", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "celebrityactor" + }, + "celebrityBusiness": { + "display": "Celebrity Business", + "category": "celebrity", + "description": "High-profile individual known for significant achievements in business or entrepreneurship", + "example": "Elon Musk", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "celebritybusiness" + }, + "celebritySport": { + "display": "Celebrity Sport", + "category": "celebrity", + "description": "Famous athlete known for achievements in a particular sport", + "example": "Michael Phelps", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "celebritysport" + }, + "chromeUserAgent": { + "display": "Chrome User Agent", + "category": "internet", + "description": "The specific identification string sent by the Google Chrome web browser when making requests on the internet", + "example": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/5312 (KHTML, like Gecko) Chrome/39.0.836.0 Mobile Safari/5312", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "chromeuseragent" + }, + "city": { + "display": "City", + "category": "address", + "description": "Part of a country with significant population, often a central hub for culture and commerce", + "example": "Marcelside", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "city" + }, + "color": { + "display": "Color", + "category": "color", + "description": "Hue seen by the eye, returns the name of the color like red or blue", + "example": "MediumOrchid", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "color" + }, + "comment": { + "display": "Comment", + "category": "word", + "description": "Statement or remark expressing an opinion, observation, or reaction", + "example": "wow", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "comment" + }, + "company": { + "display": "Company", + "category": "company", + "description": "Designated official name of a business or organization", + "example": "Moen, Pagac and Wuckert", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "company" + }, + "companySuffix": { + "display": "Company Suffix", + "category": "company", + "description": "Suffix at the end of a company name, indicating business structure, like 'Inc.' or 'LLC'", + "example": "Inc", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "companysuffix" + }, + "connective": { + "display": "Connective", + "category": "word", + "description": "Word used to connect words or sentences", + "example": "such as", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connective" + }, + "connectiveCasual": { + "display": "Connective Casual", + "category": "word", + "description": "Connective word used to indicate a cause-and-effect relationship between events or actions", + "example": "an outcome of", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connectivecasual" + }, + "connectiveComparitive": { + "display": "Connective Comparitive", + "category": "word", + "description": "Connective word used to indicate a comparison between two or more things", + "example": "in addition", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connectivecomparative" + }, + "connectiveComplaint": { + "display": "Connective Complaint", + "category": "word", + "description": "Connective word used to express dissatisfaction or complaints about a situation", + "example": "besides", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connectivecomplaint" + }, + "connectiveExamplify": { + "display": "Connective Examplify", + "category": "word", + "description": "Connective word used to provide examples or illustrations of a concept or idea", + "example": "then", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connectiveexamplify" + }, + "connectiveListing": { + "display": "Connective Listing", + "category": "word", + "description": "Connective word used to list or enumerate items or examples", + "example": "firstly", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connectivelisting" + }, + "connectiveTime": { + "display": "Connective Time", + "category": "word", + "description": "Connective word used to indicate a temporal relationship between events or actions", + "example": "finally", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "connectivetime" + }, + "country": { + "display": "Country", + "category": "address", + "description": "Nation with its own government and defined territory", + "example": "United States of America", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "country" + }, + "countryAbbreviation": { + "display": "Country Abbreviation", + "category": "address", + "description": "Shortened 2-letter form of a country's name", + "example": "US", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "countryabr" + }, + "creditCard": { + "display": "Credit Card", + "category": "payment", + "description": "Plastic card allowing users to make purchases on credit, with payment due at a later date", + "example": "{\n\t\"type\": \"UnionPay\",\n\t\"number\": \"4364599489953698\",\n\t\"exp\": \"02/24\",\n\t\"cvv\": \"300\"\n}", + "output": "Record\u003cstring,unknown\u003e", + "content_type": "application/json", + "params": null, + "any": "creditcard" + }, + "creditCardCvv": { + "display": "Credit Card CVV", + "category": "payment", + "description": "Three or four-digit security code on a credit card used for online and remote transactions", + "example": "513", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "creditcardcvv" + }, + "creditCardExp": { + "display": "Credit Card Exp", + "category": "payment", + "description": "Date when a credit card becomes invalid and cannot be used for transactions", + "example": "01/21", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "creditcardexp" + }, + "creditCardExpMonth": { + "display": "Credit Card Exp Month", + "category": "payment", + "description": "Month of the date when a credit card becomes invalid and cannot be used for transactions", + "example": "11", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "creditcardexpmonth" + }, + "creditCardExpYear": { + "display": "Credit Card Exp Year", + "category": "payment", + "description": "Year of the date when a credit card becomes invalid and cannot be used for transactions", + "example": "28", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "creditcardexpyear" + }, + "creditCardNumber": { + "display": "Credit Card Number", + "category": "payment", + "description": "Unique numerical identifier on a credit card used for making electronic payments and transactions", + "example": "4136459948995369", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "types", + "display": "Types", + "type": "string[]", + "optional": false, + "default": "all", + "options": [ + "visa", + "mastercard", + "american-express", + "diners-club", + "discover", + "jcb", + "unionpay", + "maestro", + "elo", + "hiper", + "hipercard" + ], + "description": "A select number of types you want to use when generating a credit card number" + }, + { + "field": "bins", + "display": "Bins", + "type": "string[]", + "optional": true, + "default": "", + "options": null, + "description": "Optional list of prepended bin numbers to pick from" + }, + { + "field": "gaps", + "display": "Gaps", + "type": "boolean", + "optional": false, + "default": "false", + "options": null, + "description": "Whether or not to have gaps in number" + } + ], + "any": "creditcardnumber" + }, + "creditCardNumberFormatted": { + "display": "Credit Card Number Formatted", + "category": "payment", + "description": "Unique numerical identifier on a credit card used for making electronic payments and transactions", + "example": "4136-4599-4899-5369", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "creditcardstring" + }, + "creditCardType": { + "display": "Credit Card Type", + "category": "payment", + "description": "Classification of credit cards based on the issuing company", + "example": "Visa", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "creditcardtype" + }, + "csv": { + "display": "CSV", + "category": "file", + "description": "Individual lines or data entries within a CSV (Comma-Separated Values) format", + "example": "id,first_name,last_name,password\n1,Markus,Moen,Dc0VYXjkWABx\n2,Osborne,Hilll,XPJ9OVNbs5lm", + "output": "number[]", + "content_type": "text/csv", + "params": [ + { + "field": "delimiter", + "display": "Delimiter", + "type": "string", + "optional": false, + "default": ",", + "options": null, + "description": "Separator in between row values" + }, + { + "field": "rowcount", + "display": "Row Count", + "type": "number", + "optional": false, + "default": "100", + "options": null, + "description": "Number of rows" + }, + { + "field": "fields", + "display": "Fields", + "type": "", + "optional": false, + "default": "", + "options": null, + "description": "Fields containing key name and function" + } + ], + "any": "csv" + }, + "currency": { + "display": "Currency", + "category": "payment", + "description": "Medium of exchange, often in the form of paper money or coins, used for trade and transactions", + "example": "{\n\t\"short\": \"IQD\",\n\t\"long\": \"Iraq Dinar\"\n}", + "output": "Record\u003cstring,string\u003e", + "content_type": "application/json", + "params": null, + "any": "currency" + }, + "currencyLong": { + "display": "Currency Long", + "category": "payment", + "description": "Complete name of a specific currency used for official identification in financial transactions", + "example": "United States Dollar", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "currencylong" + }, + "currencyShort": { + "display": "Currency Short", + "category": "payment", + "description": "Short 3-letter word used to represent a specific currency", + "example": "USD", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "currencyshort" + }, + "cusip": { + "display": "CUSIP", + "category": "finance", + "description": "Unique identifier for securities, especially bonds, in the United States and Canada", + "example": "38259P508", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "cusip" + }, + "databaseError": { + "display": "Database error", + "category": "error", + "description": "A problem or issue encountered while accessing or managing a database", + "example": "sql error", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errordatabase" + }, + "date": { + "display": "Date", + "category": "time", + "description": "Representation of a specific day, month, and year, often used for chronological reference", + "example": "2006-01-02T15:04:05Z07:00", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "format", + "display": "Format", + "type": "string", + "optional": false, + "default": "RFC3339", + "options": [ + "ANSIC", + "UnixDate", + "RubyDate", + "RFC822", + "RFC822Z", + "RFC850", + "RFC1123", + "RFC1123Z", + "RFC3339", + "RFC3339Nano" + ], + "description": "Date time string format output. You may also use golang time format or java time format" + } + ], + "any": "date" + }, + "dateRange": { + "display": "DateRange", + "category": "time", + "description": "Random date between two ranges", + "example": "2006-01-02T15:04:05Z07:00", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "startdate", + "display": "Start Date", + "type": "string", + "optional": false, + "default": "1970-01-01", + "options": null, + "description": "Start date time string" + }, + { + "field": "enddate", + "display": "End Date", + "type": "string", + "optional": false, + "default": "2024-03-12", + "options": null, + "description": "End date time string" + }, + { + "field": "format", + "display": "Format", + "type": "string", + "optional": false, + "default": "yyyy-MM-dd", + "options": null, + "description": "Date time string format" + } + ], + "any": "daterange" + }, + "day": { + "display": "Day", + "category": "time", + "description": "24-hour period equivalent to one rotation of Earth on its axis", + "example": "12", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "day" + }, + "demonstrativeAdjective": { + "display": "Demonstrative Adjective", + "category": "word", + "description": "Adjective used to point out specific things", + "example": "this", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectivedemonstrative" + }, + "descriptiveAdjective": { + "display": "Descriptive Adjective", + "category": "word", + "description": "Adjective that provides detailed characteristics about a noun", + "example": "brave", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectivedescriptive" + }, + "dessert": { + "display": "Dessert", + "category": "food", + "description": "Sweet treat often enjoyed after a meal", + "example": "French napoleons", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "dessert" + }, + "dice": { + "display": "Dice", + "category": "game", + "description": "Small, cube-shaped objects used in games of chance for random outcomes", + "example": "[5, 2, 3]", + "output": "number[]", + "content_type": "text/plain", + "params": [ + { + "field": "numdice", + "display": "Number of Dice", + "type": "number", + "optional": false, + "default": "1", + "options": null, + "description": "Number of dice to roll" + }, + { + "field": "sides", + "display": "Number of Sides", + "type": "number[]", + "optional": false, + "default": "[6]", + "options": null, + "description": "Number of sides on each dice" + } + ], + "any": "dice" + }, + "digit": { + "display": "Digit", + "category": "string", + "description": "Numerical symbol used to represent numbers", + "example": "0", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "digit" + }, + "digitN": { + "display": "DigitN", + "category": "string", + "description": "string of length N consisting of ASCII digits", + "example": "0136459948", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "count", + "display": "Count", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Number of digits to generate" + } + ], + "any": "digitn" + }, + "dinner": { + "display": "Dinner", + "category": "food", + "description": "Evening meal, typically the day's main and most substantial meal", + "example": "Wild addicting dip", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "dinner" + }, + "dog": { + "display": "Dog", + "category": "animal", + "description": "Various breeds that define different dogs", + "example": "Norwich Terrier", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "dog" + }, + "domainName": { + "display": "Domain Name", + "category": "internet", + "description": "Human-readable web address used to identify websites on the internet", + "example": "centraltarget.biz", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "domainname" + }, + "domainSuffix": { + "display": "Domain Suffix", + "category": "internet", + "description": "The part of a domain name that comes after the last dot, indicating its type or purpose", + "example": "org", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "domainsuffix" + }, + "drink": { + "display": "Drink", + "category": "food", + "description": "Liquid consumed for hydration, pleasure, or nutritional benefits", + "example": "Soda", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "drink" + }, + "email": { + "display": "Email", + "category": "person", + "description": "Electronic mail used for sending digital messages and communication over the internet", + "example": "markusmoen@pagac.net", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "email" + }, + "emoji": { + "display": "Emoji", + "category": "emoji", + "description": "Digital symbol expressing feelings or ideas in text messages and online chats", + "example": "🤣", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "emoji" + }, + "emojiAlias": { + "display": "Emoji Alias", + "category": "emoji", + "description": "Alternative name or keyword used to represent a specific emoji in text or code", + "example": "smile", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "emojialias" + }, + "emojiCategory": { + "display": "Emoji Category", + "category": "emoji", + "description": "Group or classification of emojis based on their common theme or use, like 'smileys' or 'animals'", + "example": "Smileys \u0026 Emotion", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "emojicategory" + }, + "emojiDescription": { + "display": "Emoji Description", + "category": "emoji", + "description": "Brief explanation of the meaning or emotion conveyed by an emoji", + "example": "face vomiting", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "emojidescription" + }, + "emojiTag": { + "display": "Emoji Tag", + "category": "emoji", + "description": "Label or keyword associated with an emoji to categorize or search for it easily", + "example": "happy", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "emojitag" + }, + "error": { + "display": "Error", + "category": "error", + "description": "Message displayed by a computer or software when a problem or mistake is encountered", + "example": "syntax error", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "error" + }, + "errorObjectWord": { + "display": "Error object word", + "category": "error", + "description": "Various categories conveying details about encountered errors", + "example": "protocol", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorobject" + }, + "farmAnimal": { + "display": "Farm Animal", + "category": "animal", + "description": "Animal name commonly found on a farm", + "example": "Chicken", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "farmanimal" + }, + "fileExtension": { + "display": "File Extension", + "category": "file", + "description": "Suffix appended to a filename indicating its format or type", + "example": "nes", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "fileextension" + }, + "fileMimeType": { + "display": "File Mime Type", + "category": "file", + "description": "Defines file format and nature for browsers and email clients using standardized identifiers", + "example": "application/json", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "filemimetype" + }, + "firefoxUserAgent": { + "display": "Firefox User Agent", + "category": "internet", + "description": "The specific identification string sent by the Firefox web browser when making requests on the internet", + "example": "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_8_3 rv:7.0) Gecko/1900-07-01 Firefox/37.0", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "firefoxuseragent" + }, + "firstName": { + "display": "First Name", + "category": "person", + "description": "The name given to a person at birth", + "example": "Markus", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "firstname" + }, + "fixedWidth": { + "display": "Fixed Width", + "category": "generate", + "description": "Fixed width rows of output data based on input fields", + "example": "Name Email Password Age\nMarkus Moen sylvanmraz@murphy.net 6VlvH6qqXc7g 13\nAlayna Wuckert santinostanton@carroll.biz g7sLrS0gEwLO 46\nLura Lockman zacherykuhic@feil.name S8gV7Z64KlHG 12", + "output": "number[]", + "content_type": "text/plain", + "params": [ + { + "field": "rowcount", + "display": "Row Count", + "type": "number", + "optional": false, + "default": "10", + "options": null, + "description": "Number of rows" + }, + { + "field": "fields", + "display": "Fields", + "type": "", + "optional": false, + "default": "", + "options": null, + "description": "Fields name, function and params" + } + ], + "any": "fixed_width" + }, + "flipACoin": { + "display": "Flip A Coin", + "category": "misc", + "description": "Decision-making method involving the tossing of a coin to determine outcomes", + "example": "Tails", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "flipacoin" + }, + "float32": { + "display": "Float32", + "category": "number", + "description": "Data type representing floating-point numbers with 32 bits of precision in computing", + "example": "3.1128167e+37", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "float32" + }, + "float32Range": { + "display": "Float32 Range", + "category": "number", + "description": "Float32 value between given range", + "example": "914774.6", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Minimum float32 value" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Maximum float32 value" + } + ], + "any": "float32range" + }, + "float64": { + "display": "Float64", + "category": "number", + "description": "Data type representing floating-point numbers with 64 bits of precision in computing", + "example": "1.644484108270445e+307", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "float64" + }, + "float64Range": { + "display": "Float64 Range", + "category": "number", + "description": "Float64 value between given range", + "example": "914774.5585333086", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Minimum float64 value" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Maximum float64 value" + } + ], + "any": "float64range" + }, + "fruit": { + "display": "Fruit", + "category": "food", + "description": "Edible plant part, typically sweet, enjoyed as a natural snack or dessert", + "example": "Peach", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "fruit" + }, + "futureTime": { + "display": "FutureTime", + "category": "time", + "description": "Date that has occurred after the current moment in time", + "example": "2107-01-24 13:00:35.820738079 +0000 UTC", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "futuretime" + }, + "gRPCError": { + "display": "gRPC error", + "category": "error", + "description": "Communication failure in the high-performance, open-source universal RPC framework", + "example": "client protocol error", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorgrpc" + }, + "gamertag": { + "display": "Gamertag", + "category": "game", + "description": "User-selected online username or alias used for identification in games", + "example": "footinterpret63", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "gamertag" + }, + "gender": { + "display": "Gender", + "category": "person", + "description": "Classification based on social and cultural norms that identifies an individual", + "example": "male", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "gender" + }, + "hackerAbbreviation": { + "display": "Hacker Abbreviation", + "category": "hacker", + "description": "Abbreviations and acronyms commonly used in the hacking and cybersecurity community", + "example": "ADP", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hackerabbreviation" + }, + "hackerAdjective": { + "display": "Hacker Adjective", + "category": "hacker", + "description": "Adjectives describing terms often associated with hackers and cybersecurity experts", + "example": "wireless", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hackeradjective" + }, + "hackerNoun": { + "display": "Hacker Noun", + "category": "hacker", + "description": "Noun representing an element, tool, or concept within the realm of hacking and cybersecurity", + "example": "driver", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hackernoun" + }, + "hackerPhrase": { + "display": "Hacker Phrase", + "category": "hacker", + "description": "Informal jargon and slang used in the hacking and cybersecurity community", + "example": "If we calculate the program, we can get to the AI pixel through the redundant XSS matrix!", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hackerphrase" + }, + "hackerVerb": { + "display": "Hacker Verb", + "category": "hacker", + "description": "Verbs associated with actions and activities in the field of hacking and cybersecurity", + "example": "synthesize", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hackerverb" + }, + "hackeringVerb": { + "display": "Hackering Verb", + "category": "hacker", + "description": "Verb describing actions and activities related to hacking, often involving computer systems and security", + "example": "connecting", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hackeringverb" + }, + "helpingVerb": { + "display": "Helping Verb", + "category": "word", + "description": "Auxiliary verb that helps the main verb complete the sentence", + "example": "be", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "verbhelping" + }, + "hexColor": { + "display": "Hex Color", + "category": "color", + "description": "Six-digit code representing a color in the color model", + "example": "#a99fb4", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexcolor" + }, + "hexUint128": { + "display": "HexUint128", + "category": "number", + "description": "Hexadecimal representation of an 128-bit unsigned integer", + "example": "0x875469578e51b5e56c95b64681d147a1", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexuint128" + }, + "hexUint16": { + "display": "HexUint16", + "category": "number", + "description": "Hexadecimal representation of an 16-bit unsigned integer", + "example": "0x8754", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexuint16" + }, + "hexUint256": { + "display": "HexUint256", + "category": "number", + "description": "Hexadecimal representation of an 256-bit unsigned integer", + "example": "0x875469578e51b5e56c95b64681d147a12cde48a4f417231b0c486abbc263e48d", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexuint256" + }, + "hexUint32": { + "display": "HexUint32", + "category": "number", + "description": "Hexadecimal representation of an 32-bit unsigned integer", + "example": "0x87546957", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexuint32" + }, + "hexUint64": { + "display": "HexUint64", + "category": "number", + "description": "Hexadecimal representation of an 64-bit unsigned integer", + "example": "0x875469578e51b5e5", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexuint64" + }, + "hexUint8": { + "display": "HexUint8", + "category": "number", + "description": "Hexadecimal representation of an 8-bit unsigned integer", + "example": "0x87", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hexuint8" + }, + "hipsterParagraph": { + "display": "Hipster Paragraph", + "category": "hipster", + "description": "Paragraph showcasing the use of trendy and unconventional vocabulary associated with hipster culture", + "example": "Microdosing roof chia echo pickled meditation cold-pressed raw denim fingerstache normcore sriracha pork belly. Wolf try-hard pop-up blog tilde hashtag health butcher waistcoat paleo portland vinegar. Microdosing sartorial blue bottle slow-carb freegan five dollar toast you probably haven't heard of them asymmetrical chia farm-to-table narwhal banjo. Gluten-free blog authentic literally synth vinyl meh ethical health fixie banh mi Yuccie. Try-hard drinking squid seitan cray VHS echo chillwave hammock kombucha food truck sustainable.\n\nPug bushwick hella tote bag cliche direct trade waistcoat yr waistcoat knausgaard pour-over master. Pitchfork jean shorts franzen flexitarian distillery hella meggings austin knausgaard crucifix wolf heirloom. Crucifix food truck you probably haven't heard of them trust fund fixie gentrify pitchfork stumptown mlkshk umami chambray blue bottle. 3 wolf moon swag +1 biodiesel knausgaard semiotics taxidermy meh artisan hoodie +1 blue bottle. Fashion axe forage mixtape Thundercats pork belly whatever 90's beard selfies chambray cred mlkshk.\n\nShabby chic typewriter VHS readymade lo-fi bitters PBR\u0026B gentrify lomo raw denim freegan put a bird on it. Raw denim cliche dreamcatcher pug fixie park trust fund migas fingerstache sriracha +1 mustache. Tilde shoreditch kickstarter franzen dreamcatcher green juice mustache neutra polaroid stumptown organic schlitz. Flexitarian ramps chicharrones kogi lo-fi mustache tilde forage street church-key williamsburg taxidermy. Chia mustache plaid mumblecore squid slow-carb disrupt Thundercats goth shoreditch master direct trade.", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "paragraphcount", + "display": "Paragraph Count", + "type": "number", + "optional": false, + "default": "2", + "options": null, + "description": "Number of paragraphs" + }, + { + "field": "sentencecount", + "display": "Sentence Count", + "type": "number", + "optional": false, + "default": "2", + "options": null, + "description": "Number of sentences in a paragraph" + }, + { + "field": "wordcount", + "display": "Word Count", + "type": "number", + "optional": false, + "default": "5", + "options": null, + "description": "Number of words in a sentence" + }, + { + "field": "paragraphseparator", + "display": "Paragraph Separator", + "type": "string", + "optional": false, + "default": "\u003cbr /\u003e", + "options": null, + "description": "String value to add between paragraphs" + } + ], + "any": "hipsterparagraph" + }, + "hipsterSentence": { + "display": "Hipster Sentence", + "category": "hipster", + "description": "Sentence showcasing the use of trendy and unconventional vocabulary associated with hipster culture", + "example": "Microdosing roof chia echo pickled.", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "wordcount", + "display": "Word Count", + "type": "number", + "optional": false, + "default": "5", + "options": null, + "description": "Number of words in a sentence" + } + ], + "any": "hipstersentence" + }, + "hipsterWord": { + "display": "Hipster Word", + "category": "hipster", + "description": "Trendy and unconventional vocabulary used by hipsters to express unique cultural preferences", + "example": "microdosing", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hipsterword" + }, + "hobby": { + "display": "Hobby", + "category": "person", + "description": "An activity pursued for leisure and pleasure", + "example": "Swimming", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "hobby" + }, + "hour": { + "display": "Hour", + "category": "time", + "description": "Unit of time equal to 60 minutes", + "example": "8", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "hour" + }, + "httpClientError": { + "display": "HTTP client error", + "category": "error", + "description": "Failure or issue occurring within a client software that sends requests to web servers", + "example": "request timeout", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorhttpclient" + }, + "httpError": { + "display": "HTTP error", + "category": "error", + "description": "A problem with a web http request", + "example": "invalid method", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorhttp" + }, + "httpMethod": { + "display": "HTTP Method", + "category": "internet", + "description": "Verb used in HTTP requests to specify the desired action to be performed on a resource", + "example": "HEAD", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "httpmethod" + }, + "httpServerError": { + "display": "HTTP server error", + "category": "error", + "description": "Failure or issue occurring within a server software that recieves requests from clients", + "example": "internal server error", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorhttpserver" + }, + "httpStatusCode": { + "display": "HTTP Status Code", + "category": "internet", + "description": "Random http status code", + "example": "200", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "httpstatuscode" + }, + "httpStatusCodeSimple": { + "display": "HTTP Status Code Simple", + "category": "internet", + "description": "Three-digit number returned by a web server to indicate the outcome of an HTTP request", + "example": "404", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "httpstatuscodesimple" + }, + "httpVersion": { + "display": "HTTP Version", + "category": "internet", + "description": "Number indicating the version of the HTTP protocol used for communication between a client and a server", + "example": "HTTP/1.1", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "httpversion" + }, + "imageJpeg": { + "display": "Image JPEG", + "category": "image", + "description": "Image file format known for its efficient compression and compatibility", + "example": "file.jpeg - bytes", + "output": "number[]", + "content_type": "image/jpeg", + "params": [ + { + "field": "width", + "display": "Width", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Image width in px" + }, + { + "field": "height", + "display": "Height", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Image height in px" + } + ], + "any": "imagejpeg" + }, + "imagePng": { + "display": "Image PNG", + "category": "image", + "description": "Image file format known for its lossless compression and support for transparency", + "example": "file.png - bytes", + "output": "number[]", + "content_type": "image/png", + "params": [ + { + "field": "width", + "display": "Width", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Image width in px" + }, + { + "field": "height", + "display": "Height", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Image height in px" + } + ], + "any": "imagepng" + }, + "imageSVG": { + "display": "Image SVG", + "category": "html", + "description": "Scalable Vector Graphics used to display vector images in web content", + "example": "\u003csvg width=\"369\" height=\"289\"\u003e\n\t\u003crect fill=\"#4f2958\" /\u003e\n\t\u003cpolygon points=\"382,87 418,212 415,110\" fill=\"#fffbb7\" /\u003e\n\u003c/svg\u003e", + "output": "string", + "content_type": "image/svg+xml", + "params": [ + { + "field": "width", + "display": "Width", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Width in px" + }, + { + "field": "height", + "display": "Height", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Height in px" + }, + { + "field": "type", + "display": "Type", + "type": "string", + "optional": true, + "default": "", + "options": [ + "rect", + "circle", + "ellipse", + "line", + "polyline", + "polygon" + ], + "description": "Sub child element type" + }, + { + "field": "colors", + "display": "Colors", + "type": "string[]", + "optional": true, + "default": "", + "options": null, + "description": "Hex or RGB array of colors to use" + } + ], + "any": "svg" + }, + "imageUrl": { + "display": "Image URL", + "category": "image", + "description": "Web address pointing to an image file that can be accessed and displayed online", + "example": "https://picsum.photos/500/500", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "width", + "display": "Width", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Image width in px" + }, + { + "field": "height", + "display": "Height", + "type": "number", + "optional": false, + "default": "500", + "options": null, + "description": "Image height in px" + } + ], + "any": "imageurl" + }, + "indefiniteAdjective": { + "display": "Indefinite Adjective", + "category": "word", + "description": "Adjective describing a non-specific noun", + "example": "few", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectiveindefinite" + }, + "inputName": { + "display": "Input Name", + "category": "html", + "description": "Attribute used to define the name of an input element in web forms", + "example": "first_name", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "inputname" + }, + "int16": { + "display": "Int16", + "category": "number", + "description": "Signed 16-bit integer, capable of representing values from 32,768 to 32,767", + "example": "2200", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "int16" + }, + "int32": { + "display": "Int32", + "category": "number", + "description": "Signed 32-bit integer, capable of representing values from -2,147,483,648 to 2,147,483,647", + "example": "-1072427943", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "int32" + }, + "int64": { + "display": "Int64", + "category": "number", + "description": "Signed 64-bit integer, capable of representing values from -9,223,372,036,854,775,808 to -9,223,372,036,854,775,807", + "example": "-8379641344161477543", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "int64" + }, + "int8": { + "display": "Int8", + "category": "number", + "description": "Signed 8-bit integer, capable of representing values from -128 to 127", + "example": "24", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "int8" + }, + "intRange": { + "display": "IntRange", + "category": "number", + "description": "Integer value between given range", + "example": "-8379477543", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Minimum int value" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Maximum int value" + } + ], + "any": "intrange" + }, + "interjection": { + "display": "Interjection", + "category": "word", + "description": "Word expressing emotion", + "example": "wow", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "interjection" + }, + "interrogativeAdjective": { + "display": "Interrogative Adjective", + "category": "word", + "description": "Adjective used to ask questions", + "example": "what", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectiveinterrogative" + }, + "intransitiveVerb": { + "display": "Intransitive Verb", + "category": "word", + "description": "Verb that does not require a direct object to complete its meaning", + "example": "laugh", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "verbintransitive" + }, + "ipv4Address": { + "display": "IPv4 Address", + "category": "internet", + "description": "Numerical label assigned to devices on a network for identification and communication", + "example": "222.83.191.222", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "ipv4address" + }, + "ipv6Address": { + "display": "IPv6 Address", + "category": "internet", + "description": "Numerical label assigned to devices on a network, providing a larger address space than IPv4 for internet communication", + "example": "2001:cafe:8898:ee17:bc35:9064:5866:d019", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "ipv6address" + }, + "isin": { + "display": "ISIN", + "category": "finance", + "description": "International standard code for uniquely identifying securities worldwide", + "example": "CVLRQCZBXQ97", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "isin" + }, + "job": { + "display": "Job", + "category": "company", + "description": "Position or role in employment, involving specific tasks and responsibilities", + "example": "{\n\t\"company\": \"ClearHealthCosts\",\n\t\"title\": \"Agent\",\n\t\"descriptor\": \"Future\",\n\t\"level\": \"Tactics\"\n}", + "output": "Record\u003cstring,string\u003e", + "content_type": "application/json", + "params": null, + "any": "job" + }, + "jobDescriptor": { + "display": "Job Descriptor", + "category": "company", + "description": "Word used to describe the duties, requirements, and nature of a job", + "example": "Central", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "jobdescriptor" + }, + "jobLevel": { + "display": "Job Level", + "category": "company", + "description": "Random job level", + "example": "Assurance", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "joblevel" + }, + "jobTitle": { + "display": "Job Title", + "category": "company", + "description": "Specific title for a position or role within a company or organization", + "example": "Director", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "jobtitle" + }, + "json": { + "display": "JSON", + "category": "file", + "description": "Format for structured data interchange used in programming, returns an object or an array of objects", + "example": "[\n\t\t\t{ \"first_name\": \"Markus\", \"last_name\": \"Moen\", \"password\": \"Dc0VYXjkWABx\" },\n\t\t\t{ \"first_name\": \"Osborne\", \"last_name\": \"Hilll\", \"password\": \"XPJ9OVNbs5lm\" },\n\t\t\t{ \"first_name\": \"Mertie\", \"last_name\": \"Halvorson\", \"password\": \"eyl3bhwfV8wA\" }\n\t\t]", + "output": "number[]", + "content_type": "application/json", + "params": [ + { + "field": "type", + "display": "Type", + "type": "string", + "optional": false, + "default": "object", + "options": [ + "object", + "array" + ], + "description": "Type of JSON, object or array" + }, + { + "field": "rowcount", + "display": "Row Count", + "type": "number", + "optional": false, + "default": "100", + "options": null, + "description": "Number of rows in JSON array" + }, + { + "field": "indent", + "display": "Indent", + "type": "boolean", + "optional": false, + "default": "false", + "options": null, + "description": "Whether or not to add indents and newlines" + }, + { + "field": "fields", + "display": "Fields", + "type": "", + "optional": false, + "default": "", + "options": null, + "description": "Fields containing key name and function to run in json format" + } + ], + "any": "json" + }, + "language": { + "display": "Language", + "category": "language", + "description": "System of communication using symbols, words, and grammar to convey meaning between individuals", + "example": "Kazakh", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "language" + }, + "languageAbbreviation": { + "display": "Language Abbreviation", + "category": "language", + "description": "Shortened form of a language's name", + "example": "kk", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "languageabbreviation" + }, + "languageBcp": { + "display": "Language BCP", + "category": "language", + "description": "Set of guidelines and standards for identifying and representing languages in computing and internet protocols", + "example": "en-US", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "languagebcp" + }, + "lastName": { + "display": "Last Name", + "category": "person", + "description": "The family name or surname of an individual", + "example": "Daniel", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "lastname" + }, + "latitude": { + "display": "Latitude", + "category": "address", + "description": "Geographic coordinate specifying north-south position on Earth's surface", + "example": "-73.534056", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "latitude" + }, + "latitudeRange": { + "display": "Latitude Range", + "category": "address", + "description": "Latitude number between the given range (default min=0, max=90)", + "example": "22.921026", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "0", + "options": null, + "description": "Minimum range" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "90", + "options": null, + "description": "Maximum range" + } + ], + "any": "latituderange" + }, + "letter": { + "display": "Letter", + "category": "string", + "description": "Character or symbol from the American Standard Code for Information Interchange (ASCII) character set", + "example": "g", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "letter" + }, + "letterN": { + "display": "LetterN", + "category": "string", + "description": "ASCII string with length N", + "example": "gbRMaRxHki", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "count", + "display": "Count", + "type": "number", + "optional": false, + "default": "", + "options": null, + "description": "Number of digits to generate" + } + ], + "any": "lettern" + }, + "lexify": { + "display": "Lexify", + "category": "string", + "description": "Replace ? with random generated letters", + "example": "?????@??????.com =\u003e billy@mister.com", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "str", + "display": "String", + "type": "string", + "optional": false, + "default": "", + "options": null, + "description": "String value to replace ?'s" + } + ], + "any": "lexify" + }, + "linkingVerb": { + "display": "Linking Verb", + "category": "word", + "description": "Verb that Connects the subject of a sentence to a subject complement", + "example": "was", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "verblinking" + }, + "logLevel": { + "display": "Log Level", + "category": "internet", + "description": "Classification used in logging to indicate the severity or priority of a log entry", + "example": "error", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "loglevel" + }, + "longitude": { + "display": "Longitude", + "category": "address", + "description": "Geographic coordinate indicating east-west position on Earth's surface", + "example": "-147.068112", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "longitude" + }, + "longitudeRange": { + "display": "Longitude Range", + "category": "address", + "description": "Longitude number between the given range (default min=0, max=180)", + "example": "-8.170450", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "0", + "options": null, + "description": "Minimum range" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "180", + "options": null, + "description": "Maximum range" + } + ], + "any": "longituderange" + }, + "loremIpsumParagraph": { + "display": "Lorem Ipsum Paragraph", + "category": "word", + "description": "Paragraph of the Lorem Ipsum placeholder text used in design and publishing", + "example": "Quia quae repellat consequatur quidem nisi quo qui voluptatum accusantium quisquam amet. Quas et ut non dolorem ipsam aut enim assumenda mollitia harum ut. Dicta similique veniam nulla voluptas at excepturi non ad maxime at non. Eaque hic repellat praesentium voluptatem qui consequuntur dolor iusto autem velit aut. Fugit tempore exercitationem harum consequatur voluptatum modi minima aut eaque et et.\n\nAut ea voluptatem dignissimos expedita odit tempore quod aut beatae ipsam iste. Minus voluptatibus dolorem maiores eius sed nihil vel enim odio voluptatem accusamus. Natus quibusdam temporibus tenetur cumque sint necessitatibus dolorem ex ducimus iusto ex. Voluptatem neque dicta explicabo officiis et ducimus sit ut ut praesentium pariatur. Illum molestias nisi at dolore ut voluptatem accusantium et fugiat et ut.\n\nExplicabo incidunt reprehenderit non quia dignissimos recusandae vitae soluta quia et quia. Aut veniam voluptas consequatur placeat sapiente non eveniet voluptatibus magni velit eum. Nobis vel repellendus sed est qui autem laudantium quidem quam ullam consequatur. Aut iusto ut commodi similique quae voluptatem atque qui fugiat eum aut. Quis distinctio consequatur voluptatem vel aliquid aut laborum facere officiis iure tempora.", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "paragraphcount", + "display": "Paragraph Count", + "type": "number", + "optional": false, + "default": "2", + "options": null, + "description": "Number of paragraphs" + }, + { + "field": "sentencecount", + "display": "Sentence Count", + "type": "number", + "optional": false, + "default": "2", + "options": null, + "description": "Number of sentences in a paragraph" + }, + { + "field": "wordcount", + "display": "Word Count", + "type": "number", + "optional": false, + "default": "5", + "options": null, + "description": "Number of words in a sentence" + }, + { + "field": "paragraphseparator", + "display": "Paragraph Separator", + "type": "string", + "optional": false, + "default": "\u003cbr /\u003e", + "options": null, + "description": "String value to add between paragraphs" + } + ], + "any": "loremipsumparagraph" + }, + "loremIpsumSentence": { + "display": "Lorem Ipsum Sentence", + "category": "word", + "description": "Sentence of the Lorem Ipsum placeholder text used in design and publishing", + "example": "Quia quae repellat consequatur quidem.", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "wordcount", + "display": "Word Count", + "type": "number", + "optional": false, + "default": "5", + "options": null, + "description": "Number of words in a sentence" + } + ], + "any": "loremipsumsentence" + }, + "loremIpsumWord": { + "display": "Lorem Ipsum Word", + "category": "word", + "description": "Word of the Lorem Ipsum placeholder text used in design and publishing", + "example": "quia", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "loremipsumword" + }, + "lunch": { + "display": "Lunch", + "category": "food", + "description": "Midday meal, often lighter than dinner, eaten around noon", + "example": "No bake hersheys bar pie", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "lunch" + }, + "macAddress": { + "display": "MAC Address", + "category": "internet", + "description": "Unique identifier assigned to network interfaces, often used in Ethernet networks", + "example": "cb:ce:06:94:22:e9", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "macaddress" + }, + "map": { + "display": "Map", + "category": "generate", + "description": "Data structure that stores key-value pairs", + "example": "{\n\t\"software\": 7518355,\n\t\"that\": [\"despite\", \"pack\", \"whereas\", \"recently\", \"there\", \"anyone\", \"time\", \"read\"],\n\t\"use\": 683598,\n\t\"whom\": \"innovate\",\n\t\"yourselves\": 1987784\n}", + "output": "Record\u003cstring,unknown\u003e", + "content_type": "application/json", + "params": null, + "any": "map" + }, + "middleName": { + "display": "Middle Name", + "category": "person", + "description": "Name between a person's first name and last name", + "example": "Belinda", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "middlename" + }, + "minecraftAnimal": { + "display": "Minecraft animal", + "category": "minecraft", + "description": "Non-hostile creatures in Minecraft, often used for resources and farming", + "example": "chicken", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftanimal" + }, + "minecraftArmorPart": { + "display": "Minecraft armor part", + "category": "minecraft", + "description": "Component of an armor set in Minecraft, such as a helmet, chestplate, leggings, or boots", + "example": "helmet", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftarmorpart" + }, + "minecraftArmorTier": { + "display": "Minecraft armor tier", + "category": "minecraft", + "description": "Classification system for armor sets in Minecraft, indicating their effectiveness and protection level", + "example": "iron", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftarmortier" + }, + "minecraftBiome": { + "display": "Minecraft biome", + "category": "minecraft", + "description": "Distinctive environmental regions in the game, characterized by unique terrain, vegetation, and weather", + "example": "forest", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftbiome" + }, + "minecraftDye": { + "display": "Minecraft dye", + "category": "minecraft", + "description": "Items used to change the color of various in-game objects", + "example": "white", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftdye" + }, + "minecraftFood": { + "display": "Minecraft food", + "category": "minecraft", + "description": "Consumable items in Minecraft that provide nourishment to the player character", + "example": "apple", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftfood" + }, + "minecraftMobBoss": { + "display": "Minecraft mob boss", + "category": "minecraft", + "description": "Powerful hostile creature in the game, often found in challenging dungeons or structures", + "example": "ender dragon", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftmobboss" + }, + "minecraftMobHostile": { + "display": "Minecraft mob hostile", + "category": "minecraft", + "description": "Aggressive creatures in the game that actively attack players when encountered", + "example": "spider", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftmobhostile" + }, + "minecraftMobNeutral": { + "display": "Minecraft mob neutral", + "category": "minecraft", + "description": "Creature in the game that only becomes hostile if provoked, typically defending itself when attacked", + "example": "bee", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftmobneutral" + }, + "minecraftMobPassive": { + "display": "Minecraft mob passive", + "category": "minecraft", + "description": "Non-aggressive creatures in the game that do not attack players", + "example": "cow", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftmobpassive" + }, + "minecraftOre": { + "display": "Minecraft ore", + "category": "minecraft", + "description": "Naturally occurring minerals found in the game Minecraft, used for crafting purposes", + "example": "coal", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftore" + }, + "minecraftTool": { + "display": "Minecraft tool", + "category": "minecraft", + "description": "Items in Minecraft designed for specific tasks, including mining, digging, and building", + "example": "shovel", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecrafttool" + }, + "minecraftVillagerJob": { + "display": "Minecraft villager job", + "category": "minecraft", + "description": "The profession or occupation assigned to a villager character in the game", + "example": "farmer", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftvillagerjob" + }, + "minecraftVillagerLevel": { + "display": "Minecraft villager level", + "category": "minecraft", + "description": "Measure of a villager's experience and proficiency in their assigned job or profession", + "example": "master", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftvillagerlevel" + }, + "minecraftVillagerStation": { + "display": "Minecraft villager station", + "category": "minecraft", + "description": "Designated area or structure in Minecraft where villagers perform their job-related tasks and trading", + "example": "furnace", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftvillagerstation" + }, + "minecraftWeapon": { + "display": "Minecraft weapon", + "category": "minecraft", + "description": "Tools and items used in Minecraft for combat and defeating hostile mobs", + "example": "bow", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftweapon" + }, + "minecraftWeather": { + "display": "Minecraft weather", + "category": "minecraft", + "description": "Atmospheric conditions in the game that include rain, thunderstorms, and clear skies, affecting gameplay and ambiance", + "example": "rain", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftweather" + }, + "minecraftWood": { + "display": "Minecraft wood", + "category": "minecraft", + "description": "Natural resource in Minecraft, used for crafting various items and building structures", + "example": "oak", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "minecraftwood" + }, + "minute": { + "display": "Minute", + "category": "time", + "description": "Unit of time equal to 60 seconds", + "example": "34", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "minute" + }, + "month": { + "display": "Month", + "category": "time", + "description": "Division of the year, typically 30 or 31 days long", + "example": "1", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "month" + }, + "monthString": { + "display": "Month String", + "category": "time", + "description": "String Representation of a month name", + "example": "September", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "monthstring" + }, + "movie": { + "display": "Movie", + "category": "movie", + "description": "A story told through moving pictures and sound", + "example": "{\n\t\"name\": \"Psycho\",\n\t\"genre\": \"Mystery\"\n}", + "output": "Record\u003cstring,string\u003e", + "content_type": "application/json", + "params": null, + "any": "movie" + }, + "movieGenre": { + "display": "Movie Genre", + "category": "movie", + "description": "Category that classifies movies based on common themes, styles, and storytelling approaches", + "example": "Action", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "moviegenre" + }, + "movieName": { + "display": "Movie Name", + "category": "movie", + "description": "Title or name of a specific film used for identification and reference", + "example": "The Matrix", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "moviename" + }, + "name": { + "display": "Name", + "category": "person", + "description": "The given and family name of an individual", + "example": "Markus Moen", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "name" + }, + "namePrefix": { + "display": "Name Prefix", + "category": "person", + "description": "A title or honorific added before a person's name", + "example": "Mr.", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nameprefix" + }, + "nameSuffix": { + "display": "Name Suffix", + "category": "person", + "description": "A title or designation added after a person's name", + "example": "Jr.", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "namesuffix" + }, + "nanosecond": { + "display": "Nanosecond", + "category": "time", + "description": "Unit of time equal to One billionth (10^-9) of a second", + "example": "196446360", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "nanosecond" + }, + "niceColors": { + "display": "Nice Colors", + "category": "color", + "description": "Attractive and appealing combinations of colors, returns an list of color hex codes", + "example": "[\"#cfffdd\",\"#b4dec1\",\"#5c5863\",\"#a85163\",\"#ff1f4c\"]", + "output": "string[]", + "content_type": "application/json", + "params": null, + "any": "nicecolors" + }, + "noun": { + "display": "Noun", + "category": "word", + "description": "Person, place, thing, or idea, named or referred to in a sentence", + "example": "aunt", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "noun" + }, + "nounAbstract": { + "display": "Noun Abstract", + "category": "word", + "description": "Ideas, qualities, or states that cannot be perceived with the five senses", + "example": "confusion", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nounabstract" + }, + "nounCollectiveAnimal": { + "display": "Noun Collective Animal", + "category": "word", + "description": "Group of animals, like a 'pack' of wolves or a 'flock' of birds", + "example": "party", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nouncollectiveanimal" + }, + "nounCollectivePeople": { + "display": "Noun Collective People", + "category": "word", + "description": "Group of people or things regarded as a unit", + "example": "body", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nouncollectivepeople" + }, + "nounCollectiveThing": { + "display": "Noun Collective Thing", + "category": "word", + "description": "Group of objects or items, such as a 'bundle' of sticks or a 'cluster' of grapes", + "example": "hand", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nouncollectivething" + }, + "nounCommon": { + "display": "Noun Common", + "category": "word", + "description": "General name for people, places, or things, not specific or unique", + "example": "part", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nouncommon" + }, + "nounConcrete": { + "display": "Noun Concrete", + "category": "word", + "description": "Names for physical entities experienced through senses like sight, touch, smell, or taste", + "example": "snowman", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nounconcrete" + }, + "nounCountable": { + "display": "Noun Countable", + "category": "word", + "description": "Items that can be counted individually", + "example": "neck", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nouncountable" + }, + "nounDeterminer": { + "display": "Noun Determiner", + "category": "word", + "description": "Word that introduces a noun and identifies it as a noun", + "example": "your", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "noundeterminer" + }, + "nounPhrase": { + "display": "Noun Phrase", + "category": "word", + "description": "Phrase with a noun as its head, functions within sentence like a noun", + "example": "a tribe", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phrasenoun" + }, + "nounProper": { + "display": "Noun Proper", + "category": "word", + "description": "Specific name for a particular person, place, or organization", + "example": "John", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "nounproper" + }, + "nounUncountable": { + "display": "Noun Uncountable", + "category": "word", + "description": "Items that can't be counted individually", + "example": "seafood", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "noununcountable" + }, + "number": { + "display": "Number", + "category": "number", + "description": "Mathematical concept used for counting, measuring, and expressing quantities or values", + "example": "14866", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "-2147483648", + "options": null, + "description": "Minimum integer value" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "2147483647", + "options": null, + "description": "Maximum integer value" + } + ], + "any": "number" + }, + "numerify": { + "display": "Numerify", + "category": "string", + "description": "Replace # with random numerical values", + "example": "(###)###-#### =\u003e (555)867-5309", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "str", + "display": "String", + "type": "string", + "optional": false, + "default": "", + "options": null, + "description": "String value to replace #'s" + } + ], + "any": "numerify" + }, + "operaUserAgent": { + "display": "Opera User Agent", + "category": "internet", + "description": "The specific identification string sent by the Opera web browser when making requests on the internet", + "example": "Opera/8.39 (Macintosh; U; PPC Mac OS X 10_8_7; en-US) Presto/2.9.335 Version/10.00", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "operauseragent" + }, + "paragraph": { + "display": "Paragraph", + "category": "word", + "description": "Distinct section of writing covering a single theme, composed of multiple sentences", + "example": "Interpret context record river mind press self should compare property outcome divide. Combine approach sustain consult discover explanation direct address church husband seek army. Begin own act welfare replace press suspect stay link place manchester specialist. Arrive price satisfy sign force application hair train provide basis right pay. Close mark teacher strengthen information attempt head touch aim iron tv take.", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "paragraphcount", + "display": "Paragraph Count", + "type": "number", + "optional": false, + "default": "2", + "options": null, + "description": "Number of paragraphs" + }, + { + "field": "sentencecount", + "display": "Sentence Count", + "type": "number", + "optional": false, + "default": "2", + "options": null, + "description": "Number of sentences in a paragraph" + }, + { + "field": "wordcount", + "display": "Word Count", + "type": "number", + "optional": false, + "default": "5", + "options": null, + "description": "Number of words in a sentence" + }, + { + "field": "paragraphseparator", + "display": "Paragraph Separator", + "type": "string", + "optional": false, + "default": "\u003cbr /\u003e", + "options": null, + "description": "String value to add between paragraphs" + } + ], + "any": "paragraph" + }, + "password": { + "display": "Password", + "category": "auth", + "description": "Secret word or phrase used to authenticate access to a system or account", + "example": "EEP+wwpk 4lU-eHNXlJZ4n K9%v\u0026TZ9e", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "lower", + "display": "Lower", + "type": "boolean", + "optional": false, + "default": "true", + "options": null, + "description": "Whether or not to add lower case characters" + }, + { + "field": "upper", + "display": "Upper", + "type": "boolean", + "optional": false, + "default": "true", + "options": null, + "description": "Whether or not to add upper case characters" + }, + { + "field": "numeric", + "display": "Numeric", + "type": "boolean", + "optional": false, + "default": "true", + "options": null, + "description": "Whether or not to add numeric characters" + }, + { + "field": "special", + "display": "Special", + "type": "boolean", + "optional": false, + "default": "true", + "options": null, + "description": "Whether or not to add special characters" + }, + { + "field": "space", + "display": "Space", + "type": "boolean", + "optional": false, + "default": "false", + "options": null, + "description": "Whether or not to add spaces" + }, + { + "field": "length", + "display": "Length", + "type": "number", + "optional": false, + "default": "12", + "options": null, + "description": "Number of characters in password" + } + ], + "any": "password" + }, + "pastTime": { + "display": "PastTime", + "category": "time", + "description": "Date that has occurred before the current moment in time", + "example": "2007-01-24 13:00:35.820738079 +0000 UTC", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pasttime" + }, + "person": { + "display": "Person", + "category": "person", + "description": "Personal data, like name and contact details, used for identification and communication", + "example": "{\n\t\"first_name\": \"Markus\",\n\t\"last_name\": \"Moen\",\n\t\"gender\": \"male\",\n\t\"ssn\": \"275413589\",\n\t\"image\": \"https://picsum.photos/208/500\",\n\t\"hobby\": \"Lacrosse\",\n\t\"job\": {\n\t\t\"company\": \"Intermap Technologies\",\n\t\t\"title\": \"Developer\",\n\t\t\"descriptor\": \"Direct\",\n\t\t\"level\": \"Paradigm\"\n\t},\n\t\"address\": {\n\t\t\"address\": \"369 North Cornerbury, Miami, North Dakota 24259\",\n\t\t\"street\": \"369 North Cornerbury\",\n\t\t\"city\": \"Miami\",\n\t\t\"state\": \"North Dakota\",\n\t\t\"zip\": \"24259\",\n\t\t\"country\": \"Ghana\",\n\t\t\"latitude\": -6.662595,\n\t\t\"longitude\": 23.921575\n\t},\n\t\"contact\": {\n\t\t\"phone\": \"3023202027\",\n\t\t\"email\": \"lamarkoelpin@heaney.biz\"\n\t},\n\t\"credit_card\": {\n\t\t\"type\": \"Maestro\",\n\t\t\"number\": \"39800889982276\",\n\t\t\"exp\": \"01/29\",\n\t\t\"cvv\": \"932\"\n\t}\n}", + "output": "Record\u003cstring,unknown\u003e", + "content_type": "application/json", + "params": null, + "any": "person" + }, + "petName": { + "display": "Pet Name", + "category": "animal", + "description": "Affectionate nickname given to a pet", + "example": "Ozzy Pawsborne", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "petname" + }, + "phone": { + "display": "Phone", + "category": "person", + "description": "Numerical sequence used to contact individuals via telephone or mobile devices", + "example": "6136459948", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phone" + }, + "phoneFormatted": { + "display": "Phone Formatted", + "category": "person", + "description": "Formatted phone number of a person", + "example": "136-459-9489", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phoneformatted" + }, + "phrase": { + "display": "Phrase", + "category": "word", + "description": "A small group of words standing together", + "example": "time will tell", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phrase" + }, + "possessiveAdjective": { + "display": "Possessive Adjective", + "category": "word", + "description": "Adjective indicating ownership or possession", + "example": "my", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectivepossessive" + }, + "preposition": { + "display": "Preposition", + "category": "word", + "description": "Words used to express the relationship of a noun or pronoun to other words in a sentence", + "example": "other than", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "preposition" + }, + "prepositionCompound": { + "display": "Preposition Compound", + "category": "word", + "description": "Preposition that can be formed by combining two or more prepositions", + "example": "according to", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "prepositioncompound" + }, + "prepositionDouble": { + "display": "Preposition Double", + "category": "word", + "description": "Two-word combination preposition, indicating a complex relation", + "example": "before", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "prepositiondouble" + }, + "prepositionPhrase": { + "display": "Preposition Phrase", + "category": "word", + "description": "Phrase starting with a preposition, showing relation between elements in a sentence.", + "example": "out the black thing", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phrasepreposition" + }, + "prepositionSimple": { + "display": "Preposition Simple", + "category": "word", + "description": "Single-word preposition showing relationships between 2 parts of a sentence", + "example": "out", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "prepositionsimple" + }, + "price": { + "display": "Price", + "category": "payment", + "description": "The amount of money or value assigned to a product, service, or asset in a transaction", + "example": "92.26", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "0", + "options": null, + "description": "Minimum price value" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "1000", + "options": null, + "description": "Maximum price value" + } + ], + "any": "price" + }, + "product": { + "display": "Product", + "category": "product", + "description": "An item created for sale or use", + "example": "{\n\t\"name\": \"olive copper monitor\",\n\t\"description\": \"Backwards caused quarterly without week it hungry thing someone him regularly. Whomever this revolt hence from his timing as quantity us these yours.\",\n\t\"categories\": [\n\t\t\"clothing\",\n\t\t\"tools and hardware\"\n\t],\n\t\"price\": 7.61,\n\t\"features\": [\n\t\t\"ultra-lightweight\"\n\t],\n\t\"color\": \"navy\",\n\t\"material\": \"brass\",\n\t\"upc\": \"012780949980\"\n}", + "output": "Record\u003cstring,unknown\u003e", + "content_type": "application/json", + "params": null, + "any": "product" + }, + "productCategory": { + "display": "Product Category", + "category": "product", + "description": "Classification grouping similar products based on shared characteristics or functions", + "example": "clothing", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "productcategory" + }, + "productDescription": { + "display": "Product Description", + "category": "product", + "description": "Explanation detailing the features and characteristics of a product", + "example": "Backwards caused quarterly without week it hungry thing someone him regularly. Whomever this revolt hence from his timing as quantity us these yours.", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "productdescription" + }, + "productFeature": { + "display": "Product Feature", + "category": "product", + "description": "Specific characteristic of a product that distinguishes it from others products", + "example": "ultra-lightweight", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "productfeature" + }, + "productMaterial": { + "display": "Product Material", + "category": "product", + "description": "The substance from which a product is made, influencing its appearance, durability, and properties", + "example": "brass", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "productmaterial" + }, + "productName": { + "display": "Product Name", + "category": "product", + "description": "Distinctive title or label assigned to a product for identification and marketing", + "example": "olive copper monitor", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "productname" + }, + "productUpc": { + "display": "Product UPC", + "category": "product", + "description": "Standardized barcode used for product identification and tracking in retail and commerce", + "example": "012780949980", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "productupc" + }, + "programmingLanguage": { + "display": "Programming Language", + "category": "language", + "description": "Formal system of instructions used to create software and perform computational tasks", + "example": "Go", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "programminglanguage" + }, + "pronoun": { + "display": "Pronoun", + "category": "word", + "description": "Word used in place of a noun to avoid repetition", + "example": "me", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronoun" + }, + "pronounDemonstrative": { + "display": "Pronoun Demonstrative", + "category": "word", + "description": "Pronoun that points out specific people or things", + "example": "this", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronoundemonstrative" + }, + "pronounIndefinite": { + "display": "Pronoun Indefinite", + "category": "word", + "description": "Pronoun that does not refer to a specific person or thing", + "example": "few", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronounindefinite" + }, + "pronounInterrogative": { + "display": "Pronoun Interrogative", + "category": "word", + "description": "Pronoun used to ask questions", + "example": "what", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronouninterrogative" + }, + "pronounObject": { + "display": "Pronoun Object", + "category": "word", + "description": "Pronoun used as the object of a verb or preposition", + "example": "it", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronounobject" + }, + "pronounPersonal": { + "display": "Pronoun Personal", + "category": "word", + "description": "Pronoun referring to a specific persons or things", + "example": "it", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronounpersonal" + }, + "pronounPossessive": { + "display": "Pronoun Possessive", + "category": "word", + "description": "Pronoun indicating ownership or belonging", + "example": "mine", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronounpossessive" + }, + "pronounReflective": { + "display": "Pronoun Reflective", + "category": "word", + "description": "Pronoun referring back to the subject of the sentence", + "example": "myself", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronounreflective" + }, + "pronounRelative": { + "display": "Pronoun Relative", + "category": "word", + "description": "Pronoun that introduces a clause, referring back to a noun or pronoun", + "example": "as", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "pronounrelative" + }, + "properAdjective": { + "display": "Proper Adjective", + "category": "word", + "description": "Adjective derived from a proper noun, often used to describe nationality or origin", + "example": "Afghan", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectiveproper" + }, + "quantitativeAdjective": { + "display": "Quantitative Adjective", + "category": "word", + "description": "Adjective that indicates the quantity or amount of something", + "example": "a little", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "adjectivequantitative" + }, + "question": { + "display": "Question", + "category": "word", + "description": "Statement formulated to inquire or seek clarification", + "example": "Roof chia echo?", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "question" + }, + "quote": { + "display": "Quote", + "category": "word", + "description": "Direct repetition of someone else's words", + "example": "\"Roof chia echo.\" - Lura Lockman", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "quote" + }, + "randomInt": { + "display": "Random Int", + "category": "number", + "description": "Randomly selected value from a slice of int", + "example": "-1,2,-3,4 =\u003e -3", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "ints", + "display": "Integers", + "type": "number[]", + "optional": false, + "default": "", + "options": null, + "description": "Delimited separated integers" + } + ], + "any": "randomint" + }, + "randomMarkdownDocument": { + "display": "Random markdown document", + "category": "template", + "description": "Lightweight markup language used for formatting plain text", + "example": "# PurpleSheep5\n\n*Author: Amie Feil*\n\nQuarterly without week it hungry thing someone. Him regularly today whomever this revolt hence. From his timing as quantity us these. Yours live these frantic not may another. How this ours his them those whose.\n\nThem batch its Iraqi most that few. Abroad cheese this whereas next how there. Gorgeous genetics time choir fiction therefore yourselves. Am those infrequently heap software quarterly rather. Punctuation yellow where several his orchard to.\n\n## Table of Contents\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n\n## Installation\n'''bash\npip install PurpleSheep5\n'''\n\n## Usage\n'''python\nresult = purplesheep5.process(\"funny request\")\nprint(\"purplesheep5 result:\", \"in progress\")\n'''\n\n## License\nMIT", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "markdown" + }, + "randomString": { + "display": "Random String", + "category": "string", + "description": "Return a random string from a string array", + "example": "hello,world,whats,up =\u003e world", + "output": "string[]", + "content_type": "text/plain", + "params": [ + { + "field": "strs", + "display": "Strings", + "type": "string[]", + "optional": false, + "default": "", + "options": null, + "description": "Delimited separated strings" + } + ], + "any": "randomstring" + }, + "randomTextEmailDocument": { + "display": "Random text email Document", + "category": "template", + "description": "Written content of an email message, including the sender's message to the recipient", + "example": "Subject: Greetings from Marcel!\n\nDear Pagac,\n\nHello there! Sending positive vibes your way.\n\nI hope you're doing great. May your week be filled with joy.\n\nVirtually woman where team late quarterly without week it hungry. Thing someone him regularly today whomever this revolt hence from. His timing as quantity us these yours live these frantic. Not may another how this ours his them those whose. Them batch its Iraqi most that few abroad cheese this.\n\nWhereas next how there gorgeous genetics time choir fiction therefore. Yourselves am those infrequently heap software quarterly rather punctuation yellow. Where several his orchard to frequently hence victorious boxers each. Does auspicious yourselves first soup tomorrow this that must conclude. Anyway some yearly who cough laugh himself both yet rarely.\n\nMe dolphin intensely block would leap plane us first then. Down them eager would hundred super throughout animal yet themselves. Been group flock shake part purchase up usually it her. None it hers boat what their there Turkmen moreover one. Lebanese to brace these shower in it everybody should whatever.\n\nI'm curious to know what you think about it. If you have a moment, please feel free to check out the project on Bitbucket\n\nI'm eager to hear what you think. Looking forward to your feedback!\n\nThank you for your consideration! Thanks in advance for your time.\n\nKind regards\nMilford Johnston\njamelhaag@king.org\n(507)096-3058", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "email_text" + }, + "randomUint": { + "display": "Random Uint", + "category": "number", + "description": "Randomly selected value from a slice of uint", + "example": "1,2,3,4 =\u003e 4", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "uints", + "display": "Unsigned Integers", + "type": "number[]", + "optional": false, + "default": "", + "options": null, + "description": "Delimited separated unsigned integers" + } + ], + "any": "randomuint" + }, + "regex": { + "display": "Regex", + "category": "generate", + "description": "Pattern-matching tool used in text processing to search and manipulate strings", + "example": "[abcdef]{5} - affec", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "str", + "display": "String", + "type": "string", + "optional": false, + "default": "", + "options": null, + "description": "Regex RE2 syntax string" + } + ], + "any": "regex" + }, + "rgbColor": { + "display": "RGB Color", + "category": "color", + "description": "Color defined by red, green, and blue light values", + "example": "[85, 224, 195]", + "output": "number[]", + "content_type": "application/json", + "params": null, + "any": "rgbcolor" + }, + "runtimeError": { + "display": "Runtime error", + "category": "error", + "description": "Malfunction occuring during program execution, often causing abrupt termination or unexpected behavior", + "example": "address out of bounds", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorruntime" + }, + "safariUserAgent": { + "display": "Safari User Agent", + "category": "internet", + "description": "The specific identification string sent by the Safari web browser when making requests on the internet", + "example": "Mozilla/5.0 (iPad; CPU OS 8_3_2 like Mac OS X; en-US) AppleWebKit/531.15.6 (KHTML, like Gecko) Version/4.0.5 Mobile/8B120 Safari/6531.15.6", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "safariuseragent" + }, + "safeColor": { + "display": "Safe Color", + "category": "color", + "description": "Colors displayed consistently on different web browsers and devices", + "example": "black", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "safecolor" + }, + "school": { + "display": "School", + "category": "school", + "description": "An institution for formal education and learning", + "example": "Harborview State Academy", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "school" + }, + "second": { + "display": "Second", + "category": "time", + "description": "Unit of time equal to 1/60th of a minute", + "example": "43", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "second" + }, + "sentence": { + "display": "Sentence", + "category": "word", + "description": "Set of words expressing a statement, question, exclamation, or command", + "example": "Interpret context record river mind.", + "output": "string", + "content_type": "text/plain", + "params": [ + { + "field": "wordcount", + "display": "Word Count", + "type": "number", + "optional": false, + "default": "5", + "options": null, + "description": "Number of words in a sentence" + } + ], + "any": "sentence" + }, + "shuffleInts": { + "display": "Shuffle Ints", + "category": "number", + "description": "Shuffles an array of ints", + "example": "1,2,3,4 =\u003e 3,1,4,2", + "output": "number[]", + "content_type": "text/plain", + "params": [ + { + "field": "ints", + "display": "Integers", + "type": "number[]", + "optional": false, + "default": "", + "options": null, + "description": "Delimited separated integers" + } + ], + "any": "shuffleints" + }, + "shuffleStrings": { + "display": "Shuffle Strings", + "category": "string", + "description": "Shuffle an array of strings", + "example": "hello,world,whats,up =\u003e whats,world,hello,up", + "output": "string[]", + "content_type": "application/json", + "params": [ + { + "field": "strs", + "display": "Strings", + "type": "string[]", + "optional": false, + "default": "", + "options": null, + "description": "Delimited separated strings" + } + ], + "any": "shufflestrings" + }, + "simpleSentence": { + "display": "Simple Sentence", + "category": "word", + "description": "Group of words that expresses a complete thought", + "example": "A tribe fly the lemony kitchen.", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "sentencesimple" + }, + "slogan": { + "display": "Slogan", + "category": "company", + "description": "Catchphrase or motto used by a company to represent its brand or values", + "example": "Universal seamless Focus, interactive.", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "slogan" + }, + "snack": { + "display": "Snack", + "category": "food", + "description": "Random snack", + "example": "Small, quick food item eaten between meals", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "snack" + }, + "sql": { + "display": "SQL", + "category": "database", + "description": "Command in SQL used to add new data records into a database table", + "example": "INSERT INTO people \n\t(id, first_name, price, age, created_at) \nVALUES \n\t(1, 'Markus', 804.92, 21, '1937-01-30 07:58:01'),\n\t(2, 'Santino', 235.13, 40, '1964-07-07 22:25:40');", + "output": "string", + "content_type": "application/sql", + "params": [ + { + "field": "table", + "display": "Table", + "type": "string", + "optional": false, + "default": "", + "options": null, + "description": "Name of the table to insert into" + }, + { + "field": "count", + "display": "Count", + "type": "number", + "optional": false, + "default": "100", + "options": null, + "description": "Number of inserts to generate" + }, + { + "field": "fields", + "display": "Fields", + "type": "", + "optional": false, + "default": "", + "options": null, + "description": "Fields containing key name and function to run in json format" + } + ], + "any": "sql" + }, + "ssn": { + "display": "SSN", + "category": "person", + "description": "Unique nine-digit identifier used for government and financial purposes in the United States", + "example": "296446360", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "ssn" + }, + "state": { + "display": "State", + "category": "address", + "description": "Governmental division within a country, often having its own laws and government", + "example": "Illinois", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "state" + }, + "stateAbbreviation": { + "display": "State Abbreviation", + "category": "address", + "description": "Shortened 2-letter form of a country's state", + "example": "IL", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "stateabr" + }, + "street": { + "display": "Street", + "category": "address", + "description": "Public road in a city or town, typically with houses and buildings on each side", + "example": "364 East Rapidsborough", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "street" + }, + "streetName": { + "display": "Street Name", + "category": "address", + "description": "Name given to a specific road or street", + "example": "View", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "streetname" + }, + "streetNumber": { + "display": "Street Number", + "category": "address", + "description": "Numerical identifier assigned to a street", + "example": "13645", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "streetnumber" + }, + "streetPrefix": { + "display": "Street Prefix", + "category": "address", + "description": "Directional or descriptive term preceding a street name, like 'East' or 'Main'", + "example": "Lake", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "streetprefix" + }, + "streetSuffix": { + "display": "Street Suffix", + "category": "address", + "description": "Designation at the end of a street name indicating type, like 'Avenue' or 'Street'", + "example": "land", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "streetsuffix" + }, + "teams": { + "display": "Teams", + "category": "person", + "description": "Randomly split people into teams", + "example": "{\n\t\"Team 1\": [\n\t\t\"Justin\",\n\t\t\"Connor\",\n\t\t\"Jeff\"\n\t],\n\t\"Team 2\": [\n\t\t\"Sharon\",\n\t\t\"Fabian\",\n\t\t\"Billy\"\n\t],\n\t\"Team 3\": [\n\t\t\"Steve\",\n\t\t\"Robert\"\n\t]\n}", + "output": "Record\u003cstring, Array\u003cstring\u003e\u003e", + "content_type": "application/json", + "params": [ + { + "field": "people", + "display": "Strings", + "type": "string[]", + "optional": false, + "default": "", + "options": null, + "description": "Array of people" + }, + { + "field": "teams", + "display": "Strings", + "type": "string[]", + "optional": false, + "default": "", + "options": null, + "description": "Array of teams" + } + ], + "any": "teams" + }, + "timezone": { + "display": "Timezone", + "category": "time", + "description": "Region where the same standard time is used, based on longitudinal divisions of the Earth", + "example": "Kaliningrad Standard Time", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "timezone" + }, + "timezoneAbbreviation": { + "display": "Timezone Abbreviation", + "category": "time", + "description": "Abbreviated 3-letter word of a timezone", + "example": "KST", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "timezoneabv" + }, + "timezoneFull": { + "display": "Timezone Full", + "category": "time", + "description": "Full name of a timezone", + "example": "(UTC+03:00) Kaliningrad, Minsk", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "timezonefull" + }, + "timezoneOffset": { + "display": "Timezone Offset", + "category": "time", + "description": "The difference in hours from Coordinated Universal Time (UTC) for a specific region", + "example": "3", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "timezoneoffset" + }, + "timezoneRegion": { + "display": "Timezone Region", + "category": "time", + "description": "Geographic area sharing the same standard time", + "example": "America/Alaska", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "timezoneregion" + }, + "transitiveVerb": { + "display": "Transitive Verb", + "category": "word", + "description": "Verb that requires a direct object to complete its meaning", + "example": "follow", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "verbtransitive" + }, + "uint16": { + "display": "Uint16", + "category": "number", + "description": "Unsigned 16-bit integer, capable of representing values from 0 to 65,535", + "example": "34968", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "uint16" + }, + "uint32": { + "display": "Uint32", + "category": "number", + "description": "Unsigned 32-bit integer, capable of representing values from 0 to 4,294,967,295", + "example": "1075055705", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "uint32" + }, + "uint64": { + "display": "Uint64", + "category": "number", + "description": "Unsigned 64-bit integer, capable of representing values from 0 to 18,446,744,073,709,551,615", + "example": "843730692693298265", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "uint64" + }, + "uint8": { + "display": "Uint8", + "category": "number", + "description": "Unsigned 8-bit integer, capable of representing values from 0 to 255", + "example": "152", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "uint8" + }, + "uintRange": { + "display": "UintRange", + "category": "number", + "description": "Non-negative integer value between given range", + "example": "1075055705", + "output": "number", + "content_type": "text/plain", + "params": [ + { + "field": "min", + "display": "Min", + "type": "number", + "optional": false, + "default": "0", + "options": null, + "description": "Minimum uint value" + }, + { + "field": "max", + "display": "Max", + "type": "number", + "optional": false, + "default": "4294967295", + "options": null, + "description": "Maximum uint value" + } + ], + "any": "uintrange" + }, + "url": { + "display": "URL", + "category": "internet", + "description": "Web address that specifies the location of a resource on the internet", + "example": "http://www.principalproductize.biz/target", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "url" + }, + "userAgent": { + "display": "User Agent", + "category": "internet", + "description": "String sent by a web browser to identify itself when requesting web content", + "example": "Mozilla/5.0 (Windows NT 5.0) AppleWebKit/5362 (KHTML, like Gecko) Chrome/37.0.834.0 Mobile Safari/5362", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "useragent" + }, + "username": { + "display": "Username", + "category": "auth", + "description": "Unique identifier assigned to a user for accessing an account or system", + "example": "Daniel1364", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "username" + }, + "uuid": { + "display": "UUID", + "category": "misc", + "description": "128-bit identifier used to uniquely identify objects or entities in computer systems", + "example": "590c1440-9888-45b0-bd51-a817ee07c3f2", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "uuid" + }, + "validationError": { + "display": "Validation error", + "category": "error", + "description": "Occurs when input data fails to meet required criteria or format specifications", + "example": "missing required field", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "errorvalidation" + }, + "vegetable": { + "display": "Vegetable", + "category": "food", + "description": "Edible plant or part of a plant, often used in savory cooking or salads", + "example": "Amaranth Leaves", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "vegetable" + }, + "verb": { + "display": "Verb", + "category": "word", + "description": "Word expressing an action, event or state", + "example": "release", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "verb" + }, + "verbPhrase": { + "display": "Verb Phrase", + "category": "word", + "description": "Phrase that Consists of a verb and its modifiers, expressing an action or state", + "example": "a tribe", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "phraseverb" + }, + "vowel": { + "display": "Vowel", + "category": "string", + "description": "Speech sound produced with an open vocal tract", + "example": "a", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "vowel" + }, + "weekday": { + "display": "Weekday", + "category": "time", + "description": "Day of the week excluding the weekend", + "example": "Friday", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "weekday" + }, + "word": { + "display": "Word", + "category": "word", + "description": "Basic unit of language representing a concept or thing, consisting of letters and having meaning", + "example": "man", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "word" + }, + "xml": { + "display": "XML", + "category": "file", + "description": "Generates an single or an array of elements in xml format", + "example": "\u003cxml\u003e\n\t\u003crecord\u003e\n\t\t\u003cfirst_name\u003eMarkus\u003c/first_name\u003e\n\t\t\u003clast_name\u003eMoen\u003c/last_name\u003e\n\t\t\u003cpassword\u003eDc0VYXjkWABx\u003c/password\u003e\n\t\u003c/record\u003e\n\t\u003crecord\u003e\n\t\t\u003cfirst_name\u003eOsborne\u003c/first_name\u003e\n\t\t\u003clast_name\u003eHilll\u003c/last_name\u003e\n\t\t\u003cpassword\u003eXPJ9OVNbs5lm\u003c/password\u003e\n\t\u003c/record\u003e\n\u003c/xml\u003e", + "output": "number[]", + "content_type": "application/xml", + "params": [ + { + "field": "type", + "display": "Type", + "type": "string", + "optional": false, + "default": "single", + "options": [ + "single", + "array" + ], + "description": "Type of XML, single or array" + }, + { + "field": "rootelement", + "display": "Root Element", + "type": "string", + "optional": false, + "default": "xml", + "options": null, + "description": "Root element wrapper name" + }, + { + "field": "recordelement", + "display": "Record Element", + "type": "string", + "optional": false, + "default": "record", + "options": null, + "description": "Record element for each record row" + }, + { + "field": "rowcount", + "display": "Row Count", + "type": "number", + "optional": false, + "default": "100", + "options": null, + "description": "Number of rows in JSON array" + }, + { + "field": "indent", + "display": "Indent", + "type": "boolean", + "optional": false, + "default": "false", + "options": null, + "description": "Whether or not to add indents and newlines" + }, + { + "field": "fields", + "display": "Fields", + "type": "", + "optional": false, + "default": "", + "options": null, + "description": "Fields containing key name and function to run in json format" + } + ], + "any": "xml" + }, + "year": { + "display": "Year", + "category": "time", + "description": "Period of 365 days, the time Earth takes to orbit the Sun", + "example": "1900", + "output": "number", + "content_type": "text/plain", + "params": null, + "any": "year" + }, + "zip": { + "display": "Zip", + "category": "address", + "description": "Numerical code for postal address sorting, specific to a geographic area", + "example": "13645", + "output": "string", + "content_type": "text/plain", + "params": null, + "any": "zip" + } +} diff --git a/functions_test.go b/functions_test.go new file mode 100644 index 0000000..1db20c3 --- /dev/null +++ b/functions_test.go @@ -0,0 +1,52 @@ +package faker + +import ( + _ "embed" + "encoding/json" + "fmt" + "testing" + + "github.com/brianvoe/gofakeit/v6" + "github.com/stretchr/testify/require" + "github.com/szkiba/xk6-faker/faker" + "github.com/szkiba/xk6-faker/module" + "go.k6.io/k6/js/modulestest" +) + +//go:embed functions.json +var functionsJSON []byte + +func Test_functions_json(t *testing.T) { + t.Parallel() + + var functions map[string]*gofakeit.Info + + require.NoError(t, json.Unmarshal(functionsJSON, &functions)) + require.Len(t, functions, len(faker.GetFuncLookups())) + + runtime := modulestest.NewRuntime(t) + err := runtime.SetupModuleSystem(map[string]any{module.ImportPath: module.New()}, nil, nil) + + require.NoError(t, err) + + _, err = runtime.RunOnEventLoop(` + let mod = require("` + module.ImportPath + `") + let faker = new mod.Faker(11) + `) + + require.NoError(t, err) + + lookups := faker.GetFuncLookups() + + for name, info := range functions { + require.Contains(t, lookups, name) + + val, err := runtime.RunOnEventLoop("typeof faker.zen." + name) + require.NoError(t, err) + require.Equal(t, "function", val.String()) + + val, err = runtime.RunOnEventLoop(fmt.Sprintf("typeof faker.%s.%s", info.Category, name)) + require.NoError(t, err) + require.Equal(t, "function", val.String()) + } +} diff --git a/go.mod b/go.mod index 1fb1222..f3454fd 100644 --- a/go.mod +++ b/go.mod @@ -1,32 +1,55 @@ module github.com/szkiba/xk6-faker -go 1.19 +go 1.21 require ( - github.com/brianvoe/gofakeit/v6 v6.20.2 - github.com/dop251/goja v0.0.0-20230531210528-d7324b2d74f7 - github.com/sirupsen/logrus v1.9.0 - go.k6.io/k6 v0.45.1 + github.com/brianvoe/gofakeit/v6 v6.28.0 + github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d + github.com/iancoleman/strcase v0.3.0 + github.com/stretchr/testify v1.8.4 + go.k6.io/k6 v0.49.0 lukechampine.com/frand v1.4.2 ) require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.9.0 // indirect - github.com/fatih/color v1.15.0 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/go-logr/logr v1.3.0 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect - github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect github.com/onsi/ginkgo v1.16.5 // indirect - github.com/onsi/gomega v1.18.1 // indirect + github.com/onsi/gomega v1.20.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.1.2 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - golang.org/x/time v0.3.0 // indirect + go.opentelemetry.io/otel v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 // indirect + go.opentelemetry.io/otel/sdk v1.21.0 // indirect + go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/time v0.5.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/grpc v1.60.0 // indirect + google.golang.org/protobuf v1.31.1-0.20231027082548-f4a6c1f6e5c1 // indirect gopkg.in/guregu/null.v3 v3.3.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f2b2d29..8d9750f 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,13 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/brianvoe/gofakeit/v6 v6.20.2 h1:FLloufuC7NcbHqDzVQ42CG9AKryS1gAGCRt8nQRsW+Y= -github.com/brianvoe/gofakeit/v6 v6.20.2/go.mod h1:Ow6qC71xtwm79anlwKRlWZW6zVq9D2XHE4QSSMP/rU8= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= +github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4= +github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -18,19 +18,27 @@ github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnm github.com/dlclark/regexp2 v1.9.0 h1:pTK/l/3qYIKaRXuHnEnIf7Y5NxfRPfpb7dis6/gdlVI= github.com/dlclark/regexp2 v1.9.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20230531210528-d7324b2d74f7 h1:cVGkvrdHgyBkYeB6kMCaF5j2d9Bg4trgbIpcUrKrvk4= -github.com/dop251/goja v0.0.0-20230531210528-d7324b2d74f7/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= +github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d h1:wi6jN5LVt/ljaBG4ue79Ekzb12QfJ52L9Q98tl8SWhw= +github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible h1:bopx7t9jyUNX1ebhr0G4gtQWmUOgwQRI0QsYhdYLgkU= github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -39,75 +47,106 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 h1:ZgoomqkdjGbQ3+qQXCkvYMCDvGDNg2k5JJDjjdTB6jY= +github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa h1:lx8ZnNPwjkXSzOROz0cg69RlErRXs+L3eDkggASWKLo= +github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa/go.mod h1:fhpOYavp5g2K74XDl/ao2y4KvhqVtKlkg1e+0UaQv7I= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd h1:AC3N94irbx2kWGA8f/2Ks7EQl2LxKIRQYuT9IJDwgiI= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 h1:94EkGmhXrVUEal+uLwFUf4fMXPhZpM5tYxuIsxrCCbI= +github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1/go.mod h1:vk/d9jpexY2Z9Bb0uB4Ndesss1Sr0Z9ZiGUrg5o9VGk= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= +github.com/onsi/gomega v1.20.2 h1:8uQq0zMgLEfa0vRrrBgaJF2gyW9Da9BmfGV+OyUzfkY= +github.com/onsi/gomega v1.20.2/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e h1:zWKUYT07mGmVBH+9UgnHXd/ekCK99C8EbDSAt5qsjXE= github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.k6.io/k6 v0.45.1 h1:z+iVxE7Qze2Ka8tKvnjerOsoTuQb8e27Vqd1wcG2IFI= -go.k6.io/k6 v0.45.1/go.mod h1:SBO/sqx6h/a0lJqEioMEpneb6zULogIyDmz+ufFqtIE= +go.k6.io/k6 v0.49.0 h1:Bk+hemV2fbzuGnU8rPl7ZPUaDBUTdZOcypLe2JZoS5k= +go.k6.io/k6 v0.49.0/go.mod h1:hnQ0FKUz10qTbRpuM8rSAmV8d7+aJZhoVmywKPhQrxg= +go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= +go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 h1:digkEZCJWobwBqMwC0cwCq8/wkkRy/OowZg5OArWZrM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0/go.mod h1:/OpE/y70qVkndM0TrxT4KBoN3RsFZP0QaofcfYrj76I= +go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= +go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= +go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= +go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -116,9 +155,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -130,22 +169,19 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -153,10 +189,10 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -165,8 +201,14 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= +google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= +google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -175,9 +217,11 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.1-0.20231027082548-f4a6c1f6e5c1 h1:fk72uXZyuZiTtW5tgd63jyVK6582lF61nRC/kGv6vCA= +google.golang.org/protobuf v1.31.1-0.20231027082548-f4a6c1f6e5c1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -192,5 +236,6 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= lukechampine.com/frand v1.4.2 h1:RzFIpOvkMXuPMBb9maa4ND4wjBn71E1Jpf8BzJHMaVw= lukechampine.com/frand v1.4.2/go.mod h1:4S/TM2ZgrKejMcKMbeLjISpJMO+/eZ1zu3vYX9dtj3s= diff --git a/module.go b/module.go deleted file mode 100644 index a88a655..0000000 --- a/module.go +++ /dev/null @@ -1,105 +0,0 @@ -// MIT License -// -// Copyright (c) 2021 Iván Szkiba -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -package faker - -import ( - "os" - "strconv" - - "github.com/dop251/goja" - "github.com/sirupsen/logrus" - "go.k6.io/k6/js/modules" -) - -const envSEED = "XK6_FAKER_SEED" - -// Register the extensions on module initialization. -func init() { - modules.Register("k6/x/faker", New()) -} - -type ( - RootModule struct{} - - ModuleInstance struct { - vu modules.VU - exports map[string]interface{} - } -) - -// Ensure the interfaces are implemented correctly. -var ( - _ modules.Instance = &ModuleInstance{} //nolint:exhaustruct - _ modules.Module = &RootModule{} -) - -// New returns a pointer to a new RootModule instance. -func New() *RootModule { - return &RootModule{} -} - -// NewModuleInstance implements the modules.Module interface and returns -// a new instance for each VU. -func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance { //nolint:varnamelen,ireturn - instance := &ModuleInstance{ - vu: vu, - exports: make(map[string]interface{}), - } - - instance.exports["Faker"] = instance.newFaker - - return instance -} - -// Exports implements the modules.Instance interface and returns the exports -// of the JS module. -func (mi *ModuleInstance) Exports() modules.Exports { - return modules.Exports{ - Named: mi.exports, - Default: newFaker(mi.vu, seed()), - } -} - -func (mi *ModuleInstance) newFaker(call goja.ConstructorCall) *goja.Object { - rt := mi.vu.Runtime() - - seed := call.Argument(0).ToInteger() - - return rt.ToValue(newFaker(mi.vu, seed)).ToObject(rt) -} - -func seed() int64 { - str := os.Getenv(envSEED) - if str == "" { - return 0 - } - - value, err := strconv.ParseInt(str, 10, 64) - if err != nil { - logrus.Error(err) // no module logger on k6 extension API... - - return 0 - } - - return value -} diff --git a/module/module.go b/module/module.go new file mode 100644 index 0000000..bb8bacb --- /dev/null +++ b/module/module.go @@ -0,0 +1,65 @@ +// Package module contains k6 faker JavaScript module. +package module + +import ( + "strconv" + + "github.com/szkiba/xk6-faker/faker" + "go.k6.io/k6/js/modules" +) + +// rootModule is k6 JavaScript module. +type rootModule struct{} + +// ImportPath contains module's JavaScript import path. +const ImportPath = "k6/x/faker" + +// New creates new root module. +func New() modules.Module { + return &rootModule{} +} + +func getseed(vu modules.VU) int64 { + if vu == nil || vu.InitEnv() == nil || vu.InitEnv().LookupEnv == nil { + return 0 + } + + str, ok := vu.InitEnv().LookupEnv("XK6_FAKER_SEED") + if !ok { + return 0 + } + + val, err := strconv.ParseInt(str, 10, 64) + if err != nil { + return 0 + } + + return val +} + +// NewModuleInstance creates new module instance. +func (root *rootModule) NewModuleInstance(vu modules.VU) modules.Instance { + mod := &module{exports: modules.Exports{ + Named: make(map[string]interface{}), + Default: faker.New(getseed(vu), vu.Runtime()), + }} + + mod.exports.Named["Faker"] = faker.Constructor + + return mod +} + +// module is a k6 JavaScript module instance. +type module struct { + exports modules.Exports +} + +// Exports is representation of ESM exports of a module. +func (mod *module) Exports() modules.Exports { + return mod.exports +} + +var ( + _ modules.Module = (*rootModule)(nil) + _ modules.Instance = (*module)(nil) +) diff --git a/module/module_internal_test.go b/module/module_internal_test.go new file mode 100644 index 0000000..73d46ef --- /dev/null +++ b/module/module_internal_test.go @@ -0,0 +1,34 @@ +package module + +import ( + "testing" + + "github.com/stretchr/testify/require" + "go.k6.io/k6/js/modulestest" +) + +func Test_getseed(t *testing.T) { + t.Parallel() + + require.Equal(t, int64(0), getseed(nil)) + + vu := modulestest.NewRuntime(t).VU + + require.Equal(t, int64(0), getseed(vu)) + + vu.InitEnvField.RuntimeOptions.Env = map[string]string{} + vu.InitEnvField.LookupEnv = func(key string) (string, bool) { + val, ok := vu.InitEnvField.RuntimeOptions.Env[key] + return val, ok + } + + require.Equal(t, int64(0), getseed(vu)) + + vu.InitEnvField.RuntimeOptions.Env["XK6_FAKER_SEED"] = "foo" + + require.Equal(t, int64(0), getseed(vu)) + + vu.InitEnvField.RuntimeOptions.Env["XK6_FAKER_SEED"] = "42" + + require.Equal(t, int64(42), getseed(vu)) +} diff --git a/module/module_test.go b/module/module_test.go new file mode 100644 index 0000000..434bf01 --- /dev/null +++ b/module/module_test.go @@ -0,0 +1,50 @@ +package module_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/szkiba/xk6-faker/module" + "go.k6.io/k6/js/modulestest" +) + +func Test_Default_Faker(t *testing.T) { + t.Parallel() + + runtime := modulestest.NewRuntime(t) + runtime.VU.InitEnvField.RuntimeOptions.Env = map[string]string{"XK6_FAKER_SEED": "11"} + + runtime.VU.InitEnvField.LookupEnv = func(key string) (string, bool) { + val, ok := runtime.VU.InitEnvField.RuntimeOptions.Env[key] + return val, ok + } + + err := runtime.SetupModuleSystem(map[string]any{module.ImportPath: module.New()}, nil, nil) + + require.NoError(t, err) + + val, err := runtime.RunOnEventLoop(` + let faker = require("` + module.ImportPath + `") + faker.default.call("username") + `) + + require.NoError(t, err) + require.Equal(t, "Abshire5538", val.String()) +} + +func Test_New_Faker(t *testing.T) { + t.Parallel() + + runtime := modulestest.NewRuntime(t) + err := runtime.SetupModuleSystem(map[string]any{module.ImportPath: module.New()}, nil, nil) + + require.NoError(t, err) + + val, err := runtime.RunOnEventLoop(` + let faker = require("` + module.ImportPath + `") + new faker.Faker(11).call("username") + `) + + require.NoError(t, err) + require.Equal(t, "Abshire5538", val.String()) +} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 49fa2b1..0000000 --- a/package-lock.json +++ /dev/null @@ -1,812 +0,0 @@ -{ - "name": "xk6-crypto", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "license": "MIT", - "devDependencies": { - "typedoc": "^0.20.36", - "typedoc-plugin-markdown": "^3.8.0" - } - }, - "node_modules/at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true, - "engines": { - "node": ">=0.1.90" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "node_modules/glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true - }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", - "dev": true, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-core-module": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", - "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", - "dev": true, - "dependencies": { - "has": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/lunr": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", - "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", - "dev": true - }, - "node_modules/marked": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/marked/-/marked-2.0.3.tgz", - "integrity": "sha512-5otztIIcJfPc2qGTN8cVtOJEjNJZ0jwa46INMagrYfk0EvqtRuEHLsEe0LrFS0/q+ZRKT0+kXK7P2T1AN5lWRA==", - "dev": true, - "bin": { - "marked": "bin/marked" - }, - "engines": { - "node": ">= 8.16.2" - } - }, - "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/onigasm": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/onigasm/-/onigasm-2.2.5.tgz", - "integrity": "sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==", - "dev": true, - "dependencies": { - "lru-cache": "^5.1.1" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "dependencies": { - "resolve": "^1.1.6" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", - "dev": true, - "dependencies": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/shelljs": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", - "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", - "dev": true, - "dependencies": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - }, - "bin": { - "shjs": "bin/shjs" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/shiki": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.3.tgz", - "integrity": "sha512-NEjg1mVbAUrzRv2eIcUt3TG7X9svX7l3n3F5/3OdFq+/BxUdmBOeKGiH4icZJBLHy354Shnj6sfBTemea2e7XA==", - "dev": true, - "dependencies": { - "onigasm": "^2.2.5", - "vscode-textmate": "^5.2.0" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/typedoc": { - "version": "0.20.36", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.36.tgz", - "integrity": "sha512-qFU+DWMV/hifQ9ZAlTjdFO9wbUIHuUBpNXzv68ZyURAP9pInjZiO4+jCPeAzHVcaBCHER9WL/+YzzTt6ZlN/Nw==", - "dev": true, - "dependencies": { - "colors": "^1.4.0", - "fs-extra": "^9.1.0", - "handlebars": "^4.7.7", - "lodash": "^4.17.21", - "lunr": "^2.3.9", - "marked": "^2.0.3", - "minimatch": "^3.0.0", - "progress": "^2.0.3", - "shelljs": "^0.8.4", - "shiki": "^0.9.3", - "typedoc-default-themes": "^0.12.10" - }, - "bin": { - "typedoc": "bin/typedoc" - }, - "engines": { - "node": ">= 10.8.0" - }, - "peerDependencies": { - "typescript": "3.9.x || 4.0.x || 4.1.x || 4.2.x" - } - }, - "node_modules/typedoc-default-themes": { - "version": "0.12.10", - "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz", - "integrity": "sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/typedoc-plugin-markdown": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.8.0.tgz", - "integrity": "sha512-TVyz7hnVa7MpFQ26U4kCmsCoExtVi9OHD70Tijo9d3G0qGDxRWw3X9EomPThi54CLszLEj/MNSRsVbylNc9EEQ==", - "dev": true, - "dependencies": { - "handlebars": "^4.7.7" - }, - "engines": { - "node": ">= 10.8.0" - }, - "peerDependencies": { - "typedoc": ">=0.20.0" - } - }, - "node_modules/typescript": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", - "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", - "dev": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/uglify-js": { - "version": "3.13.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.5.tgz", - "integrity": "sha512-xtB8yEqIkn7zmOyS2zUNBsYCBRhDkvlNxMMY2smuJ/qA8NCHeQvKCF3i9Z4k8FJH4+PJvZRtMrPynfZ75+CSZw==", - "dev": true, - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/vscode-textmate": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.4.0.tgz", - "integrity": "sha512-c0Q4zYZkcLizeYJ3hNyaVUM2AA8KDhNCA3JvXY8CeZSJuBdAy3bAvSbv46RClC4P3dSO9BdwhnKEx2zOo6vP/w==", - "dev": true - }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true - } - }, - "dependencies": { - "at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "requires": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true - }, - "handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "requires": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4", - "wordwrap": "^1.0.0" - } - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", - "dev": true - }, - "is-core-module": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", - "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "requires": { - "yallist": "^3.0.2" - } - }, - "lunr": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", - "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", - "dev": true - }, - "marked": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/marked/-/marked-2.0.3.tgz", - "integrity": "sha512-5otztIIcJfPc2qGTN8cVtOJEjNJZ0jwa46INMagrYfk0EvqtRuEHLsEe0LrFS0/q+ZRKT0+kXK7P2T1AN5lWRA==", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "onigasm": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/onigasm/-/onigasm-2.2.5.tgz", - "integrity": "sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==", - "dev": true, - "requires": { - "lru-cache": "^5.1.1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "^1.1.6" - } - }, - "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", - "dev": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - }, - "shelljs": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", - "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", - "dev": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - } - }, - "shiki": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.3.tgz", - "integrity": "sha512-NEjg1mVbAUrzRv2eIcUt3TG7X9svX7l3n3F5/3OdFq+/BxUdmBOeKGiH4icZJBLHy354Shnj6sfBTemea2e7XA==", - "dev": true, - "requires": { - "onigasm": "^2.2.5", - "vscode-textmate": "^5.2.0" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "typedoc": { - "version": "0.20.36", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.36.tgz", - "integrity": "sha512-qFU+DWMV/hifQ9ZAlTjdFO9wbUIHuUBpNXzv68ZyURAP9pInjZiO4+jCPeAzHVcaBCHER9WL/+YzzTt6ZlN/Nw==", - "dev": true, - "requires": { - "colors": "^1.4.0", - "fs-extra": "^9.1.0", - "handlebars": "^4.7.7", - "lodash": "^4.17.21", - "lunr": "^2.3.9", - "marked": "^2.0.3", - "minimatch": "^3.0.0", - "progress": "^2.0.3", - "shelljs": "^0.8.4", - "shiki": "^0.9.3", - "typedoc-default-themes": "^0.12.10" - } - }, - "typedoc-default-themes": { - "version": "0.12.10", - "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz", - "integrity": "sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==", - "dev": true - }, - "typedoc-plugin-markdown": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.8.0.tgz", - "integrity": "sha512-TVyz7hnVa7MpFQ26U4kCmsCoExtVi9OHD70Tijo9d3G0qGDxRWw3X9EomPThi54CLszLEj/MNSRsVbylNc9EEQ==", - "dev": true, - "requires": { - "handlebars": "^4.7.7" - } - }, - "typescript": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", - "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", - "dev": true, - "peer": true - }, - "uglify-js": { - "version": "3.13.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.5.tgz", - "integrity": "sha512-xtB8yEqIkn7zmOyS2zUNBsYCBRhDkvlNxMMY2smuJ/qA8NCHeQvKCF3i9Z4k8FJH4+PJvZRtMrPynfZ75+CSZw==", - "dev": true, - "optional": true - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - }, - "vscode-textmate": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.4.0.tgz", - "integrity": "sha512-c0Q4zYZkcLizeYJ3hNyaVUM2AA8KDhNCA3JvXY8CeZSJuBdAy3bAvSbv46RClC4P3dSO9BdwhnKEx2zOo6vP/w==", - "dev": true - }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 56ccb8f..0000000 --- a/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "xk6-faker", - "license": "MIT", - "devDependencies": { - "typedoc": "^0.20.36", - "typedoc-plugin-markdown": "^3.8.0" - } -} diff --git a/register.go b/register.go new file mode 100644 index 0000000..60a72bb --- /dev/null +++ b/register.go @@ -0,0 +1,16 @@ +// Package faker is a xk6-faker extension module. +package faker + +import ( + "github.com/szkiba/xk6-faker/module" + + "go.k6.io/k6/js/modules" +) + +func register() { + modules.Register(module.ImportPath, module.New()) +} + +func init() { //nolint:gochecknoinits + register() +} diff --git a/register_internal_test.go b/register_internal_test.go new file mode 100644 index 0000000..8659e42 --- /dev/null +++ b/register_internal_test.go @@ -0,0 +1,15 @@ +package faker + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_register(t *testing.T) { + t.Parallel() + + require.Panics(t, func() { + register() + }) +} diff --git a/script.js b/script.js new file mode 100644 index 0000000..e16450a --- /dev/null +++ b/script.js @@ -0,0 +1,7 @@ +import faker from "k6/x/faker"; + +console.log(faker.fake("{username}")); + +export default function () { + console.log(faker.fake("{username}")); +} diff --git a/test/expect.js b/test/expect.js deleted file mode 100644 index cc0269f..0000000 --- a/test/expect.js +++ /dev/null @@ -1,258 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2021 Iván Szkiba - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// modified version https://jslib.k6.io/expect/0.0.5/index.js - -import { check, group } from "k6"; -import { Rate } from "k6/metrics"; - -export let errors = new Rate("errors"); -export let options = { thresholds: { errors: ["rate==0"] } }; - -export class FunkBrokenChainException extends Error { - constructor(message) { - super(message); - this.brokenChain = true; - this.name = this.constructor.name; - if (typeof Error.captureStackTrace === "function") { - Error.captureStackTrace(this, this.constructor); - } else { - this.stack = new Error(message).stack; - } - } -} - -class Funk { - constructor() { - this.leftHandValue = null; // resp.status - this.leftHandValueName = null; // "my status" - this.rightHandValue = null; // 200 - this.chainBroken = false; - this.printedBrokenChainWarning = false; // print only one warning. - } - - as(name) { - this.leftHandValueName = name; - return this; - } - - _brokenChainCheck() { - if (this.chainBroken) { - if (!this.printedBrokenChainWarning) { - console.warn("This check has been aborted because the previous check in the chain has failed"); - this.printedBrokenChainWarning = true; - } - return true; - } - return false; - } - - _recordCheck(checkName, isSuccessful, value) { - if (value !== undefined) { - check( - null, - { - [checkName]: isSuccessful, - }, - { - value: value, - } - ); - } else { - check(null, { - [checkName]: isSuccessful, - }); - } - } - - _breakTheChain() { - this.chainBroken = true; - throw new FunkBrokenChainException("Chain broke, skipping this check"); - } - - toEqual(rhv) { - if (this._brokenChainCheck()) return this; - this.rightHandValue = rhv; - - let checkName = `${this.leftHandValue} is ${this.rightHandValue}`; - - let checkIsSuccessful = this.leftHandValue === this.rightHandValue; - - if (this.leftHandValueName) { - checkName = `${this.leftHandValueName} is ${this.leftHandValue}.`; - - if (!checkIsSuccessful) { - checkName += ` Expected '${this.rightHandValue}'`; - } - } - - this._recordCheck(checkName, checkIsSuccessful, this.rightHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - - toBeGreaterThan(rhv) { - if (this._brokenChainCheck()) return this; - - this.rightHandValue = rhv; - - let checkName = `${this.leftHandValueName || this.leftHandValue} is greater than ${this.rightHandValue}`; - - let checkIsSuccessful = this.leftHandValue > this.rightHandValue; - - this._recordCheck(checkName, checkIsSuccessful, this.leftHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - - toBeGreaterThanOrEqual(rhv) { - if (this._brokenChainCheck()) return this; - - this.rightHandValue = rhv; - - let checkName = `${this.leftHandValueName || this.leftHandValue} is greater or equal to ${this.rightHandValue}`; - - let checkIsSuccessful = this.leftHandValue >= this.rightHandValue; - - this._recordCheck(checkName, checkIsSuccessful, this.leftHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - toBeLessThan(rhv) { - if (this._brokenChainCheck()) return this; - - this.rightHandValue = rhv; - - let checkName = `${this.leftHandValueName || this.leftHandValue} is less than ${this.rightHandValue}`; - - let checkIsSuccessful = this.leftHandValue < this.rightHandValue; - - this._recordCheck(checkName, checkIsSuccessful, this.leftHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - toBeLessThanOrEqual(rhv) { - if (this._brokenChainCheck()) return this; - - this.rightHandValue = rhv; - - let checkName = `${this.leftHandValueName || this.leftHandValue} is less or equal to ${this.rightHandValue}`; - - let checkIsSuccessful = this.leftHandValue <= this.rightHandValue; - - this._recordCheck(checkName, checkIsSuccessful, this.leftHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - - toBeTruthy() { - if (this._brokenChainCheck()) return this; - - let checkName = `${this.leftHandValueName || this.leftHandValue} is truthy.`; - - let checkIsSuccessful = this.leftHandValue ? true : false; - - this._recordCheck(checkName, checkIsSuccessful, this.leftHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - - toBeBetween(from, to) { - if (this._brokenChainCheck()) return this; - - this.rightHandValue = `${from} - ${to}`; - - let checkName = `${this.leftHandValueName || this.leftHandValue} is between ${this.rightHandValue}`; - - let checkIsSuccessful = this.leftHandValue >= from && this.leftHandValue <= to; - - this._recordCheck(checkName, checkIsSuccessful, this.leftHandValue); - - if (!checkIsSuccessful) this._breakTheChain(); - - return this; - } - - and(lhv) { - // same as expect() but chained. - if (this._brokenChainCheck()) return this; - this.leftHandValue = lhv; - this.leftHandValueName = null; // clearing the previous .as() - return this; - } -} - -let expect = function (value1) { - let state = new Funk(); - state.leftHandValue = value1; - return state; -}; - -function handleUnexpectedException(e, testName) { - console.error(`Exception raised in test "${testName}". Failing the test and continuing. \n${e}`); - - check(null, { - [`Exception raised "${e}"`]: false, - }); -} - -let describe = function (testName, callback) { - let t = { - expect, - }; - - let success = true; - - group(testName, () => { - try { - callback(t); - success = true; - } catch (e) { - if (e.brokenChain) { - success = false; - } else { - success = false; - handleUnexpectedException(e, testName); - } - } - }); - - errors.add(!success); - - return success; -}; - -export { describe }; diff --git a/test/faker.test.js b/test/faker.test.js deleted file mode 100644 index 2db7066..0000000 --- a/test/faker.test.js +++ /dev/null @@ -1,276 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2021 Iván Szkiba - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -export { options } from "./expect.js"; -import { describe } from "./expect.js"; -import faker, { Faker } from "k6/x/faker"; - -const functions = [ - "emoji", - "emojiAlias", - "emojiCategory", - "hackerPhrase", - "ipv4Address", - "lastName", - "carTransmissionType", - "hipsterParagraph", - "httpStatusCodeSimple", - "int8", - "address", - "adjective", - "adverb", - "animalType", - "chromeUserAgent", - "float32Range", - "phoneFormatted", - "vegetable", - "uint32", - "bool", - "car", - "contact", - "firefoxUserAgent", - "password", - "safeColor", - "beerMalt", - "emojiDescription", - "float64Range", - "logLevel", - "street", - "carType", - "city", - "currencyShort", - "hipsterSentence", - "jobTitle", - "map", - "randomUint", - "url", - "animal", - "countryAbr", - "creditCardExp", - "creditCardNumber", - "jobLevel", - "noun", - "hackeringVerb", - "hour", - "monthString", - "price", - "achRouting", - "company", - "currencyLong", - "domainSuffix", - "farmAnimal", - "language", - "quote", - "streetSuffix", - "imageURL", - "shuffleInts", - "randomInt", - "shuffleAnySlice", - "creditCard", - "httpMethod", - "letter", - "number", - "operaUserAgent", - "paragraph", - "timeZone", - "domainName", - "hackerVerb", - "rgbColor", - "slice", - "beerHop", - "beerStyle", - "bitcoinAddress", - "buzzWord", - "float32", - "month", - "uUID", - "userAgent", - "sentence", - "uint64", - "country", - "email", - "flipACoin", - "longitudeInRange", - "macAddress", - "numerify", - "teams", - "dog", - "hackerNoun", - "int16", - "question", - "randomString", - "streetPrefix", - "beerAlcohol", - "latitude", - "preposition", - "zip", - "hackerAbbreviation", - "ipv6Address", - "programmingLanguage", - "word", - "companySuffix", - "dateRange", - "digit", - "imagePng", - "nameSuffix", - "languageAbbreviation", - "namePrefix", - "appName", - "beerBlg", - "carMaker", - "currency", - "hackerAdjective", - "job", - "streetName", - "breakfast", - "day", - "fruit", - "letterN", - "petName", - "carModel", - "gamertag", - "lunch", - "weekDay", - "bs", - "bitcoinPrivateKey", - "firstName", - "image", - "loremIpsumSentence", - "person", - "username", - "carFuelType", - "emojiTag", - "fileExtension", - "int64", - "name", - "sSN", - "struct", - "beerYeast", - "hexColor", - "json", - "minute", - "regex", - "shuffleStrings", - "timeZoneRegion", - "verb", - "achAccount", - "creditCardCvv", - "float64", - "hipsterWord", - "imageJpeg", - "state", - "faker", - "creditCardType", - "jobDescriptor", - "latitudeInRange", - "uint16", - "weighted", - "second", - "timeZoneAbv", - "appAuthor", - "cat", - "digitN", - "fileMimeType", - "gender", - "loremIpsumWord", - "uint8", - "beerIbu", - "generate", - "lexify", - "programmingLanguageBest", - "streetNumber", - "phone", - "timeZoneOffset", - "appVersion", - "beerName", - "date", - "dessert", - "httpStatusCode", - "int32", - "year", - "dinner", - "longitude", - "nanoSecond", - "phrase", - "stateAbr", - "timeZoneFull", - "color", - "loremIpsumParagraph", - "safariUserAgent", - "snack", -]; - -export default function () { - describe("Faker constructor", (t) => { - const f = new Faker(); - t.expect(f.name()).as("name").toBeTruthy(); - }); - - describe("Seed parameter", (t) => { - t.expect(new Faker().name() != new Faker().name()) - .as("random") - .toBeTruthy(); - - t.expect(new Faker(42).name() == new Faker(42).name()) - .as("fixed") - .toBeTruthy(); - }); - - describe("Function name mapping", (t) => { - for (const f of functions) { - t.expect(f in faker) - .as(`has ${f}()`) - .toBeTruthy(); - } - }); - - describe("generate", (t) => { - const f1 = new Faker(42); - const f2 = new Faker(42); - const result = `${f1.name()}`; - t.expect(f2.generate("{name}")).as(`{name}`).toEqual(result); - t.expect(f2.generate("##")) - .as(`##`) - .toEqual(`${f1.digitN(2)}`); - t.expect(f2.generate("??")) - .as(`??`) - .toEqual(`${f1.letterN(2)}`); - }); - - describe("numerify", (t) => { - const f1 = new Faker(42); - const f2 = new Faker(42); - t.expect(f2.numerify("##")) - .as(`##`) - .toEqual(`${f1.digitN(2)}`); - }); - - describe("lexify", (t) => { - const f1 = new Faker(42); - const f2 = new Faker(42); - t.expect(f2.lexify("??")) - .as(`??`) - .toEqual(`${f1.letterN(2)}`); - }); -} diff --git a/test/testdata/sample.csv b/test/testdata/sample.csv deleted file mode 100644 index b38840d..0000000 --- a/test/testdata/sample.csv +++ /dev/null @@ -1,6 +0,0 @@ -Year,Make,Model,Description,Price -1997,Ford,E350,"ac, abs, moon",3000.00 -1999,Chevy,"Venture ""Extended Edition""","",4900.00 -1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00 -1996,Jeep,Grand Cherokee,"MUST SELL! -air, moon roof, loaded",4799.00 diff --git a/tools/codegen/genjson.go b/tools/codegen/genjson.go new file mode 100644 index 0000000..9e2b9c8 --- /dev/null +++ b/tools/codegen/genjson.go @@ -0,0 +1,16 @@ +//go:build codegen + +package main + +import ( + "encoding/json" + "io" +) + +func jsonGen(out io.Writer) error { + encoder := json.NewEncoder(out) + + encoder.SetIndent("", " ") + + return encoder.Encode(getFuncLookups()) +} diff --git a/tools/codegen/gentest.go b/tools/codegen/gentest.go new file mode 100644 index 0000000..fb18032 --- /dev/null +++ b/tools/codegen/gentest.go @@ -0,0 +1,9 @@ +//go:build codegen + +package main + +import "io" + +func goTest(out io.Writer) error { + return nil +} diff --git a/tools/codegen/gents.go b/tools/codegen/gents.go new file mode 100644 index 0000000..d33b326 --- /dev/null +++ b/tools/codegen/gents.go @@ -0,0 +1,9 @@ +//go:build codegen + +package main + +import "io" + +func tsGen(out io.Writer) error { + return nil +} diff --git a/tools/codegen/lookup.go b/tools/codegen/lookup.go new file mode 100644 index 0000000..55cd40c --- /dev/null +++ b/tools/codegen/lookup.go @@ -0,0 +1,82 @@ +//go:build codegen + +package main + +import ( + "strings" + + "github.com/szkiba/xk6-faker/faker" + + "github.com/brianvoe/gofakeit/v6" +) + +func typemap(src string) string { + var array bool + if array = strings.HasPrefix(src, "[]"); array { + src = src[2:] + } + + switch src { + case "string": + case "bool": + src = "boolean" + case "float", "float32", "float64": + fallthrough + case "byte", "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64": + src = "number" + case "map[string]any": + src = "Record" + case "map[string]string": + src = "Record" + case "any": + src = "unknown" + case "map[string][]string": + src = "Record>" + default: + return "" + } + + if array { + src += "[]" + } + + return src +} + +func convertLookup(src *gofakeit.Info) (*gofakeit.Info, bool) { + output := typemap(src.Output) + if len(output) == 0 { + return src, false + } + + info := *src + + info.Output = output + + if len(src.Params) == 0 { + return &info, true + } + + info.Params = make([]gofakeit.Param, len(src.Params)) + + for idx, from := range src.Params { + param := from + param.Type = typemap(param.Type) + + info.Params[idx] = param + } + + return &info, true +} + +func getFuncLookups() map[string]*gofakeit.Info { + all := map[string]*gofakeit.Info{} + + for key, value := range faker.GetFuncLookups() { + if info, ok := convertLookup(value); ok { + all[key] = info + } + } + + return all +} diff --git a/tools/codegen/main.go b/tools/codegen/main.go new file mode 100644 index 0000000..2d21675 --- /dev/null +++ b/tools/codegen/main.go @@ -0,0 +1,59 @@ +//go:build codegen + +// Package main contains codegen tool. +package main + +import ( + "bytes" + "log" + "os" +) + +func usage() { + log.Fatal("error: usage: codegen {json|ts|test} filename") +} + +//nolint:forbidigo +func main() { + if len(os.Args) != 3 { + usage() + } + + command := os.Args[1] + + var ( + buff bytes.Buffer + err error + file *os.File + ) + + switch command { + case "test": + err = goTest(&buff) + case "ts": + err = tsGen(&buff) + case "json": + err = jsonGen(&buff) + default: + usage() + } + + if err != nil { + log.Fatalf("error: %s", err.Error()) + } + + file, err = os.Create(os.Args[2]) + if err != nil { + log.Fatal(err) + } + + _, err = file.Write(buff.Bytes()) + if err != nil { + log.Fatal(err) + } + + err = file.Close() + if err != nil { + log.Fatal(err) + } +} diff --git a/tsconfig.json b/tsconfig.json index 9817f06..5ad16e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,20 @@ { - "compilerOptions": { - "target": "es2015", - "module": "commonjs", - "rootDir": ".", - "strict": true - }, - "exclude": ["node_modules"] + "typedocOptions": { + "entryPoints": ["./index.d.ts"], + "out": "build/docs", + "name": "xk6-faker", + "readme": "none", + "hideGenerator": true, + "disableSources": true, + "navigation": { + "includeCategories": false, + "includeGroups": false, + "includeFolders": false + }, + "categorizeByGroup": false, + "visibilityFilters": {}, + "navigationLinks": { + "GitHub": "https://github.com/szkiba/xk6-faker" + } + } } diff --git a/typedoc.json b/typedoc.json deleted file mode 100644 index d8fcfe0..0000000 --- a/typedoc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "theme": "markdown", - "hideBreadcrumbs": true, - "disableSources": true, - "entryPoints": ["index.d.ts"], - "plugin": ["typedoc-plugin-markdown"], - "readme": "none" -}