@applitools/ufg-client
Advanced tools
Comparing version 1.10.2 to 1.11.0
# Changelog | ||
## [1.11.0](https://github.com/Applitools-Dev/sdk/compare/js/ufg-client@1.10.2...js/ufg-client@1.11.0) (2024-04-10) | ||
### Features | ||
* add prefixRenderId to SnapshotSettings ([073c81b](https://github.com/Applitools-Dev/sdk/commit/073c81b7e96411b643fe907a588f0c1ef95c4d48)) | ||
* refactor check to have a modular structure ([#2307](https://github.com/Applitools-Dev/sdk/issues/2307)) ([b9818f4](https://github.com/Applitools-Dev/sdk/commit/b9818f46e0a579ad0a4a6beaf142171aea7ce0fd)) | ||
## [1.10.2](https://github.com/Applitools-Dev/sdk/compare/js/ufg-client@1.10.1...js/ufg-client@1.10.2) (2024-03-18) | ||
@@ -4,0 +12,0 @@ |
@@ -37,2 +37,4 @@ "use strict"; | ||
render: (0, render_1.makeRender)({ requests, logger }), | ||
startRenders: requests.startRenders, | ||
getRenderResults: requests.getRenderResults, | ||
getActualEnvironment: (0, get_actual_environment_1.makeGetActualEnvironment)({ requests, logger }), | ||
@@ -39,0 +41,0 @@ getChromeEmulationDevices: requests.getChromeEmulationDevices, |
@@ -20,1 +20,2 @@ "use strict"; | ||
__exportStar(require("./server/requests"), exports); | ||
__exportStar(require("./utils/to-render-result"), exports); |
@@ -37,8 +37,8 @@ "use strict"; | ||
const startRenderWithBatching = utils.general.batchify(startRenders, { timeout: batchingTimeout }); | ||
const checkRenderResultWithBatching = utils.general.batchify(checkRenderResults, { timeout: batchingTimeout }); | ||
const getRenderResultWithBatching = utils.general.batchify(getRenderResults, { timeout: batchingTimeout }); | ||
const throttles = new Map(); | ||
const renderWithConcurrency = utils.general.wrap(render, (render, options) => { | ||
let throttle = throttles.get(options.settings.environmentId); | ||
let throttle = throttles.get(options.settings.environment.environmentId); | ||
if (!throttle) | ||
throttles.set(options.settings.environmentId, (throttle = (0, throat_1.default)(concurrency))); | ||
throttles.set(options.settings.environment.environmentId, (throttle = (0, throat_1.default)(concurrency))); | ||
return throttle(render, options); | ||
@@ -51,3 +51,3 @@ }); | ||
const render = await startRenderWithBatching({ target, settings, logger }); | ||
return checkRenderResultWithBatching({ render, signal, timedOutAt, logger }); | ||
return getRenderResultWithBatching({ render, signal, timedOutAt, logger }); | ||
} | ||
@@ -57,3 +57,6 @@ async function startRenders(batch) { | ||
try { | ||
const renders = await requests.startRenders({ requests: batch.map(([request]) => request), logger }); | ||
const renders = await requests.startRenders({ | ||
renders: batch.map(([{ target, settings }]) => ({ target, settings })), | ||
logger, | ||
}); | ||
renders.forEach((render, index) => { | ||
@@ -74,3 +77,3 @@ const [, { resolve, reject }] = batch[index]; | ||
} | ||
async function checkRenderResults(batch) { | ||
async function getRenderResults(batch) { | ||
const logger = (0, logger_1.mergeLoggers)(...batch.map(([{ logger }]) => logger)); | ||
@@ -93,3 +96,3 @@ try { | ||
}); | ||
const results = await requests.checkRenderResults({ renders: batch.map(([{ render }]) => render), logger }); | ||
const results = await requests.getRenderResults({ renders: batch.map(([{ render }]) => render), logger }); | ||
results.forEach(async (result, index) => { | ||
@@ -107,3 +110,3 @@ const [options, { resolve, reject }] = batch[index]; | ||
await utils.general.sleep(pollingTimeout); | ||
checkRenderResultWithBatching(options).then(resolve, reject); | ||
getRenderResultWithBatching(options).then(resolve, reject); | ||
} | ||
@@ -110,0 +113,0 @@ }); |
@@ -29,2 +29,3 @@ "use strict"; | ||
const req_ufg_1 = require("./req-ufg"); | ||
const to_render_result_1 = require("../utils/to-render-result"); | ||
const utils = __importStar(require("@applitools/utils")); | ||
@@ -40,3 +41,3 @@ function makeUFGRequests({ settings, logger }) { | ||
startRenders, | ||
checkRenderResults, | ||
getRenderResults, | ||
uploadResource, | ||
@@ -49,9 +50,9 @@ checkResources, | ||
}; | ||
async function startRenders({ requests, logger = mainLogger, }) { | ||
async function startRenders({ renders, logger = mainLogger, }) { | ||
logger = logger.extend(mainLogger, { tags: [`start-render-request-${utils.general.shortid()}`] }); | ||
logger.log('Request "startRenders" called for requests', requests); | ||
logger.log('Request "startRenders" called for requests', renders); | ||
const response = await req('./render', { | ||
name: 'startRenders', | ||
method: 'POST', | ||
body: requests.map(({ target, settings }) => { | ||
body: renders.map(({ target, settings }) => { | ||
var _a; | ||
@@ -62,6 +63,7 @@ const renderOptions = { | ||
resources: target.resources, | ||
selectorsToFindRegionsFor: (_a = settings.selectorsToCalculate) === null || _a === void 0 ? void 0 : _a.map(transformSelector), | ||
selectorsToFindRegionsFor: (_a = settings.selectorsToCalculate) === null || _a === void 0 ? void 0 : _a.map(toServerSelector), | ||
options: settings.ufgOptions, | ||
scriptHooks: settings.hooks, | ||
agentId: defaultAgentId, | ||
prefixRenderId: settings.prefixRenderId, | ||
webhook: settings.uploadUrl, | ||
@@ -72,3 +74,3 @@ stitchingService: settings.stitchingServiceUrl, | ||
enableMultipleResultsPerSelector: true, | ||
...transformEnvironment(settings.environment), | ||
...toServerEnvironment(settings.environment), | ||
}; | ||
@@ -88,3 +90,3 @@ if (utils.types.has(settings.environment, 'type') && settings.environment.type === 'native') { | ||
renderOptions.renderInfo.target = settings.fully ? 'full-selector' : 'selector'; | ||
renderOptions.renderInfo.selector = transformSelector(settings.region); | ||
renderOptions.renderInfo.selector = toServerSelector(settings.region); | ||
} | ||
@@ -112,7 +114,7 @@ } | ||
} | ||
async function checkRenderResults({ renders, logger = mainLogger, }) { | ||
async function getRenderResults({ renders, logger = mainLogger, }) { | ||
logger = logger.extend(mainLogger, { tags: [`ufg-request-${utils.general.shortid()}`] }); | ||
logger.log('Request "checkRenderResults" called for renders', renders); | ||
logger.log('Request "getRenderResults" called for renders', renders); | ||
const response = await req('./render-status', { | ||
name: 'checkRenderResults', | ||
name: 'getRenderResults', | ||
method: 'POST', | ||
@@ -138,24 +140,5 @@ body: renders.map(render => render.renderId), | ||
const results = await response.json().then((results) => { | ||
return results.map((result, index) => { | ||
var _a; | ||
return ({ | ||
renderId: renders[index].renderId, | ||
status: result.status, | ||
error: result.error, | ||
image: result.imageLocation, | ||
dom: result.domLocation, | ||
locationInViewport: result.imagePositionInActiveFrame, | ||
locationInView: result.imagePositionInActiveFrame, | ||
fullViewSize: result.fullPageSize, | ||
selectorRegions: (_a = result.selectorRegions) === null || _a === void 0 ? void 0 : _a.map((regions) => { | ||
return regions === null || regions === void 0 ? void 0 : regions.map(region => ({ | ||
...region, | ||
x: Math.max(0, region.x - result.imagePositionInActiveFrame.x), | ||
y: Math.max(0, region.y - result.imagePositionInActiveFrame.y), | ||
})); | ||
}), | ||
}); | ||
}); | ||
return results.map((result, index) => (0, to_render_result_1.toRenderResult)(result, { renderId: renders[index].renderId })); | ||
}); | ||
logger.log('Request "checkRenderResults" finished successfully with body', results); | ||
logger.log('Request "getRenderResults" finished successfully with body', results); | ||
return results; | ||
@@ -209,3 +192,3 @@ } | ||
stitchingService: '', | ||
...transformEnvironment(settings.environment), | ||
...toServerEnvironment(settings.environment), | ||
}; | ||
@@ -257,3 +240,3 @@ renderOptions.renderInfo.target = 'viewport'; | ||
exports.makeUFGRequests = makeUFGRequests; | ||
function transformEnvironment(environment) { | ||
function toServerEnvironment(environment) { | ||
var _a, _b; | ||
@@ -308,3 +291,3 @@ if (utils.types.has(environment, ['width', 'height'])) { | ||
} | ||
function transformSelector(selector) { | ||
function toServerSelector(selector) { | ||
var _a; | ||
@@ -311,0 +294,0 @@ if (utils.types.isString(selector)) |
{ | ||
"name": "@applitools/ufg-client", | ||
"version": "1.10.2", | ||
"version": "1.11.0", | ||
"homepage": "https://applitools.com", | ||
@@ -5,0 +5,0 @@ "bugs": { |
export * from './client'; | ||
export * from './types'; | ||
export * from './server/requests'; | ||
export * from './utils/to-render-result'; |
@@ -1,19 +0,13 @@ | ||
import type { UFGServerSettings, RenderTarget, GetActualEnvironmentSettings, ActualEnvironment, RenderSettings, RenderResult } from '../types'; | ||
import type { UFGServerSettings, RenderTarget, RenderSettings, StartedRender, GetActualEnvironmentSettings, ActualEnvironment, RenderResult } from '../types'; | ||
import { type ContentfulResource } from '../resources/resource'; | ||
import { type Logger } from '@applitools/logger'; | ||
export type RenderRequest = { | ||
target: RenderTarget; | ||
settings: RenderSettings; | ||
}; | ||
export type StartedRender = { | ||
jobId: string; | ||
renderId: string; | ||
status: string; | ||
}; | ||
export interface UFGRequests { | ||
startRenders(options: { | ||
requests: RenderRequest[]; | ||
renders: { | ||
target: RenderTarget; | ||
settings: RenderSettings; | ||
}[]; | ||
logger?: Logger; | ||
}): Promise<StartedRender[]>; | ||
checkRenderResults(options: { | ||
getRenderResults(options: { | ||
renders: StartedRender[]; | ||
@@ -20,0 +14,0 @@ logger?: Logger; |
@@ -18,2 +18,13 @@ import type { Location, Size, Region } from '@applitools/utils'; | ||
}): Promise<RenderResult>; | ||
startRenders(options: { | ||
renders: { | ||
target: RenderTarget; | ||
settings: RenderSettings; | ||
}[]; | ||
logger?: Logger; | ||
}): Promise<StartedRender[]>; | ||
getRenderResults(options: { | ||
renders: StartedRender[]; | ||
logger?: Logger; | ||
}): Promise<RenderResult[]>; | ||
getActualEnvironment(options: { | ||
@@ -167,3 +178,2 @@ settings: GetActualEnvironmentSettings; | ||
export interface RenderSettings { | ||
environmentId: string; | ||
environment: Environment; | ||
@@ -183,3 +193,9 @@ uploadUrl: string; | ||
sendDom?: boolean; | ||
prefixRenderId?: string; | ||
} | ||
export type StartedRender = { | ||
jobId: string; | ||
renderId: string; | ||
status: string; | ||
}; | ||
export interface RenderResult { | ||
@@ -186,0 +202,0 @@ renderId: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134096
41
2111