UNPKG

@cheqd/ts-proto

Version:

A TypeScript package for all transpiled cheqd ProtoBuf definitions.

716 lines (636 loc) 24.4 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.6.1 // protoc unknown // source: cheqd/resource/v2/query.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination.js"; import { FeeParams } from "./fee.js"; import { Metadata, ResourceWithMetadata } from "./resource.js"; /** QueryResourceRequest is the request type for the Query/Resource RPC method */ export interface QueryResourceRequest { /** * collection_id is an identifier of the DidDocument the resource belongs to. * Format: <unique-identifier> * * Examples: * - c82f2b02-bdab-4dd7-b833-3e143745d612 * - wGHEXrZvJxR8vw5P3UWH1j */ collectionId: string; /** * id is a unique id of the resource. * Format: <uuid> */ id: string; } /** QueryResourceResponse is the response type for the Query/Resource RPC method */ export interface QueryResourceResponse { /** * Successful resolution of the resource returns the following: * - resource is the requested resource * - metadata is the resource metadata associated with the requested resource */ resource: ResourceWithMetadata | undefined; } /** QueryResourceMetadataRequest is the request type for the Query/ResourceMetadata RPC method */ export interface QueryResourceMetadataRequest { /** * collection_id is an identifier of the DidDocument the resource belongs to. * Format: <unique-identifier> * * Examples: * - c82f2b02-bdab-4dd7-b833-3e143745d612 * - wGHEXrZvJxR8vw5P3UWH1j */ collectionId: string; /** * id is a unique id of the resource. * Format: <uuid> */ id: string; } /** QueryResourceMetadataResponse is the response type for the Query/ResourceMetadata RPC method */ export interface QueryResourceMetadataResponse { /** resource is the requested resource metadata */ resource: Metadata | undefined; } /** QueryCollectionResourcesRequest is the request type for the Query/CollectionResources RPC method */ export interface QueryCollectionResourcesRequest { /** * collection_id is an identifier of the DidDocument the resource belongs to. * Format: <unique-identifier> * * Examples: * - c82f2b02-bdab-4dd7-b833-3e143745d612 * - wGHEXrZvJxR8vw5P3UWH1j */ collectionId: string; /** pagination defines an optional pagination for the request. */ pagination: PageRequest | undefined; } /** QueryCollectionResourcesResponse is the response type for the Query/CollectionResources RPC method */ export interface QueryCollectionResourcesResponse { /** resources is the requested collection of resource metadata */ resources: Metadata[]; /** pagination defines the pagination in the response. */ pagination: PageResponse | undefined; } /** QueryParamsRequest is the request type for the Query/Params RPC method. */ export interface QueryParamsRequest { } /** QueryParamsResponse is the response type for the Query/Params RPC method. */ export interface QueryParamsResponse { /** params defines the parameters of the module. */ params: FeeParams | undefined; } function createBaseQueryResourceRequest(): QueryResourceRequest { return { collectionId: "", id: "" }; } export const QueryResourceRequest: MessageFns<QueryResourceRequest> = { encode(message: QueryResourceRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.collectionId !== "") { writer.uint32(10).string(message.collectionId); } if (message.id !== "") { writer.uint32(18).string(message.id); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryResourceRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryResourceRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.collectionId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.id = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryResourceRequest { return { collectionId: isSet(object.collectionId) ? globalThis.String(object.collectionId) : "", id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, toJSON(message: QueryResourceRequest): unknown { const obj: any = {}; if (message.collectionId !== "") { obj.collectionId = message.collectionId; } if (message.id !== "") { obj.id = message.id; } return obj; }, create<I extends Exact<DeepPartial<QueryResourceRequest>, I>>(base?: I): QueryResourceRequest { return QueryResourceRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryResourceRequest>, I>>(object: I): QueryResourceRequest { const message = createBaseQueryResourceRequest(); message.collectionId = object.collectionId ?? ""; message.id = object.id ?? ""; return message; }, }; function createBaseQueryResourceResponse(): QueryResourceResponse { return { resource: undefined }; } export const QueryResourceResponse: MessageFns<QueryResourceResponse> = { encode(message: QueryResourceResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.resource !== undefined) { ResourceWithMetadata.encode(message.resource, writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryResourceResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryResourceResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.resource = ResourceWithMetadata.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryResourceResponse { return { resource: isSet(object.resource) ? ResourceWithMetadata.fromJSON(object.resource) : undefined }; }, toJSON(message: QueryResourceResponse): unknown { const obj: any = {}; if (message.resource !== undefined) { obj.resource = ResourceWithMetadata.toJSON(message.resource); } return obj; }, create<I extends Exact<DeepPartial<QueryResourceResponse>, I>>(base?: I): QueryResourceResponse { return QueryResourceResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryResourceResponse>, I>>(object: I): QueryResourceResponse { const message = createBaseQueryResourceResponse(); message.resource = (object.resource !== undefined && object.resource !== null) ? ResourceWithMetadata.fromPartial(object.resource) : undefined; return message; }, }; function createBaseQueryResourceMetadataRequest(): QueryResourceMetadataRequest { return { collectionId: "", id: "" }; } export const QueryResourceMetadataRequest: MessageFns<QueryResourceMetadataRequest> = { encode(message: QueryResourceMetadataRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.collectionId !== "") { writer.uint32(10).string(message.collectionId); } if (message.id !== "") { writer.uint32(18).string(message.id); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryResourceMetadataRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryResourceMetadataRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.collectionId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.id = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryResourceMetadataRequest { return { collectionId: isSet(object.collectionId) ? globalThis.String(object.collectionId) : "", id: isSet(object.id) ? globalThis.String(object.id) : "", }; }, toJSON(message: QueryResourceMetadataRequest): unknown { const obj: any = {}; if (message.collectionId !== "") { obj.collectionId = message.collectionId; } if (message.id !== "") { obj.id = message.id; } return obj; }, create<I extends Exact<DeepPartial<QueryResourceMetadataRequest>, I>>(base?: I): QueryResourceMetadataRequest { return QueryResourceMetadataRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryResourceMetadataRequest>, I>>(object: I): QueryResourceMetadataRequest { const message = createBaseQueryResourceMetadataRequest(); message.collectionId = object.collectionId ?? ""; message.id = object.id ?? ""; return message; }, }; function createBaseQueryResourceMetadataResponse(): QueryResourceMetadataResponse { return { resource: undefined }; } export const QueryResourceMetadataResponse: MessageFns<QueryResourceMetadataResponse> = { encode(message: QueryResourceMetadataResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.resource !== undefined) { Metadata.encode(message.resource, writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryResourceMetadataResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryResourceMetadataResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.resource = Metadata.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryResourceMetadataResponse { return { resource: isSet(object.resource) ? Metadata.fromJSON(object.resource) : undefined }; }, toJSON(message: QueryResourceMetadataResponse): unknown { const obj: any = {}; if (message.resource !== undefined) { obj.resource = Metadata.toJSON(message.resource); } return obj; }, create<I extends Exact<DeepPartial<QueryResourceMetadataResponse>, I>>(base?: I): QueryResourceMetadataResponse { return QueryResourceMetadataResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryResourceMetadataResponse>, I>>( object: I, ): QueryResourceMetadataResponse { const message = createBaseQueryResourceMetadataResponse(); message.resource = (object.resource !== undefined && object.resource !== null) ? Metadata.fromPartial(object.resource) : undefined; return message; }, }; function createBaseQueryCollectionResourcesRequest(): QueryCollectionResourcesRequest { return { collectionId: "", pagination: undefined }; } export const QueryCollectionResourcesRequest: MessageFns<QueryCollectionResourcesRequest> = { encode(message: QueryCollectionResourcesRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.collectionId !== "") { writer.uint32(10).string(message.collectionId); } if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryCollectionResourcesRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryCollectionResourcesRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.collectionId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.pagination = PageRequest.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryCollectionResourcesRequest { return { collectionId: isSet(object.collectionId) ? globalThis.String(object.collectionId) : "", pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, }; }, toJSON(message: QueryCollectionResourcesRequest): unknown { const obj: any = {}; if (message.collectionId !== "") { obj.collectionId = message.collectionId; } if (message.pagination !== undefined) { obj.pagination = PageRequest.toJSON(message.pagination); } return obj; }, create<I extends Exact<DeepPartial<QueryCollectionResourcesRequest>, I>>(base?: I): QueryCollectionResourcesRequest { return QueryCollectionResourcesRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryCollectionResourcesRequest>, I>>( object: I, ): QueryCollectionResourcesRequest { const message = createBaseQueryCollectionResourcesRequest(); message.collectionId = object.collectionId ?? ""; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageRequest.fromPartial(object.pagination) : undefined; return message; }, }; function createBaseQueryCollectionResourcesResponse(): QueryCollectionResourcesResponse { return { resources: [], pagination: undefined }; } export const QueryCollectionResourcesResponse: MessageFns<QueryCollectionResourcesResponse> = { encode(message: QueryCollectionResourcesResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.resources) { Metadata.encode(v!, writer.uint32(10).fork()).join(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryCollectionResourcesResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryCollectionResourcesResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.resources.push(Metadata.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 18) { break; } message.pagination = PageResponse.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryCollectionResourcesResponse { return { resources: globalThis.Array.isArray(object?.resources) ? object.resources.map((e: any) => Metadata.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; }, toJSON(message: QueryCollectionResourcesResponse): unknown { const obj: any = {}; if (message.resources?.length) { obj.resources = message.resources.map((e) => Metadata.toJSON(e)); } if (message.pagination !== undefined) { obj.pagination = PageResponse.toJSON(message.pagination); } return obj; }, create<I extends Exact<DeepPartial<QueryCollectionResourcesResponse>, I>>( base?: I, ): QueryCollectionResourcesResponse { return QueryCollectionResourcesResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryCollectionResourcesResponse>, I>>( object: I, ): QueryCollectionResourcesResponse { const message = createBaseQueryCollectionResourcesResponse(); message.resources = object.resources?.map((e) => Metadata.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; return message; }, }; function createBaseQueryParamsRequest(): QueryParamsRequest { return {}; } export const QueryParamsRequest: MessageFns<QueryParamsRequest> = { encode(_: QueryParamsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryParamsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(_: any): QueryParamsRequest { return {}; }, toJSON(_: QueryParamsRequest): unknown { const obj: any = {}; return obj; }, create<I extends Exact<DeepPartial<QueryParamsRequest>, I>>(base?: I): QueryParamsRequest { return QueryParamsRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryParamsRequest>, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; }, }; function createBaseQueryParamsResponse(): QueryParamsResponse { return { params: undefined }; } export const QueryParamsResponse: MessageFns<QueryParamsResponse> = { encode(message: QueryParamsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.params !== undefined) { FeeParams.encode(message.params, writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryParamsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.params = FeeParams.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): QueryParamsResponse { return { params: isSet(object.params) ? FeeParams.fromJSON(object.params) : undefined }; }, toJSON(message: QueryParamsResponse): unknown { const obj: any = {}; if (message.params !== undefined) { obj.params = FeeParams.toJSON(message.params); } return obj; }, create<I extends Exact<DeepPartial<QueryParamsResponse>, I>>(base?: I): QueryParamsResponse { return QueryParamsResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<QueryParamsResponse>, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = (object.params !== undefined && object.params !== null) ? FeeParams.fromPartial(object.params) : undefined; return message; }, }; /** Query defines the gRPC querier service for the resource module */ export interface Query { /** Fetch data/payload for a specific resource (without metadata) */ Resource(request: QueryResourceRequest): Promise<QueryResourceResponse>; /** Fetch only metadata for a specific resource */ ResourceMetadata(request: QueryResourceMetadataRequest): Promise<QueryResourceMetadataResponse>; /** Fetch metadata for all resources in a collection */ CollectionResources(request: QueryCollectionResourcesRequest): Promise<QueryCollectionResourcesResponse>; /** Params queries params of the resource module. */ Params(request: QueryParamsRequest): Promise<QueryParamsResponse>; } export const QueryServiceName = "cheqd.resource.v2.Query"; export class QueryClientImpl implements Query { private readonly rpc: Rpc; private readonly service: string; constructor(rpc: Rpc, opts?: { service?: string }) { this.service = opts?.service || QueryServiceName; this.rpc = rpc; this.Resource = this.Resource.bind(this); this.ResourceMetadata = this.ResourceMetadata.bind(this); this.CollectionResources = this.CollectionResources.bind(this); this.Params = this.Params.bind(this); } Resource(request: QueryResourceRequest): Promise<QueryResourceResponse> { const data = QueryResourceRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "Resource", data); return promise.then((data) => QueryResourceResponse.decode(new BinaryReader(data))); } ResourceMetadata(request: QueryResourceMetadataRequest): Promise<QueryResourceMetadataResponse> { const data = QueryResourceMetadataRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ResourceMetadata", data); return promise.then((data) => QueryResourceMetadataResponse.decode(new BinaryReader(data))); } CollectionResources(request: QueryCollectionResourcesRequest): Promise<QueryCollectionResourcesResponse> { const data = QueryCollectionResourcesRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "CollectionResources", data); return promise.then((data) => QueryCollectionResourcesResponse.decode(new BinaryReader(data))); } Params(request: QueryParamsRequest): Promise<QueryParamsResponse> { const data = QueryParamsRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "Params", data); return promise.then((data) => QueryParamsResponse.decode(new BinaryReader(data))); } } interface Rpc { request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>; } type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } : Partial<T>; type KeysOfUnion<T> = T extends T ? keyof T : never; type Exact<P, I extends P> = P extends Builtin ? P : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never }; function isSet(value: any): boolean { return value !== null && value !== undefined; } interface MessageFns<T> { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create<I extends Exact<DeepPartial<T>, I>>(base?: I): T; fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T; }