@cdmbase/wiki-browser 12.0.18-alpha.29 → 12.0.18-alpha.31
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.
|
@@ -33,6 +33,18 @@
|
|
|
33
33
|
"updatedAt": "Recently",
|
|
34
34
|
"frontmatter": {}
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
"contentId": "llm-templates_folder_and_codegen_guide",
|
|
38
|
+
"slug": "templates_folder_and_codegen_guide",
|
|
39
|
+
"filePath": "/content/docs/LLM/TEMPLATES_FOLDER_AND_CODEGEN_GUIDE.md",
|
|
40
|
+
"relativePath": "LLM/TEMPLATES_FOLDER_AND_CODEGEN_GUIDE.md",
|
|
41
|
+
"categoryId": "LLM",
|
|
42
|
+
"title": "TEMPLATES_FOLDER_AND_CODEGEN_GUIDE",
|
|
43
|
+
"description": "",
|
|
44
|
+
"author": "Documentation",
|
|
45
|
+
"updatedAt": "Recently",
|
|
46
|
+
"frontmatter": {}
|
|
47
|
+
},
|
|
36
48
|
{
|
|
37
49
|
"contentId": "llm-backend-proxies-services-llm",
|
|
38
50
|
"slug": "backend-proxies-services-llm",
|
|
@@ -117,6 +129,18 @@
|
|
|
117
129
|
"updatedAt": "Recently",
|
|
118
130
|
"frontmatter": {}
|
|
119
131
|
},
|
|
132
|
+
{
|
|
133
|
+
"contentId": "llm-mcp-mcp_servers_setup_guide",
|
|
134
|
+
"slug": "mcp-mcp_servers_setup_guide",
|
|
135
|
+
"filePath": "/content/docs/LLM/mcp/MCP_SERVERS_SETUP_GUIDE.md",
|
|
136
|
+
"relativePath": "LLM/mcp/MCP_SERVERS_SETUP_GUIDE.md",
|
|
137
|
+
"categoryId": "LLM",
|
|
138
|
+
"title": "MCP_SERVERS_SETUP_GUIDE",
|
|
139
|
+
"description": "",
|
|
140
|
+
"author": "Documentation",
|
|
141
|
+
"updatedAt": "Recently",
|
|
142
|
+
"frontmatter": {}
|
|
143
|
+
},
|
|
120
144
|
{
|
|
121
145
|
"contentId": "llm-organization-components-form-llm",
|
|
122
146
|
"slug": "organization-components-form-llm",
|
|
@@ -3607,6 +3631,15 @@
|
|
|
3607
3631
|
"updatedAt": "Recently",
|
|
3608
3632
|
"categoryId": "LLM"
|
|
3609
3633
|
},
|
|
3634
|
+
{
|
|
3635
|
+
"id": "llm-mcp-mcp_servers_setup_guide",
|
|
3636
|
+
"title": "MCP_SERVERS_SETUP_GUIDE",
|
|
3637
|
+
"description": "",
|
|
3638
|
+
"slug": "mcp-mcp_servers_setup_guide",
|
|
3639
|
+
"author": "Documentation",
|
|
3640
|
+
"updatedAt": "Recently",
|
|
3641
|
+
"categoryId": "LLM"
|
|
3642
|
+
},
|
|
3610
3643
|
{
|
|
3611
3644
|
"id": "llm-organization-components-form-llm",
|
|
3612
3645
|
"title": "Organization Components Form Llm",
|
|
@@ -3660,6 +3693,15 @@
|
|
|
3660
3693
|
"author": "Documentation",
|
|
3661
3694
|
"updatedAt": "Recently",
|
|
3662
3695
|
"categoryId": "LLM"
|
|
3696
|
+
},
|
|
3697
|
+
{
|
|
3698
|
+
"id": "llm-templates_folder_and_codegen_guide",
|
|
3699
|
+
"title": "TEMPLATES_FOLDER_AND_CODEGEN_GUIDE",
|
|
3700
|
+
"description": "",
|
|
3701
|
+
"slug": "templates_folder_and_codegen_guide",
|
|
3702
|
+
"author": "Documentation",
|
|
3703
|
+
"updatedAt": "Recently",
|
|
3704
|
+
"categoryId": "LLM"
|
|
3663
3705
|
}
|
|
3664
3706
|
]
|
|
3665
3707
|
},
|
|
@@ -5340,6 +5382,7 @@
|
|
|
5340
5382
|
"contentPathMap": {
|
|
5341
5383
|
"generators-project-generate-fullproject": "/content/docs/Generators/Project/generate-fullproject.md",
|
|
5342
5384
|
"llm-logger.llm": "/content/docs/LLM/Logger.llm.md",
|
|
5385
|
+
"llm-templates_folder_and_codegen_guide": "/content/docs/LLM/TEMPLATES_FOLDER_AND_CODEGEN_GUIDE.md",
|
|
5343
5386
|
"llm-backend-proxies-services-llm": "/content/docs/LLM/backend-proxies-services-llm.md",
|
|
5344
5387
|
"llm-backend-service-llm": "/content/docs/LLM/backend-service-llm.md",
|
|
5345
5388
|
"llm-db_migration_llm": "/content/docs/LLM/db_migration_llm.md",
|
|
@@ -5347,6 +5390,7 @@
|
|
|
5347
5390
|
"llm-inngest-inngest_function_development_guide_llm": "/content/docs/LLM/inngest/INNGEST_FUNCTION_DEVELOPMENT_GUIDE_LLM.md",
|
|
5348
5391
|
"llm-inngest-inngest_namespace_llm": "/content/docs/LLM/inngest/INNGEST_NAMESPACE_LLM.md",
|
|
5349
5392
|
"llm-llm_workflow_namespace": "/content/docs/LLM/llm_workflow_namespace.md",
|
|
5393
|
+
"llm-mcp-mcp_servers_setup_guide": "/content/docs/LLM/mcp/MCP_SERVERS_SETUP_GUIDE.md",
|
|
5350
5394
|
"llm-organization-components-form-llm": "/content/docs/LLM/organization-components-form-llm.md",
|
|
5351
5395
|
"llm-page-component-llm": "/content/docs/LLM/page-component-llm.md",
|
|
5352
5396
|
"llm-preference-roles-and-permissions": "/content/docs/LLM/preference-roles-and-permissions.md",
|
|
@@ -8326,6 +8370,28 @@
|
|
|
8326
8370
|
}
|
|
8327
8371
|
]
|
|
8328
8372
|
},
|
|
8373
|
+
{
|
|
8374
|
+
"type": "directory",
|
|
8375
|
+
"name": "mcp",
|
|
8376
|
+
"path": "LLM/mcp",
|
|
8377
|
+
"children": [
|
|
8378
|
+
{
|
|
8379
|
+
"type": "file",
|
|
8380
|
+
"name": "MCP_SERVERS_SETUP_GUIDE",
|
|
8381
|
+
"title": "MCP_SERVERS_SETUP_GUIDE",
|
|
8382
|
+
"path": "LLM/mcp/MCP_SERVERS_SETUP_GUIDE.md",
|
|
8383
|
+
"contentId": "llm-mcp-mcp_servers_setup_guide",
|
|
8384
|
+
"slug": "mcp-mcp_servers_setup_guide",
|
|
8385
|
+
"categoryId": "LLM",
|
|
8386
|
+
"filePath": "/content/docs/LLM/mcp/MCP_SERVERS_SETUP_GUIDE.md",
|
|
8387
|
+
"relativePath": "LLM/mcp/MCP_SERVERS_SETUP_GUIDE.md",
|
|
8388
|
+
"description": "",
|
|
8389
|
+
"author": "Documentation",
|
|
8390
|
+
"updatedAt": "Recently",
|
|
8391
|
+
"frontmatter": {}
|
|
8392
|
+
}
|
|
8393
|
+
]
|
|
8394
|
+
},
|
|
8329
8395
|
{
|
|
8330
8396
|
"type": "file",
|
|
8331
8397
|
"name": "backend-proxies-services-llm",
|
|
@@ -8475,6 +8541,21 @@
|
|
|
8475
8541
|
"author": "Documentation",
|
|
8476
8542
|
"updatedAt": "Recently",
|
|
8477
8543
|
"frontmatter": {}
|
|
8544
|
+
},
|
|
8545
|
+
{
|
|
8546
|
+
"type": "file",
|
|
8547
|
+
"name": "TEMPLATES_FOLDER_AND_CODEGEN_GUIDE",
|
|
8548
|
+
"title": "TEMPLATES_FOLDER_AND_CODEGEN_GUIDE",
|
|
8549
|
+
"path": "LLM/TEMPLATES_FOLDER_AND_CODEGEN_GUIDE.md",
|
|
8550
|
+
"contentId": "llm-templates_folder_and_codegen_guide",
|
|
8551
|
+
"slug": "templates_folder_and_codegen_guide",
|
|
8552
|
+
"categoryId": "LLM",
|
|
8553
|
+
"filePath": "/content/docs/LLM/TEMPLATES_FOLDER_AND_CODEGEN_GUIDE.md",
|
|
8554
|
+
"relativePath": "LLM/TEMPLATES_FOLDER_AND_CODEGEN_GUIDE.md",
|
|
8555
|
+
"description": "",
|
|
8556
|
+
"author": "Documentation",
|
|
8557
|
+
"updatedAt": "Recently",
|
|
8558
|
+
"frontmatter": {}
|
|
8478
8559
|
}
|
|
8479
8560
|
]
|
|
8480
8561
|
},
|
|
@@ -10880,6 +10961,19 @@
|
|
|
10880
10961
|
],
|
|
10881
10962
|
"isFile": false
|
|
10882
10963
|
},
|
|
10964
|
+
{
|
|
10965
|
+
"title": "Mcp",
|
|
10966
|
+
"path": null,
|
|
10967
|
+
"children": [
|
|
10968
|
+
{
|
|
10969
|
+
"title": "MCP_SERVERS_SETUP_GUIDE",
|
|
10970
|
+
"path": "/help/LLM/mcp-mcp_servers_setup_guide",
|
|
10971
|
+
"children": [],
|
|
10972
|
+
"isFile": true
|
|
10973
|
+
}
|
|
10974
|
+
],
|
|
10975
|
+
"isFile": false
|
|
10976
|
+
},
|
|
10883
10977
|
{
|
|
10884
10978
|
"title": "Backend Proxies Services Llm",
|
|
10885
10979
|
"path": "/help/LLM/backend-proxies-services-llm",
|
|
@@ -10939,6 +11033,12 @@
|
|
|
10939
11033
|
"path": "/help/LLM/tailwind-css-llm",
|
|
10940
11034
|
"children": [],
|
|
10941
11035
|
"isFile": true
|
|
11036
|
+
},
|
|
11037
|
+
{
|
|
11038
|
+
"title": "TEMPLATES_FOLDER_AND_CODEGEN_GUIDE",
|
|
11039
|
+
"path": "/help/LLM/templates_folder_and_codegen_guide",
|
|
11040
|
+
"children": [],
|
|
11041
|
+
"isFile": true
|
|
10942
11042
|
}
|
|
10943
11043
|
],
|
|
10944
11044
|
"isFile": false
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Templates Folder Pattern & Code Generation Pipeline
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `packages/common/` package in both adminIde-stack and forms-stack is **entirely auto-generated**. You should **NEVER manually edit** files in `packages/common/`. Instead, all service interfaces, repository interfaces, SERVER_TYPES entries, and service-schemas are generated from **templates folders** inside each server module, combined with GraphQL schema codegen.
|
|
6
|
+
|
|
7
|
+
## The Templates Folder Pattern
|
|
8
|
+
|
|
9
|
+
### Location
|
|
10
|
+
|
|
11
|
+
Every server module has a `templates/` folder at:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
packages-modules/{module}/server/src/templates/
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or in forms-stack:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
packages/{module}/server/src/templates/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
templates/
|
|
27
|
+
├── constants/
|
|
28
|
+
│ ├── SERVER_TYPES.ts.template ← Symbol.for() DI tokens for this module
|
|
29
|
+
│ ├── DB_COLL_NAMES.ts.template ← MongoDB collection names
|
|
30
|
+
│ └── DB_SLUG_NAMES.ts.template ← (optional) slug name constants
|
|
31
|
+
├── repositories/
|
|
32
|
+
│ └── {EntityName}Repository.ts.template ← Repository interface (I{EntityName}Repository)
|
|
33
|
+
└── services/
|
|
34
|
+
├── {EntityName}Service.ts.template ← Service interface (I{EntityName}Service)
|
|
35
|
+
└── {EntityName}DataLoader.ts.template ← DataLoader interface (optional)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Template File Format
|
|
39
|
+
|
|
40
|
+
Template files use `.ts.template` extension but are **plain TypeScript** — NOT Handlebars/EJS. They are authoritative source files that get **copied/merged** into `packages/common/src/` during the `regenerateGraphql` process.
|
|
41
|
+
|
|
42
|
+
#### Example: SERVER_TYPES.ts.template
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// packages-modules/marketplace/server/src/templates/constants/SERVER_TYPES.ts.template
|
|
46
|
+
export const SERVER_TYPES = {
|
|
47
|
+
IRegistryExtensionService: Symbol.for('IRegistryExtensionService'),
|
|
48
|
+
IRegistryExtensionRepository: Symbol.for('IRegistryExtensionRepository'),
|
|
49
|
+
IExtensionContributionService: Symbol.for('IExtensionContributionService'),
|
|
50
|
+
IExtensionContributesProvider: Symbol.for('IExtensionContributesProvider'),
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Example: Service Interface Template
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// packages-modules/marketplace/server/src/templates/services/ExtensionContributionService.ts.template
|
|
58
|
+
import { IExtensionContributes } from 'common/server'; // ← reuse the generated GraphQL type
|
|
59
|
+
|
|
60
|
+
export interface IExtensionContributesProvider {
|
|
61
|
+
getContributes(extensionId: string, version?: string): Promise<IExtensionContributes>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IExtensionContributionService {
|
|
65
|
+
registerProvider(sourceCollection: string, provider: IExtensionContributesProvider): void;
|
|
66
|
+
getContributions(extensionId: string, version?: string): Promise<IExtensionContributes | null>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare module '../apollo-context' {
|
|
70
|
+
interface ServerContext {
|
|
71
|
+
extensionContributionService: IExtensionContributionService;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> **Preference: Reuse Generated GraphQL Types**
|
|
77
|
+
>
|
|
78
|
+
> When a type is already defined in the `.graphql` schema and gets generated as a TypeScript type in `generated-models.ts`, the template should **import and reuse** that generated type via `import { ITypeName } from 'common/server'` rather than redefining its own version. This avoids type duplication and keeps a single source of truth for the type shape.
|
|
79
|
+
>
|
|
80
|
+
> See [Reusing Generated GraphQL Types in Templates](#reusing-generated-graphql-types-in-templates) for details.
|
|
81
|
+
|
|
82
|
+
### What Gets Generated Where
|
|
83
|
+
|
|
84
|
+
| Template Source | Generated Destination |
|
|
85
|
+
| ------------------------------------------------------- | ------------------------------------------------------------------ |
|
|
86
|
+
| `templates/constants/SERVER_TYPES.ts.template` | **MERGED** into `packages/common/src/constants/SERVER_TYPES.ts` |
|
|
87
|
+
| `templates/services/{Entity}Service.ts.template` | **COPIED** to `packages/common/src/services/{Entity}Service.ts` |
|
|
88
|
+
| `templates/repositories/{Entity}Repository.ts.template` | **COPIED** to `packages/common/src/services/{Entity}Repository.ts` |
|
|
89
|
+
| `templates/constants/DB_COLL_NAMES.ts.template` | **MERGED** into `packages/common/src/constants/DB_COLL_NAMES.ts` |
|
|
90
|
+
| _(barrel exports)_ | `packages/common/src/services/index.ts` is **auto-updated** |
|
|
91
|
+
|
|
92
|
+
The merged SERVER_TYPES.ts has comments showing which module contributed each block:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// from package: platform-server
|
|
96
|
+
IAccountService: Symbol.for('IAccountService'),
|
|
97
|
+
// from package: marketplace-module-server
|
|
98
|
+
IRegistryExtensionService: Symbol.for('IRegistryExtensionService'),
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Code Generation Pipeline
|
|
102
|
+
|
|
103
|
+
### Commands
|
|
104
|
+
|
|
105
|
+
| Command | Script | Purpose |
|
|
106
|
+
| ------------------------ | ---------------------------------------- | ---------------------------------------------------------- |
|
|
107
|
+
| `yarn regenerateGraphql` | `tools/codegenGenerator.mjs` | Discover schemas + copy templates → generates `codegen.ts` |
|
|
108
|
+
| `yarn generateGraphql` | `graphql-codegen-esm` (reads codegen.ts) | Generate TypeScript types, Zod schemas, Apollo hooks |
|
|
109
|
+
| `postgenerateGraphql` | `lerna run build --scope=common` | Build the common package (auto-runs after generateGraphql) |
|
|
110
|
+
|
|
111
|
+
### Step 1: `yarn regenerateGraphql`
|
|
112
|
+
|
|
113
|
+
Runs `tools/codegenGenerator.mjs` which:
|
|
114
|
+
|
|
115
|
+
1. Reads `cdecode-config.json` for configuration
|
|
116
|
+
2. Calls `@common-stack/rollup-vite-utils` codegen utilities
|
|
117
|
+
3. **Discovers** all `.graphql` / `.gql` schemas from:
|
|
118
|
+
- `node_modules/@adminide-stack/*/lib/**/*.graphql` (npm packages)
|
|
119
|
+
- `packages/*/server/src/**/*.graphql` (local packages)
|
|
120
|
+
4. **Copies all templates/** to `packages/common/src/`:
|
|
121
|
+
- Merges all `SERVER_TYPES.ts.template` into one `SERVER_TYPES.ts`
|
|
122
|
+
- Copies service/repository interfaces to `services/`
|
|
123
|
+
- Updates `services/index.ts` barrel exports
|
|
124
|
+
5. **Generates** `codegen.ts` with resolved schema paths
|
|
125
|
+
|
|
126
|
+
### Step 2: `yarn generateGraphql`
|
|
127
|
+
|
|
128
|
+
Runs `graphql-codegen-esm` which reads the generated `codegen.ts` and produces 4 output files in `packages/common/src/generated/`:
|
|
129
|
+
|
|
130
|
+
| Output File | Plugin | Purpose |
|
|
131
|
+
| -------------------------- | --------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
132
|
+
| `generated-models.ts` | typescript, typescript-operations, typescript-resolvers, typescript-mongodb | TypeScript interfaces/types from GraphQL schema |
|
|
133
|
+
| `generated-zod-schemas.ts` | `@common-stack/codegen-zod/graphql` | Zod validation schemas from GraphQL types |
|
|
134
|
+
| `generated.tsx` | typescript-react-apollo | React Apollo query/mutation hooks |
|
|
135
|
+
| `introspection-result.ts` | fragment-matcher | Apollo cache fragment matching |
|
|
136
|
+
|
|
137
|
+
After writing all files, two **afterAllFileWrite** hooks run:
|
|
138
|
+
|
|
139
|
+
1. `node scripts/fix-enum-references.js` — Fixes enum reference issues in generated code
|
|
140
|
+
2. `node node_modules/@common-stack/codegen-zod/dist/service/generateAllServiceSchemas.js` — Generates `service-schemas.ts`
|
|
141
|
+
|
|
142
|
+
### Step 3: `generateAllServiceSchemas.js`
|
|
143
|
+
|
|
144
|
+
This script (from `@common-stack/codegen-zod`):
|
|
145
|
+
|
|
146
|
+
1. Reads `cdecode-config.json` → `serviceSchemas` section:
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"serviceSchemas": {
|
|
150
|
+
"servicesDir": "packages/common/src/services",
|
|
151
|
+
"outputFile": "packages/common/src/generated/service-schemas.ts",
|
|
152
|
+
"skipServices": ["AuthBackendClient", "PubSub", ...],
|
|
153
|
+
"graphqlSchemasPath": "packages/common/src/generated/generated-zod-schemas.ts"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
2. **Scans** `packages/common/src/services/` for all `.ts` files
|
|
158
|
+
3. **Parses** each file with TypeScript compiler API looking for `export interface I*Service` or `I*Manager`
|
|
159
|
+
4. **Extracts** method signatures (parameter names, types, optionality)
|
|
160
|
+
5. **Cross-references** with `generated-zod-schemas.ts` to find Zod schemas for GraphQL types
|
|
161
|
+
6. **Generates** `service-schemas.ts` with:
|
|
162
|
+
- A `{ServiceName}Schemas` object per service interface
|
|
163
|
+
- Zod schemas for each method's parameters
|
|
164
|
+
- A `topic` property (Moleculer service name)
|
|
165
|
+
- An aggregated `AllServiceSchemas` export
|
|
166
|
+
|
|
167
|
+
### Step 4: `postgenerateGraphql`
|
|
168
|
+
|
|
169
|
+
Automatically runs after `generateGraphql`:
|
|
170
|
+
|
|
171
|
+
- `lerna run build --scope=common` — Compiles the common package so other packages can use the new types
|
|
172
|
+
|
|
173
|
+
## Complete Pipeline Diagram
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
177
|
+
│ yarn regenerateGraphql │
|
|
178
|
+
│ └─ tools/codegenGenerator.mjs │
|
|
179
|
+
│ └─ reads cdecode-config.json │
|
|
180
|
+
│ └─ calls @common-stack/rollup-vite-utils/codegen │
|
|
181
|
+
│ ├─ Discovers .graphql/.gql schemas from node_modules + │
|
|
182
|
+
│ │ local packages │
|
|
183
|
+
│ ├─ Generates codegen.ts with resolved paths │
|
|
184
|
+
│ ├─ Copies all templates/ → packages/common/src/ │
|
|
185
|
+
│ │ ├─ services/*.ts.template → services/*.ts │
|
|
186
|
+
│ │ ├─ constants/SERVER_TYPES.ts.template → MERGED into │
|
|
187
|
+
│ │ │ constants/SERVER_TYPES.ts │
|
|
188
|
+
│ │ └─ Updates services/index.ts barrel exports │
|
|
189
|
+
│ └─ Sets up common package boilerplate │
|
|
190
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
191
|
+
│ yarn generateGraphql │
|
|
192
|
+
│ └─ graphql-codegen-esm (reads codegen.ts) │
|
|
193
|
+
│ └─ Generates 4 files in packages/common/src/generated/: │
|
|
194
|
+
│ ├─ generated-models.ts (TS types from .graphql) │
|
|
195
|
+
│ ├─ generated-zod-schemas.ts (Zod schemas) │
|
|
196
|
+
│ ├─ generated.tsx (React Apollo hooks) │
|
|
197
|
+
│ └─ introspection-result.ts (fragment matcher) │
|
|
198
|
+
│ └─ afterAllFileWrite hooks: │
|
|
199
|
+
│ ├─ fix-enum-references.js │
|
|
200
|
+
│ └─ generateAllServiceSchemas.js │
|
|
201
|
+
│ └─ Scans services/ interfaces → generates │
|
|
202
|
+
│ service-schemas.ts (Zod schemas for Moleculer) │
|
|
203
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
204
|
+
│ postgenerateGraphql (auto-runs) │
|
|
205
|
+
│ └─ lerna run build --scope=common │
|
|
206
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## How to Add a New Backend Service
|
|
210
|
+
|
|
211
|
+
### Step 1: Create the GraphQL Schema
|
|
212
|
+
|
|
213
|
+
Create a `.graphql` file in the server module:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
packages-modules/{module}/server/src/graphql/schemas/{entity}.graphql
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Define types, queries, mutations.
|
|
220
|
+
|
|
221
|
+
### Step 2: Create Template Files
|
|
222
|
+
|
|
223
|
+
Create template files in the server module's `templates/` folder:
|
|
224
|
+
|
|
225
|
+
**SERVICE_TYPES entries:**
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
packages-modules/{module}/server/src/templates/constants/SERVER_TYPES.ts.template
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Add Symbol.for() entries for new service/repository/dataloader.
|
|
232
|
+
|
|
233
|
+
**Service interface:**
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
packages-modules/{module}/server/src/templates/services/{EntityName}Service.ts.template
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Define the `I{EntityName}Service` interface with method signatures.
|
|
240
|
+
|
|
241
|
+
**Repository interface (if needed):**
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
packages-modules/{module}/server/src/templates/repositories/{EntityName}Repository.ts.template
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Step 3: Run Code Generation
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
yarn regenerateGraphql # Discovers schemas + copies templates to common
|
|
251
|
+
yarn generateGraphql # Generates TS types, Zod schemas, Apollo hooks, service-schemas
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
After this, `packages/common/` will have:
|
|
255
|
+
|
|
256
|
+
- Updated `SERVER_TYPES.ts` with new symbols
|
|
257
|
+
- New service interface file in `services/`
|
|
258
|
+
- Updated `services/index.ts` barrel exports
|
|
259
|
+
- Updated `generated-models.ts` with GraphQL types
|
|
260
|
+
- Updated `service-schemas.ts` with Moleculer schemas
|
|
261
|
+
|
|
262
|
+
### Step 4: Implement the Service
|
|
263
|
+
|
|
264
|
+
Create the concrete implementation:
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
packages-modules/{module}/server/src/services/{entity-name}-service.ts
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Step 5: Create Container Module
|
|
271
|
+
|
|
272
|
+
Bind the service in the container:
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
packages-modules/{module}/server/src/containers/module.ts
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Step 6: Create Resolver
|
|
279
|
+
|
|
280
|
+
Create the GraphQL resolver:
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
packages-modules/{module}/server/src/graphql/resolvers/{entity-name}-resolver.ts
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Step 7: Wire into Feature Module
|
|
287
|
+
|
|
288
|
+
Update the Feature in:
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
packages-modules/{module}/server/src/module.ts
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Reusing Generated GraphQL Types in Templates
|
|
295
|
+
|
|
296
|
+
When writing `.ts.template` files, **always prefer importing types that are already generated from GraphQL schemas** rather than defining duplicate interfaces manually.
|
|
297
|
+
|
|
298
|
+
### Why
|
|
299
|
+
|
|
300
|
+
The `yarn generateGraphql` step produces TypeScript types in `packages/common/src/generated/generated-models.ts` for every GraphQL type, query, and mutation. These generated types are the **single source of truth** for the shape of data flowing through the GraphQL layer. If a template redefines the same structure (even with a different name), the two can drift apart when the schema evolves.
|
|
301
|
+
|
|
302
|
+
### How
|
|
303
|
+
|
|
304
|
+
Template files are copied into `packages/common/src/services/` — so they can import from `'common/server'` just like any other file in the common package. The generated types are re-exported through `common/server`.
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// ✅ CORRECT — import the generated type
|
|
308
|
+
import { IExtensionContributes } from 'common/server';
|
|
309
|
+
|
|
310
|
+
export interface IExtensionContributesProvider {
|
|
311
|
+
getContributes(extensionId: string, version?: string): Promise<IExtensionContributes>;
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
// ❌ WRONG — manually redefining the same shape
|
|
317
|
+
export interface IExtensionContributesResult {
|
|
318
|
+
uiLayout?: Record<string, unknown>[];
|
|
319
|
+
configuration?: Record<string, unknown>[];
|
|
320
|
+
// ... duplicates the GraphQL-generated IExtensionContributes
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface IExtensionContributesProvider {
|
|
324
|
+
getContributes(extensionId: string, version?: string): Promise<IExtensionContributesResult>;
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### When to Define Your Own Types
|
|
329
|
+
|
|
330
|
+
Only define a type locally in the template when:
|
|
331
|
+
|
|
332
|
+
- The type has **no corresponding GraphQL schema definition** (e.g., an internal-only DTO not exposed via the API)
|
|
333
|
+
- The type intentionally **differs** from the GraphQL type (e.g., a partial/extended variant)
|
|
334
|
+
- The type is a **generic utility** interface not tied to a schema entity
|
|
335
|
+
|
|
336
|
+
### Existing Templates That Import Generated Types
|
|
337
|
+
|
|
338
|
+
Many existing templates already follow this pattern:
|
|
339
|
+
|
|
340
|
+
| Template | Imports from `'common/server'` |
|
|
341
|
+
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
|
|
342
|
+
| `ExtensionGalleryService.ts.template` | `IGalleryExtension`, `IExtensionManifest`, `IGalleryPager`, `AsDomainType`, `IRegistryExtensionModel` |
|
|
343
|
+
| `ExtensionGalleryDataLoader.ts.template` | `IGalleryExtension`, `IDataLoader` |
|
|
344
|
+
| `InstalledExtensionService.ts.template` | Multiple model types |
|
|
345
|
+
| `MarketplacePublisherService.ts.template` | `IMarketplacePublisherModel`, `AsDomainType` |
|
|
346
|
+
| `ExtensionContributionService.ts.template` | `IExtensionContributes` |
|
|
347
|
+
|
|
348
|
+
### Pipeline Order Consideration
|
|
349
|
+
|
|
350
|
+
Since `yarn regenerateGraphql` (copies templates) runs **before** `yarn generateGraphql` (generates types), you might wonder: how can a template import a type that hasn't been generated yet?
|
|
351
|
+
|
|
352
|
+
The answer is that generated types from **previous runs** are already present in `packages/common/src/generated/`. The pipeline is designed to be run incrementally:
|
|
353
|
+
|
|
354
|
+
1. First run: Define the `.graphql` schema → `generateGraphql` produces the types
|
|
355
|
+
2. Second run (or same session): Create the template that imports those types → `regenerateGraphql` copies the template → `generateGraphql` regenerates (types already exist)
|
|
356
|
+
|
|
357
|
+
In practice, you always run both commands together, so the generated types are available by the time the common package is compiled.
|
|
358
|
+
|
|
359
|
+
## Key Rules
|
|
360
|
+
|
|
361
|
+
1. **NEVER manually edit `packages/common/`** — all files are generated
|
|
362
|
+
2. **ALWAYS create `.ts.template` files** in your module's `templates/` folder for new interfaces
|
|
363
|
+
3. **ALWAYS run `yarn regenerateGraphql`** after creating/modifying template files
|
|
364
|
+
4. **ALWAYS run `yarn generateGraphql`** after creating/modifying `.graphql` schema files
|
|
365
|
+
5. **The `postgenerateGraphql` script runs automatically** — no need to manually build common
|
|
366
|
+
6. **SERVER_TYPES.ts is a merge of ALL modules'** `SERVER_TYPES.ts.template` files
|
|
367
|
+
7. **service-schemas.ts is auto-generated** from service interfaces in `packages/common/src/services/`
|
|
368
|
+
8. **PREFER importing generated GraphQL types** (`import { ITypeName } from 'common/server'`) over redefining the same shape in templates — the GraphQL schema is the single source of truth for API types
|
|
369
|
+
|
|
370
|
+
## Downstream Stacks (e.g., forms-stack)
|
|
371
|
+
|
|
372
|
+
Downstream stacks consume upstream npm packages. The flow:
|
|
373
|
+
|
|
374
|
+
1. Upstream (adminIde-stack) publishes `@adminide-stack/*` packages with compiled `.graphql` schemas in `lib/`
|
|
375
|
+
2. Downstream `codegen.ts` picks up schemas from `node_modules/@adminide-stack/*/lib/**/*.graphql`
|
|
376
|
+
3. Downstream `yarn regenerateGraphql` copies templates from both:
|
|
377
|
+
- npm packages (upstream templates)
|
|
378
|
+
- Local packages (downstream-only templates)
|
|
379
|
+
4. This is why downstream common packages have upstream types — they come through the template copy process
|
|
380
|
+
|
|
381
|
+
### Adding a New Service in Downstream Stack
|
|
382
|
+
|
|
383
|
+
If the service interface already exists in the upstream npm package:
|
|
384
|
+
|
|
385
|
+
- Just run `yarn regenerateGraphql` — it will copy the template from `node_modules/`
|
|
386
|
+
- Then run `yarn generateGraphql` — it will pick up `.graphql` schemas from `node_modules/`
|
|
387
|
+
|
|
388
|
+
If the upstream package hasn't been published yet:
|
|
389
|
+
|
|
390
|
+
- Define interfaces **locally** in the module (NOT in common)
|
|
391
|
+
- Use `Symbol.for()` for DI tokens to ensure cross-container compatibility
|
|
392
|
+
- Once upstream publishes, run `yarn regenerateGraphql` to get the official templates
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# MCP Servers Setup Guide
|
|
2
|
+
|
|
3
|
+
Share the pre-configured MCP (Model Context Protocol) servers with your team so every developer gets **Zep memory** and **Neo4j knowledge graph** tools in VS Code Copilot.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What's Included
|
|
8
|
+
|
|
9
|
+
| Server | Purpose | Tools Provided |
|
|
10
|
+
| --------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| **Zep** | Long-term memory & LLM coding guides | `search_memory`, `get_session_messages`, `get_session_memory`, `list_sessions`, `list_users`, `get_user` |
|
|
12
|
+
| **Neo4j** | Knowledge graph queries | `cypher_query`, `get_schema` |
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## For the Person Sharing (One-Time)
|
|
17
|
+
|
|
18
|
+
### Create the Bundle
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd ~
|
|
22
|
+
zip -r mcp-servers-bundle.zip \
|
|
23
|
+
.vscode/mcp-servers/neo4j-mcp/server.mjs \
|
|
24
|
+
.vscode/mcp-servers/neo4j-mcp/package.json \
|
|
25
|
+
.vscode/mcp-servers/neo4j-mcp/package-lock.json \
|
|
26
|
+
.vscode/mcp-servers/zep-mcp/server.mjs \
|
|
27
|
+
.vscode/mcp-servers/zep-mcp/package.json \
|
|
28
|
+
.vscode/mcp-servers/zep-mcp/package-lock.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This produces a **~29 KB** zip (excludes `node_modules/`). Share via Slack, email, or your internal file store.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## For Recipients
|
|
36
|
+
|
|
37
|
+
### Step 1 — Unzip
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd ~
|
|
41
|
+
unzip mcp-servers-bundle.zip
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This creates:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
~/.vscode/mcp-servers/
|
|
48
|
+
├── neo4j-mcp/
|
|
49
|
+
│ ├── server.mjs
|
|
50
|
+
│ ├── package.json
|
|
51
|
+
│ └── package-lock.json
|
|
52
|
+
└── zep-mcp/
|
|
53
|
+
├── server.mjs
|
|
54
|
+
├── package.json
|
|
55
|
+
└── package-lock.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Step 2 — Install Dependencies
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cd ~/.vscode/mcp-servers/neo4j-mcp && npm install
|
|
62
|
+
cd ~/.vscode/mcp-servers/zep-mcp && npm install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Step 3 — Add MCP Configuration
|
|
66
|
+
|
|
67
|
+
Open (or create) the **global** MCP config file:
|
|
68
|
+
|
|
69
|
+
| OS | Path |
|
|
70
|
+
| ----------- | -------------------------------------------------- |
|
|
71
|
+
| **macOS** | `~/Library/Application Support/Code/User/mcp.json` |
|
|
72
|
+
| **Linux** | `~/.config/Code/User/mcp.json` |
|
|
73
|
+
| **Windows** | `%APPDATA%\Code\User\mcp.json` |
|
|
74
|
+
|
|
75
|
+
Paste the following:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"servers": {
|
|
80
|
+
"neo4j": {
|
|
81
|
+
"type": "stdio",
|
|
82
|
+
"command": "node",
|
|
83
|
+
"args": ["${userHome}/.vscode/mcp-servers/neo4j-mcp/server.mjs"],
|
|
84
|
+
"env": {
|
|
85
|
+
"NEO4J_URI": "neo4j+s://neo4j-bolt.cdebase.dev:443",
|
|
86
|
+
"NEO4J_USERNAME": "neo4j",
|
|
87
|
+
"NEO4J_PASSWORD": "zepzepzep",
|
|
88
|
+
"NEO4J_DATABASE": "neo4j"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"zep": {
|
|
92
|
+
"type": "stdio",
|
|
93
|
+
"command": "node",
|
|
94
|
+
"args": ["${userHome}/.vscode/mcp-servers/zep-mcp/server.mjs"],
|
|
95
|
+
"env": {
|
|
96
|
+
"ZEP_API_URL": "https://zep.cdebase.dev",
|
|
97
|
+
"ZEP_API_KEY": "emVwLXNlY3JldC1rZXktY2hhbmdlLW1lLWluLXByb2R1Y3Rpb24="
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> **`${userHome}`** is resolved by VS Code at runtime — no need to hardcode your username.
|
|
105
|
+
|
|
106
|
+
### Step 4 — Restart VS Code
|
|
107
|
+
|
|
108
|
+
Reload the window (`Cmd+Shift+P` → "Developer: Reload Window") or restart VS Code entirely.
|
|
109
|
+
|
|
110
|
+
### Step 5 — Verify
|
|
111
|
+
|
|
112
|
+
Open Copilot Chat (Agent mode) and ask:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Search Zep memory for "backend service creation guide"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You should see results from the `cdebase-llm-guides` session.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Troubleshooting
|
|
123
|
+
|
|
124
|
+
### MCP servers not showing up
|
|
125
|
+
|
|
126
|
+
1. Check the config path is correct for your OS
|
|
127
|
+
2. Ensure `node` is available in your PATH (`node --version`)
|
|
128
|
+
3. Confirm `npm install` completed without errors in both server directories
|
|
129
|
+
|
|
130
|
+
### "unauthorized" errors from Zep or Neo4j
|
|
131
|
+
|
|
132
|
+
- The API keys/passwords in the config are for the shared dev environment
|
|
133
|
+
- If credentials have been rotated, get the new values from the team lead
|
|
134
|
+
|
|
135
|
+
### Servers appear but tools fail
|
|
136
|
+
|
|
137
|
+
- Restart the MCP server: `Cmd+Shift+P` → "MCP: List Servers" → select the server → "Restart"
|
|
138
|
+
- Check VS Code Output panel → select the MCP server from the dropdown for error logs
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Adding More MCP Servers Later
|
|
143
|
+
|
|
144
|
+
1. Create a new folder under `~/.vscode/mcp-servers/{server-name}/`
|
|
145
|
+
2. Add `server.mjs`, `package.json`, and install dependencies
|
|
146
|
+
3. Add a new entry in `mcp.json` under `"servers"`
|
|
147
|
+
4. Re-zip and redistribute the bundle to the team
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdmbase/wiki-browser",
|
|
3
|
-
"version": "12.0.18-alpha.
|
|
3
|
+
"version": "12.0.18-alpha.31",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
}
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "0ca551ec8a669f790a8470ff043833da3667a811",
|
|
69
69
|
"typescript": {
|
|
70
70
|
"definition": "lib/index.d.ts"
|
|
71
71
|
}
|