@playq/core 0.2.77
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 +41 -0
- package/bin/playq.js +175 -0
- package/cucumber.js +10 -0
- package/dist/exec/featureFileCache.d.ts +21 -0
- package/dist/exec/featureFileCache.js +124 -0
- package/dist/exec/featureFilePreProcess.d.ts +12 -0
- package/dist/exec/featureFilePreProcess.js +208 -0
- package/dist/exec/preLoader.d.ts +1 -0
- package/dist/exec/preLoader.js +72 -0
- package/dist/exec/preProcessEntry.d.ts +1 -0
- package/dist/exec/preProcessEntry.js +83 -0
- package/dist/exec/preProcess_old_todelete.d.ts +1 -0
- package/dist/exec/preProcess_old_todelete.js +258 -0
- package/dist/exec/runner.d.ts +1 -0
- package/dist/exec/runner.js +221 -0
- package/dist/exec/runner_orchestrator.d.ts +1 -0
- package/dist/exec/runner_orchestrator.js +85 -0
- package/dist/exec/sgGenerator.d.ts +11 -0
- package/dist/exec/sgGenerator.js +310 -0
- package/dist/global.d.ts +15 -0
- package/dist/global.js +185 -0
- package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
- package/dist/helper/actions/api/apiRequestActions.js +374 -0
- package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
- package/dist/helper/actions/api/apiValidationActions.js +615 -0
- package/dist/helper/actions/apiActions.d.ts +18 -0
- package/dist/helper/actions/apiActions.js +34 -0
- package/dist/helper/actions/apiStepDefs.d.ts +1 -0
- package/dist/helper/actions/apiStepDefs.js +64 -0
- package/dist/helper/actions/comm/commonActions.d.ts +58 -0
- package/dist/helper/actions/comm/commonActions.js +198 -0
- package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
- package/dist/helper/actions/comm/utilityActions.js +351 -0
- package/dist/helper/actions/commActions.d.ts +18 -0
- package/dist/helper/actions/commActions.js +34 -0
- package/dist/helper/actions/commStepDefs.d.ts +1 -0
- package/dist/helper/actions/commStepDefs.js +57 -0
- package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
- package/dist/helper/actions/stepGroupStepDefs.js +15 -0
- package/dist/helper/actions/web/alertActions.d.ts +61 -0
- package/dist/helper/actions/web/alertActions.js +224 -0
- package/dist/helper/actions/web/cookieActions.d.ts +45 -0
- package/dist/helper/actions/web/cookieActions.js +186 -0
- package/dist/helper/actions/web/downloadActions.d.ts +40 -0
- package/dist/helper/actions/web/downloadActions.js +153 -0
- package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
- package/dist/helper/actions/web/elementReaderActions.js +326 -0
- package/dist/helper/actions/web/formActions.d.ts +122 -0
- package/dist/helper/actions/web/formActions.js +423 -0
- package/dist/helper/actions/web/iframeActions.d.ts +23 -0
- package/dist/helper/actions/web/iframeActions.js +108 -0
- package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
- package/dist/helper/actions/web/javascriptActions.js +77 -0
- package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
- package/dist/helper/actions/web/keyboardActions.js +118 -0
- package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
- package/dist/helper/actions/web/localStorageActions.js +163 -0
- package/dist/helper/actions/web/mouseActions.d.ts +240 -0
- package/dist/helper/actions/web/mouseActions.js +609 -0
- package/dist/helper/actions/web/reportingActions.d.ts +34 -0
- package/dist/helper/actions/web/reportingActions.js +58 -0
- package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
- package/dist/helper/actions/web/screenshotActions.js +151 -0
- package/dist/helper/actions/web/testDataActions.d.ts +21 -0
- package/dist/helper/actions/web/testDataActions.js +211 -0
- package/dist/helper/actions/web/validationActions.d.ts +547 -0
- package/dist/helper/actions/web/validationActions.js +1754 -0
- package/dist/helper/actions/web/waitActions.d.ts +191 -0
- package/dist/helper/actions/web/waitActions.js +589 -0
- package/dist/helper/actions/web/webNavigation.d.ts +104 -0
- package/dist/helper/actions/web/webNavigation.js +288 -0
- package/dist/helper/actions/webActions.d.ts +32 -0
- package/dist/helper/actions/webActions.js +48 -0
- package/dist/helper/actions/webStepDefs.d.ts +1 -0
- package/dist/helper/actions/webStepDefs.js +455 -0
- package/dist/helper/browsers/browserManager.d.ts +1 -0
- package/dist/helper/browsers/browserManager.js +56 -0
- package/dist/helper/bundle/defaultEntries.d.ts +6 -0
- package/dist/helper/bundle/defaultEntries.js +200 -0
- package/dist/helper/bundle/env.d.ts +1 -0
- package/dist/helper/bundle/env.js +157 -0
- package/dist/helper/bundle/vars.d.ts +9 -0
- package/dist/helper/bundle/vars.js +375 -0
- package/dist/helper/faker/customFaker.d.ts +55 -0
- package/dist/helper/faker/customFaker.js +45 -0
- package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/dist/helper/faker/modules/dateTime.d.ts +18 -0
- package/dist/helper/faker/modules/dateTime.js +106 -0
- package/dist/helper/faker/modules/mobile.d.ts +4 -0
- package/dist/helper/faker/modules/mobile.js +59 -0
- package/dist/helper/faker/modules/nric.d.ts +32 -0
- package/dist/helper/faker/modules/nric.js +84 -0
- package/dist/helper/faker/modules/passport.d.ts +3 -0
- package/dist/helper/faker/modules/passport.js +36 -0
- package/dist/helper/faker/modules/person.d.ts +14 -0
- package/dist/helper/faker/modules/person.js +73 -0
- package/dist/helper/faker/modules/postcode.d.ts +6 -0
- package/dist/helper/faker/modules/postcode.js +47 -0
- package/dist/helper/fixtures/locAggregate.d.ts +7 -0
- package/dist/helper/fixtures/locAggregate.js +94 -0
- package/dist/helper/fixtures/logFixture.d.ts +8 -0
- package/dist/helper/fixtures/logFixture.js +56 -0
- package/dist/helper/fixtures/webFixture.d.ts +19 -0
- package/dist/helper/fixtures/webFixture.js +186 -0
- package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
- package/dist/helper/fixtures/webLocFixture.js +144 -0
- package/dist/helper/report/allureStepLogger.d.ts +0 -0
- package/dist/helper/report/allureStepLogger.js +25 -0
- package/dist/helper/report/customiseReport.d.ts +1 -0
- package/dist/helper/report/customiseReport.js +55 -0
- package/dist/helper/report/init.d.ts +1 -0
- package/dist/helper/report/init.js +14 -0
- package/dist/helper/report/report.d.ts +1 -0
- package/dist/helper/report/report.js +102 -0
- package/dist/helper/util/dataLoader.d.ts +10 -0
- package/dist/helper/util/dataLoader.js +73 -0
- package/dist/helper/util/logger.d.ts +4 -0
- package/dist/helper/util/logger.js +61 -0
- package/dist/helper/util/session/sessionUtil.d.ts +26 -0
- package/dist/helper/util/session/sessionUtil.js +729 -0
- package/dist/helper/util/stepHelpers.d.ts +2 -0
- package/dist/helper/util/stepHelpers.js +16 -0
- package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
- package/dist/helper/util/test-data/dataLoader.js +145 -0
- package/dist/helper/util/test-data/dataTest.d.ts +10 -0
- package/dist/helper/util/test-data/dataTest.js +216 -0
- package/dist/helper/util/totp/totpHelper.d.ts +38 -0
- package/dist/helper/util/totp/totpHelper.js +117 -0
- package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
- package/dist/helper/util/utilities/cryptoUtil.js +53 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
- package/dist/helper/util/utils.d.ts +2 -0
- package/dist/helper/util/utils.js +22 -0
- package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
- package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
- package/dist/helper/wrapper/assert.d.ts +9 -0
- package/dist/helper/wrapper/assert.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +57 -0
- package/dist/scripts/get-versions.d.ts +1 -0
- package/dist/scripts/get-versions.js +98 -0
- package/dist/scripts/posttest.d.ts +1 -0
- package/dist/scripts/posttest.js +29 -0
- package/dist/scripts/pretest.d.ts +1 -0
- package/dist/scripts/pretest.js +57 -0
- package/dist/scripts/util.d.ts +1 -0
- package/dist/scripts/util.js +376 -0
- package/package.json +68 -0
- package/src/exec/featureFileCache.ts +80 -0
- package/src/exec/featureFilePreProcess.ts +239 -0
- package/src/exec/preLoader.ts +72 -0
- package/src/exec/preProcessEntry.ts +59 -0
- package/src/exec/preProcess_old_todelete.ts +289 -0
- package/src/exec/runner.ts +241 -0
- package/src/exec/runnerCuke.js +90 -0
- package/src/exec/runner_orchestrator.ts +91 -0
- package/src/exec/sgGenerator.ts +373 -0
- package/src/global.ts +130 -0
- package/src/helper/actions/api/apiRequestActions.ts +362 -0
- package/src/helper/actions/api/apiValidationActions.ts +594 -0
- package/src/helper/actions/apiActions.ts +18 -0
- package/src/helper/actions/apiStepDefs.ts +80 -0
- package/src/helper/actions/comm/commonActions.ts +165 -0
- package/src/helper/actions/comm/utilityActions.ts +344 -0
- package/src/helper/actions/commActions.ts +18 -0
- package/src/helper/actions/commStepDefs.ts +72 -0
- package/src/helper/actions/stepGroupStepDefs.ts +17 -0
- package/src/helper/actions/web/alertActions.ts +179 -0
- package/src/helper/actions/web/cookieActions.ts +124 -0
- package/src/helper/actions/web/downloadActions.ts +129 -0
- package/src/helper/actions/web/elementReaderActions.ts +323 -0
- package/src/helper/actions/web/formActions.ts +469 -0
- package/src/helper/actions/web/iframeActions.ts +67 -0
- package/src/helper/actions/web/javascriptActions.ts +38 -0
- package/src/helper/actions/web/keyboardActions.ts +101 -0
- package/src/helper/actions/web/localStorageActions.ts +109 -0
- package/src/helper/actions/web/mouseActions.ts +864 -0
- package/src/helper/actions/web/reportingActions.ts +53 -0
- package/src/helper/actions/web/screenshotActions.ts +124 -0
- package/src/helper/actions/web/testDataActions.ts +162 -0
- package/src/helper/actions/web/validationActions.ts +2287 -0
- package/src/helper/actions/web/waitActions.ts +757 -0
- package/src/helper/actions/web/webNavigation.ts +313 -0
- package/src/helper/actions/webActions.ts +33 -0
- package/src/helper/actions/webStepDefs.ts +505 -0
- package/src/helper/browsers/browserManager.ts +23 -0
- package/src/helper/bundle/defaultEntries.ts +208 -0
- package/src/helper/bundle/env.ts +119 -0
- package/src/helper/bundle/vars.ts +368 -0
- package/src/helper/faker/customFaker.ts +107 -0
- package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/src/helper/faker/modules/dateTime.ts +121 -0
- package/src/helper/faker/modules/mobile.ts +58 -0
- package/src/helper/faker/modules/nric.ts +109 -0
- package/src/helper/faker/modules/passport.ts +34 -0
- package/src/helper/faker/modules/person.ts +93 -0
- package/src/helper/faker/modules/postcode.ts +57 -0
- package/src/helper/fixtures/locAggregate.ts +61 -0
- package/src/helper/fixtures/logFixture.ts +57 -0
- package/src/helper/fixtures/webFixture.ts +206 -0
- package/src/helper/fixtures/webLocFixture.ts +143 -0
- package/src/helper/report/allureStepLogger.ts +26 -0
- package/src/helper/report/customiseReport.ts +61 -0
- package/src/helper/report/init.ts +18 -0
- package/src/helper/report/report.ts +72 -0
- package/src/helper/util/dataLoader.ts +42 -0
- package/src/helper/util/logger.ts +32 -0
- package/src/helper/util/session/sessionUtil.ts +839 -0
- package/src/helper/util/stepHelpers.ts +14 -0
- package/src/helper/util/test-data/dataLoader.ts +108 -0
- package/src/helper/util/test-data/dataTest.ts +191 -0
- package/src/helper/util/test-data/registerUser.json +7 -0
- package/src/helper/util/totp/totpHelper.ts +102 -0
- package/src/helper/util/utilities/cryptoUtil.ts +53 -0
- package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
- package/src/helper/util/utils.ts +28 -0
- package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
- package/src/helper/wrapper/assert.ts +25 -0
- package/src/index.ts +17 -0
- package/src/scripts/get-versions.ts +68 -0
- package/src/scripts/posttest.ts +32 -0
- package/src/scripts/pretest.ts +48 -0
- package/src/scripts/util.ts +406 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,310 @@
|
|
|
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.extractStepGroups = extractStepGroups;
|
|
7
|
+
exports.generateStepGroups = generateStepGroups;
|
|
8
|
+
exports.generateStepGroupsIfNeeded = generateStepGroupsIfNeeded;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
12
|
+
function sha256(content) {
|
|
13
|
+
return crypto_1.default.createHash('sha256').update(content).digest('hex');
|
|
14
|
+
}
|
|
15
|
+
const stepGroupDir = path_1.default.resolve('tests/bdd/step_group');
|
|
16
|
+
const outputFilePath = path_1.default.resolve('tests/bdd/steps/_step_group/stepGroup_steps.ts');
|
|
17
|
+
// ---- Step Group Caching ----
|
|
18
|
+
const cacheFilePath = path_1.default.resolve('_Temp/.cache/stepGroupMeta.json');
|
|
19
|
+
function loadCache() {
|
|
20
|
+
if (!fs_1.default.existsSync(cacheFilePath))
|
|
21
|
+
return {};
|
|
22
|
+
try {
|
|
23
|
+
return JSON.parse(fs_1.default.readFileSync(cacheFilePath, 'utf8'));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function saveCache(data) {
|
|
30
|
+
fs_1.default.mkdirSync(path_1.default.dirname(cacheFilePath), { recursive: true });
|
|
31
|
+
fs_1.default.writeFileSync(cacheFilePath, JSON.stringify(data, null, 2), 'utf8');
|
|
32
|
+
}
|
|
33
|
+
function getStepGroupFiles() {
|
|
34
|
+
if (!fs_1.default.existsSync(stepGroupDir))
|
|
35
|
+
return [];
|
|
36
|
+
return fs_1.default.readdirSync(stepGroupDir)
|
|
37
|
+
.filter(f => f.endsWith('.feature'))
|
|
38
|
+
.map(file => {
|
|
39
|
+
const fullPath = path_1.default.join(stepGroupDir, file);
|
|
40
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
41
|
+
return { file, fullPath, mtimeMs: stat.mtimeMs };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// Regex for valid StepGroup tag
|
|
45
|
+
const stepGroupTagRegex = /^@StepGroup:([a-zA-Z0-9_]+)\.sg$/;
|
|
46
|
+
const scenarioRegex = /^Scenario:\s*(.*)$/;
|
|
47
|
+
const invalidScenarioRegex = /^Scenario Outline:/;
|
|
48
|
+
function extractStepGroups(fileContent, filename) {
|
|
49
|
+
const lines = fileContent.split(/\r?\n/);
|
|
50
|
+
// Ensure @StepGroup tag appears before Feature declaration
|
|
51
|
+
let hasStepGroupTag = false;
|
|
52
|
+
for (let i = 0; i < lines.length; i++) {
|
|
53
|
+
const line = lines[i].trim();
|
|
54
|
+
if (line === '@StepGroup') {
|
|
55
|
+
hasStepGroupTag = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (line.startsWith('Feature:'))
|
|
59
|
+
break; // Stop if Feature is encountered first
|
|
60
|
+
}
|
|
61
|
+
if (!hasStepGroupTag) {
|
|
62
|
+
console.warn(`⚠️ Skipping file "${filename}" — missing @StepGroup tag before Feature declaration.`);
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const stepGroups = [];
|
|
66
|
+
for (let i = 0; i < lines.length; i++) {
|
|
67
|
+
const line = lines[i].trim();
|
|
68
|
+
if (line.startsWith('@StepGroup:') && !stepGroupTagRegex.test(line)) {
|
|
69
|
+
throw new Error(`❌ Invalid @StepGroup tag format in file ${filename}.\n` +
|
|
70
|
+
` → Offending line: ${line}\n` +
|
|
71
|
+
` → Only alphanumeric and underscores are allowed in group names (e.g., @StepGroup:valid_name.sg)`);
|
|
72
|
+
}
|
|
73
|
+
const tagMatch = line.match(stepGroupTagRegex);
|
|
74
|
+
if (tagMatch) {
|
|
75
|
+
const rawName = tagMatch[1];
|
|
76
|
+
const groupName = `${rawName}.sg`;
|
|
77
|
+
// Validate group name: only alphanumeric and underscores allowed
|
|
78
|
+
if (!/^[a-zA-Z0-9_]+$/.test(rawName)) {
|
|
79
|
+
throw new Error(`❌ Invalid step group name "${rawName}" in file ${filename}.\n` +
|
|
80
|
+
` → Step group names must be alphanumeric with underscores only (no spaces, dashes, or special characters).`);
|
|
81
|
+
}
|
|
82
|
+
// Skip empty lines to find Scenario
|
|
83
|
+
let j = i + 1;
|
|
84
|
+
while (j < lines.length && lines[j].trim() === '')
|
|
85
|
+
j++;
|
|
86
|
+
if (j < lines.length) {
|
|
87
|
+
const descLine = lines[j].trim();
|
|
88
|
+
if (invalidScenarioRegex.test(descLine)) {
|
|
89
|
+
throw new Error(`❌ Scenario Outline is not allowed in Step Group files.\n` +
|
|
90
|
+
` → File: ${filename}\n` +
|
|
91
|
+
` → Offending Line: ${j + 1}: ${descLine}`);
|
|
92
|
+
}
|
|
93
|
+
const descMatch = descLine.match(scenarioRegex);
|
|
94
|
+
if (descMatch) {
|
|
95
|
+
const description = descMatch[1].trim();
|
|
96
|
+
// Collect steps until next @ tag or EOF
|
|
97
|
+
const steps = [];
|
|
98
|
+
let k = j + 1;
|
|
99
|
+
while (k < lines.length && !lines[k].trim().startsWith('@')) {
|
|
100
|
+
const rawLine = lines[k];
|
|
101
|
+
const stepKeywords = ['*', 'Given', 'When', 'Then', 'And', 'But'];
|
|
102
|
+
if (stepKeywords.some(keyword => rawLine.trim().startsWith(keyword))) {
|
|
103
|
+
steps.push(rawLine);
|
|
104
|
+
}
|
|
105
|
+
k++;
|
|
106
|
+
}
|
|
107
|
+
console.log(`🧪 Captured ${steps.length} steps for group: ${groupName}`);
|
|
108
|
+
stepGroups.push({ name: groupName, description, steps });
|
|
109
|
+
i = k - 1; // continue after last processed line
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return stepGroups;
|
|
115
|
+
}
|
|
116
|
+
function generateStepDef(group) {
|
|
117
|
+
const { name, description, steps } = group;
|
|
118
|
+
const commentBlock = steps.length
|
|
119
|
+
? [
|
|
120
|
+
` /*StepGroup:${name}`,
|
|
121
|
+
...steps.map(s => ` ${s.trimEnd()}`),
|
|
122
|
+
' */'
|
|
123
|
+
].join('\n')
|
|
124
|
+
: ' // No steps defined';
|
|
125
|
+
return `Given('Step Group: -${name}- -${description}-', async function () {
|
|
126
|
+
${commentBlock}
|
|
127
|
+
});`;
|
|
128
|
+
}
|
|
129
|
+
function run(options = {}) {
|
|
130
|
+
const cachedTimes = loadCache();
|
|
131
|
+
const filesMeta = getStepGroupFiles();
|
|
132
|
+
const defStat = fs_1.default.existsSync(outputFilePath) ? fs_1.default.statSync(outputFilePath) : null;
|
|
133
|
+
const cachedDefMtime = cachedTimes["__stepGroupDef"];
|
|
134
|
+
const stepGroupJsonCachePath = path_1.default.resolve('_Temp/.cache/stepGroup_cache.json');
|
|
135
|
+
const cacheStat = fs_1.default.existsSync(stepGroupJsonCachePath) ? fs_1.default.statSync(stepGroupJsonCachePath) : null;
|
|
136
|
+
const cachedJsonDefMtime = cachedTimes["__stepGroupCache"];
|
|
137
|
+
if (!options.force &&
|
|
138
|
+
defStat &&
|
|
139
|
+
defStat.mtimeMs === cachedDefMtime &&
|
|
140
|
+
cacheStat &&
|
|
141
|
+
cacheStat.mtimeMs === cachedJsonDefMtime &&
|
|
142
|
+
filesMeta.every(f => cachedTimes[f.file] === f.mtimeMs)) {
|
|
143
|
+
// All step group files, generated output, and cache are up-to-date
|
|
144
|
+
console.log('⏩ Step group definitions are up-to-date. Skipping regeneration.');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const shouldReprocessAll = options.force ||
|
|
148
|
+
(defStat && defStat.mtimeMs !== cachedDefMtime) ||
|
|
149
|
+
(cacheStat && cacheStat.mtimeMs !== cachedJsonDefMtime);
|
|
150
|
+
const changedFiles = shouldReprocessAll
|
|
151
|
+
? filesMeta
|
|
152
|
+
: filesMeta.filter(f => cachedTimes[f.file] !== f.mtimeMs);
|
|
153
|
+
const allGroups = [];
|
|
154
|
+
changedFiles.forEach(({ file, fullPath }) => {
|
|
155
|
+
const content = fs_1.default.readFileSync(fullPath, 'utf8');
|
|
156
|
+
const groups = extractStepGroups(content, file);
|
|
157
|
+
allGroups.push(...groups);
|
|
158
|
+
});
|
|
159
|
+
const groupListBlock = `/*@StepGroupList\n${JSON.stringify({ groups: allGroups.map(g => g.name) }, null, 2)}\n*/\n\n`;
|
|
160
|
+
const header = `// ************************** IMPORTANT **************************
|
|
161
|
+
// This file is auto-generated by PlayQ for Step Group.
|
|
162
|
+
// Do not edit it manually. File is auto-generated.
|
|
163
|
+
// Any changes done directly will be lost on the next generation.
|
|
164
|
+
// ***************************************************************
|
|
165
|
+
|
|
166
|
+
import { Given } from '@cucumber/cucumber';
|
|
167
|
+
|
|
168
|
+
`;
|
|
169
|
+
const output = groupListBlock + header + allGroups.map(generateStepDef).join('\n\n') + '\n';
|
|
170
|
+
const stepGroupJsonCache = {};
|
|
171
|
+
allGroups.forEach(group => {
|
|
172
|
+
stepGroupJsonCache[group.name] = {
|
|
173
|
+
description: group.description,
|
|
174
|
+
steps: group.steps
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
// --- Validate existing cache before regeneration ---
|
|
178
|
+
const stepGroupCacheStr = JSON.stringify(stepGroupJsonCache, null, 2);
|
|
179
|
+
if (fs_1.default.existsSync(stepGroupJsonCachePath)) {
|
|
180
|
+
const currentCache = fs_1.default.readFileSync(stepGroupJsonCachePath, 'utf8');
|
|
181
|
+
const currentHash = sha256(currentCache);
|
|
182
|
+
const newHash = sha256(stepGroupCacheStr);
|
|
183
|
+
if (currentHash !== newHash) {
|
|
184
|
+
console.warn('⚠️ Detected changes in stepGroup_cache.json — file appears to have been modified. It will be regenerated.');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
fs_1.default.mkdirSync(path_1.default.dirname(stepGroupJsonCachePath), { recursive: true });
|
|
188
|
+
fs_1.default.writeFileSync(stepGroupJsonCachePath, stepGroupCacheStr, 'utf8');
|
|
189
|
+
const existingOutput = fs_1.default.existsSync(outputFilePath)
|
|
190
|
+
? fs_1.default.readFileSync(outputFilePath, 'utf8')
|
|
191
|
+
: '';
|
|
192
|
+
if (sha256(existingOutput) === sha256(output)) {
|
|
193
|
+
console.log('⏩ No changes in generated output. Skipping file write.');
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
fs_1.default.mkdirSync(path_1.default.dirname(outputFilePath), { recursive: true });
|
|
197
|
+
fs_1.default.writeFileSync(outputFilePath, output, 'utf8');
|
|
198
|
+
console.log(`✅ Generated ${allGroups.length} Step Group definitions to ${outputFilePath}`);
|
|
199
|
+
}
|
|
200
|
+
const updatedCache = loadCache(); // Load existing cache
|
|
201
|
+
// Update feature file mtimes
|
|
202
|
+
filesMeta.forEach(f => {
|
|
203
|
+
updatedCache[f.file] = f.mtimeMs;
|
|
204
|
+
});
|
|
205
|
+
// Add or update stepGroup_steps.ts mtime
|
|
206
|
+
const finalDefStat = fs_1.default.statSync(outputFilePath);
|
|
207
|
+
updatedCache["__stepGroupDef"] = finalDefStat.mtimeMs;
|
|
208
|
+
// Add or update stepGroup_cache.json mtime (after writing to ensure freshness)
|
|
209
|
+
const finalJsonCacheStat = fs_1.default.statSync(stepGroupJsonCachePath);
|
|
210
|
+
updatedCache["__stepGroupCache"] = finalJsonCacheStat.mtimeMs;
|
|
211
|
+
saveCache(updatedCache);
|
|
212
|
+
}
|
|
213
|
+
if (require.main === module) {
|
|
214
|
+
run(); // Only run if this file is the entry point (e.g., called via CLI)
|
|
215
|
+
}
|
|
216
|
+
function generateStepGroups(options = {}) {
|
|
217
|
+
run(options);
|
|
218
|
+
}
|
|
219
|
+
// Exported utility to run step group generation, with optional force
|
|
220
|
+
function generateStepGroupsIfNeeded(force = false) {
|
|
221
|
+
generateStepGroups({ force });
|
|
222
|
+
}
|
|
223
|
+
// import fs from 'fs';
|
|
224
|
+
// import path from 'path';
|
|
225
|
+
// const stepGroupDir = path.resolve('test/_step_group');
|
|
226
|
+
// const outputFilePath = path.resolve('test/steps/_step_group/stepGroup_steps.ts');
|
|
227
|
+
// function extractStepGroups(): {
|
|
228
|
+
// groupName: string;
|
|
229
|
+
// description: string;
|
|
230
|
+
// steps: string[];
|
|
231
|
+
// }[] {
|
|
232
|
+
// const groupPattern = /^@<([\w\-\.]+)\/>$/;
|
|
233
|
+
// const endGroupPattern = /^@<\/([\w\-\.]+)>$/;
|
|
234
|
+
// const stepGroupFiles = fs.readdirSync(stepGroupDir)
|
|
235
|
+
// .filter(file => /\.(steps\.feature|step\.feature|sg\.feature|steps\.sg\.feature)$/i.test(file));
|
|
236
|
+
// const stepGroups: {
|
|
237
|
+
// groupName: string;
|
|
238
|
+
// description: string;
|
|
239
|
+
// steps: string[];
|
|
240
|
+
// }[] = [];
|
|
241
|
+
// stepGroupFiles.forEach(file => {
|
|
242
|
+
// const fullPath = path.join(stepGroupDir, file);
|
|
243
|
+
// const fileContent = fs.readFileSync(fullPath, 'utf-8').trim().split('\n');
|
|
244
|
+
// let currentGroup = "";
|
|
245
|
+
// let groupDesc = "";
|
|
246
|
+
// const groupLines: string[] = [];
|
|
247
|
+
// fileContent.forEach(line => {
|
|
248
|
+
// const trimmedLine = line.trim();
|
|
249
|
+
// const startMatch = trimmedLine.match(groupPattern);
|
|
250
|
+
// const endMatch = trimmedLine.match(endGroupPattern);
|
|
251
|
+
// if (startMatch) {
|
|
252
|
+
// currentGroup = startMatch[1];
|
|
253
|
+
// groupDesc = "";
|
|
254
|
+
// return;
|
|
255
|
+
// }
|
|
256
|
+
// if (trimmedLine.startsWith('@desc:') && currentGroup) {
|
|
257
|
+
// groupDesc = trimmedLine.replace('@desc:', '').trim();
|
|
258
|
+
// return;
|
|
259
|
+
// }
|
|
260
|
+
// if (endMatch && endMatch[1] === currentGroup) {
|
|
261
|
+
// stepGroups.push({
|
|
262
|
+
// groupName: currentGroup,
|
|
263
|
+
// description: groupDesc,
|
|
264
|
+
// steps: [...groupLines]
|
|
265
|
+
// });
|
|
266
|
+
// currentGroup = "";
|
|
267
|
+
// groupDesc = "";
|
|
268
|
+
// groupLines.length = 0;
|
|
269
|
+
// return;
|
|
270
|
+
// }
|
|
271
|
+
// if (currentGroup && trimmedLine !== '') {
|
|
272
|
+
// groupLines.push(trimmedLine);
|
|
273
|
+
// }
|
|
274
|
+
// });
|
|
275
|
+
// });
|
|
276
|
+
// return stepGroups;
|
|
277
|
+
// }
|
|
278
|
+
// function generateStepDefinitions(stepGroups: {
|
|
279
|
+
// groupName: string;
|
|
280
|
+
// description: string;
|
|
281
|
+
// steps: string[];
|
|
282
|
+
// }[]) {
|
|
283
|
+
// const lines: string[] = [];
|
|
284
|
+
// lines.push('// ************************** IMPORTANT **************************');
|
|
285
|
+
// lines.push('// This file is auto-generated by PlayQ for Step Group.');
|
|
286
|
+
// lines.push('// Do not edit it manually. File is auto-generated.');
|
|
287
|
+
// lines.push('// Any changes done directly will be lost on the next generation.');
|
|
288
|
+
// lines.push('// ***************************************************************');
|
|
289
|
+
// lines.push('');
|
|
290
|
+
// lines.push("import { Given } from '@cucumber/cucumber';");
|
|
291
|
+
// lines.push('');
|
|
292
|
+
// stepGroups.forEach(group => {
|
|
293
|
+
// lines.push(`Given('Step Group: -${group.groupName}- -${group.description}-', async function () {`);
|
|
294
|
+
// lines.push(` console.log("Step Group: -${group.groupName}- <${group.description}>");`);
|
|
295
|
+
// lines.push('});');
|
|
296
|
+
// lines.push('');
|
|
297
|
+
// });
|
|
298
|
+
// fs.mkdirSync(path.dirname(outputFilePath), { recursive: true });
|
|
299
|
+
// fs.writeFileSync(outputFilePath, lines.join('\n'), 'utf-8');
|
|
300
|
+
// console.log(`✅ Step definitions generated: ${outputFilePath}`);
|
|
301
|
+
// }
|
|
302
|
+
// function run() {
|
|
303
|
+
// const stepGroups = extractStepGroups();
|
|
304
|
+
// if (stepGroups.length === 0) {
|
|
305
|
+
// console.warn('⚠️ No step groups found to generate.');
|
|
306
|
+
// return;
|
|
307
|
+
// }
|
|
308
|
+
// generateStepDefinitions(stepGroups);
|
|
309
|
+
// }
|
|
310
|
+
// run();
|
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as vars from './helper/bundle/vars';
|
|
2
|
+
import { webFixture } from './helper/fixtures/webFixture';
|
|
3
|
+
import { logFixture } from './helper/fixtures/logFixture';
|
|
4
|
+
import * as utils from './helper/util/utils';
|
|
5
|
+
import { faker } from './helper/faker/customFaker';
|
|
6
|
+
import { webLocResolver } from './helper/fixtures/webLocFixture';
|
|
7
|
+
import * as comm from './helper/actions/commActions';
|
|
8
|
+
import * as web from './helper/actions/webActions';
|
|
9
|
+
import * as api from './helper/actions/apiActions';
|
|
10
|
+
import { dataTest } from './helper/util/test-data/dataTest';
|
|
11
|
+
declare const addons: any;
|
|
12
|
+
declare const engines: any;
|
|
13
|
+
declare const config: any;
|
|
14
|
+
declare let loc: any;
|
|
15
|
+
export { vars, webLocResolver, webFixture, logFixture, utils, faker, comm, web, api, dataTest, addons, engines, config, loc };
|
package/dist/global.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loc = exports.config = exports.engines = exports.addons = exports.dataTest = exports.api = exports.web = exports.comm = exports.faker = exports.utils = exports.logFixture = exports.webFixture = exports.webLocResolver = exports.vars = void 0;
|
|
37
|
+
const vars = __importStar(require("./helper/bundle/vars"));
|
|
38
|
+
exports.vars = vars;
|
|
39
|
+
const webFixture_1 = require("./helper/fixtures/webFixture");
|
|
40
|
+
Object.defineProperty(exports, "webFixture", { enumerable: true, get: function () { return webFixture_1.webFixture; } });
|
|
41
|
+
const logFixture_1 = require("./helper/fixtures/logFixture");
|
|
42
|
+
Object.defineProperty(exports, "logFixture", { enumerable: true, get: function () { return logFixture_1.logFixture; } });
|
|
43
|
+
const utils = __importStar(require("./helper/util/utils"));
|
|
44
|
+
exports.utils = utils;
|
|
45
|
+
const customFaker_1 = require("./helper/faker/customFaker");
|
|
46
|
+
Object.defineProperty(exports, "faker", { enumerable: true, get: function () { return customFaker_1.faker; } });
|
|
47
|
+
const webLocFixture_1 = require("./helper/fixtures/webLocFixture");
|
|
48
|
+
Object.defineProperty(exports, "webLocResolver", { enumerable: true, get: function () { return webLocFixture_1.webLocResolver; } });
|
|
49
|
+
const locAggregate_1 = require("./helper/fixtures/locAggregate");
|
|
50
|
+
const comm = __importStar(require("./helper/actions/commActions"));
|
|
51
|
+
exports.comm = comm;
|
|
52
|
+
const web = __importStar(require("./helper/actions/webActions"));
|
|
53
|
+
exports.web = web;
|
|
54
|
+
const api = __importStar(require("./helper/actions/apiActions"));
|
|
55
|
+
exports.api = api;
|
|
56
|
+
const dataTest_1 = require("./helper/util/test-data/dataTest");
|
|
57
|
+
Object.defineProperty(exports, "dataTest", { enumerable: true, get: function () { return dataTest_1.dataTest; } });
|
|
58
|
+
const addons = (() => {
|
|
59
|
+
const root = process.env.PLAYQ_PROJECT_ROOT || process.cwd();
|
|
60
|
+
const tryReq = (id) => { try {
|
|
61
|
+
return require(id);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
} };
|
|
66
|
+
// Prefer absolute path in new layout, then new alias; no legacy fallbacks
|
|
67
|
+
return (tryReq(require('path').join(root, 'playq', 'addons')) ||
|
|
68
|
+
tryReq('@project/addons') ||
|
|
69
|
+
undefined);
|
|
70
|
+
})();
|
|
71
|
+
exports.addons = addons;
|
|
72
|
+
const engines = (() => {
|
|
73
|
+
const root = process.env.PLAYQ_PROJECT_ROOT || process.cwd();
|
|
74
|
+
const tryReq = (id) => { try {
|
|
75
|
+
return require(id);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
} };
|
|
80
|
+
const pathMod = require('path');
|
|
81
|
+
// Start with index exports to bring in lazy wrappers (patternIq, smartAi)
|
|
82
|
+
const merged = {};
|
|
83
|
+
const idxAbs = tryReq(pathMod.join(root, 'playq', 'engines'));
|
|
84
|
+
if (idxAbs)
|
|
85
|
+
Object.assign(merged, idxAbs);
|
|
86
|
+
const idxAlias = tryReq('@project/engines');
|
|
87
|
+
if (idxAlias)
|
|
88
|
+
Object.assign(merged, idxAlias);
|
|
89
|
+
// Supplement with direct engines if missing
|
|
90
|
+
const directPattern = [
|
|
91
|
+
pathMod.join(root, 'playq', 'engines', 'patternIq', 'patternIqEngine'),
|
|
92
|
+
'@project/engines/patternIq/patternIqEngine',
|
|
93
|
+
];
|
|
94
|
+
for (const id of directPattern) {
|
|
95
|
+
if (!merged.patternIq) {
|
|
96
|
+
const mod = tryReq(id);
|
|
97
|
+
if (mod)
|
|
98
|
+
merged.patternIq = mod.patternIq || mod.default || mod;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const directSmart = [
|
|
102
|
+
pathMod.join(root, 'playq', 'engines', 'smartAi', 'smartAiEngine'),
|
|
103
|
+
'@project/engines/smartAi/smartAiEngine',
|
|
104
|
+
];
|
|
105
|
+
for (const id of directSmart) {
|
|
106
|
+
if (!merged.smartAi) {
|
|
107
|
+
const mod = tryReq(id);
|
|
108
|
+
if (mod)
|
|
109
|
+
merged.smartAi = mod.smartAi || mod.default || mod;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return merged;
|
|
113
|
+
})();
|
|
114
|
+
exports.engines = engines;
|
|
115
|
+
const config = (() => {
|
|
116
|
+
const pathMod = require('path');
|
|
117
|
+
const root = process.env.PLAYQ_PROJECT_ROOT || process.cwd();
|
|
118
|
+
const configBase = pathMod.join(root, 'resources', 'config');
|
|
119
|
+
let resolvedPath = '';
|
|
120
|
+
let configObj = {};
|
|
121
|
+
try {
|
|
122
|
+
// // Try .js first (for built/production), then .ts (for ts-node/dev)
|
|
123
|
+
// if (require('fs').existsSync(configBase + '.js')) {
|
|
124
|
+
// resolvedPath = configBase + '.js';
|
|
125
|
+
// } else if (require('fs').existsSync(configBase + '.ts')) {
|
|
126
|
+
// resolvedPath = configBase + '.ts';
|
|
127
|
+
// }
|
|
128
|
+
resolvedPath = configBase + '.ts';
|
|
129
|
+
if (resolvedPath) {
|
|
130
|
+
configObj = require(resolvedPath).config || {};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
configObj = {};
|
|
135
|
+
}
|
|
136
|
+
return configObj;
|
|
137
|
+
})();
|
|
138
|
+
exports.config = config;
|
|
139
|
+
const testType = process.env.TEST_TYPE;
|
|
140
|
+
const allowedTypes = ['ui', 'api', 'mobile'];
|
|
141
|
+
globalThis.runType = allowedTypes.includes(testType)
|
|
142
|
+
? testType
|
|
143
|
+
: 'ui';
|
|
144
|
+
globalThis.vars = vars;
|
|
145
|
+
globalThis.webLocResolver = webLocFixture_1.webLocResolver;
|
|
146
|
+
globalThis.uiFixture = webFixture_1.webFixture;
|
|
147
|
+
globalThis.logFixture = logFixture_1.logFixture;
|
|
148
|
+
globalThis.utils = utils;
|
|
149
|
+
globalThis.faker = customFaker_1.faker;
|
|
150
|
+
globalThis.comm = comm;
|
|
151
|
+
globalThis.web = web;
|
|
152
|
+
globalThis.api = api;
|
|
153
|
+
globalThis.dataTest = dataTest_1.dataTest;
|
|
154
|
+
// Build and expose 'loc' namespace; prefer folder auto-discovery to avoid requiring an index file
|
|
155
|
+
(() => {
|
|
156
|
+
try {
|
|
157
|
+
// First: dynamic aggregator scanning the project folder for *.loc.(ts|js)
|
|
158
|
+
const locNs = (0, locAggregate_1.getLocNamespace)();
|
|
159
|
+
if (locNs && Object.keys(locNs).length > 0) {
|
|
160
|
+
globalThis.loc = locNs;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch { }
|
|
165
|
+
try {
|
|
166
|
+
// Fallback: attempt to load the consumer's loc namespace via tsconfig-paths alias
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
168
|
+
const mod = require('@resources/locators');
|
|
169
|
+
const locNs = mod.default && typeof mod.default === 'object' ? { ...mod.default, ...mod } : mod;
|
|
170
|
+
globalThis.loc = locNs;
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
console.warn('⚠️ Unable to initialize loc namespace (no folder matches or alias module):', (e === null || e === void 0 ? void 0 : e.message) || e);
|
|
174
|
+
}
|
|
175
|
+
})();
|
|
176
|
+
globalThis.addons = addons;
|
|
177
|
+
globalThis.engines = engines;
|
|
178
|
+
// Export a stable 'loc' binding for consumers: import { loc } from '@playq/core'
|
|
179
|
+
let loc;
|
|
180
|
+
try {
|
|
181
|
+
exports.loc = loc = globalThis.loc || (0, locAggregate_1.getLocNamespace)() || {};
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
exports.loc = loc = {};
|
|
185
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Api: Call api -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
3
|
+
*
|
|
4
|
+
* Calls a predefined API action using configuration from a resource file, supporting dynamic variable replacement,
|
|
5
|
+
* custom headers, body, parameters, authentication, and assertion of expected status codes.
|
|
6
|
+
*
|
|
7
|
+
* This function is designed for hybrid Playwright/Cucumber test frameworks, enabling enterprise-grade API testing
|
|
8
|
+
* with robust error handling and flexible options.
|
|
9
|
+
*
|
|
10
|
+
* @param action - The API action name (corresponds to a file in `resources/api/{action}.api.ts`).
|
|
11
|
+
* @param config - The configuration key within the API module (e.g., "success", "errorCase").
|
|
12
|
+
* @param baseUrl - The base URL for the API endpoint.
|
|
13
|
+
* @param options - Optional. Additional options as a JSON string or object. Supports:
|
|
14
|
+
* - `maxUrlRedirects`: Maximum number of redirects (default: from config or 5).
|
|
15
|
+
* - `maxTimeout`: Request timeout in milliseconds (default: from config or 10000).
|
|
16
|
+
* - `auth`: Axios authentication object.
|
|
17
|
+
* - Any other Axios request config options.
|
|
18
|
+
*
|
|
19
|
+
* @throws Error if the API config is not found or if the response status does not match `expectedStatus` in config.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Example API config file: resources/api/user.api.ts
|
|
23
|
+
* export const api = {
|
|
24
|
+
* getUser: {
|
|
25
|
+
* path: "/users/{userId}",
|
|
26
|
+
* method: "GET",
|
|
27
|
+
* headers: { "Authorization": "Bearer ${token}" },
|
|
28
|
+
* expectedStatus: "200"
|
|
29
|
+
* }
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* // Usage in test:
|
|
33
|
+
* await callApi(
|
|
34
|
+
* "user",
|
|
35
|
+
* "getUser",
|
|
36
|
+
* "https://api.example.com",
|
|
37
|
+
* { userId: "123", token: "abc123" }
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // With options as a JSON string:
|
|
42
|
+
* await callApi(
|
|
43
|
+
* "user",
|
|
44
|
+
* "getUser",
|
|
45
|
+
* "https://api.example.com",
|
|
46
|
+
* '{"userId":"123","token":"abc123","maxTimeout":5000}'
|
|
47
|
+
* );
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // With custom authentication:
|
|
51
|
+
* await callApi(
|
|
52
|
+
* "user",
|
|
53
|
+
* "getUser",
|
|
54
|
+
* "https://api.example.com",
|
|
55
|
+
* { auth: { username: "admin", password: "secret" } }
|
|
56
|
+
* );
|
|
57
|
+
*/
|
|
58
|
+
export declare function callApi(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Api: Get -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
61
|
+
*
|
|
62
|
+
* Sends a GET-style request using an API config. Alias of `callApi`.
|
|
63
|
+
*
|
|
64
|
+
* @param action - API action name.
|
|
65
|
+
* @param config - Config key within the action module.
|
|
66
|
+
* @param baseUrl - Base URL for the request.
|
|
67
|
+
* @param options - Additional options forwarded to `callApi`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function get(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Api: Post -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
72
|
+
*
|
|
73
|
+
* Sends a POST-style request using an API config. Alias of `callApi`.
|
|
74
|
+
*
|
|
75
|
+
* @param action - API action name.
|
|
76
|
+
* @param config - Config key within the action module.
|
|
77
|
+
* @param baseUrl - Base URL for the request.
|
|
78
|
+
* @param options - Additional options forwarded to `callApi`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function post(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Api: Request -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
83
|
+
*
|
|
84
|
+
* Sends a request (generic wrapper). Alias of `callApi`.
|
|
85
|
+
*
|
|
86
|
+
* @param action - API action name.
|
|
87
|
+
* @param config - Config key within the action module.
|
|
88
|
+
* @param baseUrl - Base URL for the request.
|
|
89
|
+
* @param options - Additional options forwarded to `callApi`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function request(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Api: Put -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
94
|
+
* Sends a PUT-style request using an API config. Alias of callApi.
|
|
95
|
+
*/
|
|
96
|
+
export declare function put(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Api: Patch -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
99
|
+
* Sends a PATCH-style request using an API config. Alias of callApi.
|
|
100
|
+
*/
|
|
101
|
+
export declare function patch(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Api: Delete -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
104
|
+
* Sends a DELETE-style request using an API config. Alias of callApi.
|
|
105
|
+
*/
|
|
106
|
+
export declare function del(action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Api: Send request -method: {param} -action: {param} -config: {param} -baseUrl: {param} -options: {param}
|
|
109
|
+
*
|
|
110
|
+
* Sends an HTTP request using the specified method and API config.
|
|
111
|
+
* @param method - HTTP method (GET, POST, PUT, PATCH, DELETE, etc.)
|
|
112
|
+
* @param action - API action name.
|
|
113
|
+
* @param config - Config key within the action module.
|
|
114
|
+
* @param baseUrl - Base URL for the request.
|
|
115
|
+
* @param options - Additional options forwarded to callApi.
|
|
116
|
+
*/
|
|
117
|
+
export declare function sendRequest(method: string, action: string, config: string, baseUrl: string, options?: string | Record<string, any>): Promise<void>;
|