-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add default XML value * feat: Add default XML value
- Loading branch information
Showing
14 changed files
with
201 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@bnb-chain/greenfield-js-sdk': patch | ||
--- | ||
|
||
feat: Add XML default value when null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/chain-sdk/src/parseXML/parseGetUserBucketsResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { GetUserBucketsResponse } from '@/types'; | ||
import { XMLParser } from 'fast-xml-parser'; | ||
|
||
export const parseGetUserBucketsResponse = (data: string) => { | ||
const xmlParser = new XMLParser({ | ||
isArray: (tagName: string) => { | ||
if (tagName === 'Buckets') return true; | ||
return false; | ||
}, | ||
numberParseOptions: { | ||
hex: false, | ||
leadingZeros: true, | ||
skipLike: undefined, | ||
eNotation: false, | ||
}, | ||
}); | ||
|
||
return xmlParser.parse(data) as GetUserBucketsResponse; | ||
}; |
30 changes: 30 additions & 0 deletions
30
packages/chain-sdk/src/parseXML/parseListObjectsByBucketNameResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ListObjectsByBucketNameResponse } from '@/types/sp-xml/ListObjectsByBucketNameResponse'; | ||
import { XMLParser } from 'fast-xml-parser'; | ||
|
||
export const parseListObjectsByBucketNameResponse = (data: string) => { | ||
const arrayFields = ['Objects', 'CommonPrefixes']; | ||
const xmlParser = new XMLParser({ | ||
isArray: (tagName: string) => { | ||
if (arrayFields.includes(tagName)) return true; | ||
return false; | ||
}, | ||
numberParseOptions: { | ||
hex: false, | ||
leadingZeros: true, | ||
skipLike: undefined, | ||
eNotation: false, | ||
}, | ||
}); | ||
|
||
const res = xmlParser.parse(data) as ListObjectsByBucketNameResponse; | ||
|
||
if (res.GfSpListObjectsByBucketNameResponse.CommonPrefixes.length === 0) { | ||
res.GfSpListObjectsByBucketNameResponse.CommonPrefixes = []; | ||
} | ||
|
||
if (res.GfSpListObjectsByBucketNameResponse.Objects.length === 0) { | ||
res.GfSpListObjectsByBucketNameResponse.Objects = []; | ||
} | ||
|
||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { XMLParser } from 'fast-xml-parser'; | ||
import { ReadQuotaResponse } from '..'; | ||
|
||
export const parseReadQuotaResponse = (data: string) => { | ||
const xmlParser = new XMLParser(); | ||
return xmlParser.parse(data) as ReadQuotaResponse; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/chain-sdk/src/types/sp-xml/GetUserBucketsResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export interface GetUserBucketsResponse { | ||
GfSpGetUserBucketsResponse: GfSPGetUserBucketsResponse; | ||
} | ||
|
||
export interface GfSPGetUserBucketsResponse { | ||
Buckets: Bucket[]; | ||
} | ||
|
||
export interface Bucket { | ||
BucketInfo: BucketInfo; | ||
Removed: string; | ||
DeleteAt: string; | ||
DeleteReason: string; | ||
Operator: string; | ||
CreateTxHash: string; | ||
UpdateTxHash: string; | ||
UpdateAt: string; | ||
UpdateTime: string; | ||
} | ||
|
||
export interface BucketInfo { | ||
Owner: string; | ||
BucketName: string; | ||
Visibility: string; | ||
Id: string; | ||
SourceType: string; | ||
CreateAt: string; | ||
PaymentAddress: string; | ||
GlobalVirtualGroupFamilyId: string; | ||
ChargedReadQuota: string; | ||
BucketStatus: string; | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/chain-sdk/src/types/sp-xml/ListObjectsByBucketNameResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export interface ListObjectsByBucketNameResponse { | ||
GfSpListObjectsByBucketNameResponse: GfSPListObjectsByBucketNameResponse; | ||
} | ||
|
||
export interface GfSPListObjectsByBucketNameResponse { | ||
Objects: TObject[]; | ||
KeyCount: string; | ||
MaxKeys: string; | ||
IsTruncated: string; | ||
NextContinuationToken: string; | ||
Name: string; | ||
Prefix: string; | ||
Delimiter: string; | ||
CommonPrefixes: string[]; | ||
ContinuationToken: string; | ||
} | ||
|
||
export interface TObject { | ||
ObjectInfo: ObjectInfo; | ||
LockedBalance: string; | ||
Removed: string; | ||
UpdateAt: string; | ||
DeleteAt: string; | ||
DeleteReason: string; | ||
Operator: string; | ||
CreateTxHash: string; | ||
UpdateTxHash: string; | ||
SealTxHash: string; | ||
} | ||
|
||
export interface ObjectInfo { | ||
Owner: string; | ||
Creator: string; | ||
BucketName: string; | ||
ObjectName: string; | ||
Id: string; | ||
LocalVirtualGroupId: string; | ||
PayloadSize: string; | ||
Visibility: string; | ||
ContentType: string; | ||
CreateAt: string; | ||
ObjectStatus: string; | ||
RedundancyType: string; | ||
SourceType: string; | ||
Checksums: Checksum[]; | ||
} | ||
|
||
export enum Checksum { | ||
D7Dca9013758E3E20E448Eead58D2Eb075Cfd2Af6C8781B650A6Dbd1B6E49481 = 'd7dca9013758e3e20e448eead58d2eb075cfd2af6c8781b650a6dbd1b6e49481', | ||
F803F1A72B179111F3Bea2203695D1Bacefec4Ef546D4Cdc90F5C252Bcc6F827 = 'f803f1a72b179111f3bea2203695d1bacefec4ef546d4cdc90f5c252bcc6f827', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface ReadQuotaResponse { | ||
GetReadQuotaResult: { | ||
BucketID: number; | ||
BucketName: string; | ||
ReadConsumedSize: number; | ||
ReadQuotaSize: number; | ||
SPFreeReadQuotaSize: number; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export * from './GetUserBucketsResponse'; | ||
export * from './ListObjectsByBucketNameResponse'; | ||
export * from './ReadQuotaResponse'; | ||
|
||
export interface RequestErrorResponse { | ||
Error: { | ||
Code: string; | ||
Message: string; | ||
}; | ||
} | ||
|
||
export interface RequestNonceResponse { | ||
RequestNonceResp: { | ||
CurrentNonce: number; | ||
CurrentPublicKey: string; | ||
ExpiryDate: string; | ||
NextNonce: number; | ||
}; | ||
} | ||
|
||
interface ObjectInfo { | ||
Owner: number; | ||
Creator: number; | ||
BucketName: string; | ||
ObjectName: string; | ||
Id: number; | ||
LocalVirtualGroupId: number; | ||
PayloadSize: number; | ||
Visibility: number; | ||
ContentType: string; | ||
CreateAt: number; | ||
ObjectStatus: number; | ||
RedundancyType: number; | ||
SourceType: number; | ||
Checksums: string[]; | ||
} |
Oops, something went wrong.