@percy/client 1.32.0-beta.6 → 1.32.0-beta.8
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/dist/client.js +51 -1
- package/package.json +5 -5
package/dist/client.js
CHANGED
|
@@ -364,12 +364,62 @@ export class PercyClient {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
// Retrieves snapshot/comparison data by id. Requires a read access token.
|
|
367
|
+
// For `smartsnap_graph`, the API blocks (sync=true) until the graph job
|
|
368
|
+
// finishes and returns the graph payload directly in the response — there
|
|
369
|
+
// is no separate "data" endpoint to fetch after polling.
|
|
367
370
|
async getStatus(type, ids) {
|
|
368
|
-
if (!['snapshot', 'comparison'].includes(type)) throw new Error('Invalid type passed');
|
|
371
|
+
if (!['snapshot', 'comparison', 'smartsnap_graph'].includes(type)) throw new Error('Invalid type passed');
|
|
369
372
|
this.log.debug(`Getting ${type} status for ids ${ids}`);
|
|
370
373
|
return this.get(`job_status?sync=true&type=${type}&id=${ids.join()}`);
|
|
371
374
|
}
|
|
372
375
|
|
|
376
|
+
// SmartSnap endpoints authenticate against the project attached to the
|
|
377
|
+
// current Percy token (via the Authorization header). `generate-graph`
|
|
378
|
+
// takes a `build_id` (sourced from the bundler-emitted stats file) so
|
|
379
|
+
// multiple concurrent storybook builds for the same project don't share
|
|
380
|
+
// Redis state. `snapshot-name-to-commit` is project-scoped only.
|
|
381
|
+
// Graph status is polled through the shared `getStatus()` helper with
|
|
382
|
+
// type `smartsnap_graph` — the sync response returns the graph payload
|
|
383
|
+
// directly on completion.
|
|
384
|
+
|
|
385
|
+
async getSmartsnapSnapshotNameToCommit() {
|
|
386
|
+
var _this$env$git, _this$env$target, _this$env$git2, _this$env$target2;
|
|
387
|
+
this.log.debug('Smartsnap: looking up baselines...');
|
|
388
|
+
const qs = new URLSearchParams();
|
|
389
|
+
|
|
390
|
+
// Same git/PR context `createBuild` sends — the API uses these to predict
|
|
391
|
+
// the base build that *would* be selected if we called createBuild now,
|
|
392
|
+
// without actually creating one. Any missing field means the API falls
|
|
393
|
+
// back through the same strategy chain it would on real build creation.
|
|
394
|
+
if ((_this$env$git = this.env.git) !== null && _this$env$git !== void 0 && _this$env$git.branch) qs.append('branch', this.env.git.branch);
|
|
395
|
+
if ((_this$env$target = this.env.target) !== null && _this$env$target !== void 0 && _this$env$target.branch) qs.append('target_branch', this.env.target.branch);
|
|
396
|
+
if ((_this$env$git2 = this.env.git) !== null && _this$env$git2 !== void 0 && _this$env$git2.sha) qs.append('commit_sha', this.env.git.sha);
|
|
397
|
+
if ((_this$env$target2 = this.env.target) !== null && _this$env$target2 !== void 0 && _this$env$target2.commit) qs.append('target_commit_sha', this.env.target.commit);
|
|
398
|
+
if (this.env.pullRequest != null) qs.append('pull_request_number', String(this.env.pullRequest));
|
|
399
|
+
if (this.env.partial) qs.append('partial', 'true');
|
|
400
|
+
const query = qs.toString();
|
|
401
|
+
return this.get(query ? `smartsnap/snapshot-name-to-commit?${query}` : 'smartsnap/snapshot-name-to-commit', {
|
|
402
|
+
identifier: 'smartsnap.snapshot_name_to_commit'
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async generateSmartsnapGraph(buildId, {
|
|
406
|
+
files,
|
|
407
|
+
modules,
|
|
408
|
+
storybookPaths,
|
|
409
|
+
affectedNodes
|
|
410
|
+
} = {}) {
|
|
411
|
+
this.log.debug(`Smartsnap: enqueueing graph build for build ${buildId}...`);
|
|
412
|
+
return this.post('smartsnap/generate-graph', {
|
|
413
|
+
build_id: buildId,
|
|
414
|
+
files,
|
|
415
|
+
modules,
|
|
416
|
+
storybook_paths: storybookPaths,
|
|
417
|
+
affected_nodes: affectedNodes
|
|
418
|
+
}, {
|
|
419
|
+
identifier: 'smartsnap.generate_graph'
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
373
423
|
// Returns device details enabled on project associated with given token
|
|
374
424
|
async getDeviceDetails(buildId) {
|
|
375
425
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/client",
|
|
3
|
-
"version": "1.32.0-beta.
|
|
3
|
+
"version": "1.32.0-beta.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"test:coverage": "yarn test --coverage"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@percy/config": "1.32.0-beta.
|
|
37
|
-
"@percy/env": "1.32.0-beta.
|
|
38
|
-
"@percy/logger": "1.32.0-beta.
|
|
36
|
+
"@percy/config": "1.32.0-beta.8",
|
|
37
|
+
"@percy/env": "1.32.0-beta.8",
|
|
38
|
+
"@percy/logger": "1.32.0-beta.8",
|
|
39
39
|
"pac-proxy-agent": "^7.0.2",
|
|
40
40
|
"pako": "^2.1.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8e91413b6ed95aeefad697f058709e2a0fe56f0e"
|
|
43
43
|
}
|