From 32cba046e0660a53001813b6e716ba8dfc185225 Mon Sep 17 00:00:00 2001 From: Bot Anik <98603954+bot-anik@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:15:44 +0000 Subject: [PATCH] feat: update schema files --- go/cognitarium-schema/README.md | 111 +++-- go/dataverse-schema/schema.go | 84 ++-- go/law-stone-schema/client.go | 4 +- go/law-stone-schema/schema.go | 34 +- go/objectarium-schema/schema.go | 298 ++++++------ schema/axone-cognitarium.json | 668 +++++++++++++++++++++++--- schema/axone-cognitarium/execute.json | 326 +++++++++++-- schema/axone-cognitarium/query.json | 342 +++++++++++-- ts/cognitarium-schema/README.md | 111 +++-- 9 files changed, 1548 insertions(+), 430 deletions(-) diff --git a/go/cognitarium-schema/README.md b/go/cognitarium-schema/README.md index 3ef8861..734e0dd 100644 --- a/go/cognitarium-schema/README.md +++ b/go/cognitarium-schema/README.md @@ -436,12 +436,12 @@ Example: `json { "prefixes": [ { "prefix": "foaf", "namespace": "http://xmlns.co Only the smart contract owner (i.e. the address who instantiated it) is authorized to perform this action. -| parameter | description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `delete_data` | _(Required.) _ **object**. | -| `delete_data.delete` | _(Required.) _ **Array<[TripleDeleteTemplate](#tripledeletetemplate)>**. Specifies the specific triple templates to delete. If nothing is provided, the patterns from the `where` clause are used for deletion. | -| `delete_data.prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the operation. | -| `delete_data.where` | _(Required.) _ **Array<[WhereCondition](#wherecondition)>**. Defines the patterns that data (RDF triples) should match in order for it to be considered for deletion. | +| parameter | description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `delete_data` | _(Required.) _ **object**. | +| `delete_data.delete` | _(Required.) _ **Array<[TripleDeleteTemplate](#tripledeletetemplate)>**. Specifies the specific triple templates to delete. If nothing is provided and the `where` clause is a single Bgp, the patterns are used for deletion. | +| `delete_data.prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the operation. | +| `delete_data.where` | **[WhereClause](#whereclause)\|null**. Defines the patterns that data (RDF triples) should match in order for it to be considered for deletion, if any. | ## QueryMsg @@ -537,6 +537,15 @@ Contains information related to triple store. ## Definitions +### Bgp + +Represents a basic graph pattern expressed as a set of triple patterns. + +| property | description | +| -------------- | ---------------------------------------------------------------- | +| `bgp` | _(Required.) _ **object**. | +| `bgp.patterns` | _(Required.) _ **Array<[TriplePattern](#triplepattern)>**. | + ### Binary A string containing Base64-encoded data. @@ -557,11 +566,11 @@ An RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node). Represents a CONSTRUCT query over the triple store, allowing to retrieve a set of triples serialized in a specific format. -| property | description | -| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `construct` | _(Required.) _ **Array<[TripleConstructTemplate](#tripleconstructtemplate)>**. The triples to construct. If nothing is provided, the patterns from the `where` clause are used for construction. | -| `prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the query. | -| `where` | _(Required.) _ **Array<[WhereCondition](#wherecondition)>**. The WHERE clause. This clause is used to specify the triples to construct using variable bindings. | +| property | description | +| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `construct` | _(Required.) _ **Array<[TripleConstructTemplate](#tripleconstructtemplate)>**. The triples to construct. If nothing is provided and the `where` clause is a single Bgp, the patterns are used for construction. | +| `prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the query. | +| `where` | _(Required.) _ **[WhereClause](#whereclause)**. The WHERE clause. This clause is used to specify the triples to construct using variable bindings. | ### DataFormat @@ -578,11 +587,39 @@ Represents the format in which the data are serialized, for example when returne Represents a DESCRIBE query over the triple store, allowing to retrieve a description of a resource as a set of triples serialized in a specific format. -| property | description | -| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the query. | -| `resource` | _(Required.) _ **[VarOrNamedNode](#varornamednode)**. The resource to describe given as a variable or a node. | -| `where` | _(Required.) _ **Array<[WhereCondition](#wherecondition)>**. The WHERE clause. This clause is used to specify the resource identifier to describe using variable bindings. | +| property | description | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | +| `prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the query. | +| `resource` | _(Required.) _ **[VarOrNamedNode](#varornamednode)**. The resource to describe given as a variable or a node. | +| `where` | **[WhereClause](#whereclause)\|null**. The WHERE clause. This clause is used to specify the resource identifier to describe using variable bindings. | + +### Expression + +Represents a logical combination of operations whose evaluation results in a term. + +| variant | description | +| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| undefined | **object**. A named node constant. | +| undefined | **object**. A literal constant. | +| undefined | **object**. A variable that must be bound for evaluation. | +| undefined | **object**. Logical conjunction of expressions. All expressions must evaluate to true for the conjunction to be true. If the conjunction is empty, it is considered true. | +| undefined | **object**. Logical disjunction of expressions. At least one expression must evaluate to true for the disjunction to be true. If the disjunction is empty, it is considered false. | +| undefined | **object**. Equality comparison. | +| undefined | **object**. Greater than comparison. | +| undefined | **object**. Greater or equal comparison. | +| undefined | **object**. Less than comparison. | +| undefined | **object**. Less or equal comparison. | +| undefined | **object**. Negation of an expression. | + +### Filter + +Filters the inner clause matching the expression. The solutions coming from the inner clause that do not match the expression are discarded. The variables provided in the inner clause are available in the filter expression. + +| property | description | +| -------------- | ---------------------------------------------------------------------------------------------------------- | +| `filter` | _(Required.) _ **object**. | +| `filter.expr` | _(Required.) _ **object\|object\|object\|object\|object\|object\|object\|object\|object\|object\|object**. | +| `filter.inner` | _(Required.) _ **[Bgp](#bgp)\|[LateralJoin](#lateraljoin)\|[Filter](#filter)**. | ### Full @@ -619,6 +656,16 @@ A [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-ta | `language_tagged_string.language` | _(Required.) _ **string**. The [language tag](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag). | | `language_tagged_string.value` | _(Required.) _ **string**. The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). | +### LateralJoin + +Evaluates right for all result row of left + +| property | description | +| -------------------- | ------------------------------------------------------------------------------- | +| `lateral_join` | _(Required.) _ **object**. | +| `lateral_join.left` | _(Required.) _ **[Bgp](#bgp)\|[LateralJoin](#lateraljoin)\|[Filter](#filter)**. | +| `lateral_join.right` | _(Required.) _ **[Bgp](#bgp)\|[LateralJoin](#lateraljoin)\|[Filter](#filter)**. | + ### Literal An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal). @@ -712,7 +759,7 @@ Represents a SELECT query over the triple store, allowing to select variables to | `limit` | **integer\|null**. The maximum number of results to return. If `None`, there is no limit. Note: the value of the limit cannot exceed the maximum query limit defined in the store limitations. | | `prefixes` | _(Required.) _ **Array<[Prefix](#prefix)>**. The prefixes used in the query. | | `select` | _(Required.) _ **Array<[SelectItem](#selectitem)>**. The items to select. Note: the number of items to select cannot exceed the maximum query variable count defined in the store limitations. | -| `where` | _(Required.) _ **Array<[WhereCondition](#wherecondition)>**. The WHERE clause. If `None`, there is no WHERE clause, i.e. all triples are returned without filtering. | +| `where` | _(Required.) _ **[WhereClause](#whereclause)**. The WHERE clause. If `None`, there is no WHERE clause, i.e. all triples are returned without filtering. | ### Simple @@ -722,14 +769,6 @@ A [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) wit | -------- | -------------------------- | | `simple` | _(Required.) _ **string**. | -### SimpleWhereCondition - -Represents a simple condition in a [WhereCondition]. - -| variant | description | -| ------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -| [TriplePattern](#triplepattern) | **object**. Represents a triple pattern, i.e. a condition on a triple based on its subject, predicate and object. | - ### StoreLimits Contains limitations regarding store usages. @@ -887,16 +926,26 @@ A variable. | ---------- | -------------------------- | | `variable` | _(Required.) _ **string**. | -### WhereCondition +### WhereClause + +Represents a WHERE clause, i.e. a set of conditions to filter the results. -Represents a condition in a [WhereClause]. +| variant | description | +| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Bgp](#bgp) | **object**. Represents a basic graph pattern expressed as a set of triple patterns. | +| [LateralJoin](#lateraljoin) | **object**. Evaluates right for all result row of left | +| [Filter](#filter) | **object**. Filters the inner clause matching the expression. The solutions coming from the inner clause that do not match the expression are discarded. The variables provided in the inner clause are available in the filter expression. | -| variant | description | -| ----------------- | ------------------------------------------ | -| [Simple](#simple) | **object**. Represents a simple condition. | +### undefined + +A named node constant. + +| property | description | +| ------------ | -------------------------------------------------------- | +| `named_node` | _(Required.) _ **[Prefixed](#prefixed)\|[Full](#full)**. | --- -_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-cognitarium.json` (`8f8a0452855d9314`)_ +_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-cognitarium.json` (`a6344c92b24801fb`)_ diff --git a/go/dataverse-schema/schema.go b/go/dataverse-schema/schema.go index 39b7cc5..9df701f 100644 --- a/go/dataverse-schema/schema.go +++ b/go/dataverse-schema/schema.go @@ -71,47 +71,16 @@ type QueryMsg struct { Dataverse *QueryMsg_Dataverse `json:"dataverse,omitempty"` } -/* -A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. - -# Examples - -Use `from` to create instances of this and `u128` to get the value out: - -``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123); - -let b = Uint128::from(42u64); assert_eq!(b.u128(), 42); - -let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` -*/ -type Uint128 string - -type ExecuteMsg_RevokeClaims struct { - // The unique identifier of the claims to be revoked. - Identifier string `json:"identifier"` -} - -/* -Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. - -This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also . -*/ -type Binary string - -type QueryMsg_Dataverse struct{} - // `TripleStoreConfig` represents the configuration related to the management of the triple store. type TripleStoreConfig struct { - // The code id that will be used to instantiate the triple store contract in which to store dataverse semantic data. It must implement the cognitarium interface. - CodeId Uint64 `json:"code_id"` // Limitations regarding triple store usage. Limits TripleStoreLimitsInput `json:"limits"` + // The code id that will be used to instantiate the triple store contract in which to store dataverse semantic data. It must implement the cognitarium interface. + CodeId Uint64 `json:"code_id"` } // Contains requested limitations regarding store usages. type TripleStoreLimitsInput struct { - // The maximum number of bytes the store can contain. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit. - MaxByteSize *Uint128 `json:"max_byte_size,omitempty"` // The maximum number of bytes an insert data query can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit. MaxInsertDataByteSize *Uint128 `json:"max_insert_data_byte_size,omitempty"` // The maximum number of triples an insert data query can contain (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit. @@ -124,6 +93,8 @@ type TripleStoreLimitsInput struct { MaxTripleByteSize *Uint128 `json:"max_triple_byte_size,omitempty"` // The maximum number of triples the store can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit. MaxTripleCount *Uint128 `json:"max_triple_count,omitempty"` + // The maximum number of bytes the store can contain. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit. + MaxByteSize *Uint128 `json:"max_byte_size,omitempty"` } /* @@ -139,13 +110,6 @@ let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` */ type Uint64 string -type ExecuteMsg_SubmitClaims struct { - // The Verifiable Credential containing the claims. The claims must be serialized in the format specified by the `format` field. - Claims Binary `json:"claims"` - // RDF dataset serialization format for the claims. If not provided, the default format is [N-Quads](https://www.w3.org/TR/n-quads/) format. - Format *RdfDatasetFormat `json:"format,omitempty"` -} - // Represents the various serialization formats for an RDF dataset, i.e. a collection of RDF graphs ([RDF Dataset](https://www.w3.org/TR/rdf11-concepts/#section-dataset)). type RdfDatasetFormat string @@ -171,8 +135,44 @@ type Addr string // DataverseResponse is the response of the Dataverse query. type DataverseResponse struct { - // The name of the dataverse. - Name string `json:"name"` // The cognitarium contract address. TriplestoreAddress Addr `json:"triplestore_address"` + // The name of the dataverse. + Name string `json:"name"` +} + +/* +A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. + +# Examples + +Use `from` to create instances of this and `u128` to get the value out: + +``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123); + +let b = Uint128::from(42u64); assert_eq!(b.u128(), 42); + +let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` +*/ +type Uint128 string + +type ExecuteMsg_SubmitClaims struct { + // The Verifiable Credential containing the claims. The claims must be serialized in the format specified by the `format` field. + Claims Binary `json:"claims"` + // RDF dataset serialization format for the claims. If not provided, the default format is [N-Quads](https://www.w3.org/TR/n-quads/) format. + Format *RdfDatasetFormat `json:"format,omitempty"` } + +type ExecuteMsg_RevokeClaims struct { + // The unique identifier of the claims to be revoked. + Identifier string `json:"identifier"` +} + +/* +Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. + +This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also . +*/ +type Binary string + +type QueryMsg_Dataverse struct{} diff --git a/go/law-stone-schema/client.go b/go/law-stone-schema/client.go index 10ca9a1..f39a40d 100644 --- a/go/law-stone-schema/client.go +++ b/go/law-stone-schema/client.go @@ -13,12 +13,12 @@ import ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + // Ask is the client API for the QueryMsg_Ask query message + Ask(ctx context.Context, req *QueryMsg_Ask, opts ...grpc.CallOption) (*AskResponse, error) // Program is the client API for the QueryMsg_Program query message Program(ctx context.Context, req *QueryMsg_Program, opts ...grpc.CallOption) (*ProgramResponse, error) // ProgramCode is the client API for the QueryMsg_ProgramCode query message ProgramCode(ctx context.Context, req *QueryMsg_ProgramCode, opts ...grpc.CallOption) (*string, error) - // Ask is the client API for the QueryMsg_Ask query message - Ask(ctx context.Context, req *QueryMsg_Ask, opts ...grpc.CallOption) (*AskResponse, error) } type queryClient struct { diff --git a/go/law-stone-schema/schema.go b/go/law-stone-schema/schema.go index da6008e..9d23a1b 100644 --- a/go/law-stone-schema/schema.go +++ b/go/law-stone-schema/schema.go @@ -41,27 +41,10 @@ type QueryMsg struct { ProgramCode *QueryMsg_ProgramCode `json:"program_code,omitempty"` } -type AskResponse struct { - UserOutput *string `json:"user_output,omitempty"` - Answer *Answer `json:"answer,omitempty"` - GasUsed int `json:"gas_used"` - Height int `json:"height"` -} - type ExecuteMsg_BreakStone struct{} -// ProgramResponse carry elements to locate the program in a `axone-objectarium` contract. -type ProgramResponse struct { - // The program object id in the `axone-objectarium` contract. - ObjectId string `json:"object_id"` - // The `axone-objectarium` contract address on which the law program is stored. - StorageAddress string `json:"storage_address"` -} - type QueryMsg_Program struct{} -type QueryMsg_ProgramCode struct{} - type Answer struct { HasMore bool `json:"has_more"` Results []Result `json:"results"` @@ -78,6 +61,14 @@ type Substitution struct { Variable string `json:"variable"` } +// ProgramResponse carry elements to locate the program in a `axone-objectarium` contract. +type ProgramResponse struct { + // The program object id in the `axone-objectarium` contract. + ObjectId string `json:"object_id"` + // The `axone-objectarium` contract address on which the law program is stored. + StorageAddress string `json:"storage_address"` +} + /* Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. @@ -88,3 +79,12 @@ type Binary string type QueryMsg_Ask struct { Query string `json:"query"` } + +type QueryMsg_ProgramCode struct{} + +type AskResponse struct { + Answer *Answer `json:"answer,omitempty"` + GasUsed int `json:"gas_used"` + Height int `json:"height"` + UserOutput *string `json:"user_output,omitempty"` +} diff --git a/go/objectarium-schema/schema.go b/go/objectarium-schema/schema.go index e4086f8..b116a9f 100644 --- a/go/objectarium-schema/schema.go +++ b/go/objectarium-schema/schema.go @@ -3,14 +3,14 @@ package schema // Instantiate messages type InstantiateMsg struct { + // The configuration of the bucket. + Config BucketConfig `json:"config"` // The limits of the bucket. Limits BucketLimits `json:"limits"` // The configuration for paginated query. Pagination PaginationConfig `json:"pagination"` // The name of the bucket. The name could not be empty or contains whitespaces. If name contains whitespace, they will be removed. Bucket string `json:"bucket"` - // The configuration of the bucket. - Config BucketConfig `json:"config"` } // Execute messages @@ -46,58 +46,39 @@ type QueryMsg struct { } /* -BucketConfig is the type of the configuration of a bucket. - -The configuration is set at the instantiation of the bucket, and is immutable and cannot be changed. The configuration is optional and if not set, the default configuration is used. -*/ -type BucketConfig struct { - /* - The acceptable compression algorithms for the objects in the bucket. If this parameter is not set, then all compression algorithms are accepted. If this parameter is set, then only the compression algorithms in the array are accepted. +A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. - When an object is stored in the bucket without a specified compression algorithm, the first algorithm in the array is used. Therefore, the order of the algorithms in the array is significant. Typically, the most efficient compression algorithm, such as the NoCompression algorithm, should be placed first in the array. +# Examples - Any attempt to store an object using a different compression algorithm than the ones specified here will fail. - */ - AcceptedCompressionAlgorithms []CompressionAlgorithm `json:"accepted_compression_algorithms"` - /* - The algorithm used to hash the content of the objects to generate the id of the objects. The algorithm is optional and if not set, the default algorithm is used. +Use `from` to create instances of this and `u128` to get the value out: - The default algorithm is Sha256 if not set. - */ - HashAlgorithm HashAlgorithm `json:"hash_algorithm"` -} +``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123); -/* -CompressionAlgorithm is an enumeration that defines the different compression algorithms supported for compressing the content of objects. The compression algorithm specified here are relevant algorithms for compressing data on-chain, which means that they are fast to compress and decompress, and have a low computational cost. +let b = Uint128::from(42u64); assert_eq!(b.u128(), 42); -The order of the compression algorithms is based on their estimated computational cost (quite opinionated) during both compression and decompression, ranging from the lowest to the highest. This particular order is utilized to establish the default compression algorithm for storing an object. +let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` */ -type CompressionAlgorithm string - -const ( - // Represents no compression algorithm. The object is stored as is without any compression. - CompressionAlgorithm_Passthrough CompressionAlgorithm = "passthrough" - /* - Represents the Snappy algorithm. Snappy is a compression/decompression algorithm that does not aim for maximum compression. Instead, it aims for very high speeds and reasonable compression. - - See [the snappy web page](https://google.github.io/snappy/) for more information. - */ - CompressionAlgorithm_Snappy CompressionAlgorithm = "snappy" - /* - Represents the LZMA algorithm. LZMA is a lossless data compression/decompression algorithm that features a high compression ratio and a variable compression-dictionary size up to 4 GB. - - See [the LZMA wiki page](https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm) for more information. - */ - CompressionAlgorithm_Lzma CompressionAlgorithm = "lzma" -) +type Uint128 string -type ExecuteMsg_UnpinObject struct { +type QueryMsg_ObjectData struct { + // The id of the object to get. Id string `json:"id"` } -type QueryMsg_ObjectData struct { - // The id of the object to get. +// ObjectResponse is the response of the Object query. +type ObjectResponse struct { + // The owner of the object. + Owner string `json:"owner"` + // The size of the object. + Size Uint128 `json:"size"` + // The size of the object when compressed. If the object is not compressed, the value is the same as `size`. + CompressedSize Uint128 `json:"compressed_size"` + // The compression algorithm used to compress the content of the object. + CompressionAlgorithm CompressionAlgorithm `json:"compression_algorithm"` + // The id of the object. Id string `json:"id"` + // Tells if the object is pinned by at least one address. + IsPinned bool `json:"is_pinned"` } // ObjectPinsResponse is the response of the GetObjectPins query. @@ -108,28 +89,15 @@ type ObjectPinsResponse struct { PageInfo PageInfo `json:"page_info"` } -/* -PaginationConfig is the type carrying configuration for paginated queries. - -The fields are optional and if not set, there is a default configuration. -*/ -type PaginationConfig struct { - /* - The default number of elements in a page. - - Shall be less or equal than `max_page_size`. Default to '10' if not set. - */ - DefaultPageSize int `json:"default_page_size"` - /* - The maximum elements a page can contain. - - Shall be less than `u32::MAX - 1`. Default to '30' if not set. - */ - MaxPageSize int `json:"max_page_size"` +type QueryMsg_ObjectPins struct { + // The number of pins to return. + First *int `json:"first,omitempty"` + // The id of the object to get the pins for. + Id string `json:"id"` + // The point in the sequence to start returning pins. + After *string `json:"after,omitempty"` } -type QueryMsg_Bucket struct{} - // ObjectsResponse is the response of the Objects query. type ObjectsResponse struct { // The list of objects in the bucket. @@ -138,45 +106,29 @@ type ObjectsResponse struct { PageInfo PageInfo `json:"page_info"` } -// BucketStat is the type of the statistics of a bucket. -type BucketStat struct { - // The total size of the objects contained in the bucket after compression. - CompressedSize Uint128 `json:"compressed_size"` - // The number of objects in the bucket. - ObjectCount Uint128 `json:"object_count"` - // The total size of the objects contained in the bucket. - Size Uint128 `json:"size"` -} - -// BucketResponse is the response of the Bucket query. -type BucketResponse struct { - // The configuration of the bucket. - Config BucketConfig `json:"config"` - // The limits of the bucket. - Limits BucketLimits `json:"limits"` - // The name of the bucket. - Name string `json:"name"` - // The configuration for paginated query. - Pagination PaginationConfig `json:"pagination"` - // The statistics of the bucket. - Stat BucketStat `json:"stat"` -} - /* -BucketLimits is the type of the limits of a bucket. +CompressionAlgorithm is an enumeration that defines the different compression algorithms supported for compressing the content of objects. The compression algorithm specified here are relevant algorithms for compressing data on-chain, which means that they are fast to compress and decompress, and have a low computational cost. -The limits are optional and if not set, there is no limit. +The order of the compression algorithms is based on their estimated computational cost (quite opinionated) during both compression and decompression, ranging from the lowest to the highest. This particular order is utilized to establish the default compression algorithm for storing an object. */ -type BucketLimits struct { - // The maximum number of pins in the bucket for an object. - MaxObjectPins *Uint128 `json:"max_object_pins,omitempty"` - // The maximum size of the objects in the bucket. - MaxObjectSize *Uint128 `json:"max_object_size,omitempty"` - // The maximum number of objects in the bucket. - MaxObjects *Uint128 `json:"max_objects,omitempty"` - // The maximum total size of the objects in the bucket. - MaxTotalSize *Uint128 `json:"max_total_size,omitempty"` -} +type CompressionAlgorithm string + +const ( + // Represents no compression algorithm. The object is stored as is without any compression. + CompressionAlgorithm_Passthrough CompressionAlgorithm = "passthrough" + /* + Represents the Snappy algorithm. Snappy is a compression/decompression algorithm that does not aim for maximum compression. Instead, it aims for very high speeds and reasonable compression. + + See [the snappy web page](https://google.github.io/snappy/) for more information. + */ + CompressionAlgorithm_Snappy CompressionAlgorithm = "snappy" + /* + Represents the LZMA algorithm. LZMA is a lossless data compression/decompression algorithm that features a high compression ratio and a variable compression-dictionary size up to 4 GB. + + See [the LZMA wiki page](https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm) for more information. + */ + CompressionAlgorithm_Lzma CompressionAlgorithm = "lzma" +) // HashAlgorithm is an enumeration that defines the different hash algorithms supported for hashing the content of objects. type HashAlgorithm string @@ -228,6 +180,69 @@ type ExecuteMsg_ForgetObject struct { Id string `json:"id"` } +type ExecuteMsg_UnpinObject struct { + Id string `json:"id"` +} + +type QueryMsg_Bucket struct{} + +type QueryMsg_Objects struct { + // The number of objects to return. + First *int `json:"first,omitempty"` + // The owner of the objects to get. + Address *string `json:"address,omitempty"` + // The point in the sequence to start returning objects. + After *string `json:"after,omitempty"` +} + +// BucketStat is the type of the statistics of a bucket. +type BucketStat struct { + // The total size of the objects contained in the bucket after compression. + CompressedSize Uint128 `json:"compressed_size"` + // The number of objects in the bucket. + ObjectCount Uint128 `json:"object_count"` + // The total size of the objects contained in the bucket. + Size Uint128 `json:"size"` +} + +// BucketResponse is the response of the Bucket query. +type BucketResponse struct { + // The configuration of the bucket. + Config BucketConfig `json:"config"` + // The limits of the bucket. + Limits BucketLimits `json:"limits"` + // The name of the bucket. + Name string `json:"name"` + // The configuration for paginated query. + Pagination PaginationConfig `json:"pagination"` + // The statistics of the bucket. + Stat BucketStat `json:"stat"` +} + +/* +PaginationConfig is the type carrying configuration for paginated queries. + +The fields are optional and if not set, there is a default configuration. +*/ +type PaginationConfig struct { + /* + The default number of elements in a page. + + Shall be less or equal than `max_page_size`. Default to '10' if not set. + */ + DefaultPageSize int `json:"default_page_size"` + /* + The maximum elements a page can contain. + + Shall be less than `u32::MAX - 1`. Default to '30' if not set. + */ + MaxPageSize int `json:"max_page_size"` +} + +type ExecuteMsg_PinObject struct { + Id string `json:"id"` +} + /* Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. @@ -235,6 +250,11 @@ This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec