@applitools/visual-grid-cli-utils 1.21.44 → 1.21.45
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 +17 -0
- package/package.json +1 -1
- package/src/commons/fetch-raw-cdt-url.js +34 -0
- package/src/view-rendering.js +42 -1
- package/src/visual-grid-cli-utils.js +6 -0
package/README.md
CHANGED
|
@@ -13,3 +13,20 @@ npm install -g @applitools/visual-grid-cli-utils
|
|
|
13
13
|
## Using it
|
|
14
14
|
|
|
15
15
|
* To get all the options, do `visual-grid-cli-utils --help`
|
|
16
|
+
|
|
17
|
+
### `view-rendering <render-id> --raw`
|
|
18
|
+
|
|
19
|
+
* Instead of printing the view-rendering URL, `--raw` fetches a time-limited **signed URL to the
|
|
20
|
+
render's raw (unparsed) root-DOM CDT** and prints it together with its expiration.
|
|
21
|
+
* It calls the rendering-api-app `/render` endpoint with the `rawCdtOnly` option; the server
|
|
22
|
+
enforces ownership (you must own the render, or be an admin).
|
|
23
|
+
* Only renders created on or after **2026-06-26** are supported — the raw root-DOM CDT path
|
|
24
|
+
(`rdvsMetadata.rootDomRawResourcePath`) started being recorded with AD-14694. The feature is
|
|
25
|
+
not supported for renders created before then; the command prints a `404` hint explaining this.
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
vg-cli view-rendering <render-id> --raw
|
|
29
|
+
# Raw root-DOM CDT URL:
|
|
30
|
+
# https://storage.googleapis.com/rg-raw-.../<accountId>/<resourceId>?X-Goog-Signature=...
|
|
31
|
+
# Expires at: 2026-06-28T12:00:00.000Z (TTL 900s)
|
|
32
|
+
```
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const {fetch: defaultFetch} = require('@applitools/http-commons')
|
|
3
|
+
|
|
4
|
+
// Fetch a time-limited signed URL for a render's raw (unparsed) root-DOM CDT by calling the
|
|
5
|
+
// rendering-api-app `/render` endpoint with the `rawCdtOnly` flag (AD-14682). The endpoint
|
|
6
|
+
// returns `{ url, expiresAt, ttlSeconds }` and enforces ownership server-side. `fetch` is
|
|
7
|
+
// injectable for testing; it defaults to the shared http-commons fetch.
|
|
8
|
+
async function fetchRawCdtUrl({vgUrl, renderId, authToken, agentId, fetch = defaultFetch}) {
|
|
9
|
+
const renderUrl = new URL('./render', vgUrl)
|
|
10
|
+
const response = await fetch(renderUrl, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
'X-Auth-Token': authToken,
|
|
15
|
+
},
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
reRenderId: renderId,
|
|
18
|
+
rawCdtOnly: true,
|
|
19
|
+
agentId,
|
|
20
|
+
options: {
|
|
21
|
+
rawCdtOnly: true,
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
const errorBody = await response.text()
|
|
28
|
+
throw new Error(`Failed to fetch raw CDT URL - HTTP ${response.status}: ${errorBody}`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return response.json()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = fetchRawCdtUrl
|
package/src/view-rendering.js
CHANGED
|
@@ -3,6 +3,7 @@ const {exec} = require('child_process')
|
|
|
3
3
|
const retry = require('p-retry')
|
|
4
4
|
const createSession = require('./commons/create-session')
|
|
5
5
|
const calculateViewRenderingUrl = require('./commons/view-rendering-url')
|
|
6
|
+
const fetchRawCdtUrl = require('./commons/fetch-raw-cdt-url')
|
|
6
7
|
const {fetch, throwErrorFromBadStatus} = require('@applitools/http-commons')
|
|
7
8
|
const fs = require('fs')
|
|
8
9
|
|
|
@@ -52,7 +53,9 @@ async function waitForParsedStatus(vgUrl, renderId, authToken, waitTimeout = 5 *
|
|
|
52
53
|
)
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
// `_authToken` is unused — this path mints its own session below; the `_` prefix satisfies the
|
|
57
|
+
// no-unused-vars rule (was a pre-existing lint error on this line before the --raw change).
|
|
58
|
+
async function tryNewViewRenderingEndpoint(vgUrl, renderId, _authToken, apiKey, serverUrl) {
|
|
56
59
|
try {
|
|
57
60
|
console.log(`[1/3] Starting resource parsing for render: ${renderId}`)
|
|
58
61
|
// Step 1: Call rerender API with parseResourcesOnly flag
|
|
@@ -121,6 +124,7 @@ async function main({
|
|
|
121
124
|
serverUrl,
|
|
122
125
|
accountOverride,
|
|
123
126
|
downloadVhsFolder,
|
|
127
|
+
raw,
|
|
124
128
|
}) {
|
|
125
129
|
if (!apiKey) {
|
|
126
130
|
throw new Error(
|
|
@@ -134,6 +138,43 @@ async function main({
|
|
|
134
138
|
|
|
135
139
|
const vgUrl = process.env.VG_URL || 'https://render-wus.applitools.com'
|
|
136
140
|
|
|
141
|
+
// --raw: fetch a signed URL to the render's raw root-DOM CDT (via the rawCdtOnly /render
|
|
142
|
+
// option, AD-14682) and print it + its expiration, instead of the view-rendering URL.
|
|
143
|
+
if (raw) {
|
|
144
|
+
const agentId = `visual-grid-cli-utils/${require('../package.json').version}`
|
|
145
|
+
let rawCdt
|
|
146
|
+
try {
|
|
147
|
+
rawCdt = await fetchRawCdtUrl({
|
|
148
|
+
vgUrl,
|
|
149
|
+
renderId,
|
|
150
|
+
authToken: finalAuthToken,
|
|
151
|
+
agentId,
|
|
152
|
+
})
|
|
153
|
+
} catch (err) {
|
|
154
|
+
// A 404 most commonly means the render has no stored raw root-DOM CDT path. That path
|
|
155
|
+
// (rdvsMetadata.rootDomRawResourcePath) only started being recorded with AD-14694, so
|
|
156
|
+
// the feature isn't supported for renders created before then — surface a gentle hint.
|
|
157
|
+
if (String(err.message).includes('HTTP 404')) {
|
|
158
|
+
console.log('\n⚠ No raw root-DOM CDT URL is available for this render (404).')
|
|
159
|
+
console.log(
|
|
160
|
+
' This feature supports renders created on or after 2026-06-26; it is not supported',
|
|
161
|
+
)
|
|
162
|
+
console.log(' for renders created before then.')
|
|
163
|
+
console.log(`\n Server response: ${err.message}`)
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
throw err
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const {url, expiresAt, ttlSeconds} = rawCdt
|
|
170
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
|
|
171
|
+
console.log('Raw root-DOM CDT URL:')
|
|
172
|
+
console.log(url)
|
|
173
|
+
console.log(`Expires at: ${expiresAt} (TTL ${ttlSeconds}s)`)
|
|
174
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
|
|
137
178
|
// Try new view-rendering endpoint with rerender API
|
|
138
179
|
const result = await tryNewViewRenderingEndpoint(
|
|
139
180
|
vgUrl,
|
|
@@ -40,6 +40,12 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
40
40
|
.option('download-vhs-folder', {
|
|
41
41
|
describe: 'Specify a folder to which download the vhs file (in case of VHS snapshot)',
|
|
42
42
|
type: 'string',
|
|
43
|
+
})
|
|
44
|
+
.option('raw', {
|
|
45
|
+
describe:
|
|
46
|
+
"fetch a signed URL to the render's raw root-DOM CDT (and its expiration) instead of the view-rendering url",
|
|
47
|
+
default: false,
|
|
48
|
+
type: 'boolean',
|
|
43
49
|
}),
|
|
44
50
|
)
|
|
45
51
|
.command('view-resource <hash>', 'view resource url', (yargs) =>
|