@@ -2,8 +2,9 @@ import { InfraClient, InstanceOptions, IOContext } from '@vtex/api'
22import { IOClientFactory } from '../IOClientFactory'
33
44const 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
910export class VBase extends InfraClient {
@@ -21,10 +22,30 @@ export class VBase extends InfraClient {
2122 } )
2223 }
2324
25+ public resolveConflict = ( bucketKey : string , path : string , content : any ) => {
26+ const data = [
27+ {
28+ op : 'replace' ,
29+ path,
30+ value : content ,
31+ } ,
32+ ]
33+
34+ return this . http . patch ( routes . Conflicts ( `vtex.pages-graphql/${ bucketKey } ` ) , data , {
35+ metric : 'vbase-resolve-conflicts' ,
36+ } )
37+ }
38+
39+ public getConflicts = async ( ) => {
40+ return this . http . get ( routes . Conflicts ( 'vtex.pages-graphql/userData' ) , {
41+ metric : 'vbase-get-conflicts' ,
42+ } )
43+ }
44+
2445 public checkForConflicts = async ( ) => {
2546 let status : number
2647 try {
27- const response = await this . http . get ( routes . File ( 'vtex.pages-graphql' , 'store/content.json' ) , {
48+ const response = await this . http . get ( routes . File ( 'vtex.pages-graphql/userData ' , 'store/content.json' ) , {
2849 metric : 'vbase-conflict' ,
2950 } )
3051 status = response . status
0 commit comments