@singh-ankush/autodata 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ankush Kumar Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # AutoData
2
+
3
+ AI-powered test data generator for automation testing.
4
+
5
+ AutoData generates realistic test data as **plain strings** using OpenAI or OpenRouter,
6
+ designed for Playwright, Cypress, Selenium, Jest, and backend tests.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @<your-github-username>/autodata
12
+
13
+
14
+ > Usage
15
+ ```js
16
+ import { AutoData } from "@<your-github-username>/autodata";
17
+
18
+ const name = await AutoData.getData(
19
+ "An Indian name with format {Firstname_Lastname}"
20
+ );
21
+
22
+ const email = await AutoData.presets.email();
23
+ ```
@@ -0,0 +1,5 @@
1
+ import * as Presets from "./presets";
2
+ export declare class AutoData {
3
+ static getData(prompt: string): Promise<string>;
4
+ static presets: typeof Presets;
5
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AutoData = void 0;
40
+ const dotenv_1 = __importDefault(require("dotenv"));
41
+ const openaiClient_1 = require("./clients/openaiClient");
42
+ const openrouterClient_1 = require("./clients/openrouterClient");
43
+ const Presets = __importStar(require("./presets"));
44
+ dotenv_1.default.config();
45
+ class AutoData {
46
+ static async getData(prompt) {
47
+ if (!prompt || prompt.trim().length === 0) {
48
+ throw new Error("Prompt cannot be empty");
49
+ }
50
+ const provider = process.env.AUTODATA_PROVIDER ||
51
+ (process.env.OPENAI_API_KEY ? "openai" : "openrouter");
52
+ if (provider === "openai") {
53
+ if (!process.env.OPENAI_API_KEY) {
54
+ throw new Error("OPENAI_API_KEY not found");
55
+ }
56
+ return (0, openaiClient_1.generateWithOpenAI)(prompt);
57
+ }
58
+ if (provider === "openrouter") {
59
+ if (!process.env.OPENROUTER_API_KEY) {
60
+ throw new Error("OPENROUTER_API_KEY not found");
61
+ }
62
+ return (0, openrouterClient_1.generateWithOpenRouter)(prompt);
63
+ }
64
+ throw new Error("Invalid AUTODATA_PROVIDER");
65
+ }
66
+ }
67
+ exports.AutoData = AutoData;
68
+ // Expose presets
69
+ AutoData.presets = Presets;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate a completion using the OpenAI provider.
3
+ * The OpenAI client is instantiated inside the function so that the
4
+ * environment variables (loaded via dotenv) are available at runtime.
5
+ */
6
+ export declare function generateWithOpenAI(prompt: string): Promise<string>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateWithOpenAI = generateWithOpenAI;
7
+ const openai_1 = __importDefault(require("openai"));
8
+ // Default model can be overridden via environment variable
9
+ const model = process.env.OPENAI_MODEL || "gpt-4o-mini";
10
+ /**
11
+ * Generate a completion using the OpenAI provider.
12
+ * The OpenAI client is instantiated inside the function so that the
13
+ * environment variables (loaded via dotenv) are available at runtime.
14
+ */
15
+ async function generateWithOpenAI(prompt) {
16
+ // Ensure the API key is present; this mirrors the check in AutoData.ts
17
+ const apiKey = process.env.OPENAI_API_KEY;
18
+ if (!apiKey) {
19
+ throw new Error("OPENAI_API_KEY not found");
20
+ }
21
+ const client = new openai_1.default({ apiKey });
22
+ const response = await client.chat.completions.create({
23
+ model,
24
+ messages: [
25
+ {
26
+ role: "system",
27
+ content: "You generate realistic random test data. Output ONLY a single string. No explanations.",
28
+ },
29
+ { role: "user", content: prompt },
30
+ ],
31
+ temperature: 0.9,
32
+ });
33
+ return response.choices[0].message.content?.trim() ?? "";
34
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate a completion using the OpenRouter provider.
3
+ * The OpenAI client (compatible with OpenRouter) is instantiated lazily
4
+ * after environment variables have been loaded by dotenv.
5
+ */
6
+ export declare function generateWithOpenRouter(prompt: string): Promise<string>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateWithOpenRouter = generateWithOpenRouter;
7
+ const openai_1 = __importDefault(require("openai"));
8
+ // Default model can be overridden via environment variable
9
+ const model = process.env.OPENROUTER_MODEL || "openrouter/auto";
10
+ /**
11
+ * Generate a completion using the OpenRouter provider.
12
+ * The OpenAI client (compatible with OpenRouter) is instantiated lazily
13
+ * after environment variables have been loaded by dotenv.
14
+ */
15
+ async function generateWithOpenRouter(prompt) {
16
+ const apiKey = process.env.OPENROUTER_API_KEY;
17
+ if (!apiKey) {
18
+ throw new Error("OPENROUTER_API_KEY not found");
19
+ }
20
+ const client = new openai_1.default({
21
+ apiKey,
22
+ baseURL: "https://openrouter.ai/api/v1",
23
+ defaultHeaders: {
24
+ "HTTP-Referer": "https://github.com/singh-ankush/autodata",
25
+ "X-Title": "AutoData",
26
+ },
27
+ });
28
+ const response = await client.chat.completions.create({
29
+ model,
30
+ messages: [
31
+ {
32
+ role: "system",
33
+ content: "You generate realistic random test data. Output ONLY a single string. No explanations.",
34
+ },
35
+ { role: "user", content: prompt },
36
+ ],
37
+ temperature: 0.9,
38
+ });
39
+ return response.choices[0].message.content?.trim() ?? "";
40
+ }
@@ -0,0 +1 @@
1
+ export { AutoData } from "./AutoData";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoData = void 0;
4
+ var AutoData_1 = require("./AutoData");
5
+ Object.defineProperty(exports, "AutoData", { enumerable: true, get: function () { return AutoData_1.AutoData; } });
@@ -0,0 +1,5 @@
1
+ export declare function indianName(): Promise<string>;
2
+ export declare function email(): Promise<string>;
3
+ export declare function phoneIN(): Promise<string>;
4
+ export declare function addressIN(): Promise<string>;
5
+ export declare function companyName(): Promise<string>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.indianName = indianName;
4
+ exports.email = email;
5
+ exports.phoneIN = phoneIN;
6
+ exports.addressIN = addressIN;
7
+ exports.companyName = companyName;
8
+ const AutoData_1 = require("./AutoData");
9
+ async function indianName() {
10
+ return AutoData_1.AutoData.getData("An Indian full name in format {Firstname_Lastname}");
11
+ }
12
+ async function email() {
13
+ return AutoData_1.AutoData.getData("A realistic email address");
14
+ }
15
+ async function phoneIN() {
16
+ return AutoData_1.AutoData.getData("A valid Indian mobile number");
17
+ }
18
+ async function addressIN() {
19
+ return AutoData_1.AutoData.getData("A realistic Indian residential address");
20
+ }
21
+ async function companyName() {
22
+ return AutoData_1.AutoData.getData("A realistic company name");
23
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@singh-ankush/autodata",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "description": "AI-powered test data generator for automation testing",
6
+ "types": "dist/index.ts",
7
+ "module": "dist/index.esm.js",
8
+ "path" : "dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/singh-ankush/AutoData.git"
21
+ },
22
+ "keywords": ["automation", "testing", "faker", "openai" , "test data", "ai"],
23
+ "author": "Ankush Singh",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "dotenv": "^17.2.3",
27
+ "openai": "^6.15.0"
28
+ },
29
+ "devDependencies": {
30
+ "typescript": "^5.9.3"
31
+ }
32
+ }