octalens-mentions 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,3 +26,4 @@ const App = () => {
26
26
  ] });
27
27
  };
28
28
  exports.App = App;
29
+ //# sourceMappingURL=App-B-QcAxW7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App-B-QcAxW7.js","sources":["../../admin/src/pages/HomePage.tsx","../../admin/src/pages/App.tsx"],"sourcesContent":["import { Main, Box, Typography } from '@strapi/design-system';\nimport { MentionsTable } from '../components/MentionsTable';\nimport { useMentions } from '../hooks/useMentions';\n\nconst HomePage = () => {\n const { mentions, loading, error } = useMentions();\n\n return (\n <Main>\n <Box padding={8}>\n <Typography variant=\"alpha\">\n Mentions\n </Typography>\n </Box>\n <Box paddingLeft={8} paddingRight={8}> \n {loading && <Typography>Loading mentions...</Typography>}\n {error && <Typography textColor=\"danger600\">Error: {error.message}</Typography>}\n {!loading && !error && <MentionsTable mentions={mentions} />}\n </Box>\n </Main>\n );\n};\n\nexport { HomePage };\n","import { Page } from '@strapi/strapi/admin';\nimport { Routes, Route } from 'react-router-dom';\n\nimport { HomePage } from './HomePage';\n\nconst App = () => {\n return (\n <Routes>\n <Route index element={<HomePage />} />\n <Route path=\"*\" element={<Page.Error />} />\n </Routes>\n );\n};\n\nexport { App };\n"],"names":["useMentions","Main","jsx","Box","Typography","jsxs","MentionsTable","Routes","Route","Page"],"mappings":";;;;;;;AAIA,MAAM,WAAW,MAAM;AACrB,QAAM,EAAE,UAAU,SAAS,MAAA,IAAUA,MAAAA,YAAA;AAErC,yCACGC,mBAAA,EACC,UAAA;AAAA,IAAAC,2BAAAA,IAACC,aAAAA,KAAA,EAAI,SAAS,GACZ,UAAAD,2BAAAA,IAACE,2BAAW,SAAQ,SAAQ,sBAE5B,EAAA,CACF;AAAA,IACAC,2BAAAA,KAACF,aAAAA,KAAA,EAAI,aAAa,GAAG,cAAc,GAChC,UAAA;AAAA,MAAA,WAAWD,2BAAAA,IAACE,aAAAA,cAAW,UAAA,sBAAA,CAAmB;AAAA,MAC1C,SAASC,2BAAAA,KAACD,aAAAA,YAAA,EAAW,WAAU,aAAY,UAAA;AAAA,QAAA;AAAA,QAAQ,MAAM;AAAA,MAAA,GAAQ;AAAA,MACjE,CAAC,WAAW,CAAC,SAASF,2BAAAA,IAACI,MAAAA,iBAAc,SAAA,CAAoB;AAAA,IAAA,EAAA,CAC5D;AAAA,EAAA,GACF;AAEJ;AChBA,MAAM,MAAM,MAAM;AAChB,yCACGC,uBAAA,EACC,UAAA;AAAA,IAAAL,+BAACM,eAAAA,SAAM,OAAK,MAAC,SAASN,+BAAC,YAAS,GAAI;AAAA,IACpCA,+BAACM,eAAAA,SAAM,MAAK,KAAI,SAASN,2BAAAA,IAACO,MAAAA,KAAK,OAAL,CAAA,CAAW,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;;"}
@@ -26,3 +26,4 @@ const App = () => {
26
26
  export {
27
27
  App
28
28
  };
29
+ //# sourceMappingURL=App-DjWYlFjn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App-DjWYlFjn.mjs","sources":["../../admin/src/pages/HomePage.tsx","../../admin/src/pages/App.tsx"],"sourcesContent":["import { Main, Box, Typography } from '@strapi/design-system';\nimport { MentionsTable } from '../components/MentionsTable';\nimport { useMentions } from '../hooks/useMentions';\n\nconst HomePage = () => {\n const { mentions, loading, error } = useMentions();\n\n return (\n <Main>\n <Box padding={8}>\n <Typography variant=\"alpha\">\n Mentions\n </Typography>\n </Box>\n <Box paddingLeft={8} paddingRight={8}> \n {loading && <Typography>Loading mentions...</Typography>}\n {error && <Typography textColor=\"danger600\">Error: {error.message}</Typography>}\n {!loading && !error && <MentionsTable mentions={mentions} />}\n </Box>\n </Main>\n );\n};\n\nexport { HomePage };\n","import { Page } from '@strapi/strapi/admin';\nimport { Routes, Route } from 'react-router-dom';\n\nimport { HomePage } from './HomePage';\n\nconst App = () => {\n return (\n <Routes>\n <Route index element={<HomePage />} />\n <Route path=\"*\" element={<Page.Error />} />\n </Routes>\n );\n};\n\nexport { App };\n"],"names":[],"mappings":";;;;;AAIA,MAAM,WAAW,MAAM;AACrB,QAAM,EAAE,UAAU,SAAS,MAAA,IAAU,YAAA;AAErC,8BACG,MAAA,EACC,UAAA;AAAA,IAAA,oBAAC,KAAA,EAAI,SAAS,GACZ,UAAA,oBAAC,cAAW,SAAQ,SAAQ,sBAE5B,EAAA,CACF;AAAA,IACA,qBAAC,KAAA,EAAI,aAAa,GAAG,cAAc,GAChC,UAAA;AAAA,MAAA,WAAW,oBAAC,cAAW,UAAA,sBAAA,CAAmB;AAAA,MAC1C,SAAS,qBAAC,YAAA,EAAW,WAAU,aAAY,UAAA;AAAA,QAAA;AAAA,QAAQ,MAAM;AAAA,MAAA,GAAQ;AAAA,MACjE,CAAC,WAAW,CAAC,SAAS,oBAAC,iBAAc,SAAA,CAAoB;AAAA,IAAA,EAAA,CAC5D;AAAA,EAAA,GACF;AAEJ;AChBA,MAAM,MAAM,MAAM;AAChB,8BACG,QAAA,EACC,UAAA;AAAA,IAAA,oBAAC,SAAM,OAAK,MAAC,SAAS,oBAAC,YAAS,GAAI;AAAA,IACpC,oBAAC,SAAM,MAAK,KAAI,SAAS,oBAAC,KAAK,OAAL,CAAA,CAAW,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;"}
@@ -2,3 +2,4 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const en = {};
4
4
  exports.default = en;
5
+ //# sourceMappingURL=en-B4KWt_jN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-B4KWt_jN.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -2,3 +2,4 @@ const en = {};
2
2
  export {
3
3
  en as default
4
4
  };
5
+ //# sourceMappingURL=en-Byx4XI2L.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-Byx4XI2L.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -176,3 +176,4 @@ const index = {
176
176
  exports.MentionsTable = MentionsTable;
177
177
  exports.index = index;
178
178
  exports.useMentions = useMentions;
179
+ //# sourceMappingURL=index-QtHFaCQE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-QtHFaCQE.js","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/components/PluginIcon.tsx","../../admin/src/constants.ts","../../admin/src/hooks/useMentions.ts","../../admin/src/components/MentionsTable/index.tsx","../../admin/src/components/MentionsWidget/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'octalens-mentions';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { Globe } from '@strapi/icons';\n\nconst PluginIcon = () => <Globe />;\n\nexport { PluginIcon };\n","const BASE_PATH = '/octalens-mentions';\n\nexport const CONSTANTS = {\n routes: {\n MENTIONS_URL: BASE_PATH + '/mentions',\n },\n};\n","import { useEffect, useState } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport type { IMention } from '../types';\nimport { CONSTANTS } from '../constants';\n\nexport function useMentions() {\n const { get } = useFetchClient();\n const [mentions, setMentions] = useState<IMention[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchMentions = async () => {\n try {\n setLoading(true);\n setError(null);\n const { data } = await get(CONSTANTS.routes.MENTIONS_URL);\n const mentions = data?.data;\n setMentions(mentions || []);\n } catch (error) {\n console.error('Error fetching mentions:', error);\n setError(error instanceof Error ? error : new Error('Failed to fetch mentions'));\n } finally {\n setLoading(false);\n }\n };\n\n fetchMentions();\n }, [get]);\n\n return { mentions, loading, error };\n}\n","import {\n Table,\n Thead,\n Tbody,\n Tr,\n Td,\n Th,\n Typography,\n Checkbox,\n VisuallyHidden,\n Flex,\n Box,\n IconButton,\n} from '@strapi/design-system';\nimport { Pencil, Trash, Eye } from '@strapi/icons';\nimport type { IMention } from '../../types';\n\nconst COL_COUNT = 7;\n\ninterface MentionsTableProps {\n readonly mentions: IMention[];\n}\n\nexport function MentionsTable({ mentions }: MentionsTableProps) {\n return (\n <Table colCount={COL_COUNT} rowCount={mentions.length}>\n <Thead>\n <Tr>\n <Th>\n <Checkbox aria-label=\"Select all entries\" />\n </Th>\n <Th>\n <Typography variant=\"sigma\">Title</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Source</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Keyword</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Relevance Score</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Comment</Typography>\n </Th>\n <Th>\n <VisuallyHidden>Actions</VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n <Tbody>\n {mentions.map((mention) => (\n <Tr key={mention.documentId}>\n <Td>\n <Checkbox aria-label={`Select ${mention.title}`} />\n </Td>\n <Td>\n <Typography textColor=\"neutral800\" fontWeight=\"bold\">\n {mention.title || 'Untitled'}\n </Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.source}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.keyword}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.relevanceScore}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral600\" ellipsis>\n {mention.relevanceComment?.substring(0, 50)}\n {mention.relevanceComment?.length > 50 ? '...' : ''}\n </Typography>\n </Td>\n <Td>\n <Flex>\n {mention.url && (\n <IconButton\n tag=\"a\"\n href={mention.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n label=\"View source\"\n borderWidth={0}\n >\n <Eye />\n </IconButton>\n )}\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('edit', mention.documentId)}\n label=\"Edit\"\n borderWidth={0}\n >\n <Pencil />\n </IconButton>\n </Box>\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('delete', mention.documentId)}\n label=\"Delete\"\n borderWidth={0}\n >\n <Trash />\n </IconButton>\n </Box>\n </Flex>\n </Td>\n </Tr>\n ))}\n </Tbody>\n </Table>\n );\n}\n","import { Box, Typography } from '@strapi/design-system';\nimport { useMentions } from '../../hooks/useMentions';\nimport { MentionsTable } from '../MentionsTable';\n\nexport function MentionsWidget() {\n const { mentions, loading, error } = useMentions();\n\n if (loading) {\n return (\n <Box padding={4}>\n <Typography>Loading mentions...</Typography>\n </Box>\n );\n }\n\n if (error) {\n return (\n <Box padding={4}>\n <Typography textColor=\"danger600\">Error: {error.message}</Typography>\n </Box>\n );\n }\n\n return (\n <Box padding={4}>\n <MentionsTable mentions={mentions} />\n </Box>\n );\n}\n","import { Globe } from \"@strapi/icons\";\n\nimport { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport { PluginIcon } from './components/PluginIcon';\nimport { MentionsWidget } from \"./components/MentionsWidget\";\n\nexport default {\n register(app: any) {\n app.addMenuLink({\n to: `plugins/${PLUGIN_ID}`,\n icon: PluginIcon,\n intlLabel: {\n id: `${PLUGIN_ID}.plugin.name`,\n defaultMessage: PLUGIN_ID,\n },\n Component: async () => {\n const { App } = await import('./pages/App');\n\n return App;\n },\n });\n\n app.widgets.register({\n icon: Globe,\n title: {\n id: `${PLUGIN_ID}.mentions-widget.title`,\n defaultMessage: \"Social Mentions\"\n },\n component: () => Promise.resolve(MentionsWidget),\n pluginId: PLUGIN_ID,\n id: \"mentions-widget\"\n })\n\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["useRef","useEffect","jsx","Globe","useFetchClient","useState","mentions","error","Table","Thead","Tr","Th","Checkbox","Typography","VisuallyHidden","Tbody","Td","jsxs","Flex","IconButton","Eye","Box","Pencil","Trash"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACvD,QAAM,MAAMA,MAAAA,OAAO,SAAS;AAE5BC,QAAAA,UAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,CAAA,CAAE;AAEL,SAAO;AACT;ACdA,MAAM,aAAa,MAAMC,2BAAAA,IAACC,MAAAA,OAAA,EAAM;ACFhC,MAAM,YAAY;AAEX,MAAM,YAAY;AAAA,EACvB,QAAQ;AAAA,IACN,cAAc,YAAY;AAAA,EAAA;AAE9B;ACDO,SAAS,cAAc;AAC5B,QAAM,EAAE,IAAA,IAAQC,qBAAA;AAChB,QAAM,CAAC,UAAU,WAAW,IAAIC,MAAAA,SAAqB,CAAA,CAAE;AACvD,QAAM,CAAC,SAAS,UAAU,IAAIA,MAAAA,SAAS,IAAI;AAC3C,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAuB,IAAI;AAErDJ,QAAAA,UAAU,MAAM;AACd,UAAM,gBAAgB,YAAY;AAChC,UAAI;AACF,mBAAW,IAAI;AACf,iBAAS,IAAI;AACb,cAAM,EAAE,KAAA,IAAS,MAAM,IAAI,UAAU,OAAO,YAAY;AACxD,cAAMK,YAAW,MAAM;AACvB,oBAAYA,aAAY,EAAE;AAAA,MAC5B,SAASC,QAAO;AACd,gBAAQ,MAAM,4BAA4BA,MAAK;AAC/C,iBAASA,kBAAiB,QAAQA,SAAQ,IAAI,MAAM,0BAA0B,CAAC;AAAA,MACjF,UAAA;AACE,mB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;AAAA,MAElB,WAAW,YAAY;AACrB,cAAM,EAAE,IAAA,IAAQ,MAAM,QAAA,QAAA,EAAA,KAAA,MAAA,QAAO,mBAAa,CAAA;AAE1C,eAAO;AAAA,MACT;AAAA,IAAA,CACD;AAED,QAAI,QAAQ,SAAS;AAAA,MACnB,MAAMC,MAAAA;AAAAA,MACN,OAAO;AAAA,QACL,IAAI,GAAG,SAAS;AAAA,QAChB,gBAAgB;AAAA,MAAA;AAAA,MAElB,WAAW,MAAM,QAAQ,QAAQ,cAAc;AAAA,MAC/C,UAAU;AAAA,MACV,IAAI;AAAA,IAAA,CACL;AAED,QAAI,eAAe;AAAA,MACjB,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IAAA,CACP;AAAA,EAEH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AAC5B,YAAI;AACF,gBAAM,EAAE,SAAS,KAAA,IAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEhC,iBAAO,EAAE,MAAM,OAAA;AAAA,QACjB,QAAQ;AACN,iBAAO,EAAE,MAAM,CAAA,GAAI,OAAA;AAAA,QACrB;AAAA,MACF,CAAC;AAAA,IAAA;AAAA,EAEL;AACF;;;;"}
@@ -177,3 +177,4 @@ export {
177
177
  index as i,
178
178
  useMentions as u
179
179
  };
180
+ //# sourceMappingURL=index-S3IY0oBe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-S3IY0oBe.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/components/PluginIcon.tsx","../../admin/src/constants.ts","../../admin/src/hooks/useMentions.ts","../../admin/src/components/MentionsTable/index.tsx","../../admin/src/components/MentionsWidget/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'octalens-mentions';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { Globe } from '@strapi/icons';\n\nconst PluginIcon = () => <Globe />;\n\nexport { PluginIcon };\n","const BASE_PATH = '/octalens-mentions';\n\nexport const CONSTANTS = {\n routes: {\n MENTIONS_URL: BASE_PATH + '/mentions',\n },\n};\n","import { useEffect, useState } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport type { IMention } from '../types';\nimport { CONSTANTS } from '../constants';\n\nexport function useMentions() {\n const { get } = useFetchClient();\n const [mentions, setMentions] = useState<IMention[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchMentions = async () => {\n try {\n setLoading(true);\n setError(null);\n const { data } = await get(CONSTANTS.routes.MENTIONS_URL);\n const mentions = data?.data;\n setMentions(mentions || []);\n } catch (error) {\n console.error('Error fetching mentions:', error);\n setError(error instanceof Error ? error : new Error('Failed to fetch mentions'));\n } finally {\n setLoading(false);\n }\n };\n\n fetchMentions();\n }, [get]);\n\n return { mentions, loading, error };\n}\n","import {\n Table,\n Thead,\n Tbody,\n Tr,\n Td,\n Th,\n Typography,\n Checkbox,\n VisuallyHidden,\n Flex,\n Box,\n IconButton,\n} from '@strapi/design-system';\nimport { Pencil, Trash, Eye } from '@strapi/icons';\nimport type { IMention } from '../../types';\n\nconst COL_COUNT = 7;\n\ninterface MentionsTableProps {\n readonly mentions: IMention[];\n}\n\nexport function MentionsTable({ mentions }: MentionsTableProps) {\n return (\n <Table colCount={COL_COUNT} rowCount={mentions.length}>\n <Thead>\n <Tr>\n <Th>\n <Checkbox aria-label=\"Select all entries\" />\n </Th>\n <Th>\n <Typography variant=\"sigma\">Title</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Source</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Keyword</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Relevance Score</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">Comment</Typography>\n </Th>\n <Th>\n <VisuallyHidden>Actions</VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n <Tbody>\n {mentions.map((mention) => (\n <Tr key={mention.documentId}>\n <Td>\n <Checkbox aria-label={`Select ${mention.title}`} />\n </Td>\n <Td>\n <Typography textColor=\"neutral800\" fontWeight=\"bold\">\n {mention.title || 'Untitled'}\n </Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.source}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.keyword}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{mention.relevanceScore}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral600\" ellipsis>\n {mention.relevanceComment?.substring(0, 50)}\n {mention.relevanceComment?.length > 50 ? '...' : ''}\n </Typography>\n </Td>\n <Td>\n <Flex>\n {mention.url && (\n <IconButton\n tag=\"a\"\n href={mention.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n label=\"View source\"\n borderWidth={0}\n >\n <Eye />\n </IconButton>\n )}\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('edit', mention.documentId)}\n label=\"Edit\"\n borderWidth={0}\n >\n <Pencil />\n </IconButton>\n </Box>\n <Box paddingLeft={1}>\n <IconButton\n onClick={() => console.log('delete', mention.documentId)}\n label=\"Delete\"\n borderWidth={0}\n >\n <Trash />\n </IconButton>\n </Box>\n </Flex>\n </Td>\n </Tr>\n ))}\n </Tbody>\n </Table>\n );\n}\n","import { Box, Typography } from '@strapi/design-system';\nimport { useMentions } from '../../hooks/useMentions';\nimport { MentionsTable } from '../MentionsTable';\n\nexport function MentionsWidget() {\n const { mentions, loading, error } = useMentions();\n\n if (loading) {\n return (\n <Box padding={4}>\n <Typography>Loading mentions...</Typography>\n </Box>\n );\n }\n\n if (error) {\n return (\n <Box padding={4}>\n <Typography textColor=\"danger600\">Error: {error.message}</Typography>\n </Box>\n );\n }\n\n return (\n <Box padding={4}>\n <MentionsTable mentions={mentions} />\n </Box>\n );\n}\n","import { Globe } from \"@strapi/icons\";\n\nimport { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport { PluginIcon } from './components/PluginIcon';\nimport { MentionsWidget } from \"./components/MentionsWidget\";\n\nexport default {\n register(app: any) {\n app.addMenuLink({\n to: `plugins/${PLUGIN_ID}`,\n icon: PluginIcon,\n intlLabel: {\n id: `${PLUGIN_ID}.plugin.name`,\n defaultMessage: PLUGIN_ID,\n },\n Component: async () => {\n const { App } = await import('./pages/App');\n\n return App;\n },\n });\n\n app.widgets.register({\n icon: Globe,\n title: {\n id: `${PLUGIN_ID}.mentions-widget.title`,\n defaultMessage: \"Social Mentions\"\n },\n component: () => Promise.resolve(MentionsWidget),\n pluginId: PLUGIN_ID,\n id: \"mentions-widget\"\n })\n\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["mentions","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACvD,QAAM,MAAM,OAAO,SAAS;AAE5B,YAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,CAAA,CAAE;AAEL,SAAO;AACT;ACdA,MAAM,aAAa,MAAM,oBA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AAM;AAAA,MACN,WAAW;AAAA,QACT,IAAI,GAAG,SAAS;AAAA,QAChB,gBAAgB;AAAA,MAAA;AAAA,MAElB,WAAW,YAAY;AACrB,cAAM,EAAE,IAAA,IAAQ,MAAM,OAAO,oBAAa;AAE1C,eAAO;AAAA,MACT;AAAA,IAAA,CACD;AAED,QAAI,QAAQ,SAAS;AAAA,MACnB,MAAM;AAAA,MACN,OAAO;AAAA,QACL,IAAI,GAAG,SAAS;AAAA,QAChB,gBAAgB;AAAA,MAAA;AAAA,MAElB,WAAW,MAAM,QAAQ,QAAQ,cAAc;AAAA,MAC/C,UAAU;AAAA,MACV,IAAI;AAAA,IAAA,CACL;AAED,QAAI,eAAe;AAAA,MACjB,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IAAA,CACP;AAAA,EAEH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AAC5B,YAAI;AACF,gBAAM,EAAE,SAAS,KAAA,IAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,OAAA,mBAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEhC,iBAAO,EAAE,MAAM,OAAA;AAAA,QACjB,QAAQ;AACN,iBAAO,EAAE,MAAM,CAAA,GAAI,OAAA;AAAA,QACrB;AAAA,MACF,CAAC;AAAA,IAAA;AAAA,EAEL;AACF;"}
@@ -2,3 +2,4 @@
2
2
  const index = require("../_chunks/index-QtHFaCQE.js");
3
3
  require("@strapi/icons");
4
4
  module.exports = index.index;
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -3,3 +3,4 @@ import "@strapi/icons";
3
3
  export {
4
4
  i as default
5
5
  };
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ const bootstrap = ({ strapi }) => {
3
+ };
4
+ const destroy = ({ strapi }) => {
5
+ };
6
+ const register = ({ strapi }) => {
7
+ };
8
+ const config = {
9
+ default: {},
10
+ validator() {
11
+ }
12
+ };
13
+ const kind = "collectionType";
14
+ const collectionName = "mention";
15
+ const info = {
16
+ singularName: "mention",
17
+ pluralName: "mentions",
18
+ displayName: "Mention"
19
+ };
20
+ const options = {
21
+ draftAndPublish: false
22
+ };
23
+ const pluginOptions = {
24
+ "content-manager": {
25
+ visible: true
26
+ },
27
+ "content-type-builder": {
28
+ visible: false
29
+ }
30
+ };
31
+ const attributes = {
32
+ action: {
33
+ type: "string"
34
+ },
35
+ title: {
36
+ type: "string"
37
+ },
38
+ body: {
39
+ type: "text"
40
+ },
41
+ url: {
42
+ type: "string"
43
+ },
44
+ timestamp: {
45
+ type: "string"
46
+ },
47
+ imageUrl: {
48
+ type: "string"
49
+ },
50
+ author: {
51
+ type: "string"
52
+ },
53
+ authorProfileLink: {
54
+ type: "string"
55
+ },
56
+ source: {
57
+ type: "string"
58
+ },
59
+ sourceId: {
60
+ type: "string"
61
+ },
62
+ relevanceScore: {
63
+ type: "string"
64
+ },
65
+ relevanceComment: {
66
+ type: "text"
67
+ },
68
+ keyword: {
69
+ type: "string"
70
+ },
71
+ bookmarked: {
72
+ type: "boolean",
73
+ "default": false
74
+ },
75
+ language: {
76
+ type: "string"
77
+ },
78
+ sentimentLabel: {
79
+ type: "string"
80
+ },
81
+ viewId: {
82
+ type: "integer"
83
+ },
84
+ viewName: {
85
+ type: "string"
86
+ },
87
+ subreddit: {
88
+ type: "string"
89
+ }
90
+ };
91
+ const schema = {
92
+ kind,
93
+ collectionName,
94
+ info,
95
+ options,
96
+ pluginOptions,
97
+ attributes
98
+ };
99
+ const mention$2 = {
100
+ schema
101
+ };
102
+ const contentTypes = {
103
+ mention: mention$2
104
+ };
105
+ const { createCoreController } = require("@strapi/strapi").factories;
106
+ const mention$1 = createCoreController("plugin::octalens-mentions.mention");
107
+ function getMentionTitle(title, body) {
108
+ if (!title || title.trim() === "" || title.toLowerCase() === "untitled") {
109
+ if (!body) return "Untitled";
110
+ const excerpt = body.substring(0, 100).trim();
111
+ return excerpt.length === 64 ? `${excerpt}...` : excerpt;
112
+ }
113
+ return title;
114
+ }
115
+ const controller = ({ strapi }) => ({
116
+ async ingest(ctx) {
117
+ const requestBody = ctx.request.body;
118
+ console.dir(requestBody, { depth: null });
119
+ if (!requestBody?.data) return ctx.badRequest("Missing data in request body");
120
+ const rawTitle = requestBody.data?.title || "";
121
+ const rawBody = requestBody.data?.body || "";
122
+ const generatedTitle = getMentionTitle(rawTitle, rawBody);
123
+ const mentionData = {
124
+ action: requestBody.action,
125
+ title: generatedTitle,
126
+ body: rawBody,
127
+ url: requestBody.data?.url || "",
128
+ timestamp: requestBody.data?.timestamp || "",
129
+ imageUrl: requestBody.data?.imageUrl || "",
130
+ author: requestBody.data?.author || "",
131
+ authorProfileLink: requestBody.data?.authorProfileLink || "",
132
+ source: requestBody.data?.source || "",
133
+ sourceId: requestBody.data?.sourceId || "",
134
+ relevanceScore: requestBody.data?.relevanceScore || "",
135
+ relevanceComment: requestBody.data?.relevanceComment || "",
136
+ keyword: requestBody.data?.keyword || "",
137
+ bookmarked: requestBody.data?.bookmarked || false,
138
+ language: requestBody.data?.language || "",
139
+ sentimentLabel: requestBody.data?.sentimentLabel || "",
140
+ viewId: requestBody.data?.viewId || void 0,
141
+ viewName: requestBody.data?.viewName || "",
142
+ subreddit: requestBody.data?.subreddit || ""
143
+ };
144
+ console.log("###############################");
145
+ console.log("Parsed mention data:", mentionData);
146
+ console.log("###############################");
147
+ try {
148
+ const mention2 = await strapi.service("plugin::octalens-mentions.mention").create({
149
+ data: mentionData
150
+ });
151
+ ctx.body = { data: mention2 };
152
+ } catch (error) {
153
+ console.error("Error creating mention:", error);
154
+ ctx.throw(500, "Failed to create mention");
155
+ }
156
+ }
157
+ });
158
+ const controllers = {
159
+ mention: mention$1,
160
+ ingest: controller
161
+ };
162
+ const middlewares = {};
163
+ const policies = {};
164
+ const adminApiRoutes = [
165
+ {
166
+ method: "GET",
167
+ path: "/mentions",
168
+ handler: "mention.find",
169
+ config: {
170
+ policies: ["admin::isAuthenticatedAdmin"]
171
+ }
172
+ }
173
+ ];
174
+ const contentApiRoutes = [
175
+ {
176
+ method: "GET",
177
+ path: "/mentions",
178
+ handler: "mention.find",
179
+ config: {
180
+ policies: []
181
+ }
182
+ },
183
+ {
184
+ method: "GET",
185
+ path: "/mentions/:id",
186
+ handler: "mention.findOne",
187
+ config: {
188
+ policies: []
189
+ }
190
+ },
191
+ {
192
+ method: "DELETE",
193
+ path: "/mentions/:id",
194
+ handler: "mention.delete",
195
+ config: {
196
+ policies: []
197
+ }
198
+ },
199
+ {
200
+ method: "PUT",
201
+ path: "/mentions/:id",
202
+ handler: "mention.update",
203
+ config: {
204
+ policies: []
205
+ }
206
+ },
207
+ {
208
+ method: "POST",
209
+ path: "/mentions",
210
+ handler: "mention.create",
211
+ config: {
212
+ policies: []
213
+ }
214
+ },
215
+ {
216
+ method: "POST",
217
+ path: "/ingest",
218
+ handler: "ingest.ingest"
219
+ }
220
+ ];
221
+ const routes = {
222
+ "admin-api": {
223
+ type: "admin",
224
+ routes: [...adminApiRoutes]
225
+ },
226
+ "content-api": {
227
+ type: "content-api",
228
+ routes: [...contentApiRoutes]
229
+ }
230
+ };
231
+ const { createCoreService } = require("@strapi/strapi").factories;
232
+ const mention = createCoreService("plugin::octalens-mentions.mention");
233
+ const services = {
234
+ mention
235
+ };
236
+ const index = {
237
+ register,
238
+ bootstrap,
239
+ destroy,
240
+ config,
241
+ controllers,
242
+ routes,
243
+ services,
244
+ contentTypes,
245
+ policies,
246
+ middlewares
247
+ };
248
+ module.exports = index;
249
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../server/src/bootstrap.ts","../../server/src/destroy.ts","../../server/src/register.ts","../../server/src/config/index.ts","../../server/src/content-types/mention/index.ts","../../server/src/content-types/index.ts","../../server/src/controllers/mention/index.ts","../../server/src/controllers/ingest/index.ts","../../server/src/controllers/index.ts","../../server/src/middlewares/index.ts","../../server/src/policies/index.ts","../../server/src/routes/admin-api.ts","../../server/src/routes/content-api.ts","../../server/src/routes/index.ts","../../server/src/services/mention/index.ts","../../server/src/services/index.ts","../../server/src/index.ts"],"sourcesContent":["import type { Core } from '@strapi/strapi';\n\nconst bootstrap = ({ strapi }: { strapi: Core.Strapi }) => {\n // bootstrap phase\n};\n\nexport default bootstrap;\n","import type { Core } from '@strapi/strapi';\n\nconst destroy = ({ strapi }: { strapi: Core.Strapi }) => {\n // destroy phase\n};\n\nexport default destroy;\n","import type { Core } from '@strapi/strapi';\n\nconst register = ({ strapi }: { strapi: Core.Strapi }) => {\n // register phase\n};\n\nexport default register;\n","export default {\n default: {},\n validator() {},\n};\n","import schema from './schema.json';\n\nexport default {\n schema,\n};","import mention from './mention';\n\nexport default {\n mention,\n};","'use strict';\n\n/**\n * mention controller\n */\n\nconst { createCoreController } = require('@strapi/strapi').factories;\n\nexport default createCoreController('plugin::octalens-mentions.mention');","import type { Core } from '@strapi/strapi';\n\n/**\n * Gets the display title for a mention.\n * If title is empty or \"Untitled\", uses the first 100 characters from body.\n */\nfunction getMentionTitle(title: string, body: string): string {\n if (!title || title.trim() === '' || title.toLowerCase() === 'untitled') {\n if (!body) return 'Untitled';\n\n const excerpt = body.substring(0, 100).trim();\n return excerpt.length === 64 ? `${excerpt}...` : excerpt;\n }\n\n return title;\n}\n\nconst controller = ({ strapi }: { strapi: Core.Strapi }) => ({\n async ingest(ctx) {\n const requestBody = ctx.request.body;\n\n console.dir(requestBody, { depth: null})\n\n if (!requestBody?.data) return ctx.badRequest('Missing data in request body');\n\n const rawTitle = requestBody.data?.title || '';\n const rawBody = requestBody.data?.body || '';\n const generatedTitle = getMentionTitle(rawTitle, rawBody);\n\n const mentionData = {\n action: requestBody.action,\n title: generatedTitle,\n body: rawBody,\n url: requestBody.data?.url || '',\n timestamp: requestBody.data?.timestamp || '',\n imageUrl: requestBody.data?.imageUrl || '',\n author: requestBody.data?.author || '',\n authorProfileLink: requestBody.data?.authorProfileLink || '',\n source: requestBody.data?.source || '',\n sourceId: requestBody.data?.sourceId || '',\n relevanceScore: requestBody.data?.relevanceScore || '',\n relevanceComment: requestBody.data?.relevanceComment || '',\n keyword: requestBody.data?.keyword || '',\n bookmarked: requestBody.data?.bookmarked || false,\n language: requestBody.data?.language || '',\n sentimentLabel: requestBody.data?.sentimentLabel || '',\n viewId: requestBody.data?.viewId || undefined,\n viewName: requestBody.data?.viewName || '',\n subreddit: requestBody.data?.subreddit || '',\n };\n\n console.log('###############################');\n console.log('Parsed mention data:', mentionData);\n console.log('###############################');\n \n\n try {\n const mention = await strapi.service('plugin::octalens-mentions.mention').create({\n data: mentionData,\n });\n\n ctx.body = { data: mention };\n } catch (error) {\n console.error('Error creating mention:', error);\n ctx.throw(500, 'Failed to create mention');\n }\n },\n});\n\nexport default controller;\n","import mention from './mention';\nimport ingest from './ingest';\n\nexport default {\n mention,\n ingest\n};","export default {};\n","export default {};\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n];\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: [],\n },\n },\n {\n method: 'GET',\n path: '/mentions/:id',\n handler: 'mention.findOne',\n config: {\n policies: [],\n },\n },\n {\n method: 'DELETE',\n path: '/mentions/:id',\n handler: 'mention.delete',\n config: {\n policies: [],\n },\n },\n {\n method: 'PUT',\n path: '/mentions/:id',\n handler: 'mention.update',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/mentions',\n handler: 'mention.create',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/ingest',\n handler: 'ingest.ingest'\n }\n];\n","\"use strict\";\n\nimport adminApiRoutes from \"./admin-api\";\nimport contentApiRoutes from \"./content-api\";\n\n\nexport default {\n \"admin-api\": {\n type: \"admin\",\n routes: [...adminApiRoutes],\n },\n \"content-api\": {\n type: \"content-api\",\n routes: [...contentApiRoutes],\n },\n};","'use strict';\n\n/**\n * mention service\n */\n\nconst { createCoreService } = require('@strapi/strapi').factories;\n\nexport default createCoreService('plugin::octalens-mentions.mention');\n","import mention from './mention';\n\nexport default {\n mention,\n};\n","/**\n * Application methods\n */\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport register from './register';\n\n/**\n * Plugin server methods\n */\nimport config from './config';\nimport contentTypes from './content-types';\nimport controllers from './controllers';\nimport middlewares from './middlewares';\nimport policies from './policies';\nimport routes from './routes';\nimport services from './services';\n\nexport default {\n register,\n bootstrap,\n destroy,\n config,\n controllers,\n routes,\n services,\n contentTypes,\n policies,\n middlewares,\n};\n"],"names":["mention","ingest"],"mappings":";AAEA,MAAM,YAAY,CAAC,EAAE,aAAsC;AAE3D;ACFA,MAAM,UAAU,CAAC,EAAE,aAAsC;AAEzD;ACFA,MAAM,WAAW,CAAC,EAAE,aAAsC;AAE1D;ACJA,MAAA,SAAe;AAAA,EACb,SAAS,CAAA;AAAA,EACT,YAAY;AAAA,EAAC;AACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACDA,MAAA,YAAe;AAAA,EACb;AACF;ACFA,MAAA,eAAe;AAAA,EAAA,SACbA;AACF;ACEA,MAAM,EAAE,qBAAA,IAAyB,QAAQ,gBAAgB,EAAE;AAE3D,MAAA,YAAe,qBAAqB,mCAAmC;ACFvE,SAAS,gBAAgB,OAAe,MAAsB;AAC5D,MAAI,CAAC,SAAS,MAAM,KAAA,MAAW,MAAM,MAAM,YAAA,MAAkB,YAAY;AACvE,QAAI,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A,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAEb;ACxCA,MAAA,SAAe;AAAA,EACb,aAAa;AAAA,IACX,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,cAAc;AAAA,EAAA;AAAA,EAE5B,eAAe;AAAA,IACb,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,gBAAgB;AAAA,EAAA;AAEhC;ACTA,MAAM,EAAE,kBAAA,IAAsB,QAAQ,gBAAgB,EAAE;AAExD,MAAA,UAAe,kBAAkB,mCAAmC;ACNpE,MAAA,WAAe;AAAA,EACb;AACF;ACcA,MAAA,QAAe;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;"}
@@ -0,0 +1,250 @@
1
+ const bootstrap = ({ strapi }) => {
2
+ };
3
+ const destroy = ({ strapi }) => {
4
+ };
5
+ const register = ({ strapi }) => {
6
+ };
7
+ const config = {
8
+ default: {},
9
+ validator() {
10
+ }
11
+ };
12
+ const kind = "collectionType";
13
+ const collectionName = "mention";
14
+ const info = {
15
+ singularName: "mention",
16
+ pluralName: "mentions",
17
+ displayName: "Mention"
18
+ };
19
+ const options = {
20
+ draftAndPublish: false
21
+ };
22
+ const pluginOptions = {
23
+ "content-manager": {
24
+ visible: true
25
+ },
26
+ "content-type-builder": {
27
+ visible: false
28
+ }
29
+ };
30
+ const attributes = {
31
+ action: {
32
+ type: "string"
33
+ },
34
+ title: {
35
+ type: "string"
36
+ },
37
+ body: {
38
+ type: "text"
39
+ },
40
+ url: {
41
+ type: "string"
42
+ },
43
+ timestamp: {
44
+ type: "string"
45
+ },
46
+ imageUrl: {
47
+ type: "string"
48
+ },
49
+ author: {
50
+ type: "string"
51
+ },
52
+ authorProfileLink: {
53
+ type: "string"
54
+ },
55
+ source: {
56
+ type: "string"
57
+ },
58
+ sourceId: {
59
+ type: "string"
60
+ },
61
+ relevanceScore: {
62
+ type: "string"
63
+ },
64
+ relevanceComment: {
65
+ type: "text"
66
+ },
67
+ keyword: {
68
+ type: "string"
69
+ },
70
+ bookmarked: {
71
+ type: "boolean",
72
+ "default": false
73
+ },
74
+ language: {
75
+ type: "string"
76
+ },
77
+ sentimentLabel: {
78
+ type: "string"
79
+ },
80
+ viewId: {
81
+ type: "integer"
82
+ },
83
+ viewName: {
84
+ type: "string"
85
+ },
86
+ subreddit: {
87
+ type: "string"
88
+ }
89
+ };
90
+ const schema = {
91
+ kind,
92
+ collectionName,
93
+ info,
94
+ options,
95
+ pluginOptions,
96
+ attributes
97
+ };
98
+ const mention$2 = {
99
+ schema
100
+ };
101
+ const contentTypes = {
102
+ mention: mention$2
103
+ };
104
+ const { createCoreController } = require("@strapi/strapi").factories;
105
+ const mention$1 = createCoreController("plugin::octalens-mentions.mention");
106
+ function getMentionTitle(title, body) {
107
+ if (!title || title.trim() === "" || title.toLowerCase() === "untitled") {
108
+ if (!body) return "Untitled";
109
+ const excerpt = body.substring(0, 100).trim();
110
+ return excerpt.length === 64 ? `${excerpt}...` : excerpt;
111
+ }
112
+ return title;
113
+ }
114
+ const controller = ({ strapi }) => ({
115
+ async ingest(ctx) {
116
+ const requestBody = ctx.request.body;
117
+ console.dir(requestBody, { depth: null });
118
+ if (!requestBody?.data) return ctx.badRequest("Missing data in request body");
119
+ const rawTitle = requestBody.data?.title || "";
120
+ const rawBody = requestBody.data?.body || "";
121
+ const generatedTitle = getMentionTitle(rawTitle, rawBody);
122
+ const mentionData = {
123
+ action: requestBody.action,
124
+ title: generatedTitle,
125
+ body: rawBody,
126
+ url: requestBody.data?.url || "",
127
+ timestamp: requestBody.data?.timestamp || "",
128
+ imageUrl: requestBody.data?.imageUrl || "",
129
+ author: requestBody.data?.author || "",
130
+ authorProfileLink: requestBody.data?.authorProfileLink || "",
131
+ source: requestBody.data?.source || "",
132
+ sourceId: requestBody.data?.sourceId || "",
133
+ relevanceScore: requestBody.data?.relevanceScore || "",
134
+ relevanceComment: requestBody.data?.relevanceComment || "",
135
+ keyword: requestBody.data?.keyword || "",
136
+ bookmarked: requestBody.data?.bookmarked || false,
137
+ language: requestBody.data?.language || "",
138
+ sentimentLabel: requestBody.data?.sentimentLabel || "",
139
+ viewId: requestBody.data?.viewId || void 0,
140
+ viewName: requestBody.data?.viewName || "",
141
+ subreddit: requestBody.data?.subreddit || ""
142
+ };
143
+ console.log("###############################");
144
+ console.log("Parsed mention data:", mentionData);
145
+ console.log("###############################");
146
+ try {
147
+ const mention2 = await strapi.service("plugin::octalens-mentions.mention").create({
148
+ data: mentionData
149
+ });
150
+ ctx.body = { data: mention2 };
151
+ } catch (error) {
152
+ console.error("Error creating mention:", error);
153
+ ctx.throw(500, "Failed to create mention");
154
+ }
155
+ }
156
+ });
157
+ const controllers = {
158
+ mention: mention$1,
159
+ ingest: controller
160
+ };
161
+ const middlewares = {};
162
+ const policies = {};
163
+ const adminApiRoutes = [
164
+ {
165
+ method: "GET",
166
+ path: "/mentions",
167
+ handler: "mention.find",
168
+ config: {
169
+ policies: ["admin::isAuthenticatedAdmin"]
170
+ }
171
+ }
172
+ ];
173
+ const contentApiRoutes = [
174
+ {
175
+ method: "GET",
176
+ path: "/mentions",
177
+ handler: "mention.find",
178
+ config: {
179
+ policies: []
180
+ }
181
+ },
182
+ {
183
+ method: "GET",
184
+ path: "/mentions/:id",
185
+ handler: "mention.findOne",
186
+ config: {
187
+ policies: []
188
+ }
189
+ },
190
+ {
191
+ method: "DELETE",
192
+ path: "/mentions/:id",
193
+ handler: "mention.delete",
194
+ config: {
195
+ policies: []
196
+ }
197
+ },
198
+ {
199
+ method: "PUT",
200
+ path: "/mentions/:id",
201
+ handler: "mention.update",
202
+ config: {
203
+ policies: []
204
+ }
205
+ },
206
+ {
207
+ method: "POST",
208
+ path: "/mentions",
209
+ handler: "mention.create",
210
+ config: {
211
+ policies: []
212
+ }
213
+ },
214
+ {
215
+ method: "POST",
216
+ path: "/ingest",
217
+ handler: "ingest.ingest"
218
+ }
219
+ ];
220
+ const routes = {
221
+ "admin-api": {
222
+ type: "admin",
223
+ routes: [...adminApiRoutes]
224
+ },
225
+ "content-api": {
226
+ type: "content-api",
227
+ routes: [...contentApiRoutes]
228
+ }
229
+ };
230
+ const { createCoreService } = require("@strapi/strapi").factories;
231
+ const mention = createCoreService("plugin::octalens-mentions.mention");
232
+ const services = {
233
+ mention
234
+ };
235
+ const index = {
236
+ register,
237
+ bootstrap,
238
+ destroy,
239
+ config,
240
+ controllers,
241
+ routes,
242
+ services,
243
+ contentTypes,
244
+ policies,
245
+ middlewares
246
+ };
247
+ export {
248
+ index as default
249
+ };
250
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../server/src/bootstrap.ts","../../server/src/destroy.ts","../../server/src/register.ts","../../server/src/config/index.ts","../../server/src/content-types/mention/index.ts","../../server/src/content-types/index.ts","../../server/src/controllers/mention/index.ts","../../server/src/controllers/ingest/index.ts","../../server/src/controllers/index.ts","../../server/src/middlewares/index.ts","../../server/src/policies/index.ts","../../server/src/routes/admin-api.ts","../../server/src/routes/content-api.ts","../../server/src/routes/index.ts","../../server/src/services/mention/index.ts","../../server/src/services/index.ts","../../server/src/index.ts"],"sourcesContent":["import type { Core } from '@strapi/strapi';\n\nconst bootstrap = ({ strapi }: { strapi: Core.Strapi }) => {\n // bootstrap phase\n};\n\nexport default bootstrap;\n","import type { Core } from '@strapi/strapi';\n\nconst destroy = ({ strapi }: { strapi: Core.Strapi }) => {\n // destroy phase\n};\n\nexport default destroy;\n","import type { Core } from '@strapi/strapi';\n\nconst register = ({ strapi }: { strapi: Core.Strapi }) => {\n // register phase\n};\n\nexport default register;\n","export default {\n default: {},\n validator() {},\n};\n","import schema from './schema.json';\n\nexport default {\n schema,\n};","import mention from './mention';\n\nexport default {\n mention,\n};","'use strict';\n\n/**\n * mention controller\n */\n\nconst { createCoreController } = require('@strapi/strapi').factories;\n\nexport default createCoreController('plugin::octalens-mentions.mention');","import type { Core } from '@strapi/strapi';\n\n/**\n * Gets the display title for a mention.\n * If title is empty or \"Untitled\", uses the first 100 characters from body.\n */\nfunction getMentionTitle(title: string, body: string): string {\n if (!title || title.trim() === '' || title.toLowerCase() === 'untitled') {\n if (!body) return 'Untitled';\n\n const excerpt = body.substring(0, 100).trim();\n return excerpt.length === 64 ? `${excerpt}...` : excerpt;\n }\n\n return title;\n}\n\nconst controller = ({ strapi }: { strapi: Core.Strapi }) => ({\n async ingest(ctx) {\n const requestBody = ctx.request.body;\n\n console.dir(requestBody, { depth: null})\n\n if (!requestBody?.data) return ctx.badRequest('Missing data in request body');\n\n const rawTitle = requestBody.data?.title || '';\n const rawBody = requestBody.data?.body || '';\n const generatedTitle = getMentionTitle(rawTitle, rawBody);\n\n const mentionData = {\n action: requestBody.action,\n title: generatedTitle,\n body: rawBody,\n url: requestBody.data?.url || '',\n timestamp: requestBody.data?.timestamp || '',\n imageUrl: requestBody.data?.imageUrl || '',\n author: requestBody.data?.author || '',\n authorProfileLink: requestBody.data?.authorProfileLink || '',\n source: requestBody.data?.source || '',\n sourceId: requestBody.data?.sourceId || '',\n relevanceScore: requestBody.data?.relevanceScore || '',\n relevanceComment: requestBody.data?.relevanceComment || '',\n keyword: requestBody.data?.keyword || '',\n bookmarked: requestBody.data?.bookmarked || false,\n language: requestBody.data?.language || '',\n sentimentLabel: requestBody.data?.sentimentLabel || '',\n viewId: requestBody.data?.viewId || undefined,\n viewName: requestBody.data?.viewName || '',\n subreddit: requestBody.data?.subreddit || '',\n };\n\n console.log('###############################');\n console.log('Parsed mention data:', mentionData);\n console.log('###############################');\n \n\n try {\n const mention = await strapi.service('plugin::octalens-mentions.mention').create({\n data: mentionData,\n });\n\n ctx.body = { data: mention };\n } catch (error) {\n console.error('Error creating mention:', error);\n ctx.throw(500, 'Failed to create mention');\n }\n },\n});\n\nexport default controller;\n","import mention from './mention';\nimport ingest from './ingest';\n\nexport default {\n mention,\n ingest\n};","export default {};\n","export default {};\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n];\n","export default [\n {\n method: 'GET',\n path: '/mentions',\n handler: 'mention.find',\n config: {\n policies: [],\n },\n },\n {\n method: 'GET',\n path: '/mentions/:id',\n handler: 'mention.findOne',\n config: {\n policies: [],\n },\n },\n {\n method: 'DELETE',\n path: '/mentions/:id',\n handler: 'mention.delete',\n config: {\n policies: [],\n },\n },\n {\n method: 'PUT',\n path: '/mentions/:id',\n handler: 'mention.update',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/mentions',\n handler: 'mention.create',\n config: {\n policies: [],\n },\n },\n {\n method: 'POST',\n path: '/ingest',\n handler: 'ingest.ingest'\n }\n];\n","\"use strict\";\n\nimport adminApiRoutes from \"./admin-api\";\nimport contentApiRoutes from \"./content-api\";\n\n\nexport default {\n \"admin-api\": {\n type: \"admin\",\n routes: [...adminApiRoutes],\n },\n \"content-api\": {\n type: \"content-api\",\n routes: [...contentApiRoutes],\n },\n};","'use strict';\n\n/**\n * mention service\n */\n\nconst { createCoreService } = require('@strapi/strapi').factories;\n\nexport default createCoreService('plugin::octalens-mentions.mention');\n","import mention from './mention';\n\nexport default {\n mention,\n};\n","/**\n * Application methods\n */\nimport bootstrap from './bootstrap';\nimport destroy from './destroy';\nimport register from './register';\n\n/**\n * Plugin server methods\n */\nimport config from './config';\nimport contentTypes from './content-types';\nimport controllers from './controllers';\nimport middlewares from './middlewares';\nimport policies from './policies';\nimport routes from './routes';\nimport services from './services';\n\nexport default {\n register,\n bootstrap,\n destroy,\n config,\n controllers,\n routes,\n services,\n contentTypes,\n policies,\n middlewares,\n};\n"],"names":["mention","ingest"],"mappings":"AAEA,MAAM,YAAY,CAAC,EAAE,aAAsC;AAE3D;ACFA,MAAM,UAAU,CAAC,EAAE,aAAsC;AAEzD;ACFA,MAAM,WAAW,CAAC,EAAE,aAAsC;AAE1D;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S;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,UAAU,CAAA;AAAA,IAAC;AAAA,EACb;AAAA,EAEF;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAEb;ACxCA,MAAA,SAAe;AAAA,EACb,aAAa;AAAA,IACX,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,cAAc;AAAA,EAAA;AAAA,EAE5B,eAAe;AAAA,IACb,MAAM;AAAA,IACN,QAAQ,CAAC,GAAG,gBAAgB;AAAA,EAAA;AAEhC;ACTA,MAAM,EAAE,kBAAA,IAAsB,QAAQ,gBAAgB,EAAE;AAExD,MAAA,UAAe,kBAAkB,mCAAmC;ACNpE,MAAA,WAAe;AAAA,EACb;AACF;ACcA,MAAA,QAAe;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.12",
2
+ "version": "0.0.14",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {
@@ -1,80 +0,0 @@
1
- {
2
- "kind": "collectionType",
3
- "collectionName": "mention",
4
- "info": {
5
- "singularName": "mention",
6
- "pluralName": "mentions",
7
- "displayName": "Mention"
8
- },
9
- "options": {
10
- "draftAndPublish": false
11
- },
12
- "pluginOptions": {
13
- "content-manager": {
14
- "visible": true
15
- },
16
- "content-type-builder": {
17
- "visible": false
18
- }
19
- },
20
- "attributes": {
21
- "action": {
22
- "type": "string"
23
- },
24
- "title": {
25
- "type": "string"
26
- },
27
- "body": {
28
- "type": "text"
29
- },
30
- "url": {
31
- "type": "string"
32
- },
33
- "timestamp": {
34
- "type": "string"
35
- },
36
- "imageUrl": {
37
- "type": "string"
38
- },
39
- "author": {
40
- "type": "string"
41
- },
42
- "authorProfileLink": {
43
- "type": "string"
44
- },
45
- "source": {
46
- "type": "string"
47
- },
48
- "sourceId": {
49
- "type": "string"
50
- },
51
- "relevanceScore": {
52
- "type": "string"
53
- },
54
- "relevanceComment": {
55
- "type": "text"
56
- },
57
- "keyword": {
58
- "type": "string"
59
- },
60
- "bookmarked": {
61
- "type": "boolean",
62
- "default": false
63
- },
64
- "language": {
65
- "type": "string"
66
- },
67
- "sentimentLabel": {
68
- "type": "string"
69
- },
70
- "viewId": {
71
- "type": "integer"
72
- },
73
- "viewName": {
74
- "type": "string"
75
- },
76
- "subreddit": {
77
- "type": "string"
78
- }
79
- }
80
- }