@getanthill/datastore
Version:
Event-Sourced Datastore
106 lines • 3.17 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.properties = void 0;
const c = __importStar(require("../../../constants"));
const MODEL_DATABASE = 'datastore';
const MODEL_NAME = 'attributes';
const MODEL_DESCRIPTION = 'ABAC authorization attribute';
const CORRELATION_FIELD = 'attribute_id';
const is_enabled = c.COMPONENTS.is_enabled;
const name = {
...c.COMPONENT_TAG_SNAKECASE,
description: 'Attribute name',
};
const value = {
description: 'Value associated to the attribute',
anyOf: [
{ type: 'boolean' },
{ type: 'number' },
{ type: 'string' },
{ type: 'object' },
{ type: 'array' },
],
};
const description = {
...c.COMPONENT_STRING,
description: 'Description of this conversation',
};
const scope = {
...c.COMPONENT_TAGS_SNAKECASE,
description: 'Scope of the attribute',
minItems: 1,
};
exports.properties = {
is_enabled,
scope,
name,
value,
description,
};
const modelConfig = {
is_enabled: true,
db: MODEL_DATABASE,
name: MODEL_NAME,
description: MODEL_DESCRIPTION,
correlation_field: CORRELATION_FIELD,
schema: {
model: {
properties: exports.properties,
},
events: {
[c.EVENT_TYPE_CREATED]: {
'0_0_0': {
required: ['scope', 'name', 'value'],
properties: exports.properties,
},
},
[c.EVENT_TYPE_UPDATED]: {
'0_0_0': {
properties: {
is_enabled,
value,
},
},
},
[c.EVENT_TYPE_RESTORED]: {
'0_0_0': {
properties: exports.properties,
},
},
},
},
indexes: [
{
collection: MODEL_NAME,
fields: { scope: 1, name: 1 },
opts: {
name: 'scope_1_name_1',
},
},
],
};
exports.default = modelConfig;
//# sourceMappingURL=attributes.js.map