UNPKG

forest-express

Version:

Official package for all Forest Express Lianas

142 lines (141 loc) 3.59 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 = 'intercom'; exports.createCollections = function (Implementation, apimap, collectionName) { var _inject = inject(), modelsManager = _inject.modelsManager; var collectionDisplayName = _.capitalize(collectionName); var model = modelsManager.getModels()[collectionName]; // jshint camelcase: false pushIntoApimap(apimap, { name: "".concat(Implementation.getModelName(model), "_intercom_conversations"), displayName: "".concat(collectionDisplayName, " Conversations"), icon: 'intercom', integration: INTEGRATION_NAME, onlyForRelationships: true, isVirtual: true, isReadOnly: true, fields: [{ field: 'subject', type: 'String' }, { field: 'body', type: ['String'] }, { field: 'open', type: 'Boolean' }, { field: 'read', type: 'Boolean' }, { field: 'assignee', type: 'String' }] }); pushIntoApimap(apimap, { name: "".concat(Implementation.getModelName(model), "_intercom_attributes"), displayName: "".concat(collectionDisplayName, " Attributes"), icon: 'intercom', integration: INTEGRATION_NAME, onlyForRelationships: true, isVirtual: true, isReadOnly: true, fields: [{ field: 'email', type: 'String', isFilterable: false }, { field: 'name', type: 'String', isFilterable: false }, { field: 'role', type: 'String', isFilterable: false }, { field: 'companies', type: ['String'], isFilterable: false }, { field: 'tags', type: ['String'], isFilterable: false }, { field: 'platform', type: 'String', isFilterable: false }, { field: 'browser', type: 'String', isFilterable: false }, { field: 'city', type: 'String', isFilterable: false }, { field: 'country', type: 'String', isFilterable: false }, { field: 'signed_up_at', type: 'Date', isFilterable: false }, { field: 'last_request_at', type: 'Date', isFilterable: false }, { field: 'last_seen_at', type: 'Date', isFilterable: false }, { field: 'last_replied_at', type: 'Date', isFilterable: false }, { field: 'last_contacted_at', type: 'Date', isFilterable: false }, { field: 'last_email_opened_at', type: 'Date', isFilterable: false }, { field: 'last_email_clicked_at', type: 'Date', isFilterable: false }, { field: 'created_at', type: 'Date', isFilterable: false }, { field: 'updated_at', type: 'Date', isFilterable: false }] }); }; exports.createFields = function (implementation, model, schemaFields) { schemaFields.push({ field: 'intercom_conversations', type: ['String'], reference: "".concat(implementation.getModelName(model), "_intercom_conversations.id"), column: null, isFilterable: false, integration: INTEGRATION_NAME, isVirtual: true }); schemaFields.push({ field: 'intercom_attributes', type: 'String', reference: "".concat(implementation.getModelName(model), "_intercom_attributes.id"), column: null, isFilterable: false, integration: INTEGRATION_NAME, isVirtual: true }); };