@jaypie/mcp 0.1.9 → 0.2.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 (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 +10 -7
  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 +408 -0
  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/Templates_CDK_Subpackage.md +113 -0
  13. package/prompts/Templates_Express_Subpackage.md +183 -0
  14. package/prompts/Templates_Project_Monorepo.md +326 -0
  15. package/prompts/Templates_Project_Subpackage.md +93 -0
  16. package/LICENSE.txt +0 -21
  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,68 +1,78 @@
1
1
  ---
2
2
  trigger: model_decision
3
- description: When asked to create a new workspace or subpackage for express, usually packages/express, to run as serverless Lambdas behind API Gateway
3
+ description: Create a new Express application subpackage that runs as a serverless Lambda behind API Gateway using @jaypie/express utilities
4
4
  ---
5
5
 
6
- # Jaypie Initialize Express on Lambda Subpackage
6
+ # Jaypie Initialize Express Application on Lambda
7
+
8
+ Create an Express application subpackage that uses @jaypie/express to run as a serverless Lambda behind API Gateway. This prompt is for creating **application packages** (like packages/api or packages/backend), not the @jaypie/express library itself.
7
9
 
8
10
  ## Process
9
11
 
10
12
  1. Follow Jaypie_Init_Project_Subpackage.md:
11
- * Use @project-org/express in packages/express
13
+ * Choose an appropriate package name (e.g., @project-org/api, @project-org/backend)
14
+ * Use packages/<package-name> for the directory (e.g., packages/api)
12
15
  * This creates the basic subpackage structure with package.json, tsconfig.json, and vitest config files
13
16
 
14
- 2. Copy Express-specific template files:
15
- * Copy `prompts/templates/express-subpackage/index.ts` to `packages/express/index.ts`
16
- * Copy `prompts/templates/express-subpackage/src/app.ts` to `packages/express/src/app.ts`
17
- * Copy `prompts/templates/express-subpackage/src/handler.config.ts` to `packages/express/src/handler.config.ts`
18
- * Copy `prompts/templates/express-subpackage/src/routes/resource.router.ts` to `packages/express/src/routes/resource.router.ts`
19
- * Copy `prompts/templates/express-subpackage/src/routes/resource/resourceGet.route.ts` to `packages/express/src/routes/resource/resourceGet.route.ts`
20
- * Copy `prompts/templates/express-subpackage/src/routes/resource/__tests__/resourceGet.route.spec.ts` to `packages/express/src/routes/resource/__tests__/resourceGet.route.spec.ts`
21
- * Copy `prompts/templates/express-subpackage/src/types/express.ts` to `packages/express/src/types/express.ts`
17
+ 2. Create Express application files using Templates_Express_Subpackage.md:
18
+ * Create `packages/<package-name>/index.ts` using the index.ts template
19
+ * Create `packages/<package-name>/src/app.ts` using the app.ts template
20
+ * Create `packages/<package-name>/src/handler.config.ts` using the handler.config.ts template
21
+ * Create `packages/<package-name>/src/routes/resource.router.ts` using the resource.router.ts template
22
+ * Create `packages/<package-name>/src/routes/resource/resourceGet.route.ts` using the resourceGet.route.ts template
23
+ * Create `packages/<package-name>/src/routes/resource/__tests__/resourceGet.route.spec.ts` using the test template
24
+ * Create `packages/<package-name>/src/types/express.ts` using the express types template
25
+ * All templates are documented in Templates_Express_Subpackage.md
22
26
 
23
27
  3. Update package.json scripts:
24
- * Modify the existing scripts section to include:
28
+ * Add these scripts to the package.json:
25
29
  * `"dev": "tsx watch index.ts"`
26
30
  * `"start": "node dist/index.js"`
27
31
  * `"build": "tsc"`
28
- * Run `npm run format:package`
32
+ * Keep existing scripts from the template (test, lint, typecheck, format)
33
+ * Run `npm --workspace ./packages/<package-name> run format:package`
29
34
 
30
35
  4. Install dependencies:
31
- * `npm --workspace ./packages/express install jaypie express @codegenie/serverless-express`
32
- * `npm --workspace ./packages/express install --save-dev @types/express @types/cors`
33
- * Always run `npm install`, never update package.json with dependencies from memory
36
+ * `npm --workspace ./packages/<package-name> install jaypie express @codegenie/serverless-express`
37
+ * `npm --workspace ./packages/<package-name> install --save-dev @types/express @types/cors tsx`
38
+ * Always use npm install commands; never manually edit package.json dependencies
34
39
 
35
40
  5. Update TypeScript configuration:
36
- * Update packages/express/tsconfig.json to include index.ts in the include array: `"include": ["src/**/*", "index.ts"]`
41
+ * Edit packages/<package-name>/tsconfig.json to include index.ts in the include array
42
+ * Change include to: `"include": ["src/**/*", "index.ts"]`
37
43
  * Change exclude to: `"exclude": ["node_modules", "dist", "**/*.spec.ts"]`
38
- * Test the build
39
- * Ensure dist/ is in gitignore
44
+ * Test the build with `npm --workspace ./packages/<package-name> run build`
45
+ * Verify dist/ is in root .gitignore (it should already be there)
40
46
 
41
47
  6. Update the top-level package.json:
42
- * Add `"dev:express": "npm --workspace packages/express run dev"` and `"start:express": "npm --workspace packages/express run start"`
43
- * If there is no stand-alone `dev` or `start`, create a `dev` running `dev:express` and `start` running `start:express`
44
- * If `dev` or `start` exist, add calls to express if it fits the goal of the current commands
48
+ * Add workspace-specific dev and start scripts
49
+ * Add `"dev:<package-name>": "npm --workspace packages/<package-name> run dev"`
50
+ * Add `"start:<package-name>": "npm --workspace packages/<package-name> run start"`
51
+ * If there is no standalone `dev` or `start` script, create them referencing the new package
52
+ * If `dev` or `start` scripts already exist, consider whether to update them based on project needs
45
53
 
46
54
  ## Pattern
47
55
 
48
56
  - TypeScript with ES modules (`"type": "module"`)
49
57
  - Handler pattern: configuration → lifecycle → processing → response
50
- - Optional `handlerConfig` for shared configuration and lifecycle management
51
- - Clean separation of concerns with middleware patterns
52
- - Lambda-optimized Express configuration
58
+ - Use `handlerConfig` helper for shared configuration and lifecycle management
59
+ - Separation of concerns: routers, route handlers, and middleware
60
+ - Lambda-optimized Express configuration using @codegenie/serverless-express
61
+ - Development mode: Express listens on port 8080 when NODE_ENV=development
53
62
 
54
63
  ## Structure
55
64
 
56
65
  ```
57
- express/
66
+ <package-name>/
58
67
  ├── package.json
59
68
  ├── tsconfig.json
60
- ├── vitest.config.ts
61
- ├── vitest.setup.ts
62
- ├── index.ts
69
+ ├── vite.config.ts # From template
70
+ ├── vitest.config.ts # From template
71
+ ├── vitest.setup.ts # From template
72
+ ├── index.ts # Lambda handler entry point
63
73
  ├── src/
64
- │ ├── app.ts
65
- │ ├── handler.config.ts
74
+ │ ├── app.ts # Express app configuration
75
+ │ ├── handler.config.ts # Shared handler configuration helper
66
76
  │ ├── routes/
67
77
  │ │ ├── resource.router.ts
68
78
  │ │ └── resource/
@@ -70,18 +80,36 @@ express/
70
80
  │ │ └── __tests__/
71
81
  │ │ └── resourceGet.route.spec.ts
72
82
  │ └── types/
73
- │ └── express.ts
74
- └── dist/
83
+ │ └── express.ts # Express type augmentation for req.locals
84
+ └── dist/ # Generated by tsc
75
85
  ```
76
86
 
77
87
  ## Local Development
78
88
 
79
- ### Listening on Port 8080
89
+ The index.ts template checks `process.env.NODE_ENV === "development"` to enable local development mode. In this mode, Express listens on port 8080 (port 3000 is typically reserved for frontend applications).
90
+
91
+ Start local development with:
92
+ ```bash
93
+ npm run dev:<package-name>
94
+ ```
80
95
 
81
- A local entrypoint, usually index.ts, may check `process.env.NODE_ENV === "development"` and be allowed to listen on port 8080 (preserving 3000 for front ends).
82
- `npm run dev:express` should be configured to initialize this mode locally.
96
+ This runs `tsx watch index.ts`, which:
97
+ - Sets up the Express app
98
+ - Listens on port 8080
99
+ - Auto-reloads on file changes
100
+ - Does not invoke serverless-express wrapper
83
101
 
84
102
  ## Version Compatibility
85
103
 
86
- Jaypie uses Express 4.
87
- There is no immediately planned upgrade to Express 5.
104
+ - Express: 4.x (Express 5 upgrade not planned)
105
+ - Node: ES modules with TypeScript
106
+ - @codegenie/serverless-express: 4.x
107
+ - @types/express: Compatible with Express 4.x
108
+
109
+ ## Context Files
110
+
111
+ Reference these files for additional guidance:
112
+ - `Jaypie_Init_Project_Subpackage.md` - Subpackage initialization process
113
+ - `Templates_Express_Subpackage.md` - Code templates for all files
114
+ - `Jaypie_Express_Package.md` - Documentation on @jaypie/express features
115
+ - `Jaypie_Core_Errors_and_Logging.md` - Error handling patterns
@@ -25,10 +25,10 @@ Create AWS Lambda functions that integrate with Jaypie for event-driven processi
25
25
  ```
26
26
  packages/lambda/
27
27
  ├── package.json # Define dependencies and scripts
28
- ├── tsconfig.json # TypeScript configuration
29
- ├── rollup.config.ts # Bundle configuration
30
- ├── vitest.config.ts # Test configuration
31
- ├── vitest.setup.ts # Test setup and mocks
28
+ ├── tsconfig.json # TypeScript configuration
29
+ ├── rollup.config.mjs # Bundle configuration
30
+ ├── vite.config.js # Test configuration
31
+ ├── testSetup.ts # Test setup and matchers
32
32
  └── src/
33
33
  ├── index.ts # Export handlers
34
34
  ├── worker.ts # Lambda function implementation
@@ -43,21 +43,37 @@ packages/lambda/
43
43
  "name": "@yourorg/lambda",
44
44
  "version": "0.1.0",
45
45
  "type": "module",
46
- "main": "dist/index.js",
47
- "types": "dist/index.d.ts",
46
+ "exports": {
47
+ ".": {
48
+ "types": "./dist/esm/index.d.ts",
49
+ "import": "./dist/esm/index.js",
50
+ "require": "./dist/cjs/index.cjs"
51
+ }
52
+ },
53
+ "main": "./dist/cjs/index.cjs",
54
+ "module": "./dist/esm/index.js",
55
+ "types": "./dist/esm/index.d.ts",
56
+ "files": [
57
+ "dist"
58
+ ],
48
59
  "scripts": {
49
60
  "build": "rollup --config",
61
+ "format": "npm run format:package && npm run format:lint",
62
+ "format:lint": "eslint --fix .",
63
+ "format:package": "sort-package-json ./package.json",
50
64
  "lint": "eslint .",
51
- "test": "vitest run",
65
+ "test": "vitest run .",
52
66
  "typecheck": "tsc --noEmit"
53
67
  },
54
68
  "dependencies": {
55
- "jaypie": "^1.1.0"
69
+ "@jaypie/core": "^1.1.0",
70
+ "@jaypie/lambda": "^1.1.0"
56
71
  },
57
72
  "devDependencies": {
58
73
  "@rollup/plugin-typescript": "^12.0.0",
59
74
  "@types/aws-lambda": "^8.10.0",
60
75
  "rollup": "^4.0.0",
76
+ "rollup-plugin-auto-external": "^2.0.0",
61
77
  "typescript": "^5.0.0"
62
78
  }
63
79
  }
@@ -74,107 +90,124 @@ packages/lambda/
74
90
  "declaration": true,
75
91
  "outDir": "./dist",
76
92
  "strict": true,
77
- "esModuleInterop": true
93
+ "esModuleInterop": true,
94
+ "skipLibCheck": true,
95
+ "forceConsistentCasingInFileNames": true
78
96
  },
79
97
  "include": ["src/**/*"],
80
- "exclude": ["node_modules", "dist"]
98
+ "exclude": ["node_modules", "dist", "src/__tests__"]
81
99
  }
82
100
  ```
83
101
 
84
102
  ### 4. Configure Rollup
85
103
 
86
- ```typescript
104
+ Create `rollup.config.mjs`:
105
+
106
+ ```javascript
107
+ import autoExternal from "rollup-plugin-auto-external";
87
108
  import typescript from "@rollup/plugin-typescript";
88
- import type { RollupOptions } from "rollup";
89
109
 
90
- const config: RollupOptions[] = [
110
+ export default [
111
+ // ES modules version
91
112
  {
92
- input: "src/worker.ts",
113
+ input: "src/index.ts",
93
114
  output: {
94
- file: "dist/worker.js",
115
+ dir: "dist/esm",
95
116
  format: "es",
96
- sourcemap: true
117
+ sourcemap: true,
97
118
  },
98
119
  plugins: [
120
+ autoExternal(),
99
121
  typescript({
100
- exclude: ["**/__tests__/**/*"]
101
- })
122
+ tsconfig: "./tsconfig.json",
123
+ declaration: true,
124
+ outDir: "dist/esm",
125
+ }),
102
126
  ],
103
- external: ["jaypie"]
104
127
  },
128
+ // CommonJS version
105
129
  {
106
130
  input: "src/index.ts",
107
131
  output: {
108
- file: "dist/index.js",
109
- format: "es",
110
- sourcemap: true
132
+ dir: "dist/cjs",
133
+ format: "cjs",
134
+ sourcemap: true,
135
+ exports: "named",
136
+ entryFileNames: "[name].cjs",
111
137
  },
112
138
  plugins: [
139
+ autoExternal(),
113
140
  typescript({
114
- exclude: ["**/__tests__/**/*"]
115
- })
141
+ tsconfig: "./tsconfig.json",
142
+ declaration: true,
143
+ outDir: "dist/cjs",
144
+ }),
116
145
  ],
117
- external: ["jaypie"]
118
- }
146
+ },
119
147
  ];
120
-
121
- export default config;
122
148
  ```
123
149
 
124
150
  ### 5. Setup Vitest
125
151
 
126
- ```typescript
127
- // vitest.config.ts
152
+ Create `vite.config.js`:
153
+
154
+ ```javascript
155
+ /// <reference types="vitest" />
156
+
128
157
  import { defineConfig } from "vite";
129
158
 
130
159
  export default defineConfig({
131
160
  test: {
132
- setupFiles: ["./vitest.setup.ts"]
133
- }
161
+ setupFiles: ["./testSetup.ts"],
162
+ },
134
163
  });
164
+ ```
135
165
 
136
- // vitest.setup.ts
166
+ Create `testSetup.ts`:
167
+
168
+ ```typescript
137
169
  import { matchers as jaypieMatchers } from "@jaypie/testkit";
138
170
  import * as extendedMatchers from "jest-extended";
139
- import { expect, vi } from "vitest";
171
+ import { expect } from "vitest";
140
172
 
141
173
  expect.extend(extendedMatchers);
142
174
  expect.extend(jaypieMatchers);
143
-
144
- vi.mock("jaypie", async () => vi.importActual("@jaypie/testkit/mock"));
145
175
  ```
146
176
 
177
+ Note: Do not mock `jaypie` in the setup file for lambda consumer packages. Mock in individual test files as needed.
178
+
147
179
  ### 6. Create Handler Implementation
148
180
 
149
181
  ```typescript
150
182
  // src/worker.ts
151
- import { lambdaHandler, log } from "jaypie";
152
- import type { Context } from "jaypie";
183
+ import { log } from "@jaypie/core";
184
+ import { lambdaHandler } from "@jaypie/lambda";
185
+ import type { LambdaContext } from "@jaypie/lambda";
153
186
 
154
187
  export interface WorkerEvent {
155
188
  message?: string;
156
189
  }
157
190
 
158
191
  export const handler = lambdaHandler(
159
- async (event: WorkerEvent, context: Context) => {
192
+ async (event: WorkerEvent, context?: LambdaContext) => {
160
193
  log.trace("worker: start");
161
-
194
+
162
195
  const message = event?.message || "Hello, world!";
163
-
196
+
164
197
  log.trace("worker: processing message", { message });
165
-
198
+
166
199
  const response = {
167
200
  status: "success",
168
201
  message,
169
- timestamp: new Date().toISOString()
202
+ timestamp: new Date().toISOString(),
170
203
  };
171
-
204
+
172
205
  log.trace("worker: complete");
173
206
  return response;
174
207
  },
175
208
  {
176
- name: "worker"
177
- }
209
+ name: "worker",
210
+ },
178
211
  );
179
212
  ```
180
213
 
@@ -187,59 +220,145 @@ export { handler as workerHandler } from "./worker.js";
187
220
 
188
221
  ### 8. Write Tests
189
222
 
223
+ Tests are organized in sections: Base Cases, Error Conditions, Security, Observability, Happy Paths, Features, Specific Scenarios. Omit sections that are not applicable.
224
+
190
225
  ```typescript
191
226
  // src/__tests__/worker.spec.ts
192
- import { vi, describe, it, expect, beforeEach } from "vitest";
193
- import { handler, WorkerEvent } from "../worker.js";
194
- import { log } from "jaypie";
195
- import type { Context } from "jaypie";
227
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
228
+
229
+ import { log } from "@jaypie/core";
230
+ import { restoreLog, spyLog } from "@jaypie/testkit";
231
+
232
+ // Subject
233
+ import { handler } from "../worker.js";
234
+ import type { WorkerEvent } from "../worker.js";
235
+
236
+ //
237
+ //
238
+ // Mock modules
239
+ //
196
240
 
197
- vi.mock("jaypie", async () => vi.importActual("@jaypie/testkit/mock"));
241
+ vi.mock("@jaypie/core", async () => {
242
+ const actual = await vi.importActual("@jaypie/core");
243
+ return {
244
+ ...actual,
245
+ };
246
+ });
247
+
248
+ //
249
+ //
250
+ // Mock environment
251
+ //
252
+
253
+ const DEFAULT_ENV = process.env;
254
+ beforeEach(() => {
255
+ process.env = { ...process.env };
256
+ spyLog(log);
257
+ });
258
+ afterEach(() => {
259
+ process.env = DEFAULT_ENV;
260
+ vi.clearAllMocks();
261
+ restoreLog(log);
262
+ });
263
+
264
+ //
265
+ //
266
+ // Run tests
267
+ //
198
268
 
199
269
  describe("worker Lambda handler", () => {
200
- beforeEach(() => {
201
- vi.clearAllMocks();
270
+ describe("Base Cases", () => {
271
+ it("Works", async () => {
272
+ const event: WorkerEvent = {};
273
+ const result = await handler(event);
274
+ expect(result).toBeDefined();
275
+ });
202
276
  });
203
277
 
204
- it("returns success with provided message", async () => {
205
- const event: WorkerEvent = {
206
- message: "Test message"
207
- };
208
-
209
- const result = await handler(event, {} as Context);
210
-
211
- expect(result).toHaveProperty("status", "success");
212
- expect(result).toHaveProperty("message", "Test message");
213
- expect(result).toHaveProperty("timestamp");
278
+ describe("Observability", () => {
279
+ it("Does not log above trace", async () => {
280
+ const event: WorkerEvent = { message: "Test" };
281
+ await handler(event);
282
+ expect(log).not.toBeCalledAboveTrace();
283
+ });
214
284
  });
215
285
 
216
- it("returns default message when none provided", async () => {
217
- const event = {} as WorkerEvent;
286
+ describe("Happy Paths", () => {
287
+ it("Returns success with provided message", async () => {
288
+ const event: WorkerEvent = {
289
+ message: "Test message",
290
+ };
218
291
 
219
- const result = await handler(event, {} as Context);
220
-
221
- expect(result).toHaveProperty("message", "Hello, world!");
222
- });
292
+ const result = await handler(event);
223
293
 
224
- it("logs trace for operations", async () => {
225
- const event: WorkerEvent = {
226
- message: "Test message"
227
- };
294
+ expect(result).toHaveProperty("status", "success");
295
+ expect(result).toHaveProperty("message", "Test message");
296
+ expect(result).toHaveProperty("timestamp");
297
+ });
298
+
299
+ it("Returns default message when none provided", async () => {
300
+ const event: WorkerEvent = {};
228
301
 
229
- await handler(event, {} as Context);
230
-
231
- expect(log.trace).toHaveBeenCalled();
232
- expect(log).not.toBeCalledAboveTrace();
302
+ const result = await handler(event);
303
+
304
+ expect(result).toHaveProperty("message", "Hello, world!");
305
+ });
233
306
  });
234
307
  });
235
308
  ```
236
309
 
237
- ### 9. Build and Deploy
310
+ ### 9. Build and Test
311
+
312
+ Build, lint, typecheck, and test the package:
238
313
 
239
314
  ```bash
240
- # Build the Lambda package
241
- npm run build
315
+ # Install dependencies (from monorepo root)
316
+ npm install <package> -w packages/lambda
317
+
318
+ # Lint and format
319
+ npm run format -w packages/lambda
320
+
321
+ # Type check
322
+ npm run typecheck -w packages/lambda
323
+
324
+ # Build the package
325
+ npm run build -w packages/lambda
326
+
327
+ # Run tests
328
+ npm run test -w packages/lambda
329
+ ```
330
+
331
+ ### 10. Deploy
332
+
333
+ Deploy using AWS CDK or other deployment tool. The Lambda handler will be referenced as "workerHandler" from the built package.
334
+
335
+ ## Important Notes
336
+
337
+ ### Import Patterns
338
+
339
+ - Import `lambdaHandler` from `@jaypie/lambda`, not from `jaypie`
340
+ - Import `log` from `@jaypie/core`, not from `jaypie`
341
+ - Use `LambdaContext` type from `@jaypie/lambda`, not `Context` from `jaypie`
342
+ - TypeScript files must use `.js` extension in relative imports (e.g., `from "./worker.js"`)
343
+
344
+ ### Test Structure
345
+
346
+ - Tests are organized in 7 sections: Base Cases, Error Conditions, Security, Observability, Happy Paths, Features, Specific Scenarios
347
+ - Omit sections that are not applicable
348
+ - Use `spyLog` and `restoreLog` from `@jaypie/testkit` for logging tests
349
+ - Use Jaypie matchers like `toBeCalledAboveTrace()` for observability tests
350
+ - Mock `@jaypie/core` in test files, not in `testSetup.ts`
351
+
352
+ ### Build Configuration
353
+
354
+ - Use `rollup-plugin-auto-external` to automatically exclude dependencies from bundles
355
+ - Build both ESM and CommonJS formats for maximum compatibility
356
+ - Use `vite.config.js` (not `vitest.config.ts`) for test configuration
357
+ - Use `testSetup.ts` (not `vitest.setup.ts`) for test setup
358
+
359
+ ### Code Style
242
360
 
243
- # Deploy using AWS CDK or other deployment tool
244
- # The Lambda handler will be referenced as "workerHandler"
245
- ```
361
+ - Use double quotes, trailing commas, semicolons
362
+ - Alphabetize imports and properties
363
+ - Define constants for hard-coded values at file top
364
+ - Never throw vanilla Error; use errors from `@jaypie/errors`
@@ -15,10 +15,11 @@ Create a subpackage within an existing monorepo project.
15
15
 
16
16
  ## Guidelines
17
17
 
18
- * Follow Jaypie_Project_Structure.md conventions
19
- * Subpackage names follow "@project-org/package-name" pattern
18
+ * Follow Jaypie_Ideal_Project_Structure.md conventions
19
+ * Subpackage names follow "@project-org/package-name" pattern (example: "@jaypie/errors")
20
20
  * Use `"version": "0.0.1"`, `"type": "module"`, and `"private": true`
21
21
  * Place packages in `packages/<package-name>/` directory
22
+ * Build tool: Use Vite for new TypeScript packages (template uses Vite). Some older packages use Rollup.
22
23
 
23
24
  ## Process
24
25
 
@@ -30,12 +31,12 @@ Create a subpackage within an existing monorepo project.
30
31
  └── tsconfig.json
31
32
  ```
32
33
 
33
- 2. Copy template files:
34
- * Copy `prompts/templates/project-subpackage/package.json` to `packages/<package-name>/package.json`
35
- * Copy `prompts/templates/project-subpackage/tsconfig.json` to `packages/<package-name>/tsconfig.json`
36
- * Copy `prompts/templates/project-subpackage/vite.config.ts` to `packages/<package-name>/vite.config.ts`
37
- * Copy `prompts/templates/project-subpackage/vitest.config.ts` to `packages/<package-name>/vitest.config.ts`
38
- * Copy `prompts/templates/project-subpackage/vitest.setup.ts` to `packages/<package-name>/vitest.setup.ts`
34
+ 2. Create template files using Templates_Project_Subpackage.md:
35
+ * Create `packages/<package-name>/package.json` from template
36
+ * Create `packages/<package-name>/tsconfig.json` from template
37
+ * Create `packages/<package-name>/vite.config.ts` from template
38
+ * Create `packages/<package-name>/vitest.config.ts` from template
39
+ * Create `packages/<package-name>/vitest.setup.ts` from template
39
40
 
40
41
  3. Update package.json:
41
42
  * Edit name from "@project-org/project-name" to "@project-org/<package-name>"
@@ -43,28 +44,22 @@ Create a subpackage within an existing monorepo project.
43
44
 
44
45
  4. Create basic src structure:
45
46
  * Create `src/index.ts` with basic export
46
- * Create `src/index.spec.ts` with basic test
47
+ * Create `src/__tests__/` directory for tests
48
+ * Create `src/__tests__/index.spec.ts` with basic test (use sections: Base Cases, Happy Paths)
47
49
 
48
50
  5. Update workspace configuration:
49
- * Update `references` in root `tsconfig.json`
50
- * Update `paths` in root `tsconfig.base.json`
51
- * Add package path to root `vitest.workspace.js`
52
- * Remove wildcards from `vitest.workspace.js` if present
51
+ * Add package path to `test.projects` array in root `vitest.config.ts` (format: "packages/<package-name>")
52
+ * Ensure packages are listed explicitly (no wildcards)
53
+ * Example: Add "packages/new-package" to the projects array
53
54
 
54
- 6. Install requested software:
55
- * Always use `npm --workspace ./packages/new-package install`
56
- * Never edit `package.json` from memory
55
+ 6. Install dependencies for the new package:
56
+ * Use `npm install <package-name> --workspace ./packages/<package-name>` to add dependencies
57
+ * Use `npm install <package-name> --workspace ./packages/<package-name> --save-dev` for dev dependencies
58
+ * Never manually edit `package.json` - always use npm commands to maintain package-lock.json
57
59
 
58
60
  ## Context
59
61
 
60
- prompts/prompts/Jaypie_Project_Structure.md
61
- prompts/templates/project-monorepo/tsconfig.base.json
62
- prompts/templates/project-subpackage/package.json
63
- prompts/templates/project-subpackage/tsconfig.json
64
- prompts/templates/project-subpackage/vite.config.ts
65
- prompts/templates/project-subpackage/vitest.config.ts
66
- prompts/templates/project-subpackage/vitest.setup.ts
62
+ prompts/Jaypie_Ideal_Project_Structure.md
63
+ prompts/Templates_Project_Subpackage.md
67
64
  package.json
68
- tsconfig.json
69
- tsconfig.base.json
70
- vitest.workspace.js
65
+ vitest.config.ts
@@ -4,6 +4,10 @@ description: Old conventions repositories should update and the new conventions
4
4
 
5
5
  # Jaypie Legacy Patterns
6
6
 
7
+ ## Mongoose
8
+
9
+ Use MongoDB directly or something else
10
+
7
11
  ## TypeScript, Not Vanilla JavaScript
8
12
 
9
13
  ## Vite for Builds