UNPKG

@cerbos/embedded

Version:

Client library for interacting with embedded Cerbos policy decision points generated by Cerbos Hub from server-side Node.js and browser-based applications

661 lines 24.3 kB
"use strict"; // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // source: cerbos/response/v1/response.proto Object.defineProperty(exports, "__esModule", { value: true }); exports.ServerInfoResponse = exports.CheckResourcesResponse_ResultEntry_ActionsEntry = exports.CheckResourcesResponse_ResultEntry_Meta_ActionsEntry = exports.CheckResourcesResponse_ResultEntry_Meta_EffectMeta = exports.CheckResourcesResponse_ResultEntry_Meta = exports.CheckResourcesResponse_ResultEntry_Resource = exports.CheckResourcesResponse_ResultEntry = exports.CheckResourcesResponse = exports.CheckResourceBatchResponse_ActionEffectMap_ActionsEntry = exports.CheckResourceBatchResponse_ActionEffectMap = exports.CheckResourceBatchResponse = exports.CheckResourceSetResponse_ResourceInstancesEntry = exports.CheckResourceSetResponse_Meta_ResourceInstancesEntry = exports.CheckResourceSetResponse_Meta_ActionMeta_ActionsEntry = exports.CheckResourceSetResponse_Meta_ActionMeta = exports.CheckResourceSetResponse_Meta_EffectMeta = exports.CheckResourceSetResponse_Meta = exports.CheckResourceSetResponse_ActionEffectMap_ActionsEntry = exports.CheckResourceSetResponse_ActionEffectMap = exports.CheckResourceSetResponse = exports.PlanResourcesResponse_Meta_MatchedScopesEntry = exports.PlanResourcesResponse_Meta = exports.PlanResourcesResponse = exports.protobufPackage = void 0; /* eslint-disable */ const effect_1 = require("../../effect/v1/effect"); const engine_1 = require("../../engine/v1/engine"); const schema_1 = require("../../schema/v1/schema"); exports.protobufPackage = "cerbos.response.v1"; exports.PlanResourcesResponse = { fromJSON(object) { return { requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : "", action: isSet(object.action) ? globalThis.String(object.action) : "", actions: globalThis.Array.isArray(object?.actions) ? object.actions.map((e) => globalThis.String(e)) : [], resourceKind: isSet(object.resourceKind) ? globalThis.String(object.resourceKind) : "", policyVersion: isSet(object.policyVersion) ? globalThis.String(object.policyVersion) : "", filter: isSet(object.filter) ? engine_1.PlanResourcesFilter.fromJSON(object.filter) : undefined, meta: isSet(object.meta) ? exports.PlanResourcesResponse_Meta.fromJSON(object.meta) : undefined, validationErrors: globalThis.Array.isArray(object?.validationErrors) ? object.validationErrors.map((e) => schema_1.ValidationError.fromJSON(e)) : [], cerbosCallId: isSet(object.cerbosCallId) ? globalThis.String(object.cerbosCallId) : "", }; }, toJSON(message) { const obj = {}; if (message.requestId !== "") { obj.requestId = message.requestId; } if (message.action !== "") { obj.action = message.action; } if (message.actions?.length) { obj.actions = message.actions; } if (message.resourceKind !== "") { obj.resourceKind = message.resourceKind; } if (message.policyVersion !== "") { obj.policyVersion = message.policyVersion; } if (message.filter !== undefined) { obj.filter = engine_1.PlanResourcesFilter.toJSON(message.filter); } if (message.meta !== undefined) { obj.meta = exports.PlanResourcesResponse_Meta.toJSON(message.meta); } if (message.validationErrors?.length) { obj.validationErrors = message.validationErrors.map((e) => schema_1.ValidationError.toJSON(e)); } if (message.cerbosCallId !== "") { obj.cerbosCallId = message.cerbosCallId; } return obj; }, }; exports.PlanResourcesResponse_Meta = { fromJSON(object) { return { filterDebug: isSet(object.filterDebug) ? globalThis.String(object.filterDebug) : "", matchedScope: isSet(object.matchedScope) ? globalThis.String(object.matchedScope) : "", matchedScopes: isObject(object.matchedScopes) ? Object.entries(object.matchedScopes).reduce((acc, [key, value]) => { acc[key] = String(value); return acc; }, {}) : {}, }; }, toJSON(message) { const obj = {}; if (message.filterDebug !== "") { obj.filterDebug = message.filterDebug; } if (message.matchedScope !== "") { obj.matchedScope = message.matchedScope; } if (message.matchedScopes) { const entries = Object.entries(message.matchedScopes); if (entries.length > 0) { obj.matchedScopes = {}; entries.forEach(([k, v]) => { obj.matchedScopes[k] = v; }); } } return obj; }, }; exports.PlanResourcesResponse_Meta_MatchedScopesEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? globalThis.String(object.value) : "", }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== "") { obj.value = message.value; } return obj; }, }; exports.CheckResourceSetResponse = { fromJSON(object) { return { requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : "", resourceInstances: isObject(object.resourceInstances) ? Object.entries(object.resourceInstances).reduce((acc, [key, value]) => { acc[key] = exports.CheckResourceSetResponse_ActionEffectMap.fromJSON(value); return acc; }, {}) : {}, meta: isSet(object.meta) ? exports.CheckResourceSetResponse_Meta.fromJSON(object.meta) : undefined, }; }, toJSON(message) { const obj = {}; if (message.requestId !== "") { obj.requestId = message.requestId; } if (message.resourceInstances) { const entries = Object.entries(message.resourceInstances); if (entries.length > 0) { obj.resourceInstances = {}; entries.forEach(([k, v]) => { obj.resourceInstances[k] = exports.CheckResourceSetResponse_ActionEffectMap.toJSON(v); }); } } if (message.meta !== undefined) { obj.meta = exports.CheckResourceSetResponse_Meta.toJSON(message.meta); } return obj; }, }; exports.CheckResourceSetResponse_ActionEffectMap = { fromJSON(object) { return { actions: isObject(object.actions) ? Object.entries(object.actions).reduce((acc, [key, value]) => { acc[key] = (0, effect_1.effectFromJSON)(value); return acc; }, {}) : {}, validationErrors: globalThis.Array.isArray(object?.validationErrors) ? object.validationErrors.map((e) => schema_1.ValidationError.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.actions) { const entries = Object.entries(message.actions); if (entries.length > 0) { obj.actions = {}; entries.forEach(([k, v]) => { obj.actions[k] = (0, effect_1.effectToJSON)(v); }); } } if (message.validationErrors?.length) { obj.validationErrors = message.validationErrors.map((e) => schema_1.ValidationError.toJSON(e)); } return obj; }, }; exports.CheckResourceSetResponse_ActionEffectMap_ActionsEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? (0, effect_1.effectFromJSON)(object.value) : 0, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== 0) { obj.value = (0, effect_1.effectToJSON)(message.value); } return obj; }, }; exports.CheckResourceSetResponse_Meta = { fromJSON(object) { return { resourceInstances: isObject(object.resourceInstances) ? Object.entries(object.resourceInstances).reduce((acc, [key, value]) => { acc[key] = exports.CheckResourceSetResponse_Meta_ActionMeta.fromJSON(value); return acc; }, {}) : {}, }; }, toJSON(message) { const obj = {}; if (message.resourceInstances) { const entries = Object.entries(message.resourceInstances); if (entries.length > 0) { obj.resourceInstances = {}; entries.forEach(([k, v]) => { obj.resourceInstances[k] = exports.CheckResourceSetResponse_Meta_ActionMeta.toJSON(v); }); } } return obj; }, }; exports.CheckResourceSetResponse_Meta_EffectMeta = { fromJSON(object) { return { matchedPolicy: isSet(object.matchedPolicy) ? globalThis.String(object.matchedPolicy) : "", matchedScope: isSet(object.matchedScope) ? globalThis.String(object.matchedScope) : "", }; }, toJSON(message) { const obj = {}; if (message.matchedPolicy !== "") { obj.matchedPolicy = message.matchedPolicy; } if (message.matchedScope !== "") { obj.matchedScope = message.matchedScope; } return obj; }, }; exports.CheckResourceSetResponse_Meta_ActionMeta = { fromJSON(object) { return { actions: isObject(object.actions) ? Object.entries(object.actions).reduce((acc, [key, value]) => { acc[key] = exports.CheckResourceSetResponse_Meta_EffectMeta.fromJSON(value); return acc; }, {}) : {}, effectiveDerivedRoles: globalThis.Array.isArray(object?.effectiveDerivedRoles) ? object.effectiveDerivedRoles.map((e) => globalThis.String(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.actions) { const entries = Object.entries(message.actions); if (entries.length > 0) { obj.actions = {}; entries.forEach(([k, v]) => { obj.actions[k] = exports.CheckResourceSetResponse_Meta_EffectMeta.toJSON(v); }); } } if (message.effectiveDerivedRoles?.length) { obj.effectiveDerivedRoles = message.effectiveDerivedRoles; } return obj; }, }; exports.CheckResourceSetResponse_Meta_ActionMeta_ActionsEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? exports.CheckResourceSetResponse_Meta_EffectMeta.fromJSON(object.value) : undefined, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== undefined) { obj.value = exports.CheckResourceSetResponse_Meta_EffectMeta.toJSON(message.value); } return obj; }, }; exports.CheckResourceSetResponse_Meta_ResourceInstancesEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? exports.CheckResourceSetResponse_Meta_ActionMeta.fromJSON(object.value) : undefined, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== undefined) { obj.value = exports.CheckResourceSetResponse_Meta_ActionMeta.toJSON(message.value); } return obj; }, }; exports.CheckResourceSetResponse_ResourceInstancesEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? exports.CheckResourceSetResponse_ActionEffectMap.fromJSON(object.value) : undefined, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== undefined) { obj.value = exports.CheckResourceSetResponse_ActionEffectMap.toJSON(message.value); } return obj; }, }; exports.CheckResourceBatchResponse = { fromJSON(object) { return { requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : "", results: globalThis.Array.isArray(object?.results) ? object.results.map((e) => exports.CheckResourceBatchResponse_ActionEffectMap.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.requestId !== "") { obj.requestId = message.requestId; } if (message.results?.length) { obj.results = message.results.map((e) => exports.CheckResourceBatchResponse_ActionEffectMap.toJSON(e)); } return obj; }, }; exports.CheckResourceBatchResponse_ActionEffectMap = { fromJSON(object) { return { resourceId: isSet(object.resourceId) ? globalThis.String(object.resourceId) : "", actions: isObject(object.actions) ? Object.entries(object.actions).reduce((acc, [key, value]) => { acc[key] = (0, effect_1.effectFromJSON)(value); return acc; }, {}) : {}, validationErrors: globalThis.Array.isArray(object?.validationErrors) ? object.validationErrors.map((e) => schema_1.ValidationError.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.resourceId !== "") { obj.resourceId = message.resourceId; } if (message.actions) { const entries = Object.entries(message.actions); if (entries.length > 0) { obj.actions = {}; entries.forEach(([k, v]) => { obj.actions[k] = (0, effect_1.effectToJSON)(v); }); } } if (message.validationErrors?.length) { obj.validationErrors = message.validationErrors.map((e) => schema_1.ValidationError.toJSON(e)); } return obj; }, }; exports.CheckResourceBatchResponse_ActionEffectMap_ActionsEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? (0, effect_1.effectFromJSON)(object.value) : 0, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== 0) { obj.value = (0, effect_1.effectToJSON)(message.value); } return obj; }, }; exports.CheckResourcesResponse = { fromJSON(object) { return { requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : "", results: globalThis.Array.isArray(object?.results) ? object.results.map((e) => exports.CheckResourcesResponse_ResultEntry.fromJSON(e)) : [], cerbosCallId: isSet(object.cerbosCallId) ? globalThis.String(object.cerbosCallId) : "", }; }, toJSON(message) { const obj = {}; if (message.requestId !== "") { obj.requestId = message.requestId; } if (message.results?.length) { obj.results = message.results.map((e) => exports.CheckResourcesResponse_ResultEntry.toJSON(e)); } if (message.cerbosCallId !== "") { obj.cerbosCallId = message.cerbosCallId; } return obj; }, }; exports.CheckResourcesResponse_ResultEntry = { fromJSON(object) { return { resource: isSet(object.resource) ? exports.CheckResourcesResponse_ResultEntry_Resource.fromJSON(object.resource) : undefined, actions: isObject(object.actions) ? Object.entries(object.actions).reduce((acc, [key, value]) => { acc[key] = (0, effect_1.effectFromJSON)(value); return acc; }, {}) : {}, validationErrors: globalThis.Array.isArray(object?.validationErrors) ? object.validationErrors.map((e) => schema_1.ValidationError.fromJSON(e)) : [], meta: isSet(object.meta) ? exports.CheckResourcesResponse_ResultEntry_Meta.fromJSON(object.meta) : undefined, outputs: globalThis.Array.isArray(object?.outputs) ? object.outputs.map((e) => engine_1.OutputEntry.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.resource !== undefined) { obj.resource = exports.CheckResourcesResponse_ResultEntry_Resource.toJSON(message.resource); } if (message.actions) { const entries = Object.entries(message.actions); if (entries.length > 0) { obj.actions = {}; entries.forEach(([k, v]) => { obj.actions[k] = (0, effect_1.effectToJSON)(v); }); } } if (message.validationErrors?.length) { obj.validationErrors = message.validationErrors.map((e) => schema_1.ValidationError.toJSON(e)); } if (message.meta !== undefined) { obj.meta = exports.CheckResourcesResponse_ResultEntry_Meta.toJSON(message.meta); } if (message.outputs?.length) { obj.outputs = message.outputs.map((e) => engine_1.OutputEntry.toJSON(e)); } return obj; }, }; exports.CheckResourcesResponse_ResultEntry_Resource = { fromJSON(object) { return { id: isSet(object.id) ? globalThis.String(object.id) : "", kind: isSet(object.kind) ? globalThis.String(object.kind) : "", policyVersion: isSet(object.policyVersion) ? globalThis.String(object.policyVersion) : "", scope: isSet(object.scope) ? globalThis.String(object.scope) : "", }; }, toJSON(message) { const obj = {}; if (message.id !== "") { obj.id = message.id; } if (message.kind !== "") { obj.kind = message.kind; } if (message.policyVersion !== "") { obj.policyVersion = message.policyVersion; } if (message.scope !== "") { obj.scope = message.scope; } return obj; }, }; exports.CheckResourcesResponse_ResultEntry_Meta = { fromJSON(object) { return { actions: isObject(object.actions) ? Object.entries(object.actions).reduce((acc, [key, value]) => { acc[key] = exports.CheckResourcesResponse_ResultEntry_Meta_EffectMeta.fromJSON(value); return acc; }, {}) : {}, effectiveDerivedRoles: globalThis.Array.isArray(object?.effectiveDerivedRoles) ? object.effectiveDerivedRoles.map((e) => globalThis.String(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.actions) { const entries = Object.entries(message.actions); if (entries.length > 0) { obj.actions = {}; entries.forEach(([k, v]) => { obj.actions[k] = exports.CheckResourcesResponse_ResultEntry_Meta_EffectMeta.toJSON(v); }); } } if (message.effectiveDerivedRoles?.length) { obj.effectiveDerivedRoles = message.effectiveDerivedRoles; } return obj; }, }; exports.CheckResourcesResponse_ResultEntry_Meta_EffectMeta = { fromJSON(object) { return { matchedPolicy: isSet(object.matchedPolicy) ? globalThis.String(object.matchedPolicy) : "", matchedScope: isSet(object.matchedScope) ? globalThis.String(object.matchedScope) : "", }; }, toJSON(message) { const obj = {}; if (message.matchedPolicy !== "") { obj.matchedPolicy = message.matchedPolicy; } if (message.matchedScope !== "") { obj.matchedScope = message.matchedScope; } return obj; }, }; exports.CheckResourcesResponse_ResultEntry_Meta_ActionsEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? exports.CheckResourcesResponse_ResultEntry_Meta_EffectMeta.fromJSON(object.value) : undefined, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== undefined) { obj.value = exports.CheckResourcesResponse_ResultEntry_Meta_EffectMeta.toJSON(message.value); } return obj; }, }; exports.CheckResourcesResponse_ResultEntry_ActionsEntry = { fromJSON(object) { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? (0, effect_1.effectFromJSON)(object.value) : 0, }; }, toJSON(message) { const obj = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== 0) { obj.value = (0, effect_1.effectToJSON)(message.value); } return obj; }, }; exports.ServerInfoResponse = { fromJSON(object) { return { version: isSet(object.version) ? globalThis.String(object.version) : "", commit: isSet(object.commit) ? globalThis.String(object.commit) : "", buildDate: isSet(object.buildDate) ? globalThis.String(object.buildDate) : "", }; }, toJSON(message) { const obj = {}; if (message.version !== "") { obj.version = message.version; } if (message.commit !== "") { obj.commit = message.commit; } if (message.buildDate !== "") { obj.buildDate = message.buildDate; } return obj; }, }; function isObject(value) { return typeof value === "object" && value !== null; } function isSet(value) { return value !== null && value !== undefined; } //# sourceMappingURL=response.js.map