strapi-content-embeddings 0.1.0

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.
Files changed (61) hide show
  1. package/README.md +276 -0
  2. package/dist/_chunks/App-7LMg3lrX.mjs +1004 -0
  3. package/dist/_chunks/App-wC2qv6kC.js +1008 -0
  4. package/dist/_chunks/en-B4KWt_jN.js +4 -0
  5. package/dist/_chunks/en-Byx4XI2L.mjs +4 -0
  6. package/dist/_chunks/index-Cz9cEuvw.mjs +411 -0
  7. package/dist/_chunks/index-o-tbBpJG.js +413 -0
  8. package/dist/admin/index.js +4 -0
  9. package/dist/admin/index.mjs +5 -0
  10. package/dist/admin/src/components/Initializer.d.ts +5 -0
  11. package/dist/admin/src/components/PluginIcon.d.ts +2 -0
  12. package/dist/admin/src/components/custom/BackLink.d.ts +5 -0
  13. package/dist/admin/src/components/custom/ChatModal.d.ts +1 -0
  14. package/dist/admin/src/components/custom/EmbeddingsModal.d.ts +1 -0
  15. package/dist/admin/src/components/custom/EmbeddingsTable.d.ts +12 -0
  16. package/dist/admin/src/components/custom/EmbeddingsWidget.d.ts +1 -0
  17. package/dist/admin/src/components/custom/EmptyState.d.ts +1 -0
  18. package/dist/admin/src/components/custom/Illo.d.ts +1 -0
  19. package/dist/admin/src/components/custom/Markdown.d.ts +5 -0
  20. package/dist/admin/src/components/custom/MarkdownEditor.d.ts +9 -0
  21. package/dist/admin/src/components/custom/RobotIcon.d.ts +6 -0
  22. package/dist/admin/src/components/forms/CreateEmbeddingForm.d.ts +15 -0
  23. package/dist/admin/src/index.d.ts +12 -0
  24. package/dist/admin/src/pages/App.d.ts +2 -0
  25. package/dist/admin/src/pages/CreateEmbeddings.d.ts +1 -0
  26. package/dist/admin/src/pages/EmbeddingDetails.d.ts +1 -0
  27. package/dist/admin/src/pages/HomePage.d.ts +1 -0
  28. package/dist/admin/src/pluginId.d.ts +1 -0
  29. package/dist/admin/src/utils/api.d.ts +33 -0
  30. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  31. package/dist/server/index.js +1359 -0
  32. package/dist/server/index.mjs +1360 -0
  33. package/dist/server/src/bootstrap.d.ts +5 -0
  34. package/dist/server/src/config/index.d.ts +26 -0
  35. package/dist/server/src/content-types/embedding/index.d.ts +54 -0
  36. package/dist/server/src/content-types/index.d.ts +56 -0
  37. package/dist/server/src/controllers/controller.d.ts +12 -0
  38. package/dist/server/src/controllers/index.d.ts +18 -0
  39. package/dist/server/src/controllers/mcp.d.ts +18 -0
  40. package/dist/server/src/destroy.d.ts +5 -0
  41. package/dist/server/src/index.d.ts +154 -0
  42. package/dist/server/src/mcp/index.d.ts +6 -0
  43. package/dist/server/src/mcp/schemas/index.d.ts +65 -0
  44. package/dist/server/src/mcp/server.d.ts +8 -0
  45. package/dist/server/src/mcp/tools/create-embedding.d.ts +38 -0
  46. package/dist/server/src/mcp/tools/get-embedding.d.ts +34 -0
  47. package/dist/server/src/mcp/tools/index.d.ts +114 -0
  48. package/dist/server/src/mcp/tools/list-embeddings.d.ts +40 -0
  49. package/dist/server/src/mcp/tools/rag-query.d.ts +34 -0
  50. package/dist/server/src/mcp/tools/semantic-search.d.ts +34 -0
  51. package/dist/server/src/middlewares/index.d.ts +2 -0
  52. package/dist/server/src/plugin-manager.d.ts +45 -0
  53. package/dist/server/src/policies/index.d.ts +2 -0
  54. package/dist/server/src/register.d.ts +5 -0
  55. package/dist/server/src/routes/admin.d.ts +14 -0
  56. package/dist/server/src/routes/content-api.d.ts +15 -0
  57. package/dist/server/src/routes/index.d.ts +36 -0
  58. package/dist/server/src/services/embeddings.d.ts +45 -0
  59. package/dist/server/src/services/index.d.ts +26 -0
  60. package/dist/style.css +95 -0
  61. package/package.json +104 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * RAG Query Tool
3
+ *
4
+ * Performs Retrieval-Augmented Generation to answer questions using embedded content.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ export declare const ragQueryTool: {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ query: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ includeSourceDocuments: {
18
+ type: string;
19
+ description: string;
20
+ default: boolean;
21
+ };
22
+ };
23
+ required: string[];
24
+ };
25
+ };
26
+ export declare function handleRagQuery(strapi: Core.Strapi, args: {
27
+ query: string;
28
+ includeSourceDocuments?: boolean;
29
+ }): Promise<{
30
+ content: {
31
+ type: string;
32
+ text: string;
33
+ }[];
34
+ }>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Semantic Search Tool
3
+ *
4
+ * Performs vector similarity search to find relevant content.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ export declare const semanticSearchTool: {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ query: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ limit: {
18
+ type: string;
19
+ description: string;
20
+ default: number;
21
+ };
22
+ };
23
+ required: string[];
24
+ };
25
+ };
26
+ export declare function handleSemanticSearch(strapi: Core.Strapi, args: {
27
+ query: string;
28
+ limit?: number;
29
+ }): Promise<{
30
+ content: {
31
+ type: string;
32
+ text: string;
33
+ }[];
34
+ }>;
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,45 @@
1
+ import { OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai";
2
+ import { Document } from "@langchain/core/documents";
3
+ import { Pool } from "pg";
4
+ import { type EmbeddingModelName } from "./config";
5
+ interface PluginConfig {
6
+ openAIApiKey: string;
7
+ neonConnectionString: string;
8
+ embeddingModel?: EmbeddingModelName;
9
+ }
10
+ interface EmbeddingDocument {
11
+ id: string;
12
+ title: string;
13
+ content: string;
14
+ collectionType?: string;
15
+ fieldName?: string;
16
+ }
17
+ interface CreateEmbeddingResult {
18
+ embeddingId: string;
19
+ embedding: number[];
20
+ }
21
+ interface QueryResponse {
22
+ text: string;
23
+ sourceDocuments: Document[];
24
+ }
25
+ declare class PluginManager {
26
+ private embeddings;
27
+ private chat;
28
+ private pool;
29
+ private embeddingModel;
30
+ private dimensions;
31
+ private vectorStoreConfig;
32
+ initializePool(connectionString: string): Promise<Pool>;
33
+ private initializeVectorTable;
34
+ initializeEmbeddings(openAIApiKey: string): Promise<OpenAIEmbeddings>;
35
+ initializeChat(openAIApiKey: string): Promise<ChatOpenAI>;
36
+ initialize(config: PluginConfig): Promise<void>;
37
+ createEmbedding(docData: EmbeddingDocument): Promise<CreateEmbeddingResult>;
38
+ deleteEmbedding(strapiId: string): Promise<void>;
39
+ queryEmbedding(query: string): Promise<QueryResponse>;
40
+ similaritySearch(query: string, k?: number): Promise<Document[]>;
41
+ isInitialized(): boolean;
42
+ destroy(): Promise<void>;
43
+ }
44
+ export declare const pluginManager: PluginManager;
45
+ export type { PluginConfig, EmbeddingDocument, QueryResponse, CreateEmbeddingResult };
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ declare const register: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => void;
5
+ export default register;
@@ -0,0 +1,14 @@
1
+ declare const _default: {
2
+ method: string;
3
+ path: string;
4
+ handler: string;
5
+ config: {
6
+ policies: {
7
+ name: string;
8
+ config: {
9
+ actions: string[];
10
+ };
11
+ }[];
12
+ };
13
+ }[];
14
+ export default _default;
@@ -0,0 +1,15 @@
1
+ declare const _default: ({
2
+ method: string;
3
+ path: string;
4
+ handler: string;
5
+ config?: undefined;
6
+ } | {
7
+ method: string;
8
+ path: string;
9
+ handler: string;
10
+ config: {
11
+ auth: boolean;
12
+ policies: any[];
13
+ };
14
+ })[];
15
+ export default _default;
@@ -0,0 +1,36 @@
1
+ declare const _default: {
2
+ "content-api": {
3
+ type: string;
4
+ routes: ({
5
+ method: string;
6
+ path: string;
7
+ handler: string;
8
+ config?: undefined;
9
+ } | {
10
+ method: string;
11
+ path: string;
12
+ handler: string;
13
+ config: {
14
+ auth: boolean;
15
+ policies: any[];
16
+ };
17
+ })[];
18
+ };
19
+ admin: {
20
+ type: string;
21
+ routes: {
22
+ method: string;
23
+ path: string;
24
+ handler: string;
25
+ config: {
26
+ policies: {
27
+ name: string;
28
+ config: {
29
+ actions: string[];
30
+ };
31
+ }[];
32
+ };
33
+ }[];
34
+ };
35
+ };
36
+ export default _default;
@@ -0,0 +1,45 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ export interface CreateEmbeddingData {
3
+ data: {
4
+ title: string;
5
+ content: string;
6
+ collectionType?: string;
7
+ fieldName?: string;
8
+ metadata?: Record<string, any>;
9
+ related?: {
10
+ __type: string;
11
+ id: number;
12
+ };
13
+ };
14
+ }
15
+ export interface UpdateEmbeddingData {
16
+ data: {
17
+ title?: string;
18
+ content?: string;
19
+ metadata?: Record<string, any>;
20
+ };
21
+ }
22
+ declare const embeddings: ({ strapi }: {
23
+ strapi: Core.Strapi;
24
+ }) => {
25
+ createEmbedding(data: CreateEmbeddingData): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
26
+ deleteEmbedding(id: number | string): Promise<{
27
+ documentId: string;
28
+ entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
29
+ }>;
30
+ updateEmbedding(id: string, data: UpdateEmbeddingData): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
31
+ queryEmbeddings(query: string): Promise<import("../plugin-manager").QueryResponse | {
32
+ error: string;
33
+ }>;
34
+ getEmbedding(id: number | string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
35
+ getEmbeddings(params?: {
36
+ page?: number;
37
+ pageSize?: number;
38
+ filters?: any;
39
+ }): Promise<{
40
+ data: import("@strapi/types/dist/modules/documents").AnyDocument[];
41
+ count: number;
42
+ totalCount: number;
43
+ }>;
44
+ };
45
+ export default embeddings;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ embeddings: ({ strapi }: {
3
+ strapi: import("@strapi/types/dist/core").Strapi;
4
+ }) => {
5
+ createEmbedding(data: import("./embeddings").CreateEmbeddingData): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
6
+ deleteEmbedding(id: string | number): Promise<{
7
+ documentId: string;
8
+ entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
9
+ }>;
10
+ updateEmbedding(id: string, data: import("./embeddings").UpdateEmbeddingData): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
11
+ queryEmbeddings(query: string): Promise<import("../plugin-manager").QueryResponse | {
12
+ error: string;
13
+ }>;
14
+ getEmbedding(id: string | number): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
15
+ getEmbeddings(params?: {
16
+ page?: number;
17
+ pageSize?: number;
18
+ filters?: any;
19
+ }): Promise<{
20
+ data: import("@strapi/types/dist/modules/documents").AnyDocument[];
21
+ count: number;
22
+ totalCount: number;
23
+ }>;
24
+ };
25
+ };
26
+ export default _default;
package/dist/style.css ADDED
@@ -0,0 +1,95 @@
1
+ /* Content editable area styling */
2
+ .mdx-editor-content {
3
+ padding: 1rem;
4
+ min-height: 200px;
5
+ outline: none;
6
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
7
+ Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
8
+ font-size: 14px;
9
+ line-height: 1.6;
10
+ }
11
+
12
+ /* Heading styles */
13
+ .mdx-editor-content h1 {
14
+ font-size: 1.75rem;
15
+ font-weight: 600;
16
+ margin: 0 0 1rem;
17
+ }
18
+
19
+ .mdx-editor-content h2 {
20
+ font-size: 1.5rem;
21
+ font-weight: 600;
22
+ margin: 1rem 0 0.75rem;
23
+ }
24
+
25
+ .mdx-editor-content h3 {
26
+ font-size: 1.25rem;
27
+ font-weight: 600;
28
+ margin: 1rem 0 0.5rem;
29
+ }
30
+
31
+ /* Paragraph and list styles */
32
+ .mdx-editor-content p {
33
+ margin: 0 0 1rem;
34
+ }
35
+
36
+ .mdx-editor-content ul,
37
+ .mdx-editor-content ol {
38
+ margin: 0 0 1rem;
39
+ padding-left: 1.5rem;
40
+ }
41
+
42
+ .mdx-editor-content li {
43
+ margin: 0.25rem 0;
44
+ }
45
+
46
+ /* Code styles */
47
+ .mdx-editor-content code {
48
+ background: #f0f0f5;
49
+ padding: 0.2em 0.4em;
50
+ border-radius: 3px;
51
+ font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
52
+ font-size: 0.9em;
53
+ }
54
+
55
+ .mdx-editor-content pre {
56
+ background: #2d2d2d;
57
+ color: #f8f8f2;
58
+ padding: 1rem;
59
+ border-radius: 4px;
60
+ overflow-x: auto;
61
+ margin: 0 0 1rem;
62
+ }
63
+
64
+ .mdx-editor-content pre code {
65
+ background: none;
66
+ padding: 0;
67
+ }
68
+
69
+ /* Blockquote styles */
70
+ .mdx-editor-content blockquote {
71
+ border-left: 3px solid #dcdce4;
72
+ margin: 0 0 1rem;
73
+ padding-left: 1rem;
74
+ color: #666;
75
+ }
76
+
77
+ /* Link styles */
78
+ .mdx-editor-content a {
79
+ color: #4945ff;
80
+ text-decoration: underline;
81
+ }
82
+
83
+ /* Horizontal rule */
84
+ .mdx-editor-content hr {
85
+ border: none;
86
+ border-top: 1px solid #dcdce4;
87
+ margin: 1.5rem 0;
88
+ }
89
+
90
+ /* Toolbar styling */
91
+ [class*="_toolbarRoot"] {
92
+ background: #f6f6f9;
93
+ border-bottom: 1px solid #dcdce4;
94
+ padding: 4px 8px;
95
+ }
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "strapi-content-embeddings",
3
+ "version": "0.1.0",
4
+ "description": "Strapi v5 plugin for vector embeddings with OpenAI and Neon PostgreSQL. Enables semantic search, RAG chat, and MCP (Model Context Protocol) integration.",
5
+ "keywords": [
6
+ "strapi",
7
+ "strapi-plugin",
8
+ "embeddings",
9
+ "vector-search",
10
+ "rag",
11
+ "openai",
12
+ "neon",
13
+ "pgvector",
14
+ "mcp",
15
+ "semantic-search"
16
+ ],
17
+ "license": "MIT",
18
+ "author": "Paul Bratslavsky <codingafterthirty@gmail.com>",
19
+ "homepage": "https://github.com/PaulBrats662/strapi-content-embeddings#readme",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/PaulBratslavsky/strapi-content-embeddings.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/PaulBratslavsky/strapi-content-embeddings/issues"
26
+ },
27
+ "type": "commonjs",
28
+ "overrides": {
29
+ "@langchain/core": "1.1.9"
30
+ },
31
+ "exports": {
32
+ "./package.json": "./package.json",
33
+ "./strapi-admin": {
34
+ "types": "./dist/admin/src/index.d.tsx",
35
+ "source": "./admin/src/index.tsx",
36
+ "import": "./dist/admin/index.mjs",
37
+ "require": "./dist/admin/index.js",
38
+ "default": "./dist/admin/index.js"
39
+ },
40
+ "./strapi-server": {
41
+ "types": "./dist/server/src/index.d.ts",
42
+ "source": "./server/src/index.ts",
43
+ "import": "./dist/server/index.mjs",
44
+ "require": "./dist/server/index.js",
45
+ "default": "./dist/server/index.js"
46
+ }
47
+ },
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "scripts": {
52
+ "build": "strapi-plugin build",
53
+ "setup-db": "node scripts/setup-db.js",
54
+ "test:ts:back": "run -T tsc -p server/tsconfig.json",
55
+ "test:ts:front": "run -T tsc -p admin/tsconfig.json",
56
+ "verify": "strapi-plugin verify",
57
+ "watch": "strapi-plugin watch",
58
+ "watch:link": "strapi-plugin watch:link"
59
+ },
60
+ "dependencies": {
61
+ "@langchain/community": "^1.1.2",
62
+ "@langchain/core": "1.1.9",
63
+ "@langchain/openai": "^1.2.1",
64
+ "@mdxeditor/editor": "^3.52.3",
65
+ "@modelcontextprotocol/sdk": "^1.12.0",
66
+ "@strapi/design-system": "^2.0.0-rc.12",
67
+ "@strapi/icons": "^2.0.0-rc.12",
68
+ "langchain": "^1.2.4",
69
+ "pg": "^8.13.1",
70
+ "qs": "^6.13.1",
71
+ "react-intl": "^6.8.4",
72
+ "react-markdown": "^10.1.0",
73
+ "zod": "^3.24.0"
74
+ },
75
+ "devDependencies": {
76
+ "@strapi/sdk-plugin": "^5.2.7",
77
+ "@strapi/strapi": "^5.2.0",
78
+ "@strapi/typescript-utils": "^5.2.0",
79
+ "@types/pg": "^8.11.10",
80
+ "@types/qs": "^6.9.17",
81
+ "@types/react": "^18.3.12",
82
+ "@types/react-dom": "^18.3.1",
83
+ "prettier": "^3.3.3",
84
+ "react": "^18.3.1",
85
+ "react-dom": "^18.3.1",
86
+ "react-router-dom": "^6.27.0",
87
+ "styled-components": "^6.1.13",
88
+ "typescript": "^5.6.3"
89
+ },
90
+ "peerDependencies": {
91
+ "@strapi/sdk-plugin": "^5.2.7",
92
+ "@strapi/strapi": "^5.2.0",
93
+ "react": "^18.3.1",
94
+ "react-dom": "^18.3.1",
95
+ "react-router-dom": "^6.27.0",
96
+ "styled-components": "^6.1.13"
97
+ },
98
+ "strapi": {
99
+ "kind": "plugin",
100
+ "name": "strapi-content-embeddings",
101
+ "displayName": "Content Embeddings",
102
+ "description": "Vector embeddings with semantic search, RAG chat, and MCP integration."
103
+ }
104
+ }