@cheqd/ts-proto
Version:
A TypeScript package for all transpiled cheqd ProtoBuf definitions.
982 lines (907 loc) • 30.3 kB
text/typescript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.6.1
// protoc unknown
// source: cheqd/did/v2/diddoc.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { Timestamp } from "../../../google/protobuf/timestamp.js";
/**
* DidDoc defines a DID Document, as defined in the DID Core specification.
* Documentation: https://www.w3.org/TR/did-core/
*/
export interface DidDoc {
/**
* context is a list of URIs used to identify the context of the DID document.
* Default: https://www.w3.org/ns/did/v1
*/
context: string[];
/**
* id is the DID of the DID document.
* Format: did:cheqd:<namespace>:<unique-identifier>
*/
id: string;
/** controller is a list of DIDs that are allowed to control the DID document. */
controller: string[];
/**
* verificationMethod is a list of verification methods that can be used to
* verify a digital signature or cryptographic proof.
*/
verificationMethod: VerificationMethod[];
/**
* authentication is a list of verification methods that can be used to
* authenticate as the DID subject.
*/
authentication: string[];
/**
* assertionMethod is a list of verification methods that can be used to
* assert statements as the DID subject.
*/
assertionMethod: string[];
/**
* capabilityInvocation is a list of verification methods that can be used to
* invoke capabilities as the DID subject.
*/
capabilityInvocation: string[];
/**
* capabilityDelegation is a list of verification methods that can be used to
* delegate capabilities as the DID subject.
*/
capabilityDelegation: string[];
/**
* keyAgreement is a list of verification methods that can be used to perform
* key agreement as the DID subject.
*/
keyAgreement: string[];
/** service is a list of services that can be used to interact with the DID subject. */
service: Service[];
/** alsoKnownAs is a list of DIDs that are known to refer to the same DID subject. */
alsoKnownAs: string[];
}
/**
* VerificationMethod defines a verification method, as defined in the DID Core specification.
* Documentation: https://www.w3.org/TR/did-core/#verification-methods
*/
export interface VerificationMethod {
/**
* id is the unique identifier of the verification method.
* Format: did:cheqd:<namespace>:<unique-identifier>#<key-id>
*/
id: string;
/**
* type is the type of the verification method.
* Example: Ed25519VerificationKey2020
*/
verificationMethodType: string;
/**
* controller is the DID of the controller of the verification method.
* Format: did:cheqd:<namespace>:<unique-identifier>
*/
controller: string;
/**
* verification_material is the public key of the verification method.
* Commonly used verification material types: publicJwk, publicKeyBase58, publicKeyMultibase
*/
verificationMaterial: string;
}
/**
* Service defines a service, as defined in the DID Core specification.
* Documentation: https://www.w3.org/TR/did-core/#services
*/
export interface Service {
/**
* id is the unique identifier of the service.
* Format: did:cheqd:<namespace>:<unique-identifier>#<service-id>
*/
id: string;
/**
* type is the type of the service.
* Example: LinkedResource
*/
serviceType: string;
/**
* serviceEndpoint is the endpoint of the service.
* Example: https://example.com/endpoint
*/
serviceEndpoint: string[];
/**
* recipient key identify the recipient’s public encryption keys
* Format: did:cheqd:<namespace>:<unique-identifier>#<key-id> or did:key:<identifier>
*/
recipientKeys: string[];
/**
* routing keys contain a list of mediator or relay keys
* Format: did:cheqd:<namespace>:<unique-identifier>#<key-id> or did:key:<identifier>
*/
routingKeys: string[];
/**
* accept: list of MIME types or protocol formats the service supports.
* format: ["didcomm/v2", "didcomm/v1"]
*/
accept: string[];
/** priority: An integer defining the priority of this service entry. */
priority: number;
}
/**
* DidDocWithMetadata defines a DID Document with metadata, as defined in the DID Core specification.
* Contains the DID Document, as well as DID Document metadata.
*/
export interface DidDocWithMetadata {
/** didDocument is the DID Document. */
didDoc:
| DidDoc
| undefined;
/** didDocumentMetadata is the DID Document metadata. */
metadata: Metadata | undefined;
}
/**
* Metadata defines DID Document metadata, as defined in the DID Core specification.
* Documentation: https://www.w3.org/TR/did-core/#did-document-metadata-properties
*/
export interface Metadata {
/**
* created is the timestamp of the creation of the DID Document.
* Format: RFC3339
* Example: 2021-03-10T15:16:17Z
*/
created:
| Date
| undefined;
/**
* updated is the timestamp of the last update of the DID Document.
* Format: RFC3339
* Example: 2021-03-10T15:16:17Z
*/
updated:
| Date
| undefined;
/**
* deactivated is a flag that indicates whether the DID Document is deactivated.
* Default: false
*/
deactivated: boolean;
/**
* version_id is the version identifier of the DID Document.
* Format: UUID
* Example: 123e4567-e89b-12d3-a456-426655440000
*/
versionId: string;
/**
* next_version_id is the version identifier of the next version of the DID Document.
* Format: UUID
* Example: 123e4567-e89b-12d3-a456-426655440000
*/
nextVersionId: string;
/**
* previous_version_id is the version identifier of the previous version of the DID Document.
* Format: UUID
* Example: 123e4567-e89b-12d3-a456-426655440000
*/
previousVersionId: string;
}
function createBaseDidDoc(): DidDoc {
return {
context: [],
id: "",
controller: [],
verificationMethod: [],
authentication: [],
assertionMethod: [],
capabilityInvocation: [],
capabilityDelegation: [],
keyAgreement: [],
service: [],
alsoKnownAs: [],
};
}
export const DidDoc: MessageFns<DidDoc> = {
encode(message: DidDoc, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
for (const v of message.context) {
writer.uint32(10).string(v!);
}
if (message.id !== "") {
writer.uint32(18).string(message.id);
}
for (const v of message.controller) {
writer.uint32(26).string(v!);
}
for (const v of message.verificationMethod) {
VerificationMethod.encode(v!, writer.uint32(34).fork()).join();
}
for (const v of message.authentication) {
writer.uint32(42).string(v!);
}
for (const v of message.assertionMethod) {
writer.uint32(50).string(v!);
}
for (const v of message.capabilityInvocation) {
writer.uint32(58).string(v!);
}
for (const v of message.capabilityDelegation) {
writer.uint32(66).string(v!);
}
for (const v of message.keyAgreement) {
writer.uint32(74).string(v!);
}
for (const v of message.service) {
Service.encode(v!, writer.uint32(82).fork()).join();
}
for (const v of message.alsoKnownAs) {
writer.uint32(90).string(v!);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): DidDoc {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDidDoc();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.context.push(reader.string());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.id = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.controller.push(reader.string());
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.verificationMethod.push(VerificationMethod.decode(reader, reader.uint32()));
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.authentication.push(reader.string());
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.assertionMethod.push(reader.string());
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.capabilityInvocation.push(reader.string());
continue;
}
case 8: {
if (tag !== 66) {
break;
}
message.capabilityDelegation.push(reader.string());
continue;
}
case 9: {
if (tag !== 74) {
break;
}
message.keyAgreement.push(reader.string());
continue;
}
case 10: {
if (tag !== 82) {
break;
}
message.service.push(Service.decode(reader, reader.uint32()));
continue;
}
case 11: {
if (tag !== 90) {
break;
}
message.alsoKnownAs.push(reader.string());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): DidDoc {
return {
context: globalThis.Array.isArray(object?.context) ? object.context.map((e: any) => globalThis.String(e)) : [],
id: isSet(object.id) ? globalThis.String(object.id) : "",
controller: globalThis.Array.isArray(object?.controller)
? object.controller.map((e: any) => globalThis.String(e))
: [],
verificationMethod: globalThis.Array.isArray(object?.verificationMethod)
? object.verificationMethod.map((e: any) => VerificationMethod.fromJSON(e))
: [],
authentication: globalThis.Array.isArray(object?.authentication)
? object.authentication.map((e: any) => globalThis.String(e))
: [],
assertionMethod: globalThis.Array.isArray(object?.assertionMethod)
? object.assertionMethod.map((e: any) => globalThis.String(e))
: [],
capabilityInvocation: globalThis.Array.isArray(object?.capabilityInvocation)
? object.capabilityInvocation.map((e: any) => globalThis.String(e))
: [],
capabilityDelegation: globalThis.Array.isArray(object?.capabilityDelegation)
? object.capabilityDelegation.map((e: any) => globalThis.String(e))
: [],
keyAgreement: globalThis.Array.isArray(object?.keyAgreement)
? object.keyAgreement.map((e: any) => globalThis.String(e))
: [],
service: globalThis.Array.isArray(object?.service) ? object.service.map((e: any) => Service.fromJSON(e)) : [],
alsoKnownAs: globalThis.Array.isArray(object?.alsoKnownAs)
? object.alsoKnownAs.map((e: any) => globalThis.String(e))
: [],
};
},
toJSON(message: DidDoc): unknown {
const obj: any = {};
if (message.context?.length) {
obj.context = message.context;
}
if (message.id !== "") {
obj.id = message.id;
}
if (message.controller?.length) {
obj.controller = message.controller;
}
if (message.verificationMethod?.length) {
obj.verificationMethod = message.verificationMethod.map((e) => VerificationMethod.toJSON(e));
}
if (message.authentication?.length) {
obj.authentication = message.authentication;
}
if (message.assertionMethod?.length) {
obj.assertionMethod = message.assertionMethod;
}
if (message.capabilityInvocation?.length) {
obj.capabilityInvocation = message.capabilityInvocation;
}
if (message.capabilityDelegation?.length) {
obj.capabilityDelegation = message.capabilityDelegation;
}
if (message.keyAgreement?.length) {
obj.keyAgreement = message.keyAgreement;
}
if (message.service?.length) {
obj.service = message.service.map((e) => Service.toJSON(e));
}
if (message.alsoKnownAs?.length) {
obj.alsoKnownAs = message.alsoKnownAs;
}
return obj;
},
create<I extends Exact<DeepPartial<DidDoc>, I>>(base?: I): DidDoc {
return DidDoc.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<DidDoc>, I>>(object: I): DidDoc {
const message = createBaseDidDoc();
message.context = object.context?.map((e) => e) || [];
message.id = object.id ?? "";
message.controller = object.controller?.map((e) => e) || [];
message.verificationMethod = object.verificationMethod?.map((e) => VerificationMethod.fromPartial(e)) || [];
message.authentication = object.authentication?.map((e) => e) || [];
message.assertionMethod = object.assertionMethod?.map((e) => e) || [];
message.capabilityInvocation = object.capabilityInvocation?.map((e) => e) || [];
message.capabilityDelegation = object.capabilityDelegation?.map((e) => e) || [];
message.keyAgreement = object.keyAgreement?.map((e) => e) || [];
message.service = object.service?.map((e) => Service.fromPartial(e)) || [];
message.alsoKnownAs = object.alsoKnownAs?.map((e) => e) || [];
return message;
},
};
function createBaseVerificationMethod(): VerificationMethod {
return { id: "", verificationMethodType: "", controller: "", verificationMaterial: "" };
}
export const VerificationMethod: MessageFns<VerificationMethod> = {
encode(message: VerificationMethod, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.verificationMethodType !== "") {
writer.uint32(18).string(message.verificationMethodType);
}
if (message.controller !== "") {
writer.uint32(26).string(message.controller);
}
if (message.verificationMaterial !== "") {
writer.uint32(34).string(message.verificationMaterial);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): VerificationMethod {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseVerificationMethod();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.verificationMethodType = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.controller = reader.string();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.verificationMaterial = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): VerificationMethod {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
verificationMethodType: isSet(object.verificationMethodType)
? globalThis.String(object.verificationMethodType)
: "",
controller: isSet(object.controller) ? globalThis.String(object.controller) : "",
verificationMaterial: isSet(object.verificationMaterial) ? globalThis.String(object.verificationMaterial) : "",
};
},
toJSON(message: VerificationMethod): unknown {
const obj: any = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.verificationMethodType !== "") {
obj.verificationMethodType = message.verificationMethodType;
}
if (message.controller !== "") {
obj.controller = message.controller;
}
if (message.verificationMaterial !== "") {
obj.verificationMaterial = message.verificationMaterial;
}
return obj;
},
create<I extends Exact<DeepPartial<VerificationMethod>, I>>(base?: I): VerificationMethod {
return VerificationMethod.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<VerificationMethod>, I>>(object: I): VerificationMethod {
const message = createBaseVerificationMethod();
message.id = object.id ?? "";
message.verificationMethodType = object.verificationMethodType ?? "";
message.controller = object.controller ?? "";
message.verificationMaterial = object.verificationMaterial ?? "";
return message;
},
};
function createBaseService(): Service {
return { id: "", serviceType: "", serviceEndpoint: [], recipientKeys: [], routingKeys: [], accept: [], priority: 0 };
}
export const Service: MessageFns<Service> = {
encode(message: Service, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.serviceType !== "") {
writer.uint32(18).string(message.serviceType);
}
for (const v of message.serviceEndpoint) {
writer.uint32(26).string(v!);
}
for (const v of message.recipientKeys) {
writer.uint32(34).string(v!);
}
for (const v of message.routingKeys) {
writer.uint32(42).string(v!);
}
for (const v of message.accept) {
writer.uint32(50).string(v!);
}
if (message.priority !== 0) {
writer.uint32(56).uint32(message.priority);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Service {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseService();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.serviceType = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.serviceEndpoint.push(reader.string());
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.recipientKeys.push(reader.string());
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.routingKeys.push(reader.string());
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.accept.push(reader.string());
continue;
}
case 7: {
if (tag !== 56) {
break;
}
message.priority = reader.uint32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Service {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
serviceType: isSet(object.serviceType) ? globalThis.String(object.serviceType) : "",
serviceEndpoint: globalThis.Array.isArray(object?.serviceEndpoint)
? object.serviceEndpoint.map((e: any) => globalThis.String(e))
: [],
recipientKeys: globalThis.Array.isArray(object?.recipientKeys)
? object.recipientKeys.map((e: any) => globalThis.String(e))
: [],
routingKeys: globalThis.Array.isArray(object?.routingKeys)
? object.routingKeys.map((e: any) => globalThis.String(e))
: [],
accept: globalThis.Array.isArray(object?.accept) ? object.accept.map((e: any) => globalThis.String(e)) : [],
priority: isSet(object.priority) ? globalThis.Number(object.priority) : 0,
};
},
toJSON(message: Service): unknown {
const obj: any = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.serviceType !== "") {
obj.serviceType = message.serviceType;
}
if (message.serviceEndpoint?.length) {
obj.serviceEndpoint = message.serviceEndpoint;
}
if (message.recipientKeys?.length) {
obj.recipientKeys = message.recipientKeys;
}
if (message.routingKeys?.length) {
obj.routingKeys = message.routingKeys;
}
if (message.accept?.length) {
obj.accept = message.accept;
}
if (message.priority !== 0) {
obj.priority = Math.round(message.priority);
}
return obj;
},
create<I extends Exact<DeepPartial<Service>, I>>(base?: I): Service {
return Service.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Service>, I>>(object: I): Service {
const message = createBaseService();
message.id = object.id ?? "";
message.serviceType = object.serviceType ?? "";
message.serviceEndpoint = object.serviceEndpoint?.map((e) => e) || [];
message.recipientKeys = object.recipientKeys?.map((e) => e) || [];
message.routingKeys = object.routingKeys?.map((e) => e) || [];
message.accept = object.accept?.map((e) => e) || [];
message.priority = object.priority ?? 0;
return message;
},
};
function createBaseDidDocWithMetadata(): DidDocWithMetadata {
return { didDoc: undefined, metadata: undefined };
}
export const DidDocWithMetadata: MessageFns<DidDocWithMetadata> = {
encode(message: DidDocWithMetadata, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.didDoc !== undefined) {
DidDoc.encode(message.didDoc, writer.uint32(10).fork()).join();
}
if (message.metadata !== undefined) {
Metadata.encode(message.metadata, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): DidDocWithMetadata {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDidDocWithMetadata();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.didDoc = DidDoc.decode(reader, reader.uint32());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.metadata = Metadata.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): DidDocWithMetadata {
return {
didDoc: isSet(object.didDoc) ? DidDoc.fromJSON(object.didDoc) : undefined,
metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined,
};
},
toJSON(message: DidDocWithMetadata): unknown {
const obj: any = {};
if (message.didDoc !== undefined) {
obj.didDoc = DidDoc.toJSON(message.didDoc);
}
if (message.metadata !== undefined) {
obj.metadata = Metadata.toJSON(message.metadata);
}
return obj;
},
create<I extends Exact<DeepPartial<DidDocWithMetadata>, I>>(base?: I): DidDocWithMetadata {
return DidDocWithMetadata.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<DidDocWithMetadata>, I>>(object: I): DidDocWithMetadata {
const message = createBaseDidDocWithMetadata();
message.didDoc = (object.didDoc !== undefined && object.didDoc !== null)
? DidDoc.fromPartial(object.didDoc)
: undefined;
message.metadata = (object.metadata !== undefined && object.metadata !== null)
? Metadata.fromPartial(object.metadata)
: undefined;
return message;
},
};
function createBaseMetadata(): Metadata {
return {
created: undefined,
updated: undefined,
deactivated: false,
versionId: "",
nextVersionId: "",
previousVersionId: "",
};
}
export const Metadata: MessageFns<Metadata> = {
encode(message: Metadata, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.created !== undefined) {
Timestamp.encode(toTimestamp(message.created), writer.uint32(10).fork()).join();
}
if (message.updated !== undefined) {
Timestamp.encode(toTimestamp(message.updated), writer.uint32(18).fork()).join();
}
if (message.deactivated !== false) {
writer.uint32(24).bool(message.deactivated);
}
if (message.versionId !== "") {
writer.uint32(34).string(message.versionId);
}
if (message.nextVersionId !== "") {
writer.uint32(42).string(message.nextVersionId);
}
if (message.previousVersionId !== "") {
writer.uint32(50).string(message.previousVersionId);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Metadata {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMetadata();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.created = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.updated = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
case 3: {
if (tag !== 24) {
break;
}
message.deactivated = reader.bool();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.versionId = reader.string();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.nextVersionId = reader.string();
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.previousVersionId = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Metadata {
return {
created: isSet(object.created) ? fromJsonTimestamp(object.created) : undefined,
updated: isSet(object.updated) ? fromJsonTimestamp(object.updated) : undefined,
deactivated: isSet(object.deactivated) ? globalThis.Boolean(object.deactivated) : false,
versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : "",
nextVersionId: isSet(object.nextVersionId) ? globalThis.String(object.nextVersionId) : "",
previousVersionId: isSet(object.previousVersionId) ? globalThis.String(object.previousVersionId) : "",
};
},
toJSON(message: Metadata): unknown {
const obj: any = {};
if (message.created !== undefined) {
obj.created = message.created.toISOString();
}
if (message.updated !== undefined) {
obj.updated = message.updated.toISOString();
}
if (message.deactivated !== false) {
obj.deactivated = message.deactivated;
}
if (message.versionId !== "") {
obj.versionId = message.versionId;
}
if (message.nextVersionId !== "") {
obj.nextVersionId = message.nextVersionId;
}
if (message.previousVersionId !== "") {
obj.previousVersionId = message.previousVersionId;
}
return obj;
},
create<I extends Exact<DeepPartial<Metadata>, I>>(base?: I): Metadata {
return Metadata.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Metadata>, I>>(object: I): Metadata {
const message = createBaseMetadata();
message.created = object.created ?? undefined;
message.updated = object.updated ?? undefined;
message.deactivated = object.deactivated ?? false;
message.versionId = object.versionId ?? "";
message.nextVersionId = object.nextVersionId ?? "";
message.previousVersionId = object.previousVersionId ?? "";
return message;
},
};
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 toTimestamp(date: Date): Timestamp {
const seconds = BigInt(Math.trunc(date.getTime() / 1_000));
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
function fromTimestamp(t: Timestamp): Date {
let millis = (globalThis.Number(t.seconds.toString()) || 0) * 1_000;
millis += (t.nanos || 0) / 1_000_000;
return new globalThis.Date(millis);
}
function fromJsonTimestamp(o: any): Date {
if (o instanceof globalThis.Date) {
return o;
} else if (typeof o === "string") {
return new globalThis.Date(o);
} else {
return fromTimestamp(Timestamp.fromJSON(o));
}
}
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;
}