{"id":29195345,"url":"https://github.com/sullay/proto-mock","last_synced_at":"2025-07-02T05:03:14.351Z","repository":{"id":153245879,"uuid":"628486829","full_name":"sullay/proto-mock","owner":"sullay","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-12T02:14:28.000Z","size":63,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-27T09:35:29.455Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sullay.png","metadata":{"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-04-16T05:02:33.000Z","updated_at":"2023-11-06T05:24:45.000Z","dependencies_parsed_at":"2024-04-12T03:25:08.044Z","dependency_job_id":"62cb5d05-e5ce-4d61-9f7f-0947ff60ef50","html_url":"https://github.com/sullay/proto-mock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sullay/proto-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sullay%2Fproto-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sullay%2Fproto-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sullay%2Fproto-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sullay%2Fproto-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sullay","download_url":"https://codeload.github.com/sullay/proto-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sullay%2Fproto-mock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262361881,"owners_count":23299103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-02T05:03:13.274Z","updated_at":"2025-07-02T05:03:14.329Z","avatar_url":"https://github.com/sullay.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proto-mock\n\n`proto-mock` is a Node.js library that generates random data for given Protobuf message types.\n\n## Installation\n\n```bash\nnpm install proto-mock\n```\n\n## Usage\n\n```typescript\nimport { generateMockData } from 'proto-mock';\n\nconst mockData = await generateMockData('path/to/proto/file.proto', 'MyMessageType');\nconsole.log(mockData);\n```\n\n### `generateMockData(protoFilePath: string, messageType: string, options?: GenerateMockDataOptions): Promise\u003cany\u003e`\n\n*   `protoFilePath` - Required. The path to the Protobuf file.\n*   `messageType` - Required. The name of the message type.\n*   `options` - Optional. The settings for generating random data.\n*   `keyValueRange` - Optional parameter that specifies the value range for specific fields. Default is {} (empty object).\n\nReturn value: A Promise that asynchronously returns the generated random data.\n\n### `GenerateMockDataOptions`\n\n*   `maxRepeatedLength` - Optional. Specifies the maximum length of generated arrays. Defaults to 3.\n*   `maxMapEntries` - Optional. Specifies the maximum number of entries in generated maps. Defaults to 3.\n*   `keepCase` - Optional. Specifies whether to preserve the case of field names. Defaults to false (camel case).\n\n## Example\n\nSuppose there is a `person.proto` file defining a `Person` message type:\n\n```protobuf\nsyntax = \"proto3\";\n\npackage example;\n\nmessage Person {\n  string name = 1;\n  int32 age = 2;\n  repeated string email = 3;\n}\n```\n\nUsing `proto-mock`, random data can be generated for the `Person` type:\n\n```typescript\nimport { generateMockData } from 'proto-mock';\n\nconst mockData = await generateMockData('path/to/person.proto', 'Person');\nconsole.log(mockData);\n// Outputs randomly generated data similar to:\n// {\n//   name: 'Lola Hudson',\n//   age: -12713,\n//   email: [ 'calvinkoch@example.com', 'jakefernandez@example.com' ]\n// }\n```\n\nBy using keyValueRange, you can control the value range of specific fields to ensure that the generated random data meets your expectations.\n\n```typescript\nimport { generateMockData } from 'proto-mock';\n\nconst options = {\n  keyValueRange: {\n    name: ['Alice', 'Bob'],\n    age: [18, 21, 30]\n  }\n};\n\nconst mockData = await generateMockData('path/to/person.proto', 'Person', options);\nconsole.log(mockData);\n// Outputs random data similar to the following:\n// {\n//   name: 'Alice',\n//   age: 21,\n//   email: [ 'calvinkoch@example.com', 'jakefernandez@example.com' ]\n// }\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsullay%2Fproto-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsullay%2Fproto-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsullay%2Fproto-mock/lists"}