UNPKG

@webiny/api-security-so-ddb

Version:
181 lines (179 loc) 3.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTenantLinkEntity = exports.createTeamEntity = exports.createSystemEntity = exports.createGroupEntity = exports.createApiKeyEntity = void 0; var _toolbox = require("@webiny/db-dynamodb/toolbox"); var _types = require("../types"); const createEntity = (entityName, table, attributes) => { return new _toolbox.Entity({ table, name: entityName, attributes: { PK: { partitionKey: true }, SK: { sortKey: true }, GSI1_PK: { type: "string" }, GSI1_SK: { type: "string" }, TYPE: { type: "string" }, ...(attributes || {}) } }); }; const createGroupEntity = (table, attributes = {}) => { return createEntity(_types.ENTITIES.GROUP, table, { id: { type: "string" }, tenant: { type: "string" }, system: { type: "boolean" }, createdBy: { type: "map" }, createdOn: { type: "string" }, name: { type: "string" }, slug: { type: "string" }, description: { type: "string" }, permissions: { type: "list" }, webinyVersion: { type: "string" }, ...attributes }); }; exports.createGroupEntity = createGroupEntity; const createTeamEntity = (table, attributes = {}) => { return createEntity(_types.ENTITIES.TEAM, table, { id: { type: "string" }, tenant: { type: "string" }, system: { type: "boolean" }, createdBy: { type: "map" }, createdOn: { type: "string" }, name: { type: "string" }, slug: { type: "string" }, description: { type: "string" }, groups: { type: "list" }, webinyVersion: { type: "string" }, ...attributes }); }; exports.createTeamEntity = createTeamEntity; const createApiKeyEntity = (table, attributes = {}) => { return createEntity(_types.ENTITIES.API_KEY, table, { id: { type: "string" }, token: { type: "string" }, tenant: { type: "string" }, createdBy: { type: "map" }, createdOn: { type: "string" }, name: { type: "string" }, description: { type: "string" }, permissions: { type: "list" }, webinyVersion: { type: "string" }, ...attributes }); }; exports.createApiKeyEntity = createApiKeyEntity; const createSystemEntity = (table, attributes = {}) => { return createEntity(_types.ENTITIES.SYSTEM, table, { tenant: { type: "string" }, version: { type: "string" }, installedOn: { type: "string" }, createdOn: { type: "string" }, ...attributes }); }; exports.createSystemEntity = createSystemEntity; const createTenantLinkEntity = (table, attributes = {}) => { return createEntity(_types.ENTITIES.TENANT_LINK, table, { createdOn: { type: "string" }, identity: { type: "string" }, tenant: { type: "string" }, type: { type: "string" }, data: { type: "map" }, webinyVersion: { type: "string" }, ...attributes }); }; exports.createTenantLinkEntity = createTenantLinkEntity; //# sourceMappingURL=entities.js.map