@primerouting/zitadel-node
Version:
Library for API access to ZITADEL. Provides compiled gRPC service clients and helpers for applications and service accounts. Support http2 self-hosted instances
145 lines (144 loc) • 5.48 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.181.1
// protoc unknown
// source: zitadel/resources/object/v3alpha/object.proto
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Details = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timestamp_1 = require("../../../../google/protobuf/timestamp");
const object_1 = require("../../../object/v3alpha/object");
exports.protobufPackage = "zitadel.resources.object.v3alpha";
function createBaseDetails() {
return { id: "", sequence: long_1.default.UZERO, changeDate: undefined, owner: undefined };
}
exports.Details = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (!message.sequence.equals(long_1.default.UZERO)) {
writer.uint32(16).uint64(message.sequence);
}
if (message.changeDate !== undefined) {
timestamp_1.Timestamp.encode(toTimestamp(message.changeDate), writer.uint32(26).fork()).ldelim();
}
if (message.owner !== undefined) {
object_1.Owner.encode(message.owner, writer.uint32(34).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDetails();
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 !== 16) {
break;
}
message.sequence = reader.uint64();
continue;
case 3:
if (tag !== 26) {
break;
}
message.changeDate = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
continue;
case 4:
if (tag !== 34) {
break;
}
message.owner = object_1.Owner.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
sequence: isSet(object.sequence) ? long_1.default.fromValue(object.sequence) : long_1.default.UZERO,
changeDate: isSet(object.changeDate) ? fromJsonTimestamp(object.changeDate) : undefined,
owner: isSet(object.owner) ? object_1.Owner.fromJSON(object.owner) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (!message.sequence.equals(long_1.default.UZERO)) {
obj.sequence = (message.sequence || long_1.default.UZERO).toString();
}
if (message.changeDate !== undefined) {
obj.changeDate = message.changeDate.toISOString();
}
if (message.owner !== undefined) {
obj.owner = object_1.Owner.toJSON(message.owner);
}
return obj;
},
create(base) {
return exports.Details.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseDetails();
message.id = object.id ?? "";
message.sequence = (object.sequence !== undefined && object.sequence !== null)
? long_1.default.fromValue(object.sequence)
: long_1.default.UZERO;
message.changeDate = object.changeDate ?? undefined;
message.owner = (object.owner !== undefined && object.owner !== null) ? object_1.Owner.fromPartial(object.owner) : undefined;
return message;
},
};
function toTimestamp(date) {
const seconds = numberToLong(Math.trunc(date.getTime() / 1_000));
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
function fromTimestamp(t) {
let millis = (t.seconds.toNumber() || 0) * 1_000;
millis += (t.nanos || 0) / 1_000_000;
return new globalThis.Date(millis);
}
function fromJsonTimestamp(o) {
if (o instanceof globalThis.Date) {
return o;
}
else if (typeof o === "string") {
return new globalThis.Date(o);
}
else {
return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
}
}
function numberToLong(number) {
return long_1.default.fromNumber(number);
}
if (minimal_1.default.util.Long !== long_1.default) {
minimal_1.default.util.Long = long_1.default;
minimal_1.default.configure();
}
function isSet(value) {
return value !== null && value !== undefined;
}
;