@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
57 lines • 1.75 kB
JavaScript
;
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// source: cerbos/policy/v1/policy.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.SourceAttributes_AttributesEntry = exports.SourceAttributes = exports.protobufPackage = void 0;
/* eslint-disable */
exports.protobufPackage = "cerbos.policy.v1";
exports.SourceAttributes = {
fromJSON(object) {
return {
attributes: isObject(object.attributes)
? Object.entries(object.attributes).reduce((acc, [key, value]) => {
acc[key] = value;
return acc;
}, {})
: {},
};
},
toJSON(message) {
const obj = {};
if (message.attributes) {
const entries = Object.entries(message.attributes);
if (entries.length > 0) {
obj.attributes = {};
entries.forEach(([k, v]) => {
obj.attributes[k] = v;
});
}
}
return obj;
},
};
exports.SourceAttributes_AttributesEntry = {
fromJSON(object) {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object?.value) ? object.value : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.value !== undefined) {
obj.value = message.value;
}
return obj;
},
};
function isObject(value) {
return typeof value === "object" && value !== null;
}
function isSet(value) {
return value !== null && value !== undefined;
}
//# sourceMappingURL=policy.js.map