UNPKG

forest-express

Version:

Official package for all Forest Express Lianas

98 lines (97 loc) 2.85 kB
"use strict"; var _require = require('@forestadmin/context'), inject = _require.inject; var _ = require('lodash'); var _require2 = require('../../utils/integrations'), pushIntoApimap = _require2.pushIntoApimap; var INTEGRATION_NAME = 'layer'; exports.createCollections = function (Implementation, apimap, collectionAndFieldName) { var _inject = inject(), modelsManager = _inject.modelsManager; // jshint camelcase: false var collectionName = collectionAndFieldName.split('.')[0]; var model = modelsManager.getModels()[collectionName]; var referenceName = "".concat(Implementation.getModelName(model), ".id"); var collectionDisplayName = _.capitalize(collectionName); pushIntoApimap(apimap, { name: "".concat(Implementation.getModelName(model), "_layer_conversations"), displayName: "".concat(collectionDisplayName, " Conversations"), icon: 'layer', integration: INTEGRATION_NAME, isVirtual: true, isReadOnly: true, onlyForRelationships: true, paginationType: 'cursor', fields: [{ field: 'id', type: 'String', isFilterable: false }, { field: 'title', type: 'String', isFilterable: false }, { field: 'createdAt', type: 'Date', isFilterable: false }, { field: 'lastMessage', type: 'String', reference: "".concat(Implementation.getModelName(model), "_layer_messages"), isFilterable: false }, { field: 'messages', type: ['String'], reference: "".concat(Implementation.getModelName(model), "_layer_messages"), isFilterable: false }, { field: 'participants', type: ['String'], reference: referenceName, isFilterable: false }] }); pushIntoApimap(apimap, { name: "".concat(Implementation.getModelName(model), "_layer_messages"), displayName: "".concat(collectionDisplayName, " Messages"), icon: 'layer', integration: INTEGRATION_NAME, onlyForRelationships: true, isVirtual: true, isReadOnly: true, paginationType: 'cursor', fields: [{ field: 'id', type: 'String', isFilterable: false }, { field: 'sender', type: 'String', isFilterable: false }, { field: 'sentAt', type: 'Date', isFilterable: false }, { field: 'content', type: 'String', isFilterable: false }, { field: 'mimeType', type: 'String', isFilterable: false }], actions: [] }); }; exports.createFields = function (Implementation, model, schemaFields) { schemaFields.push({ field: 'layer_conversations', displayName: 'Conversations', type: ['String'], reference: "".concat(Implementation.getModelName(model), "_layer_conversations.id"), column: null, isFilterable: false, integration: INTEGRATION_NAME }); };