@zitadel/node
Version:
Library for API access to ZITADEL. Provides compiled gRPC service clients and helpers for applications and service accounts.
309 lines (308 loc) • 11 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.7.5
// protoc unknown
// source: zitadel/analytics/v2beta/telemetry.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import Long from "long";
import { Timestamp } from "../../../google/protobuf/timestamp.js";
export const protobufPackage = "zitadel.analytics.v2beta";
export var CountParentType;
(function (CountParentType) {
CountParentType[CountParentType["COUNT_PARENT_TYPE_UNSPECIFIED"] = 0] = "COUNT_PARENT_TYPE_UNSPECIFIED";
CountParentType[CountParentType["COUNT_PARENT_TYPE_INSTANCE"] = 1] = "COUNT_PARENT_TYPE_INSTANCE";
CountParentType[CountParentType["COUNT_PARENT_TYPE_ORGANIZATION"] = 2] = "COUNT_PARENT_TYPE_ORGANIZATION";
CountParentType[CountParentType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CountParentType || (CountParentType = {}));
export function countParentTypeFromJSON(object) {
switch (object) {
case 0:
case "COUNT_PARENT_TYPE_UNSPECIFIED":
return CountParentType.COUNT_PARENT_TYPE_UNSPECIFIED;
case 1:
case "COUNT_PARENT_TYPE_INSTANCE":
return CountParentType.COUNT_PARENT_TYPE_INSTANCE;
case 2:
case "COUNT_PARENT_TYPE_ORGANIZATION":
return CountParentType.COUNT_PARENT_TYPE_ORGANIZATION;
case -1:
case "UNRECOGNIZED":
default:
return CountParentType.UNRECOGNIZED;
}
}
export function countParentTypeToJSON(object) {
switch (object) {
case CountParentType.COUNT_PARENT_TYPE_UNSPECIFIED:
return "COUNT_PARENT_TYPE_UNSPECIFIED";
case CountParentType.COUNT_PARENT_TYPE_INSTANCE:
return "COUNT_PARENT_TYPE_INSTANCE";
case CountParentType.COUNT_PARENT_TYPE_ORGANIZATION:
return "COUNT_PARENT_TYPE_ORGANIZATION";
case CountParentType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseInstanceInformation() {
return { id: "", domains: [], createdAt: undefined };
}
export const InstanceInformation = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
for (const v of message.domains) {
writer.uint32(18).string(v);
}
if (message.createdAt !== undefined) {
Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseInstanceInformation();
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.domains.push(reader.string());
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
domains: globalThis.Array.isArray(object?.domains) ? object.domains.map((e) => globalThis.String(e)) : [],
createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.domains?.length) {
obj.domains = message.domains;
}
if (message.createdAt !== undefined) {
obj.createdAt = message.createdAt.toISOString();
}
return obj;
},
create(base) {
return InstanceInformation.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseInstanceInformation();
message.id = object.id ?? "";
message.domains = object.domains?.map((e) => e) || [];
message.createdAt = object.createdAt ?? undefined;
return message;
},
};
function createBaseResourceCount() {
return {
instanceId: "",
parentType: 0,
parentId: "",
resourceName: "",
tableName: "",
updatedAt: undefined,
amount: 0,
};
}
export const ResourceCount = {
encode(message, writer = new BinaryWriter()) {
if (message.instanceId !== "") {
writer.uint32(26).string(message.instanceId);
}
if (message.parentType !== 0) {
writer.uint32(32).int32(message.parentType);
}
if (message.parentId !== "") {
writer.uint32(42).string(message.parentId);
}
if (message.resourceName !== "") {
writer.uint32(50).string(message.resourceName);
}
if (message.tableName !== "") {
writer.uint32(58).string(message.tableName);
}
if (message.updatedAt !== undefined) {
Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(66).fork()).join();
}
if (message.amount !== 0) {
writer.uint32(72).uint32(message.amount);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseResourceCount();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 3: {
if (tag !== 26) {
break;
}
message.instanceId = reader.string();
continue;
}
case 4: {
if (tag !== 32) {
break;
}
message.parentType = reader.int32();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.parentId = reader.string();
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.resourceName = reader.string();
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.tableName = reader.string();
continue;
}
case 8: {
if (tag !== 66) {
break;
}
message.updatedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
case 9: {
if (tag !== 72) {
break;
}
message.amount = reader.uint32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
instanceId: isSet(object.instanceId) ? globalThis.String(object.instanceId) : "",
parentType: isSet(object.parentType) ? countParentTypeFromJSON(object.parentType) : 0,
parentId: isSet(object.parentId) ? globalThis.String(object.parentId) : "",
resourceName: isSet(object.resourceName) ? globalThis.String(object.resourceName) : "",
tableName: isSet(object.tableName) ? globalThis.String(object.tableName) : "",
updatedAt: isSet(object.updatedAt) ? fromJsonTimestamp(object.updatedAt) : undefined,
amount: isSet(object.amount) ? globalThis.Number(object.amount) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.instanceId !== "") {
obj.instanceId = message.instanceId;
}
if (message.parentType !== 0) {
obj.parentType = countParentTypeToJSON(message.parentType);
}
if (message.parentId !== "") {
obj.parentId = message.parentId;
}
if (message.resourceName !== "") {
obj.resourceName = message.resourceName;
}
if (message.tableName !== "") {
obj.tableName = message.tableName;
}
if (message.updatedAt !== undefined) {
obj.updatedAt = message.updatedAt.toISOString();
}
if (message.amount !== 0) {
obj.amount = Math.round(message.amount);
}
return obj;
},
create(base) {
return ResourceCount.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseResourceCount();
message.instanceId = object.instanceId ?? "";
message.parentType = object.parentType ?? 0;
message.parentId = object.parentId ?? "";
message.resourceName = object.resourceName ?? "";
message.tableName = object.tableName ?? "";
message.updatedAt = object.updatedAt ?? undefined;
message.amount = object.amount ?? 0;
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.fromJSON(o));
}
}
function numberToLong(number) {
return Long.fromNumber(number);
}
function isSet(value) {
return value !== null && value !== undefined;
}