@percy/client 1.32.6 → 1.32.7-beta.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/dist/client.js +61 -5
- package/package.json +6 -6
package/dist/client.js
CHANGED
|
@@ -401,10 +401,45 @@ export class PercyClient {
|
|
|
401
401
|
|
|
402
402
|
// Retrieves snapshot/comparison data by id. Requires a read access token.
|
|
403
403
|
async getStatus(type, ids) {
|
|
404
|
-
if (!['snapshot', 'comparison'].includes(type)) throw new Error('Invalid type passed');
|
|
404
|
+
if (!['snapshot', 'comparison', 'intelli_story_graph'].includes(type)) throw new Error('Invalid type passed');
|
|
405
405
|
this.log.debug(`Getting ${type} status for ids ${ids}`);
|
|
406
406
|
return this.get(`job_status?sync=true&type=${type}&id=${ids.join()}`);
|
|
407
407
|
}
|
|
408
|
+
async getIntelliStorySnapshotNameToCommit(buildId) {
|
|
409
|
+
var _this$env$git, _this$env$target, _this$env$git2, _this$env$target2;
|
|
410
|
+
this.log.debug('IntelliStory: looking up baselines...');
|
|
411
|
+
const qs = new URLSearchParams();
|
|
412
|
+
if (buildId) qs.append('build_id', buildId);
|
|
413
|
+
if ((_this$env$git = this.env.git) !== null && _this$env$git !== void 0 && _this$env$git.branch) qs.append('branch', this.env.git.branch);
|
|
414
|
+
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);
|
|
415
|
+
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);
|
|
416
|
+
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);
|
|
417
|
+
if (this.env.pullRequest != null) qs.append('pull_request_number', String(this.env.pullRequest));
|
|
418
|
+
if (this.env.partial) qs.append('partial', 'true');
|
|
419
|
+
const query = qs.toString();
|
|
420
|
+
return this.get(query ? `intelli_story/snapshot-name-to-commit?${query}` : 'intelli_story/snapshot-name-to-commit', {
|
|
421
|
+
identifier: 'intelli_story.snapshot_name_to_commit'
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async generateIntelliStoryGraph(buildId, {
|
|
425
|
+
files,
|
|
426
|
+
modules,
|
|
427
|
+
storybookPaths,
|
|
428
|
+
affectedNodes,
|
|
429
|
+
affectedFileLocations
|
|
430
|
+
} = {}) {
|
|
431
|
+
this.log.debug(`IntelliStory: enqueueing graph build for build ${buildId}...`);
|
|
432
|
+
return this.post('intelli_story/generate-graph', {
|
|
433
|
+
build_id: buildId,
|
|
434
|
+
files,
|
|
435
|
+
modules,
|
|
436
|
+
storybook_paths: storybookPaths,
|
|
437
|
+
affected_nodes: affectedNodes,
|
|
438
|
+
affected_file_locations: affectedFileLocations
|
|
439
|
+
}, {
|
|
440
|
+
identifier: 'intelli_story.generate_graph'
|
|
441
|
+
});
|
|
442
|
+
}
|
|
408
443
|
|
|
409
444
|
// Returns device details enabled on project associated with given token
|
|
410
445
|
async getDeviceDetails(buildId) {
|
|
@@ -571,6 +606,8 @@ export class PercyClient {
|
|
|
571
606
|
regions,
|
|
572
607
|
algorithm,
|
|
573
608
|
algorithmConfiguration,
|
|
609
|
+
intelliStory,
|
|
610
|
+
storybookPath,
|
|
574
611
|
resources = [],
|
|
575
612
|
meta
|
|
576
613
|
} = {}) {
|
|
@@ -604,7 +641,11 @@ export class PercyClient {
|
|
|
604
641
|
'enable-javascript': enableJavaScript || null,
|
|
605
642
|
'enable-layout': enableLayout || false,
|
|
606
643
|
'th-test-case-execution-id': thTestCaseExecutionId || null,
|
|
607
|
-
browsers: normalizeBrowsers(browsers) || null
|
|
644
|
+
browsers: normalizeBrowsers(browsers) || null,
|
|
645
|
+
// IntelliStory: when enabled, the API selects affected snapshots
|
|
646
|
+
// server-side using the story's source path.
|
|
647
|
+
'intelli-story': intelliStory || null,
|
|
648
|
+
'storybook-path': storybookPath || null
|
|
608
649
|
},
|
|
609
650
|
relationships: {
|
|
610
651
|
resources: {
|
|
@@ -640,23 +681,38 @@ export class PercyClient {
|
|
|
640
681
|
// Convenience method for creating a snapshot for the active build, uploading
|
|
641
682
|
// missing resources for the snapshot, and finalizing the snapshot.
|
|
642
683
|
async sendSnapshot(buildId, options) {
|
|
643
|
-
var _snapshot$data$relati;
|
|
684
|
+
var _snapshot$data, _snapshot$data$relati;
|
|
644
685
|
let {
|
|
645
686
|
meta = {}
|
|
646
687
|
} = options;
|
|
647
688
|
let snapshot = await this.createSnapshot(buildId, options);
|
|
689
|
+
|
|
690
|
+
// The API always creates the snapshot record now; when server-side SmartSnap
|
|
691
|
+
// selection skips it, the response carries `skipped-via-smartsnap: true` and
|
|
692
|
+
// there are no resources to upload. Tally kept vs skipped so the storybook
|
|
693
|
+
// flow can print an IntelliStory summary.
|
|
694
|
+
let skipped = !!(snapshot !== null && snapshot !== void 0 && (_snapshot$data = snapshot.data) !== null && _snapshot$data !== void 0 && (_snapshot$data = _snapshot$data.attributes) !== null && _snapshot$data !== void 0 && _snapshot$data['skipped-via-smartsnap']);
|
|
695
|
+
if (typeof options.intelliStory === 'boolean') {
|
|
696
|
+
this.intelliStoryStats ?? (this.intelliStoryStats = {
|
|
697
|
+
kept: 0,
|
|
698
|
+
skipped: 0
|
|
699
|
+
});
|
|
700
|
+
this.intelliStoryStats[skipped ? 'skipped' : 'kept'] += 1;
|
|
701
|
+
}
|
|
648
702
|
meta.snapshotId = snapshot.data.id;
|
|
649
703
|
let missing = (_snapshot$data$relati = snapshot.data.relationships) === null || _snapshot$data$relati === void 0 || (_snapshot$data$relati = _snapshot$data$relati['missing-resources']) === null || _snapshot$data$relati === void 0 ? void 0 : _snapshot$data$relati.data;
|
|
650
704
|
this.log.debug(`${(missing === null || missing === void 0 ? void 0 : missing.length) || 0} Missing resources: ${options.name}...`, meta);
|
|
651
|
-
if (
|
|
705
|
+
if (skipped) {
|
|
706
|
+
this.log.debug('skipping resource upload because this is a intellistory skip build', meta);
|
|
707
|
+
} else if (missing !== null && missing !== void 0 && missing.length) {
|
|
652
708
|
let resources = options.resources.reduce((acc, r) => Object.assign(acc, {
|
|
653
709
|
[r.sha]: r
|
|
654
710
|
}), {});
|
|
655
711
|
await this.uploadResources(buildId, missing.map(({
|
|
656
712
|
id
|
|
657
713
|
}) => resources[id]), meta);
|
|
714
|
+
this.log.debug(`Resources uploaded: ${options.name}...`, meta);
|
|
658
715
|
}
|
|
659
|
-
this.log.debug(`Resources uploaded: ${options.name}...`, meta);
|
|
660
716
|
await this.finalizeSnapshot(snapshot.data.id, meta);
|
|
661
717
|
this.log.debug(`Finalized snapshot: ${options.name}...`, meta);
|
|
662
718
|
return snapshot;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/client",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.7-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "beta"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"test:coverage": "yarn test --coverage"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@percy/config": "1.32.
|
|
37
|
-
"@percy/env": "1.32.
|
|
38
|
-
"@percy/logger": "1.32.
|
|
36
|
+
"@percy/config": "1.32.7-beta.0",
|
|
37
|
+
"@percy/env": "1.32.7-beta.0",
|
|
38
|
+
"@percy/logger": "1.32.7-beta.0",
|
|
39
39
|
"pac-proxy-agent": "^7.0.2",
|
|
40
40
|
"pako": "^2.1.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "f86a18de3e04d3cfa9d14ce5d186ad66c3f8e020"
|
|
43
43
|
}
|