Skip to content

Commit 8555172

Browse files
committed
Merge remote-tracking branch 'origin' into julio/log-browser-url
2 parents cfe0cbb + fd94730 commit 8555172

File tree

5 files changed

+68
-13
lines changed

5 files changed

+68
-13
lines changed

.vtex/catalog-info.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: backstage.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: toolbelt
5+
description: CLI that offers all you need to start using the VTEX IO platform efficiently
6+
tags:
7+
- typescript
8+
- oclif
9+
annotations:
10+
vtex.com/janus-acronym: ""
11+
vtex.com/o11y-os-index: ""
12+
grafana/dashboard-selector: ""
13+
github.com/project-slug: vtex/toolbelt
14+
backstage.io/techdocs-ref: dir:../
15+
vtex.com/application-id: 5YP7PPID
16+
spec:
17+
lifecycle: stable
18+
owner: te-0029
19+
type: cli
20+
dependsOn: []

.vtex/deployment.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- name: toolbelt
2+
build:
3+
provider: dkcicd
4+
pipelines:
5+
- name: techdocs-v1
6+
parameters:
7+
entityReference: default/component/toolbelt
8+
sourceDir: ./
9+
when:
10+
- event: push
11+
source: branch
12+
regex: main
13+
path:
14+
- "docs/**"
15+
- README.md
16+
- .vtex/deployment.yaml

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Updated
10+
- Extend VBase client, integrating the `getConflicts` and the `resolveConflict` endpoints.
911

1012
### Fixed
1113

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vtex",
3-
"version": "4.1.0",
3+
"version": "4.2.0",
44
"description": "The platform for e-commerce apps",
55
"bin": "bin/run",
66
"main": "lib/api/index.js",

src/api/clients/IOClients/infra/VBase.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { InfraClient, InstanceOptions, IOContext } from '@vtex/api'
22
import { IOClientFactory } from '../IOClientFactory'
33

44
const routes = {
5-
Bucket: (bucket: string) => `/buckets/${bucket}`,
6-
File: (bucket: string, path: string) => `${routes.Bucket(bucket)}/userData/files/${path}`,
5+
Bucket: (bucket: string) => `${bucket}`,
6+
File: (bucket: string, path: string) => `buckets/${routes.Bucket(bucket)}/files/${path}`,
7+
Conflicts: (bucket: string) => `buckets/${routes.Bucket(bucket)}/conflicts`,
78
}
89

910
export class VBase extends InfraClient {
@@ -21,16 +22,32 @@ export class VBase extends InfraClient {
2122
})
2223
}
2324

25+
// Resolve a specific pages-graphql conflict
26+
public resolveConflict = (bucketKey: string, path: string, content: any) => {
27+
const data = [
28+
{
29+
op: 'replace',
30+
path,
31+
value: content,
32+
},
33+
]
34+
35+
return this.http.patch(routes.Conflicts(`vtex.pages-graphql/${bucketKey}`), data, {
36+
metric: 'vbase-resolve-conflicts',
37+
})
38+
}
39+
40+
// List all conflicts in the pages-graphql bucket
41+
public getConflicts = async () => {
42+
return this.http.get(routes.Conflicts('vtex.pages-graphql/userData'), {
43+
metric: 'vbase-get-conflicts',
44+
})
45+
}
46+
47+
// Verify if there is at least one conlfict in the pages-graphql bucket
2448
public checkForConflicts = async () => {
25-
let status: number
26-
try {
27-
const response = await this.http.get(routes.File('vtex.pages-graphql', 'store/content.json'), {
28-
metric: 'vbase-conflict',
29-
})
30-
status = response.status
31-
} catch (error) {
32-
status = error.response && error.response.status
33-
}
34-
return status === 409
49+
const response = await this.getConflicts().then(res => res.data)
50+
51+
return response?.length > 0
3552
}
3653
}

0 commit comments

Comments
 (0)