@jaypie/mcp 0.1.10 → 0.2.1

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 (41) hide show
  1. package/dist/datadog.d.ts +212 -0
  2. package/dist/index.js +1461 -6
  3. package/dist/index.js.map +1 -1
  4. package/package.json +9 -5
  5. package/prompts/Development_Process.md +57 -35
  6. package/prompts/Jaypie_CDK_Constructs_and_Patterns.md +143 -19
  7. package/prompts/Jaypie_Express_Package.md +35 -15
  8. package/prompts/Jaypie_Init_Express_on_Lambda.md +66 -38
  9. package/prompts/Jaypie_Init_Lambda_Package.md +202 -83
  10. package/prompts/Jaypie_Init_Project_Subpackage.md +21 -26
  11. package/prompts/Jaypie_Legacy_Patterns.md +4 -0
  12. package/prompts/Jaypie_Repokit.md +103 -0
  13. package/prompts/Templates_CDK_Subpackage.md +113 -0
  14. package/prompts/Templates_Express_Subpackage.md +183 -0
  15. package/prompts/Templates_Project_Monorepo.md +326 -0
  16. package/prompts/Templates_Project_Subpackage.md +93 -0
  17. package/prompts/Jaypie_Mongoose_Models_Package.md +0 -231
  18. package/prompts/Jaypie_Mongoose_with_Express_CRUD.md +0 -1000
  19. package/prompts/templates/cdk-subpackage/bin/cdk.ts +0 -11
  20. package/prompts/templates/cdk-subpackage/cdk.json +0 -19
  21. package/prompts/templates/cdk-subpackage/lib/cdk-app.ts +0 -41
  22. package/prompts/templates/cdk-subpackage/lib/cdk-infrastructure.ts +0 -15
  23. package/prompts/templates/express-subpackage/index.ts +0 -8
  24. package/prompts/templates/express-subpackage/src/app.ts +0 -18
  25. package/prompts/templates/express-subpackage/src/handler.config.ts +0 -44
  26. package/prompts/templates/express-subpackage/src/routes/resource/__tests__/resourceGet.route.spec.ts +0 -29
  27. package/prompts/templates/express-subpackage/src/routes/resource/resourceGet.route.ts +0 -22
  28. package/prompts/templates/express-subpackage/src/routes/resource.router.ts +0 -11
  29. package/prompts/templates/express-subpackage/src/types/express.ts +0 -9
  30. package/prompts/templates/project-monorepo/.vscode/settings.json +0 -72
  31. package/prompts/templates/project-monorepo/eslint.config.mjs +0 -1
  32. package/prompts/templates/project-monorepo/gitignore +0 -11
  33. package/prompts/templates/project-monorepo/package.json +0 -20
  34. package/prompts/templates/project-monorepo/tsconfig.base.json +0 -18
  35. package/prompts/templates/project-monorepo/tsconfig.json +0 -6
  36. package/prompts/templates/project-monorepo/vitest.workspace.js +0 -3
  37. package/prompts/templates/project-subpackage/package.json +0 -16
  38. package/prompts/templates/project-subpackage/tsconfig.json +0 -11
  39. package/prompts/templates/project-subpackage/vite.config.ts +0 -21
  40. package/prompts/templates/project-subpackage/vitest.config.ts +0 -7
  41. package/prompts/templates/project-subpackage/vitest.setup.ts +0 -6
@@ -1,231 +0,0 @@
1
- ---
2
- description: Document describes a Jaypie pattern repeated in many projects but not yet offered as a package within Jaypie
3
- globs: packages/models/**
4
- status: Work in Progress
5
- ---
6
-
7
- # Jaypie Mongoose Models Package
8
-
9
- Create reusable MongoDB models with rich relationship management using Mongoose and Jaypie.
10
-
11
- ## Goal
12
-
13
- Define document schemas with bidirectional relationships and consistent utilities for mongoose models.
14
-
15
- ## Guidelines
16
-
17
- - Uses ES modules with `.js` extensions (`"type": "module"`)
18
- - Requires mongoose and jaypie as dependencies
19
- - Follows schema organization pattern: definition → hooks → methods → statics → export
20
- - Every schema should use `projectSchema.plugin.js` for relationship methods
21
- - Every document has `uuid` field for external references
22
-
23
- ## Process
24
-
25
- ### Package Setup
26
-
27
- 1. Create package structure:
28
- ```
29
- models/
30
- ├── package.json
31
- ├── src/
32
- │ ├── constants.js
33
- │ ├── index.js
34
- │ ├── user.schema.js
35
- │ ├── projectSchema.plugin.js
36
- │ └── __tests__/
37
- │ ├── constants.spec.js
38
- │ ├── index.spec.js
39
- │ ├── user.schema.spec.js
40
- │ └── projectSchema.plugin.spec.js
41
- ├── testSetup.js
42
- └── vite.config.js
43
- ```
44
-
45
- 2. Configure package.json:
46
- ```json
47
- {
48
- "name": "@yournamespace/models",
49
- "type": "module",
50
- "exports": {
51
- ".": {
52
- "default": {
53
- "require": "./dist/module.cjs.js",
54
- "default": "./src/index.js"
55
- }
56
- }
57
- },
58
- "main": "src/index.js",
59
- "dependencies": {
60
- "jaypie": "^1.1.0",
61
- "mongoose": "^7.0.0"
62
- }
63
- }
64
- ```
65
-
66
- ### Core Files Implementation
67
-
68
- 1. projectSchema.plugin.js
69
- - Plugin providing relationship management methods
70
- - Key functions: allLeanByIds, allLeanByUuids, createWithRelationships, deleteWithRelationships, toJsonWithRelationships, updateWithRelationships
71
- - Utility functions: idsToUuids, uuidsToIds, oneByUuid, oneByXid
72
-
73
- 2. constants.ts
74
- ```typescript
75
- import { v5 as uuidv5 } from "uuid";
76
-
77
- const NAMESPACE_ROOT = "your-namespace-uuid";
78
- export const NAMESPACE = {
79
- USER: uuidv5("USER", NAMESPACE_ROOT),
80
- };
81
-
82
- export const SCHEMA = {
83
- USER: "user",
84
- };
85
-
86
- export default {
87
- NAMESPACE,
88
- SCHEMA,
89
- };
90
- ```
91
-
92
- 3. user.schema.ts
93
- ```typescript
94
- import { Schema } from "mongoose";
95
- import projectSchema from "./projectSchema.plugin.js";
96
-
97
- const schema = new Schema(
98
- {
99
- deletedAt: {
100
- type: Schema.Types.Date,
101
- },
102
- name: {
103
- type: Schema.Types.String,
104
- },
105
- uuid: {
106
- index: true,
107
- type: Schema.Types.String,
108
- },
109
- xid: {
110
- index: true,
111
- type: Schema.Types.String,
112
- },
113
- },
114
- { timestamps: true },
115
- );
116
-
117
- schema.plugin(projectSchema);
118
-
119
- export default schema;
120
- ```
121
-
122
- 4. index.ts
123
- ```typescript
124
- import { connect, disconnect, envsKey, log } from "jaypie";
125
- import mongoose, { Model, Schema } from "mongoose";
126
- import { SCHEMA } from "./constants.js";
127
- import userSchema from "./user.schema.js";
128
-
129
- let instantiatedModel: Record<string, Model<any>> | null;
130
- const { model } = mongoose;
131
-
132
- function getModel(name: string, schema: Schema): Model<any> {
133
- if (!instantiatedModel) {
134
- log.warn("[@yournamespace/models] Models have not been instantiated");
135
- instantiatedModel = {};
136
- }
137
- return instantiatedModel[name] || (instantiatedModel[name] = model(name, schema));
138
- }
139
-
140
- export default {
141
- connect: async (uri: string = envsKey("MONGODB_URI")) => {
142
- if (instantiatedModel) {
143
- log.warn("[@yournamespace/models] Models already instantiated");
144
- } else {
145
- instantiatedModel = {};
146
- }
147
- return uri ? mongoose.connect(uri) : connect();
148
- },
149
- disconnect: () => {
150
- instantiatedModel = null;
151
- return disconnect();
152
- },
153
- get User() {
154
- return getModel(SCHEMA.USER, userSchema);
155
- },
156
- };
157
-
158
- export { default as MODEL } from "./constants.js";
159
- ```
160
-
161
- ### Testing
162
-
163
- 1. vite.config.ts
164
- ```typescript
165
- import { defineConfig } from "vite";
166
-
167
- export default defineConfig({
168
- test: {
169
- globals: false,
170
- setupFiles: ["./testSetup.ts"],
171
- },
172
- });
173
- ```
174
-
175
- 2. testSetup.ts
176
- ```typescript
177
- import { beforeEach, vi } from "vitest";
178
- import mongoose from "mongoose";
179
-
180
- // Mock mongoose methods
181
- vi.mock("mongoose", async () => {
182
- const actual = await vi.importActual("mongoose");
183
- return {
184
- ...actual,
185
- connect: vi.fn().mockResolvedValue({}),
186
- disconnect: vi.fn().mockResolvedValue({}),
187
- };
188
- });
189
-
190
- // Reset mocks before each test
191
- beforeEach(() => {
192
- vi.clearAllMocks();
193
- });
194
- ```
195
-
196
- ### Usage
197
-
198
- 1. Connect to database:
199
- ```typescript
200
- import Model from "@yournamespace/models";
201
-
202
- await Model.connect();
203
- ```
204
-
205
- 2. Create document:
206
- ```typescript
207
- const user = await Model.User.createWithRelationships({
208
- uuid: "user-uuid",
209
- values: { name: "Test User" },
210
- });
211
- ```
212
-
213
- 3. Find document:
214
- ```typescript
215
- const user = await Model.User.oneByUuid("user-uuid");
216
- ```
217
-
218
- 4. Update with relationships:
219
- ```typescript
220
- await Model.User.updateWithRelationships({
221
- uuid: "user-uuid",
222
- values: { name: "Updated Name" },
223
- });
224
- ```
225
-
226
- 5. Delete with relationships:
227
- ```typescript
228
- await Model.User.deleteWithRelationships({
229
- uuid: "user-uuid",
230
- });
231
- ```