Update the openapi schema

This commit is contained in:
Arnaud 2025-04-02 16:47:37 +02:00
parent 9280eb48cd
commit a402afe689
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
3 changed files with 110 additions and 72 deletions

View File

@ -27,10 +27,6 @@ components:
maxLength: 66
example: 0x...
BigInt:
type: string
description: Integer represented as decimal string
Cid:
type: string
description: Content Identifier as specified at https://github.com/multiformats/cid
@ -55,17 +51,18 @@ components:
description: The amount of tokens paid per byte per second per slot to hosts the client is willing to pay
Duration:
type: string
description: The duration of the request in seconds as decimal string
type: integer
format: int64
description: The duration of the request in seconds
ProofProbability:
type: string
description: How often storage proofs are required as decimal string
Expiry:
type: string
type: integer
format: int64
description: A timestamp as seconds since unix epoch at which this request expires if the Request does not find requested amount of nodes to host the data.
default: 10 minutes
SPR:
type: string
@ -177,8 +174,9 @@ components:
- totalCollateral
properties:
totalSize:
type: string
description: Total size of availability's storage in bytes as decimal string
type: integer
format: int64
description: Total size of availability's storage in bytes
duration:
$ref: "#/components/schemas/Duration"
minPricePerBytePerSecond:
@ -208,17 +206,14 @@ components:
$ref: "#/components/schemas/Id"
readonly: true
freeSize:
type: string
type: integer
format: int64
description: Unused size of availability's storage in bytes as decimal string
readonly: true
readOnly: true
totalRemainingCollateral:
type: string
description: Total collateral effective (in amount of tokens) that can be used for matching requests
readonly: true
SalesAvailabilityCREATE:
allOf:
- $ref: "#/components/schemas/SalesAvailability"
readOnly: true
Slot:
type: object
@ -232,8 +227,9 @@ components:
request:
$ref: "#/components/schemas/StorageRequest"
slotIndex:
type: string
description: Slot Index as decimal string
type: integer
format: int64
description: Slot Index number
SlotAgent:
type: object
@ -243,8 +239,9 @@ components:
- slotIndex
properties:
slotIndex:
type: string
description: Slot Index as decimal string
type: integer
format: int64
description: Slot Index number
requestId:
$ref: "#/components/schemas/Id"
request:
@ -284,12 +281,15 @@ components:
availabilityId:
$ref: "#/components/schemas/Id"
size:
$ref: "#/components/schemas/BigInt"
type: integer
format: int64
description: Size of the slot in bytes
requestId:
$ref: "#/components/schemas/Id"
slotIndex:
type: string
description: Slot Index as decimal string
type: integer
format: int64
description: Slot Index number
validUntil:
type: integer
description: Timestamp after which the reservation will no longer be valid.
@ -312,17 +312,20 @@ components:
nodes:
description: Minimal number of nodes the content should be stored on
type: integer
default: 1
default: 3
minimum: 3
tolerance:
description: Additional number of nodes on top of the `nodes` property that can be lost before pronouncing the content lost
type: integer
default: 0
default: 1
minimum: 1
collateralPerByte:
type: string
description: Number as decimal string that represents how much collateral per byte is asked from hosts that wants to fill a slots
expiry:
type: string
description: Number as decimal string that represents expiry threshold in seconds from when the Request is submitted. When the threshold is reached and the Request does not find requested amount of nodes to host the data, the Request is voided. The number of seconds can not be higher then the Request's duration itself.
type: integer
format: int64
description: Number that represents expiry threshold in seconds from when the Request is submitted. When the threshold is reached and the Request does not find requested amount of nodes to host the data, the Request is voided. The number of seconds can not be higher then the Request's duration itself.
StorageAsk:
type: object
required:
@ -331,14 +334,17 @@ components:
- duration
- proofProbability
- pricePerBytePerSecond
- collateralPerByte
- maxSlotLoss
properties:
slots:
description: Number of slots (eq. hosts) that the Request want to have the content spread over
type: integer
format: int64
slotSize:
type: string
description: Amount of storage per slot (in bytes) as decimal string
type: integer
format: int64
description: Amount of storage per slot in bytes
duration:
$ref: "#/components/schemas/Duration"
proofProbability:
@ -347,6 +353,7 @@ components:
$ref: "#/components/schemas/PricePerBytePerSecond"
maxSlotLoss:
type: integer
format: int64
description: Max slots that can be lost without data considered to be lost
StorageRequest:
@ -779,7 +786,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/SalesAvailabilityCREATE"
$ref: "#/components/schemas/SalesAvailability"
responses:
"201":
description: Created storage availability
@ -814,7 +821,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/SalesAvailabilityCREATE"
$ref: "#/components/schemas/SalesAvailability"
responses:
"204":
description: Availability successfully updated

View File

@ -62,15 +62,15 @@ export class CodexMarketplace {
}: CodexAvailabilityWithoutTypes) {
const availability: CodexAvailability = {
...a,
totalSize: parseInt(a.totalSize, 10),
duration: parseInt(a.duration, 10),
totalSize: a.totalSize,
duration: a.duration,
minPricePerBytePerSecond: parseInt(a.minPricePerBytePerSecond, 10),
totalCollateral: parseInt(a.totalCollateral, 10),
totalRemainingCollateral: parseInt(a.totalRemainingCollateral, 10),
};
if (freeSize) {
availability.freeSize = parseInt(freeSize, 10);
availability.freeSize = freeSize;
}
return availability;
@ -116,8 +116,8 @@ export class CodexMarketplace {
const url = this.url + Api.config.prefix + "/sales/availability";
const body: CodexAvailabilityCreateBody = {
totalSize: result.output.totalSize.toString(),
duration: result.output.duration.toString(),
totalSize: result.output.totalSize,
duration: result.output.duration,
minPricePerBytePerSecond:
result.output.minPricePerBytePerSecond.toString(),
totalCollateral: result.output.totalCollateral.toString(),
@ -165,8 +165,8 @@ export class CodexMarketplace {
this.url + Api.config.prefix + "/sales/availability/" + result.output.id;
const body: CodexAvailabilityCreateBody = {
totalSize: result.output.totalSize.toString(),
duration: result.output.duration.toString(),
totalSize: result.output.totalSize,
duration: result.output.duration,
minPricePerBytePerSecond:
result.output.minPricePerBytePerSecond.toString(),
totalCollateral: result.output.totalCollateral.toString(),
@ -239,8 +239,8 @@ export class CodexMarketplace {
...p.request,
ask: {
...p.request.ask,
slotSize: parseInt(p.request.ask.slotSize, 10),
duration: parseInt(p.request.ask.duration, 10),
slotSize: p.request.ask.slotSize,
duration: p.request.ask.duration,
proofProbability: parseInt(p.request.ask.proofProbability, 10),
pricePerBytePerSecond: parseInt(
p.request.ask.pricePerBytePerSecond,
@ -330,12 +330,12 @@ export class CodexMarketplace {
return Fetch.safeText(url, {
method: "POST",
body: JSON.stringify({
duration: duration.toString(),
duration: duration,
pricePerBytePerSecond: pricePerBytePerSecond.toString(),
proofProbability: proofProbability.toString(),
nodes,
collateralPerByte: collateralPerByte.toString(),
expiry: expiry.toString(),
expiry: expiry,
tolerance,
} satisfies CodexStorageRequestCreateBody),
});

View File

@ -361,8 +361,6 @@ export interface components {
* @example 0x...
*/
Id: string;
/** @description Integer represented as decimal string */
BigInt: string;
/**
* @description Content Identifier as specified at https://github.com/multiformats/cid
* @example QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N
@ -382,15 +380,18 @@ export interface components {
EthereumAddress: string;
/** @description The amount of tokens paid per byte per second per slot to hosts the client is willing to pay */
PricePerBytePerSecond: string;
/** @description The duration of the request in seconds as decimal string */
Duration: string;
/**
* Format: int64
* @description The duration of the request in seconds
*/
Duration: number;
/** @description How often storage proofs are required as decimal string */
ProofProbability: string;
/**
* Format: int64
* @description A timestamp as seconds since unix epoch at which this request expires if the Request does not find requested amount of nodes to host the data.
* @default 10 minutes
*/
Expiry: string;
Expiry: number;
/** @description Signed Peer Record (libp2p) */
SPR: string;
SPRRead: {
@ -431,8 +432,11 @@ export interface components {
codex: components["schemas"]["CodexVersion"];
};
SalesAvailability: {
/** @description Total size of availability's storage in bytes as decimal string */
totalSize: string;
/**
* Format: int64
* @description Total size of availability's storage in bytes
*/
totalSize: number;
duration: components["schemas"]["Duration"];
/** @description Minimal price per byte per second paid (in amount of tokens) for the hosted request's slot for the request's duration as decimal string */
minPricePerBytePerSecond: string;
@ -451,21 +455,29 @@ export interface components {
};
SalesAvailabilityREAD: components["schemas"]["SalesAvailability"] & {
id: components["schemas"]["Id"];
/** @description Unused size of availability's storage in bytes as decimal string */
freeSize?: string;
/**
* Format: int64
* @description Unused size of availability's storage in bytes as decimal string
*/
readonly freeSize?: number;
/** @description Total collateral effective (in amount of tokens) that can be used for matching requests */
totalRemainingCollateral: string;
readonly totalRemainingCollateral: string;
};
SalesAvailabilityCREATE: components["schemas"]["SalesAvailability"];
Slot: {
id: components["schemas"]["SlotId"];
request: components["schemas"]["StorageRequest"];
/** @description Slot Index as decimal string */
slotIndex: string;
/**
* Format: int64
* @description Slot Index number
*/
slotIndex: number;
};
SlotAgent: {
/** @description Slot Index as decimal string */
slotIndex: string;
/**
* Format: int64
* @description Slot Index number
*/
slotIndex: number;
requestId: components["schemas"]["Id"];
request?: components["schemas"]["StorageRequest"];
reservation?: components["schemas"]["Reservation"];
@ -478,10 +490,17 @@ export interface components {
Reservation: {
id: components["schemas"]["Id"];
availabilityId: components["schemas"]["Id"];
size: components["schemas"]["BigInt"];
/**
* Format: int64
* @description Size of the slot in bytes
*/
size: number;
requestId: components["schemas"]["Id"];
/** @description Slot Index as decimal string */
slotIndex: string;
/**
* Format: int64
* @description Slot Index number
*/
slotIndex: number;
/** @description Timestamp after which the reservation will no longer be valid. */
validUntil: number;
};
@ -491,28 +510,40 @@ export interface components {
proofProbability: components["schemas"]["ProofProbability"];
/**
* @description Minimal number of nodes the content should be stored on
* @default 1
* @default 3
*/
nodes?: number;
/**
* @description Additional number of nodes on top of the `nodes` property that can be lost before pronouncing the content lost
* @default 0
* @default 1
*/
tolerance?: number;
/** @description Number as decimal string that represents how much collateral per byte is asked from hosts that wants to fill a slots */
collateralPerByte: string;
/** @description Number as decimal string that represents expiry threshold in seconds from when the Request is submitted. When the threshold is reached and the Request does not find requested amount of nodes to host the data, the Request is voided. The number of seconds can not be higher then the Request's duration itself. */
expiry: string;
/**
* Format: int64
* @description Number that represents expiry threshold in seconds from when the Request is submitted. When the threshold is reached and the Request does not find requested amount of nodes to host the data, the Request is voided. The number of seconds can not be higher then the Request's duration itself.
*/
expiry: number;
};
StorageAsk: {
/** @description Number of slots (eq. hosts) that the Request want to have the content spread over */
/**
* Format: int64
* @description Number of slots (eq. hosts) that the Request want to have the content spread over
*/
slots: number;
/** @description Amount of storage per slot (in bytes) as decimal string */
slotSize: string;
/**
* Format: int64
* @description Amount of storage per slot in bytes
*/
slotSize: number;
duration: components["schemas"]["Duration"];
proofProbability: components["schemas"]["ProofProbability"];
pricePerBytePerSecond: components["schemas"]["PricePerBytePerSecond"];
/** @description Max slots that can be lost without data considered to be lost */
/**
* Format: int64
* @description Max slots that can be lost without data considered to be lost
*/
maxSlotLoss: number;
};
StorageRequest: {
@ -1032,7 +1063,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/json": components["schemas"]["SalesAvailabilityCREATE"];
"application/json": components["schemas"]["SalesAvailability"];
};
};
responses: {
@ -1087,7 +1118,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/json": components["schemas"]["SalesAvailabilityCREATE"];
"application/json": components["schemas"]["SalesAvailability"];
};
};
responses: {