UNPKG

@ragnaraven/zitadel-node-dual

Version:

Library for API access to ZITADEL with modern ES import syntax. Works everywhere - NestJS, Node.js, any TypeScript environment. No more require()!

348 lines 11.3 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var telemetry_exports = {}; __export(telemetry_exports, { CountParentType: () => CountParentType, InstanceInformation: () => InstanceInformation, ResourceCount: () => ResourceCount, countParentTypeFromJSON: () => countParentTypeFromJSON, countParentTypeToJSON: () => countParentTypeToJSON, protobufPackage: () => protobufPackage }); module.exports = __toCommonJS(telemetry_exports); var import_wire = require("@bufbuild/protobuf/wire"); var import_long = __toESM(require("long")); var import_timestamp = require("../../../google/protobuf/timestamp.js"); const protobufPackage = "zitadel.analytics.v2beta"; var CountParentType = /* @__PURE__ */ ((CountParentType2) => { CountParentType2[CountParentType2["COUNT_PARENT_TYPE_UNSPECIFIED"] = 0] = "COUNT_PARENT_TYPE_UNSPECIFIED"; CountParentType2[CountParentType2["COUNT_PARENT_TYPE_INSTANCE"] = 1] = "COUNT_PARENT_TYPE_INSTANCE"; CountParentType2[CountParentType2["COUNT_PARENT_TYPE_ORGANIZATION"] = 2] = "COUNT_PARENT_TYPE_ORGANIZATION"; CountParentType2[CountParentType2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; return CountParentType2; })(CountParentType || {}); function countParentTypeFromJSON(object) { switch (object) { case 0: case "COUNT_PARENT_TYPE_UNSPECIFIED": return 0 /* COUNT_PARENT_TYPE_UNSPECIFIED */; case 1: case "COUNT_PARENT_TYPE_INSTANCE": return 1 /* COUNT_PARENT_TYPE_INSTANCE */; case 2: case "COUNT_PARENT_TYPE_ORGANIZATION": return 2 /* COUNT_PARENT_TYPE_ORGANIZATION */; case -1: case "UNRECOGNIZED": default: return -1 /* UNRECOGNIZED */; } } function countParentTypeToJSON(object) { switch (object) { case 0 /* COUNT_PARENT_TYPE_UNSPECIFIED */: return "COUNT_PARENT_TYPE_UNSPECIFIED"; case 1 /* COUNT_PARENT_TYPE_INSTANCE */: return "COUNT_PARENT_TYPE_INSTANCE"; case 2 /* COUNT_PARENT_TYPE_ORGANIZATION */: return "COUNT_PARENT_TYPE_ORGANIZATION"; case -1 /* UNRECOGNIZED */: default: return "UNRECOGNIZED"; } } function createBaseInstanceInformation() { return { id: "", domains: [], createdAt: void 0 }; } const InstanceInformation = { encode(message, writer = new import_wire.BinaryWriter()) { if (message.id !== "") { writer.uint32(10).string(message.id); } for (const v of message.domains) { writer.uint32(18).string(v); } if (message.createdAt !== void 0) { import_timestamp.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input); const end = length === void 0 ? 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(import_timestamp.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) : void 0 }; }, toJSON(message) { const obj = {}; if (message.id !== "") { obj.id = message.id; } if (message.domains?.length) { obj.domains = message.domains; } if (message.createdAt !== void 0) { 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 ?? void 0; return message; } }; function createBaseResourceCount() { return { instanceId: "", parentType: 0, parentId: "", resourceName: "", tableName: "", updatedAt: void 0, amount: 0 }; } const ResourceCount = { encode(message, writer = new import_wire.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 !== void 0) { import_timestamp.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 import_wire.BinaryReader ? input : new import_wire.BinaryReader(input); const end = length === void 0 ? 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(import_timestamp.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) : void 0, 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 !== void 0) { 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 ?? void 0; message.amount = object.amount ?? 0; return message; } }; function toTimestamp(date) { const seconds = numberToLong(Math.trunc(date.getTime() / 1e3)); const nanos = date.getTime() % 1e3 * 1e6; return { seconds, nanos }; } function fromTimestamp(t) { let millis = (t.seconds.toNumber() || 0) * 1e3; millis += (t.nanos || 0) / 1e6; 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(import_timestamp.Timestamp.fromJSON(o)); } } function numberToLong(number) { return import_long.default.fromNumber(number); } function isSet(value) { return value !== null && value !== void 0; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CountParentType, InstanceInformation, ResourceCount, countParentTypeFromJSON, countParentTypeToJSON, protobufPackage }); //# sourceMappingURL=telemetry.js.map