@atezca/core 1.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/README.md +47 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1566 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +1539 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +204 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.js +101 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +91 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
var AtezcaState = class {
|
|
5
|
+
config = null;
|
|
6
|
+
commands = [];
|
|
7
|
+
setConfig(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
getConfig() {
|
|
11
|
+
return this.config;
|
|
12
|
+
}
|
|
13
|
+
addCommand(command) {
|
|
14
|
+
this.commands.push(command);
|
|
15
|
+
}
|
|
16
|
+
getCommands() {
|
|
17
|
+
return [...this.commands];
|
|
18
|
+
}
|
|
19
|
+
clear() {
|
|
20
|
+
this.config = null;
|
|
21
|
+
this.commands = [];
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var ATEZCA_STATE_KEY = /* @__PURE__ */ Symbol.for("__ATEZCA_STATE__");
|
|
25
|
+
if (!globalThis[ATEZCA_STATE_KEY]) {
|
|
26
|
+
globalThis[ATEZCA_STATE_KEY] = new AtezcaState();
|
|
27
|
+
}
|
|
28
|
+
var state = globalThis[ATEZCA_STATE_KEY];
|
|
29
|
+
function setup(config) {
|
|
30
|
+
if (!config.url) {
|
|
31
|
+
throw new Error("az.setup() requires a url");
|
|
32
|
+
}
|
|
33
|
+
state.setConfig({
|
|
34
|
+
...config,
|
|
35
|
+
browser: config.browser ?? "chromium",
|
|
36
|
+
headless: config.headless ?? true,
|
|
37
|
+
timeout: config.timeout ?? 3e4,
|
|
38
|
+
outputDir: config.outputDir ?? "generated-tests",
|
|
39
|
+
cacheEnabled: config.cacheEnabled ?? true,
|
|
40
|
+
retries: config.retries ?? 3,
|
|
41
|
+
aiProvider: config.aiProvider,
|
|
42
|
+
apiKey: config.apiKey,
|
|
43
|
+
disableSSL: config.disableSSL ?? false
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function test(actionType, description) {
|
|
47
|
+
if (!state.getConfig()) {
|
|
48
|
+
throw new Error("az.setup() must be called before az.test()");
|
|
49
|
+
}
|
|
50
|
+
if (!description || description.trim() === "") {
|
|
51
|
+
throw new Error("az.test() requires a description");
|
|
52
|
+
}
|
|
53
|
+
const validTypes = ["navigate", "interact", "wait", "expect"];
|
|
54
|
+
if (!validTypes.includes(actionType)) {
|
|
55
|
+
throw new Error(`Invalid action type: ${actionType}. Must be one of: ${validTypes.join(", ")}`);
|
|
56
|
+
}
|
|
57
|
+
state.addCommand({
|
|
58
|
+
actionType,
|
|
59
|
+
description: description.trim(),
|
|
60
|
+
timestamp: Date.now()
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function getState() {
|
|
64
|
+
return {
|
|
65
|
+
config: state.getConfig(),
|
|
66
|
+
commands: state.getCommands()
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function clearState() {
|
|
70
|
+
state.clear();
|
|
71
|
+
}
|
|
72
|
+
function wait(milliseconds) {
|
|
73
|
+
if (!state.getConfig()) {
|
|
74
|
+
throw new Error("az.setup() must be called before az.wait()");
|
|
75
|
+
}
|
|
76
|
+
if (typeof milliseconds !== "number" || milliseconds < 0) {
|
|
77
|
+
throw new Error("az.wait() requires a positive number of milliseconds");
|
|
78
|
+
}
|
|
79
|
+
state.addCommand({
|
|
80
|
+
actionType: "wait",
|
|
81
|
+
description: `wait ${milliseconds}ms`,
|
|
82
|
+
timestamp: Date.now()
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var az = {
|
|
86
|
+
setup,
|
|
87
|
+
test,
|
|
88
|
+
wait
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
exports.az = az;
|
|
92
|
+
exports.azSetup = setup;
|
|
93
|
+
exports.azTest = test;
|
|
94
|
+
exports.azWait = wait;
|
|
95
|
+
exports.clearState = clearState;
|
|
96
|
+
exports.getState = getState;
|
|
97
|
+
exports.setup = setup;
|
|
98
|
+
exports.test = test;
|
|
99
|
+
exports.wait = wait;
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAKA,IAAM,cAAN,MAAkB;AAAA,EACR,MAAA,GAA6B,IAAA;AAAA,EAC7B,WAA0B,EAAC;AAAA,EAEnC,UAAU,MAAA,EAA2B;AACnC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,SAAA,GAAgC;AAC9B,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EAEA,WAAW,OAAA,EAA4B;AACrC,IAAA,IAAA,CAAK,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,EAC5B;AAAA,EAEA,WAAA,GAA6B;AAC3B,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAQ,CAAA;AAAA,EAC1B;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,IAAA;AACd,IAAA,IAAA,CAAK,WAAW,EAAC;AAAA,EACnB;AACF,CAAA;AAGA,IAAM,gBAAA,mBAAmB,MAAA,CAAO,GAAA,CAAI,kBAAkB,CAAA;AACtD,IAAI,CAAE,UAAA,CAAmB,gBAAgB,CAAA,EAAG;AAC1C,EAAC,UAAA,CAAmB,gBAAgB,CAAA,GAAI,IAAI,WAAA,EAAY;AAC1D;AACA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;AAEA,EAAA,KAAA,CAAM,UAAA,CAAW;AAAA,IACf,UAAA;AAAA,IACA,WAAA,EAAa,YAAY,IAAA,EAAK;AAAA,IAC9B,SAAA,EAAW,KAAK,GAAA;AAAI,GACrB,CAAA;AACH;AAMO,SAAS,QAAA,GAAW;AACzB,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,MAAM,SAAA,EAAU;AAAA,IACxB,QAAA,EAAU,MAAM,WAAA;AAAY,GAC9B;AACF;AAMO,SAAS,UAAA,GAAa;AAC3B,EAAA,KAAA,CAAM,KAAA,EAAM;AACd;AAWO,SAAS,KAAK,YAAA,EAA4B;AAC/C,EAAA,IAAI,CAAC,KAAA,CAAM,SAAA,EAAU,EAAG;AACtB,IAAA,MAAM,IAAI,MAAM,4CAA4C,CAAA;AAAA,EAC9D;AAEA,EAAA,IAAI,OAAO,YAAA,KAAiB,QAAA,IAAY,YAAA,GAAe,CAAA,EAAG;AACxD,IAAA,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAAA,EACxE;AAEA,EAAA,KAAA,CAAM,UAAA,CAAW;AAAA,IACf,UAAA,EAAY,MAAA;AAAA,IACZ,WAAA,EAAa,QAAQ,YAAY,CAAA,EAAA,CAAA;AAAA,IACjC,SAAA,EAAW,KAAK,GAAA;AAAI,GACrB,CAAA;AACH;AAKO,IAAM,EAAA,GAAK;AAAA,EAChB,KAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import type { SetupConfig, TestCommand, ActionType } from './types/index.js';\n\n/**\n * Global state for Atezca test suite\n */\nclass AtezcaState {\n private config: SetupConfig | null = null;\n private commands: TestCommand[] = [];\n\n setConfig(config: SetupConfig): void {\n this.config = config;\n }\n\n getConfig(): SetupConfig | null {\n return this.config;\n }\n\n addCommand(command: TestCommand): void {\n this.commands.push(command);\n }\n\n getCommands(): TestCommand[] {\n return [...this.commands];\n }\n\n clear(): void {\n this.config = null;\n this.commands = [];\n }\n}\n\n// Use globalThis to ensure state is shared across module instances\nconst ATEZCA_STATE_KEY = Symbol.for('__ATEZCA_STATE__');\nif (!(globalThis as any)[ATEZCA_STATE_KEY]) {\n (globalThis as any)[ATEZCA_STATE_KEY] = new AtezcaState();\n}\nconst state: AtezcaState = (globalThis as any)[ATEZCA_STATE_KEY];\n\n/**\n * Setup Atezca test configuration\n * \n * @example\n * ```ts\n * az.setup({\n * url: \"https://example.com\",\n * browser: \"chromium\",\n * headless: true\n * });\n * ```\n */\nexport function setup(config: SetupConfig): void {\n if (!config.url) {\n throw new Error('az.setup() requires a url');\n }\n \n state.setConfig({\n ...config,\n browser: config.browser ?? 'chromium',\n headless: config.headless ?? true,\n timeout: config.timeout ?? 30000,\n outputDir: config.outputDir ?? 'generated-tests',\n cacheEnabled: config.cacheEnabled ?? true,\n retries: config.retries ?? 3,\n aiProvider: config.aiProvider,\n apiKey: config.apiKey,\n disableSSL: config.disableSSL ?? false,\n });\n}\n\n/**\n * Define a test action using natural language\n * \n * @example\n * ```ts\n * az.test(\"interact\", \"click button 'Login'\");\n * az.test(\"expect\", \"show success message\");\n * az.test(\"wait\", \"until page is loaded\");\n * ```\n */\nexport function test(actionType: ActionType, description: string): void {\n if (!state.getConfig()) {\n throw new Error('az.setup() must be called before az.test()');\n }\n\n if (!description || description.trim() === '') {\n throw new Error('az.test() requires a description');\n }\n\n const validTypes: ActionType[] = ['navigate', 'interact', 'wait', 'expect'];\n if (!validTypes.includes(actionType)) {\n throw new Error(`Invalid action type: ${actionType}. Must be one of: ${validTypes.join(', ')}`);\n }\n\n state.addCommand({\n actionType,\n description: description.trim(),\n timestamp: Date.now(),\n });\n}\n\n/**\n * Get current state (for internal use)\n * @internal\n */\nexport function getState() {\n return {\n config: state.getConfig(),\n commands: state.getCommands(),\n };\n}\n\n/**\n * Clear state (for internal use)\n * @internal\n */\nexport function clearState() {\n state.clear();\n}\n\n/**\n * Wait for a specified number of milliseconds\n * \n * @example\n * ```ts\n * az.wait(1000); // Wait 1 second\n * az.wait(2500); // Wait 2.5 seconds\n * ```\n */\nexport function wait(milliseconds: number): void {\n if (!state.getConfig()) {\n throw new Error('az.setup() must be called before az.wait()');\n }\n\n if (typeof milliseconds !== 'number' || milliseconds < 0) {\n throw new Error('az.wait() requires a positive number of milliseconds');\n }\n\n state.addCommand({\n actionType: 'wait',\n description: `wait ${milliseconds}ms`,\n timestamp: Date.now(),\n });\n}\n\n/**\n * Main API export\n */\nexport const az = {\n setup,\n test,\n wait,\n};\n\n// Named exports for convenience\nexport { setup as azSetup, test as azTest, wait as azWait };\n\n// Re-export types\nexport type * from './types/index.js';\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var AtezcaState = class {
|
|
3
|
+
config = null;
|
|
4
|
+
commands = [];
|
|
5
|
+
setConfig(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
getConfig() {
|
|
9
|
+
return this.config;
|
|
10
|
+
}
|
|
11
|
+
addCommand(command) {
|
|
12
|
+
this.commands.push(command);
|
|
13
|
+
}
|
|
14
|
+
getCommands() {
|
|
15
|
+
return [...this.commands];
|
|
16
|
+
}
|
|
17
|
+
clear() {
|
|
18
|
+
this.config = null;
|
|
19
|
+
this.commands = [];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var ATEZCA_STATE_KEY = /* @__PURE__ */ Symbol.for("__ATEZCA_STATE__");
|
|
23
|
+
if (!globalThis[ATEZCA_STATE_KEY]) {
|
|
24
|
+
globalThis[ATEZCA_STATE_KEY] = new AtezcaState();
|
|
25
|
+
}
|
|
26
|
+
var state = globalThis[ATEZCA_STATE_KEY];
|
|
27
|
+
function setup(config) {
|
|
28
|
+
if (!config.url) {
|
|
29
|
+
throw new Error("az.setup() requires a url");
|
|
30
|
+
}
|
|
31
|
+
state.setConfig({
|
|
32
|
+
...config,
|
|
33
|
+
browser: config.browser ?? "chromium",
|
|
34
|
+
headless: config.headless ?? true,
|
|
35
|
+
timeout: config.timeout ?? 3e4,
|
|
36
|
+
outputDir: config.outputDir ?? "generated-tests",
|
|
37
|
+
cacheEnabled: config.cacheEnabled ?? true,
|
|
38
|
+
retries: config.retries ?? 3,
|
|
39
|
+
aiProvider: config.aiProvider,
|
|
40
|
+
apiKey: config.apiKey,
|
|
41
|
+
disableSSL: config.disableSSL ?? false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function test(actionType, description) {
|
|
45
|
+
if (!state.getConfig()) {
|
|
46
|
+
throw new Error("az.setup() must be called before az.test()");
|
|
47
|
+
}
|
|
48
|
+
if (!description || description.trim() === "") {
|
|
49
|
+
throw new Error("az.test() requires a description");
|
|
50
|
+
}
|
|
51
|
+
const validTypes = ["navigate", "interact", "wait", "expect"];
|
|
52
|
+
if (!validTypes.includes(actionType)) {
|
|
53
|
+
throw new Error(`Invalid action type: ${actionType}. Must be one of: ${validTypes.join(", ")}`);
|
|
54
|
+
}
|
|
55
|
+
state.addCommand({
|
|
56
|
+
actionType,
|
|
57
|
+
description: description.trim(),
|
|
58
|
+
timestamp: Date.now()
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getState() {
|
|
62
|
+
return {
|
|
63
|
+
config: state.getConfig(),
|
|
64
|
+
commands: state.getCommands()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function clearState() {
|
|
68
|
+
state.clear();
|
|
69
|
+
}
|
|
70
|
+
function wait(milliseconds) {
|
|
71
|
+
if (!state.getConfig()) {
|
|
72
|
+
throw new Error("az.setup() must be called before az.wait()");
|
|
73
|
+
}
|
|
74
|
+
if (typeof milliseconds !== "number" || milliseconds < 0) {
|
|
75
|
+
throw new Error("az.wait() requires a positive number of milliseconds");
|
|
76
|
+
}
|
|
77
|
+
state.addCommand({
|
|
78
|
+
actionType: "wait",
|
|
79
|
+
description: `wait ${milliseconds}ms`,
|
|
80
|
+
timestamp: Date.now()
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var az = {
|
|
84
|
+
setup,
|
|
85
|
+
test,
|
|
86
|
+
wait
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { az, setup as azSetup, test as azTest, wait as azWait, clearState, getState, setup, test, wait };
|
|
90
|
+
//# sourceMappingURL=index.mjs.map
|
|
91
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAKA,IAAM,cAAN,MAAkB;AAAA,EACR,MAAA,GAA6B,IAAA;AAAA,EAC7B,WAA0B,EAAC;AAAA,EAEnC,UAAU,MAAA,EAA2B;AACnC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,SAAA,GAAgC;AAC9B,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EAEA,WAAW,OAAA,EAA4B;AACrC,IAAA,IAAA,CAAK,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,EAC5B;AAAA,EAEA,WAAA,GAA6B;AAC3B,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAQ,CAAA;AAAA,EAC1B;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,IAAA;AACd,IAAA,IAAA,CAAK,WAAW,EAAC;AAAA,EACnB;AACF,CAAA;AAGA,IAAM,gBAAA,mBAAmB,MAAA,CAAO,GAAA,CAAI,kBAAkB,CAAA;AACtD,IAAI,CAAE,UAAA,CAAmB,gBAAgB,CAAA,EAAG;AAC1C,EAAC,UAAA,CAAmB,gBAAgB,CAAA,GAAI,IAAI,WAAA,EAAY;AAC1D;AACA,IAAM,KAAA,GAAsB,WAAmB,gBAAgB,CAAA;AAcxD,SAAS,MAAM,MAAA,EAA2B;AAC/C,EAAA,IAAI,CAAC,OAAO,GAAA,EAAK;AACf,IAAA,MAAM,IAAI,MAAM,2BAA2B,CAAA;AAAA,EAC7C;AAEA,EAAA,KAAA,CAAM,SAA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,IACL,MAAA,EAAQ,MAAM,SAAA,EAAU;AAAA,IACxB,QAAA,EAAU,MAAM,WAAA;AAAY,GAC9B;AACF;AAMO,SAAS,UAAA,GAAa;AAC3B,EAAA,KAAA,CAAM,KAAA,EAAM;AACd;AAWO,SAAS,KAAK,YAAA,EAA4B;AAC/C,EAAA,IAAI,CAAC,KAAA,CAAM,SAAA,EAAU,EAAG;AACtB,IAAA,MAAM,IAAI,MAAM,4CAA4C,CAAA;AAAA,EAC9D;AAEA,EAAA,IAAI,OAAO,YAAA,KAAiB,QAAA,IAAY,YAAA,GAAe,CAAA,EAAG;AACxD,IAAA,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAAA,EACxE;AAEA,EAAA,KAAA,CAAM,UAAA,CAAW;AAAA,IACf,UAAA,EAAY,MAAA;AAAA,IACZ,WAAA,EAAa,QAAQ,YAAY,CAAA,EAAA,CAAA;AAAA,IACjC,SAAA,EAAW,KAAK,GAAA;AAAI,GACrB,CAAA;AACH;AAKO,IAAM,EAAA,GAAK;AAAA,EAChB,KAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF","file":"index.mjs","sourcesContent":["import type { SetupConfig, TestCommand, ActionType } from './types/index.js';\n\n/**\n * Global state for Atezca test suite\n */\nclass AtezcaState {\n private config: SetupConfig | null = null;\n private commands: TestCommand[] = [];\n\n setConfig(config: SetupConfig): void {\n this.config = config;\n }\n\n getConfig(): SetupConfig | null {\n return this.config;\n }\n\n addCommand(command: TestCommand): void {\n this.commands.push(command);\n }\n\n getCommands(): TestCommand[] {\n return [...this.commands];\n }\n\n clear(): void {\n this.config = null;\n this.commands = [];\n }\n}\n\n// Use globalThis to ensure state is shared across module instances\nconst ATEZCA_STATE_KEY = Symbol.for('__ATEZCA_STATE__');\nif (!(globalThis as any)[ATEZCA_STATE_KEY]) {\n (globalThis as any)[ATEZCA_STATE_KEY] = new AtezcaState();\n}\nconst state: AtezcaState = (globalThis as any)[ATEZCA_STATE_KEY];\n\n/**\n * Setup Atezca test configuration\n * \n * @example\n * ```ts\n * az.setup({\n * url: \"https://example.com\",\n * browser: \"chromium\",\n * headless: true\n * });\n * ```\n */\nexport function setup(config: SetupConfig): void {\n if (!config.url) {\n throw new Error('az.setup() requires a url');\n }\n \n state.setConfig({\n ...config,\n browser: config.browser ?? 'chromium',\n headless: config.headless ?? true,\n timeout: config.timeout ?? 30000,\n outputDir: config.outputDir ?? 'generated-tests',\n cacheEnabled: config.cacheEnabled ?? true,\n retries: config.retries ?? 3,\n aiProvider: config.aiProvider,\n apiKey: config.apiKey,\n disableSSL: config.disableSSL ?? false,\n });\n}\n\n/**\n * Define a test action using natural language\n * \n * @example\n * ```ts\n * az.test(\"interact\", \"click button 'Login'\");\n * az.test(\"expect\", \"show success message\");\n * az.test(\"wait\", \"until page is loaded\");\n * ```\n */\nexport function test(actionType: ActionType, description: string): void {\n if (!state.getConfig()) {\n throw new Error('az.setup() must be called before az.test()');\n }\n\n if (!description || description.trim() === '') {\n throw new Error('az.test() requires a description');\n }\n\n const validTypes: ActionType[] = ['navigate', 'interact', 'wait', 'expect'];\n if (!validTypes.includes(actionType)) {\n throw new Error(`Invalid action type: ${actionType}. Must be one of: ${validTypes.join(', ')}`);\n }\n\n state.addCommand({\n actionType,\n description: description.trim(),\n timestamp: Date.now(),\n });\n}\n\n/**\n * Get current state (for internal use)\n * @internal\n */\nexport function getState() {\n return {\n config: state.getConfig(),\n commands: state.getCommands(),\n };\n}\n\n/**\n * Clear state (for internal use)\n * @internal\n */\nexport function clearState() {\n state.clear();\n}\n\n/**\n * Wait for a specified number of milliseconds\n * \n * @example\n * ```ts\n * az.wait(1000); // Wait 1 second\n * az.wait(2500); // Wait 2.5 seconds\n * ```\n */\nexport function wait(milliseconds: number): void {\n if (!state.getConfig()) {\n throw new Error('az.setup() must be called before az.wait()');\n }\n\n if (typeof milliseconds !== 'number' || milliseconds < 0) {\n throw new Error('az.wait() requires a positive number of milliseconds');\n }\n\n state.addCommand({\n actionType: 'wait',\n description: `wait ${milliseconds}ms`,\n timestamp: Date.now(),\n });\n}\n\n/**\n * Main API export\n */\nexport const az = {\n setup,\n test,\n wait,\n};\n\n// Named exports for convenience\nexport { setup as azSetup, test as azTest, wait as azWait };\n\n// Re-export types\nexport type * from './types/index.js';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atezca/core",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "AI-powered E2E testing library with natural language syntax",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"az": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"prepublishOnly": "pnpm build && pnpm test"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"testing",
|
|
33
|
+
"e2e",
|
|
34
|
+
"playwright",
|
|
35
|
+
"ai",
|
|
36
|
+
"claude",
|
|
37
|
+
"natural-language",
|
|
38
|
+
"test-automation"
|
|
39
|
+
],
|
|
40
|
+
"author": "",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@anthropic-ai/sdk": "^0.30.0",
|
|
44
|
+
"@google/generative-ai": "^0.21.0",
|
|
45
|
+
"playwright": "^1.48.0",
|
|
46
|
+
"dotenv": "^16.4.5",
|
|
47
|
+
"zod": "^3.23.8",
|
|
48
|
+
"chalk": "^5.3.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.11.19",
|
|
52
|
+
"tsup": "^8.0.2",
|
|
53
|
+
"typescript": "^5.3.3",
|
|
54
|
+
"vitest": "^1.3.1"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|