@joktec/skills 0.1.2 → 0.1.4
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.
- package/README.md +20 -4
- package/bin/joktec-skills.mjs +33 -27
- package/dist/claude/skills/joktec-adapter-skill/SKILL.md +5 -0
- package/dist/claude/skills/joktec-adapter-skill/references/adapters.md +28 -0
- package/dist/claude/skills/joktec-broker-skill/SKILL.md +5 -0
- package/dist/claude/skills/joktec-broker-skill/references/brokers.md +29 -0
- package/dist/claude/skills/joktec-common-skill/SKILL.md +4 -0
- package/dist/claude/skills/joktec-common-skill/references/core.md +56 -0
- package/dist/claude/skills/joktec-common-skill/references/utils-cron.md +28 -0
- package/dist/claude/skills/joktec-database-extended-skill/SKILL.md +5 -0
- package/dist/claude/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
- package/dist/claude/skills/joktec-framework-skill/SKILL.md +1 -0
- package/dist/claude/skills/joktec-framework-skill/references/framework-map.md +34 -0
- package/dist/claude/skills/joktec-integration-skill/SKILL.md +5 -0
- package/dist/claude/skills/joktec-integration-skill/references/integrations.md +29 -0
- package/dist/claude/skills/joktec-mongo-skill/SKILL.md +5 -0
- package/dist/claude/skills/joktec-mongo-skill/references/repository.md +43 -0
- package/dist/claude/skills/joktec-mongo-skill/references/schema-and-plugins.md +29 -0
- package/dist/claude/skills/joktec-mysql-skill/SKILL.md +7 -1
- package/dist/claude/skills/joktec-mysql-skill/references/entities.md +100 -0
- package/dist/claude/skills/joktec-mysql-skill/references/repository.md +49 -0
- package/dist/claude/skills/joktec-tool-skill/SKILL.md +5 -0
- package/dist/claude/skills/joktec-tool-skill/references/tools.md +35 -0
- package/dist/codex/skills/joktec-adapter-skill/SKILL.md +5 -0
- package/dist/codex/skills/joktec-adapter-skill/references/adapters.md +28 -0
- package/dist/codex/skills/joktec-broker-skill/SKILL.md +5 -0
- package/dist/codex/skills/joktec-broker-skill/references/brokers.md +29 -0
- package/dist/codex/skills/joktec-common-skill/SKILL.md +4 -0
- package/dist/codex/skills/joktec-common-skill/references/core.md +56 -0
- package/dist/codex/skills/joktec-common-skill/references/utils-cron.md +28 -0
- package/dist/codex/skills/joktec-database-extended-skill/SKILL.md +5 -0
- package/dist/codex/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
- package/dist/codex/skills/joktec-framework-skill/SKILL.md +1 -0
- package/dist/codex/skills/joktec-framework-skill/references/framework-map.md +34 -0
- package/dist/codex/skills/joktec-integration-skill/SKILL.md +5 -0
- package/dist/codex/skills/joktec-integration-skill/references/integrations.md +29 -0
- package/dist/codex/skills/joktec-mongo-skill/SKILL.md +5 -0
- package/dist/codex/skills/joktec-mongo-skill/references/repository.md +43 -0
- package/dist/codex/skills/joktec-mongo-skill/references/schema-and-plugins.md +29 -0
- package/dist/codex/skills/joktec-mysql-skill/SKILL.md +7 -1
- package/dist/codex/skills/joktec-mysql-skill/references/entities.md +100 -0
- package/dist/codex/skills/joktec-mysql-skill/references/repository.md +49 -0
- package/dist/codex/skills/joktec-tool-skill/SKILL.md +5 -0
- package/dist/codex/skills/joktec-tool-skill/references/tools.md +35 -0
- package/dist/copilot/.github/copilot-instructions.md +495 -1
- package/dist/cursor/.cursor/rules/joktec-adapter-skill.mdc +29 -0
- package/dist/cursor/.cursor/rules/joktec-broker-skill.mdc +30 -0
- package/dist/cursor/.cursor/rules/joktec-common-skill.mdc +85 -0
- package/dist/cursor/.cursor/rules/joktec-database-extended-skill.mdc +25 -0
- package/dist/cursor/.cursor/rules/joktec-framework-skill.mdc +35 -0
- package/dist/cursor/.cursor/rules/joktec-integration-skill.mdc +30 -0
- package/dist/cursor/.cursor/rules/joktec-mongo-skill.mdc +73 -0
- package/dist/cursor/.cursor/rules/joktec-mysql-skill.mdc +152 -1
- package/dist/cursor/.cursor/rules/joktec-tool-skill.mdc +36 -0
- package/dist/gemini/GEMINI.md +495 -1
- package/dist/windsurf/.windsurf/rules/joktec-adapter-skill.md +29 -0
- package/dist/windsurf/.windsurf/rules/joktec-broker-skill.md +30 -0
- package/dist/windsurf/.windsurf/rules/joktec-common-skill.md +85 -0
- package/dist/windsurf/.windsurf/rules/joktec-database-extended-skill.md +25 -0
- package/dist/windsurf/.windsurf/rules/joktec-framework-skill.md +35 -0
- package/dist/windsurf/.windsurf/rules/joktec-integration-skill.md +30 -0
- package/dist/windsurf/.windsurf/rules/joktec-mongo-skill.md +73 -0
- package/dist/windsurf/.windsurf/rules/joktec-mysql-skill.md +152 -1
- package/dist/windsurf/.windsurf/rules/joktec-tool-skill.md +36 -0
- package/package.json +1 -1
- package/scripts/validate-skills.mjs +32 -0
- package/skill-pack.json +261 -52
- package/skills/joktec-adapter-skill/SKILL.md +5 -0
- package/skills/joktec-adapter-skill/references/adapters.md +28 -0
- package/skills/joktec-broker-skill/SKILL.md +5 -0
- package/skills/joktec-broker-skill/references/brokers.md +29 -0
- package/skills/joktec-common-skill/SKILL.md +4 -0
- package/skills/joktec-common-skill/references/core.md +56 -0
- package/skills/joktec-common-skill/references/utils-cron.md +28 -0
- package/skills/joktec-database-extended-skill/SKILL.md +5 -0
- package/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
- package/skills/joktec-framework-skill/SKILL.md +1 -0
- package/skills/joktec-framework-skill/references/framework-map.md +34 -0
- package/skills/joktec-integration-skill/SKILL.md +5 -0
- package/skills/joktec-integration-skill/references/integrations.md +29 -0
- package/skills/joktec-mongo-skill/SKILL.md +5 -0
- package/skills/joktec-mongo-skill/references/repository.md +43 -0
- package/skills/joktec-mongo-skill/references/schema-and-plugins.md +29 -0
- package/skills/joktec-mysql-skill/SKILL.md +7 -1
- package/skills/joktec-mysql-skill/references/entities.md +100 -0
- package/skills/joktec-mysql-skill/references/repository.md +49 -0
- package/skills/joktec-tool-skill/SKILL.md +5 -0
- package/skills/joktec-tool-skill/references/tools.md +35 -0
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
# Mongo Repository Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/databases/mongo/README.md`
|
|
8
|
+
- `packages/databases/mongo/AGENTS.md`
|
|
9
|
+
- `packages/databases/mongo/src/index.ts`
|
|
10
|
+
- `packages/databases/mongo/src/mongo.module.ts`
|
|
11
|
+
- `packages/databases/mongo/src/mongo.service.ts`
|
|
12
|
+
- `packages/databases/mongo/src/mongo.repo.ts`
|
|
13
|
+
- `packages/databases/mongo/src/helpers/mongo.helper.ts`
|
|
14
|
+
- `packages/databases/mongo/src/helpers/mongo.pipeline.ts`
|
|
15
|
+
- `packages/databases/mongo/src/helpers/mongo.utils.ts`
|
|
16
|
+
- `packages/databases/mongo/src/models/*`
|
|
17
|
+
|
|
3
18
|
## Module Setup
|
|
4
19
|
|
|
5
20
|
Register schemas with `MongoModule.forRoot({ conId, models: [...] })`. Use the same `conId` in app repositories when using non-default connections.
|
|
6
21
|
|
|
22
|
+
Best practice:
|
|
23
|
+
|
|
24
|
+
- Register app schema classes in the consumer app repository module.
|
|
25
|
+
- Use one owner process for index creation in multi-process deployments.
|
|
26
|
+
- Preserve `conId` through service/repo constructors for multi-connection apps.
|
|
27
|
+
- Do not rely on the global mongoose model registry when `MongoService` provides connection-aware resolution.
|
|
28
|
+
|
|
7
29
|
## Repository Pattern
|
|
8
30
|
|
|
9
31
|
Extend `MongoRepo` and pass the schema class to the base constructor. Services can then use `BaseService` from `@joktec/core`.
|
|
10
32
|
|
|
33
|
+
Repository checklist:
|
|
34
|
+
|
|
35
|
+
- Keep schema-specific query helpers in the app repository, not in controllers.
|
|
36
|
+
- Use repository methods for standard reads so query parsing, soft delete, populate, and pagination stay consistent.
|
|
37
|
+
- Pass transaction/session options through read-modify-write flows when the app uses transactions.
|
|
38
|
+
- Normalize returned documents through repository/service response paths so ObjectId values do not leak unexpectedly into DTOs.
|
|
39
|
+
|
|
11
40
|
## Query Safety
|
|
12
41
|
|
|
13
42
|
- Root `id` can act as an API alias for `_id` in query conditions.
|
|
@@ -15,6 +44,20 @@ Extend `MongoRepo` and pass the schema class to the base constructor. Services c
|
|
|
15
44
|
- `$like`, `$begin`, and `$end` escape regex input by default.
|
|
16
45
|
- Do not rely on broad conversion when storing raw snapshots, maps, or nested subdocuments.
|
|
17
46
|
|
|
47
|
+
Anti-patterns:
|
|
48
|
+
|
|
49
|
+
- Do not convert every nested `id` key into `_id`; only API-facing query aliases should be converted.
|
|
50
|
+
- Do not cast every 24-character hex string into ObjectId; fields like `externalId`, `code`, and `slug` may be strings.
|
|
51
|
+
- Do not inject soft-delete conditions into unknown nested aggregate branches unless the target collection is known.
|
|
52
|
+
|
|
18
53
|
## Pagination
|
|
19
54
|
|
|
20
55
|
`MongoRepo.paginate` supports page, offset, and cursor responses. Cursor mode defaults to `_id`; custom `cursorKey` appends `_id` as a tie-breaker.
|
|
56
|
+
|
|
57
|
+
Cursor checklist:
|
|
58
|
+
|
|
59
|
+
- Use `_id` for default Mongo cursor ordering.
|
|
60
|
+
- Use `createdAt` or another indexed stable key when the product requires chronological cursor behavior.
|
|
61
|
+
- Append `_id` as a tie-breaker for non-unique cursor keys.
|
|
62
|
+
- Fetch `limit + 1` records and generate `nextCursor` only when another page exists.
|
|
63
|
+
- Treat cursor tokens as opaque; clients should not parse them.
|
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
# Mongo Schema And Plugins
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/databases/mongo/src/decorators/scheme.decorator.ts`
|
|
8
|
+
- `packages/databases/mongo/src/decorators/prop.decorator.ts`
|
|
9
|
+
- `packages/databases/mongo/src/decorators/props/*`
|
|
10
|
+
- `packages/databases/mongo/src/models/mongo.schema.ts`
|
|
11
|
+
- `packages/databases/mongo/src/plugins/paranoid.plugin.ts`
|
|
12
|
+
- `packages/databases/mongo/src/plugins/strict-reference.plugin.ts`
|
|
13
|
+
- `packages/databases/mongo/src/plugins/transform.plugin.ts`
|
|
14
|
+
|
|
3
15
|
## Schema Decorators
|
|
4
16
|
|
|
5
17
|
Use `@Schema` and `@Prop` wrappers from `@joktec/mongo` for Typegoose schema metadata plus validation, transform, and Swagger metadata.
|
|
6
18
|
|
|
7
19
|
Avoid mutating shared option objects across multiple properties.
|
|
8
20
|
|
|
21
|
+
Best practice:
|
|
22
|
+
|
|
23
|
+
- Use schema-first decorators when the schema should be reused by DTO mapped types.
|
|
24
|
+
- Keep raw `@prop` or raw Mongoose decorators only when the wrapper cannot express the behavior.
|
|
25
|
+
- Pass custom validators/transforms explicitly rather than adding hidden global behavior.
|
|
26
|
+
- Keep maps, snapshots, and dynamic objects explicit so helper conversion does not alter their shape.
|
|
27
|
+
- Keep app-level reference semantics visible; strict reference plugin checks existence, but the app still owns domain rules.
|
|
28
|
+
|
|
9
29
|
## Plugins
|
|
10
30
|
|
|
11
31
|
- Paranoid plugin handles soft delete filtering and must respect aggregate first-stage constraints such as `$geoNear`.
|
|
12
32
|
- Strict reference plugin validates referenced documents and must resolve models through the active connection.
|
|
13
33
|
- Transform plugin centralizes common document transformation and should not break Mongo update operators.
|
|
14
34
|
|
|
35
|
+
Plugin checklist:
|
|
36
|
+
|
|
37
|
+
- Paranoid aggregate injection must not come before `$geoNear`.
|
|
38
|
+
- Strict reference checks must be connection-aware in multi-connection apps.
|
|
39
|
+
- Transform behavior must preserve update operators such as `$set`, `$inc`, `$push`, and `$addToSet`.
|
|
40
|
+
- Do not treat plugins as a replacement for app authorization or domain validation.
|
|
41
|
+
|
|
15
42
|
## Debug Output
|
|
16
43
|
|
|
17
44
|
Use `mongoDebug(collection, method, ...args)` when a Mongoose debug callback should be rendered as a Mongo shell-friendly command.
|
|
45
|
+
|
|
46
|
+
Debug output is for developer diagnostics. Do not log credentials or sensitive document payloads in production logs.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-mysql-skill
|
|
3
3
|
description: Use when working with @joktec/mysql in a consumer app, including MysqlModule setup, TypeORM entities, schema-first @Column/@PrimaryColumn decorators, MysqlRepo, MysqlService, transactions, dialect support, uuidv7 ids, query safety, and cursor pagination.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec MySQL Skill
|
|
@@ -15,8 +19,10 @@ Use this skill for relational resources backed by JokTec's TypeORM wrapper.
|
|
|
15
19
|
- Treat `mysql`, `mariadb`, and `postgres` as the first-class dialects.
|
|
16
20
|
- Keep `sync` explicit and normally enabled only by an owner process or development bootstrap.
|
|
17
21
|
- Do not add new behavior to deprecated `MysqlFinder`; use `MysqlRepo.qb()` and `MysqlHelper` paths.
|
|
22
|
+
- When migrating an entity to the new schema-first decorators, migrate the whole property decorator stack, not only the TypeORM primary key decorator.
|
|
23
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
18
24
|
|
|
19
25
|
## References
|
|
20
26
|
|
|
21
27
|
- Read `references/repository.md` for connection lifecycle, repository usage, query safety, transaction, and cursor behavior.
|
|
22
|
-
- Read `references/entities.md` for `@Tables`, `@Column`, `@PrimaryColumn`, uuidv7, and
|
|
28
|
+
- Read `references/entities.md` for `@Tables`, `@Column`, `@PrimaryColumn`, uuidv7, dialect guidance, and legacy decorator migration rules.
|
|
@@ -1,14 +1,114 @@
|
|
|
1
1
|
# MySQL Entity Decorators
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/databases/mysql/src/decorators/table.decorator.ts`
|
|
8
|
+
- `packages/databases/mysql/src/decorators/column.decorator.ts`
|
|
9
|
+
- `packages/databases/mysql/src/decorators/columns/column.type.ts`
|
|
10
|
+
- `packages/databases/mysql/src/decorators/columns/column.factory.ts`
|
|
11
|
+
- `packages/databases/mysql/src/decorators/columns/primary.column.ts`
|
|
12
|
+
- `packages/databases/mysql/src/decorators/columns/string.column.ts`
|
|
13
|
+
- `packages/databases/mysql/src/decorators/columns/number.column.ts`
|
|
14
|
+
- `packages/databases/mysql/src/decorators/columns/transform.column.ts`
|
|
15
|
+
- `packages/databases/mysql/src/decorators/columns/swagger.column.ts`
|
|
16
|
+
|
|
3
17
|
## Schema-First Entity Pattern
|
|
4
18
|
|
|
5
19
|
Use `@Tables`, `@Column`, and `@PrimaryColumn` from `@joktec/mysql` when an entity should also act as the source class for mapped DTOs.
|
|
6
20
|
|
|
21
|
+
The new decorators are not thin TypeORM aliases. They are schema-first wrappers that compose:
|
|
22
|
+
|
|
23
|
+
- TypeORM column/primary column metadata.
|
|
24
|
+
- `class-validator` behavior through `@joktec/utils` validators.
|
|
25
|
+
- `class-transformer` expose/exclude behavior.
|
|
26
|
+
- Swagger property metadata.
|
|
27
|
+
|
|
28
|
+
When migrating old entities, remove duplicate property decorators from `typeorm`, `class-validator`, `class-transformer`, and Swagger when the wrapper option can represent the same behavior.
|
|
29
|
+
|
|
30
|
+
## Legacy Decorator Migration
|
|
31
|
+
|
|
32
|
+
Migrate a whole property at a time. Do not only replace `PrimaryGeneratedColumn`.
|
|
33
|
+
|
|
34
|
+
Common mappings:
|
|
35
|
+
|
|
36
|
+
| Legacy decorators | New decorator shape |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `@PrimaryGeneratedColumn()` | `@PrimaryColumn('increment')` |
|
|
39
|
+
| `@PrimaryGeneratedColumn('uuid')` | `@PrimaryColumn('uuid')` |
|
|
40
|
+
| app-generated ordered UUID id | `@PrimaryColumn('uuidv7')` |
|
|
41
|
+
| `@Column(...)` | `@Column(...)` from `@joktec/mysql` |
|
|
42
|
+
| `@IsNotEmpty()` | `@Column({ required: true })` |
|
|
43
|
+
| `@IsOptional()` | `@Column({ required: false })` or nullable TypeORM option when storage allows null |
|
|
44
|
+
| `@IsEmail()` | `@Column({ isEmail: true })` |
|
|
45
|
+
| `@IsMobilePhone()` | `@Column({ isPhone: true })` |
|
|
46
|
+
| `@IsHexColor()` | `@Column({ isHexColor: true })` |
|
|
47
|
+
| `@IsUrl()` | `@Column({ isUrl: true })` |
|
|
48
|
+
| `@MinLength(n)` | `@Column({ minLength: n })` |
|
|
49
|
+
| `@MaxLength(n)` | `@Column({ maxLength: n })` |
|
|
50
|
+
| `@Min(n)` | `@Column({ min: n })` |
|
|
51
|
+
| `@Max(n)` | `@Column({ max: n })` |
|
|
52
|
+
| `@Expose()` | default behavior of `@Column(...)` |
|
|
53
|
+
| `@Expose({ groups })` | `@Column({ groups })` |
|
|
54
|
+
| `@Exclude({ toPlainOnly: true })` plus hidden Swagger | `@Column({ hidden: true })` |
|
|
55
|
+
| `@ApiProperty(...)` | `@Column({ swagger: ... })`, or native options such as `example`, `comment`, `deprecated`, `min`, `max`, `minLength`, `maxLength` |
|
|
56
|
+
|
|
57
|
+
Preserve decorators only when the wrapper cannot express them, by passing them through `decorators: [...]`.
|
|
58
|
+
|
|
59
|
+
Migration checklist:
|
|
60
|
+
|
|
61
|
+
- Replace TypeORM column decorators with wrappers from `@joktec/mysql`.
|
|
62
|
+
- Remove duplicate `class-validator` decorators when equivalent wrapper options exist.
|
|
63
|
+
- Remove duplicate `class-transformer` decorators when `hidden` or `groups` expresses the same behavior.
|
|
64
|
+
- Move Swagger examples/descriptions/limits into wrapper options where possible.
|
|
65
|
+
- Preserve custom validators/transforms only through `decorators: [...]`.
|
|
66
|
+
- Keep database-specific options such as `type`, `length`, `nullable`, `unique`, `default`, `enum`, and `comment`.
|
|
67
|
+
- Rebuild and run entity-related tests after migration because DTO metadata and TypeORM metadata both change.
|
|
68
|
+
|
|
69
|
+
Example migration:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
// Before
|
|
73
|
+
@Column({ type: 'varchar', length: 255 })
|
|
74
|
+
@IsEmail()
|
|
75
|
+
@IsNotEmpty()
|
|
76
|
+
@Expose()
|
|
77
|
+
@ApiProperty({ example: 'user@example.com' })
|
|
78
|
+
email!: string;
|
|
79
|
+
|
|
80
|
+
// After
|
|
81
|
+
@Column('varchar', {
|
|
82
|
+
length: 255,
|
|
83
|
+
required: true,
|
|
84
|
+
isEmail: true,
|
|
85
|
+
example: 'user@example.com',
|
|
86
|
+
})
|
|
87
|
+
email!: string;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
For hidden fields:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// Before
|
|
94
|
+
@Column({ type: 'varchar', length: 255 })
|
|
95
|
+
@Exclude({ toPlainOnly: true })
|
|
96
|
+
@ApiHideProperty()
|
|
97
|
+
password!: string;
|
|
98
|
+
|
|
99
|
+
// After
|
|
100
|
+
@Column('varchar', { length: 255, hidden: true })
|
|
101
|
+
password!: string;
|
|
102
|
+
```
|
|
103
|
+
|
|
7
104
|
## Primary Keys
|
|
8
105
|
|
|
9
106
|
- Prefer numeric auto-increment keys for write-heavy MySQL tables.
|
|
10
107
|
- Use UUIDs when the app needs globally unique or public identifiers.
|
|
11
108
|
- Prefer `uuidv7` over random UUIDs when the id participates in ordered indexes or cursor-like access.
|
|
109
|
+
- When switching from UUID v4 to uuidv7, verify downstream code does not assume random UUID ordering.
|
|
110
|
+
|
|
111
|
+
Do not blindly convert every primary key to uuidv7. Keep numeric increment keys when the table is internal, write-heavy, and does not need public/global identifiers.
|
|
12
112
|
|
|
13
113
|
## Dialects
|
|
14
114
|
|
|
@@ -1,23 +1,72 @@
|
|
|
1
1
|
# MySQL Repository Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/databases/mysql/README.md`
|
|
8
|
+
- `packages/databases/mysql/AGENTS.md`
|
|
9
|
+
- `packages/databases/mysql/src/index.ts`
|
|
10
|
+
- `packages/databases/mysql/src/mysql.module.ts`
|
|
11
|
+
- `packages/databases/mysql/src/mysql.service.ts`
|
|
12
|
+
- `packages/databases/mysql/src/mysql.repo.ts`
|
|
13
|
+
- `packages/databases/mysql/src/helpers/mysql.helper.ts`
|
|
14
|
+
- `packages/databases/mysql/src/helpers/mysql.finder.ts`
|
|
15
|
+
- `packages/databases/mysql/src/services/mysql.dialect.ts`
|
|
16
|
+
- `packages/databases/mysql/src/models/*`
|
|
17
|
+
|
|
3
18
|
## Module Setup
|
|
4
19
|
|
|
5
20
|
Register entities with `MysqlModule.forRoot({ conId, models: [...] })`. Use `conId` for multiple DataSources.
|
|
6
21
|
|
|
22
|
+
Best practice:
|
|
23
|
+
|
|
24
|
+
- Register consumer app entities in an app repository module.
|
|
25
|
+
- Keep `sync` disabled in request-facing processes unless the app intentionally owns schema sync.
|
|
26
|
+
- Use one controlled owner process for schema sync/migration in multi-process deployments.
|
|
27
|
+
- Preserve `conId` when resolving repositories or transaction-scoped managers.
|
|
28
|
+
|
|
7
29
|
## Repository Pattern
|
|
8
30
|
|
|
9
31
|
Extend `MysqlRepo` and pass the entity class to the base constructor. Services can use `BaseService` when CRUD behavior follows the shared contract.
|
|
10
32
|
|
|
33
|
+
Repository checklist:
|
|
34
|
+
|
|
35
|
+
- Keep entity-specific SQL helpers in the app repository, not in controllers.
|
|
36
|
+
- Use `MysqlRepo.qb()` and repository methods for standard reads so field validation, relation loading, soft delete, and pagination stay consistent.
|
|
37
|
+
- Do not add new behavior to `MysqlFinder`; it is deprecated compatibility code.
|
|
38
|
+
- Keep read/write operations in the same transaction context when the app passes a manager or query runner.
|
|
39
|
+
|
|
11
40
|
## Query Safety
|
|
12
41
|
|
|
13
42
|
- Validate field paths against TypeORM metadata before interpolating SQL identifiers.
|
|
14
43
|
- Use parameter binding for values.
|
|
15
44
|
- Keep logical operators such as `$and` and `$or` grouped through QueryBuilder behavior.
|
|
16
45
|
|
|
46
|
+
Anti-patterns:
|
|
47
|
+
|
|
48
|
+
- Do not interpolate user-provided field names or relation names into SQL without TypeORM metadata validation.
|
|
49
|
+
- Do not assume MySQL-only syntax when the package supports MySQL, MariaDB, and Postgres.
|
|
50
|
+
- Do not use a relation/populate path unless it maps to entity metadata.
|
|
51
|
+
|
|
17
52
|
## Pagination
|
|
18
53
|
|
|
19
54
|
`MysqlRepo.paginate` supports page, offset, and cursor responses. Cursor mode defaults to `createdAt` plus primary key columns. Custom cursor keys must be mapped columns.
|
|
20
55
|
|
|
56
|
+
Cursor checklist:
|
|
57
|
+
|
|
58
|
+
- Use `createdAt + primary key` as the default stable cursor.
|
|
59
|
+
- Add primary keys as tie-breakers for non-unique cursor keys.
|
|
60
|
+
- Ensure cursor keys are indexed for hot list endpoints.
|
|
61
|
+
- Validate cursor payload shape before building SQL.
|
|
62
|
+
- Treat cursor tokens as opaque; clients should not parse them.
|
|
63
|
+
|
|
21
64
|
## Transactions
|
|
22
65
|
|
|
23
66
|
When using transaction-scoped operations, pass the manager or query runner through repository options so pre-read and write operations use the same context.
|
|
67
|
+
|
|
68
|
+
Transaction checklist:
|
|
69
|
+
|
|
70
|
+
- Use one manager/query runner for read-modify-write flows.
|
|
71
|
+
- Rollback tests should prove that both pre-read dependent writes and writes are transaction-scoped.
|
|
72
|
+
- Avoid mixing default repositories and transaction-scoped repositories in one operation.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-tool-skill
|
|
3
3
|
description: Use when wiring or using JokTec tool packages @joktec/http, @joktec/file, or @joktec/alert, including Axios-backed HTTP clients, file classification helpers, Slack-compatible alert webhooks, config-driven lifecycle, and app-neutral utility services.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec Tool Skill
|
|
@@ -19,6 +23,7 @@ Use this skill for reusable utility services.
|
|
|
19
23
|
- Use config-driven clients instead of direct ad hoc setup in app code.
|
|
20
24
|
- Preserve retry, metrics, proxy, and upload behavior where the package exposes it.
|
|
21
25
|
- Keep alert tokens and webhook URLs in runtime config only.
|
|
26
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
22
27
|
|
|
23
28
|
## Reference
|
|
24
29
|
|
|
@@ -1,13 +1,48 @@
|
|
|
1
1
|
# Tool Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/tools/README.md`
|
|
8
|
+
- `packages/tools/AGENTS.md`
|
|
9
|
+
- `packages/tools/<package>/README.md`
|
|
10
|
+
- `packages/tools/<package>/src/index.ts`
|
|
11
|
+
- package config/module/service/helper files under `src/`
|
|
12
|
+
|
|
3
13
|
## HTTP
|
|
4
14
|
|
|
5
15
|
Use `@joktec/http` for Axios-backed requests, uploads, proxy agent support, retry config, and metrics where exposed.
|
|
6
16
|
|
|
17
|
+
Best practice:
|
|
18
|
+
|
|
19
|
+
- Use the package service for outbound HTTP so retry/proxy/metrics behavior stays centralized.
|
|
20
|
+
- Keep external endpoint URLs and credentials in runtime config.
|
|
21
|
+
- Be careful with ESM/CommonJS import changes in HTTP/Axios ecosystem packages.
|
|
22
|
+
- Test request behavior with mocks unless the test is an explicit consumer integration scenario.
|
|
23
|
+
|
|
7
24
|
## File
|
|
8
25
|
|
|
9
26
|
Use `@joktec/file` for shared file helpers and classification behavior instead of duplicating local utility code.
|
|
10
27
|
|
|
28
|
+
Best practice:
|
|
29
|
+
|
|
30
|
+
- Keep filesystem paths and temporary directories environment-specific.
|
|
31
|
+
- Validate upload/file inputs before passing them into business workflows.
|
|
32
|
+
- Use package helpers for MIME/classification behavior when consistency matters across services.
|
|
33
|
+
|
|
11
34
|
## Alert
|
|
12
35
|
|
|
13
36
|
Use `@joktec/alert` for Slack-compatible webhook alerts. Keep webhook URLs and credentials out of source control.
|
|
37
|
+
|
|
38
|
+
Best practice:
|
|
39
|
+
|
|
40
|
+
- Treat alert messages as operational notifications, not business workflows.
|
|
41
|
+
- Do not leak secrets, tokens, connection strings, or personal data into alert payloads.
|
|
42
|
+
- `@joktec/alert` is present but less complete than core database/client packages; inspect source before depending on advanced behavior.
|
|
43
|
+
|
|
44
|
+
## Anti-Patterns
|
|
45
|
+
|
|
46
|
+
- Do not scatter raw Axios instances across the app when `@joktec/http` should own shared behavior.
|
|
47
|
+
- Do not commit webhook URLs or proxy credentials.
|
|
48
|
+
- Do not use tool packages as hidden places for app business rules.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-adapter-skill
|
|
3
3
|
description: Use when wiring or using JokTec adapter packages @joktec/cacher, @joktec/mailer, @joktec/notifier, or @joktec/storage for cache, mail delivery, push notifications, object storage, config-driven clients, and app-neutral adapter services.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec Adapter Skill
|
|
@@ -20,6 +24,7 @@ Use this skill for pluggable external capability adapters.
|
|
|
20
24
|
- Use validated config and `conId` where supported.
|
|
21
25
|
- Keep secrets and credentials in app config or runtime environment, never in code.
|
|
22
26
|
- Prefer adapter services over direct SDK usage in app services.
|
|
27
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
23
28
|
|
|
24
29
|
## Reference
|
|
25
30
|
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
# Adapter Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/adapters/README.md`
|
|
8
|
+
- `packages/adapters/AGENTS.md`
|
|
9
|
+
- `packages/adapters/<package>/README.md`
|
|
10
|
+
- `packages/adapters/<package>/src/index.ts`
|
|
11
|
+
- package module/config/service files under `src/`
|
|
12
|
+
|
|
3
13
|
## Runtime Pattern
|
|
4
14
|
|
|
5
15
|
Adapters are global Nest modules. Services own native client creation and expose package-specific operations.
|
|
6
16
|
|
|
17
|
+
Most adapters follow `AbstractClientService`: config is validated, native clients are created by the service, `conId` selects the connection, and shutdown/retry/debug behavior should remain package-owned.
|
|
18
|
+
|
|
7
19
|
## Package Notes
|
|
8
20
|
|
|
9
21
|
- Cacher: choose local, Redis, or Memcached stores based on runtime config.
|
|
10
22
|
- Mailer: centralize mail transport configuration in the service that owns outbound email.
|
|
11
23
|
- Notifier: keep push provider configuration outside app business logic.
|
|
12
24
|
- Storage: keep storage metadata and object operations behind the adapter service.
|
|
25
|
+
|
|
26
|
+
## Best Practices
|
|
27
|
+
|
|
28
|
+
- Import adapter modules in the application layer, then inject services into domain services.
|
|
29
|
+
- Keep provider credentials, endpoints, bucket names, SMTP secrets, and push credentials in runtime config.
|
|
30
|
+
- Keep business payload composition in the consuming app. The adapter should send/cache/store, not decide product semantics.
|
|
31
|
+
- Use `conId` for multiple providers or tenants instead of creating ad-hoc service instances.
|
|
32
|
+
- Normalize provider errors at the package/app boundary so controllers do not branch on SDK-specific messages.
|
|
33
|
+
- Mock SDK clients in unit tests; run live provider checks only in explicit integration or consumer harness tests.
|
|
34
|
+
|
|
35
|
+
## Anti-Patterns
|
|
36
|
+
|
|
37
|
+
- Do not put email template business rules inside `@joktec/mailer`.
|
|
38
|
+
- Do not hardcode S3 buckets, Redis URLs, SMTP credentials, or notification tokens in source.
|
|
39
|
+
- Do not bypass adapter services by importing provider SDK clients directly throughout the app.
|
|
40
|
+
- Do not assume every adapter has identical method names; read each package README/source before calling.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-broker-skill
|
|
3
3
|
description: Use when wiring or using JokTec broker packages @joktec/kafka, @joktec/rabbit, @joktec/sqs, or @joktec/redcast, including client config, producer decorators, consumer loaders, message handlers, auto-binding, and app-level broker flows.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec Broker Skill
|
|
@@ -20,6 +24,7 @@ Use this skill for message broker packages.
|
|
|
20
24
|
- Use broker decorators for transport wiring, not for domain policy.
|
|
21
25
|
- Preserve config-driven client selection and `conId` when available.
|
|
22
26
|
- Keep topic, queue, and routing names explicit in app configuration or decorators.
|
|
27
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
23
28
|
|
|
24
29
|
## Reference
|
|
25
30
|
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
# Broker Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/brokers/README.md`
|
|
8
|
+
- `packages/brokers/AGENTS.md`
|
|
9
|
+
- `packages/brokers/<package>/README.md`
|
|
10
|
+
- `packages/brokers/<package>/src/index.ts`
|
|
11
|
+
- package decorators, loaders, config, and service files under `src/`
|
|
12
|
+
|
|
3
13
|
## Runtime Pattern
|
|
4
14
|
|
|
5
15
|
Broker services follow `AbstractClientService` lifecycle. Loader classes discover decorator metadata after module initialization. Apps define producers, consumers, and message semantics.
|
|
6
16
|
|
|
17
|
+
Use broker packages for transport wiring, not for business workflow ownership. The consuming app owns event names, payload contracts, idempotency, retry policy, dead-letter behavior, and handler semantics.
|
|
18
|
+
|
|
7
19
|
## Package Notes
|
|
8
20
|
|
|
9
21
|
- Kafka: check topic existence and broker advertised listeners in local development.
|
|
10
22
|
- RabbitMQ: use module options and decorators for exchanges, queues, and bindings.
|
|
11
23
|
- SQS: local ElasticMQ-style environments may require queues to exist before consumers start.
|
|
12
24
|
- Redcast: use Redis-backed list, stream, or pub/sub behavior when a lightweight broker is enough.
|
|
25
|
+
|
|
26
|
+
## Best Practices
|
|
27
|
+
|
|
28
|
+
- Start consumers only in processes that should own subscriptions.
|
|
29
|
+
- Keep producer and consumer payload DTOs versionable and explicit.
|
|
30
|
+
- Use config paths or module options for topic/queue names when supported.
|
|
31
|
+
- Make handlers idempotent; brokers may redeliver.
|
|
32
|
+
- Add observable effects for consumer tests rather than asserting log text.
|
|
33
|
+
- Keep broker health/preflight checks separate from business request handling.
|
|
34
|
+
- In local stacks, verify broker-specific infrastructure: Kafka topics, Rabbit exchanges/queues, SQS queues, Redis password/db.
|
|
35
|
+
|
|
36
|
+
## Anti-Patterns
|
|
37
|
+
|
|
38
|
+
- Do not hide domain workflows inside decorators or broker package services.
|
|
39
|
+
- Do not assume auto-create topic/queue behavior unless the package and local broker support it.
|
|
40
|
+
- Do not run the same consumer group/queue owner in every process by accident.
|
|
41
|
+
- Do not swallow message handling errors without retry/dead-letter visibility.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-common-skill
|
|
3
3
|
description: Use when implementing or wiring @joktec/core, @joktec/utils, or @joktec/cron in a consumer app, especially BaseController, BaseService, pagination, config, client lifecycle, bootstrap, cron decorators, or utility helpers.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
# JokTec Common Skill
|
|
@@ -21,6 +24,7 @@ Use this skill for shared framework primitives, low-level helpers, cron utilitie
|
|
|
21
24
|
- Use page, offset, or cursor pagination contracts from core; let database packages execute storage-specific pagination.
|
|
22
25
|
- Use `AbstractClientService` patterns for client packages that need config, lifecycle, retry, and `conId`.
|
|
23
26
|
- Use `@joktec/utils` for shared helpers instead of duplicating conversion, validation, hashing, or UUID logic.
|
|
27
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
24
28
|
|
|
25
29
|
## References
|
|
26
30
|
|
|
@@ -1,19 +1,75 @@
|
|
|
1
1
|
# Common Core Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect these framework files before guessing:
|
|
6
|
+
|
|
7
|
+
- `packages/common/core/README.md`
|
|
8
|
+
- `packages/common/core/AGENTS.md`
|
|
9
|
+
- `packages/common/core/src/index.ts`
|
|
10
|
+
- `packages/common/core/src/abstractions/*`
|
|
11
|
+
- `packages/common/core/src/models/base.request.ts`
|
|
12
|
+
- `packages/common/core/src/models/base.response.ts`
|
|
13
|
+
- `packages/common/core/src/models/paginations/*`
|
|
14
|
+
- `packages/common/core/src/client/abstract-client.service.ts`
|
|
15
|
+
- `packages/common/core/src/infras/application.ts`
|
|
16
|
+
- `packages/common/core/src/modules/*`
|
|
17
|
+
|
|
3
18
|
## Runtime Bootstrap
|
|
4
19
|
|
|
5
20
|
Use the application bootstrap helpers from `@joktec/core` for gateway and microservice runtimes. Keep runtime behavior config-driven.
|
|
6
21
|
|
|
22
|
+
Best practice:
|
|
23
|
+
|
|
24
|
+
- Use `Application.bootstrap(AppModule)` instead of hand-rolling Nest bootstrap unless the consumer app has a specific runtime reason.
|
|
25
|
+
- Keep gateway-only behavior in gateway runtime modules and microservice-only behavior in micro runtime modules.
|
|
26
|
+
- Register framework modules through their dynamic module APIs when provided.
|
|
27
|
+
- Do not duplicate config parsing, logger setup, metrics setup, or process lifecycle hooks in consumer apps.
|
|
28
|
+
|
|
7
29
|
## CRUD Abstractions
|
|
8
30
|
|
|
9
31
|
- `BaseController` creates standard REST CRUD endpoints for DTO-backed resources.
|
|
10
32
|
- `BaseService` delegates repository operations through the shared repository contract.
|
|
11
33
|
- `ClientController` and `ClientService` provide generated microservice CRUD patterns.
|
|
12
34
|
|
|
35
|
+
Use BaseController/BaseService when the resource follows standard CRUD. Avoid them when the endpoint has domain-specific command semantics, multi-step transactions, or non-standard authorization that would make the generic abstraction obscure behavior.
|
|
36
|
+
|
|
37
|
+
Controller checklist:
|
|
38
|
+
|
|
39
|
+
- choose the DTO/entity class intentionally
|
|
40
|
+
- set `paginationMode` for the representative Swagger response shape
|
|
41
|
+
- use `customDto.paginationDto` only when the built-in page/offset/cursor response does not represent the API
|
|
42
|
+
- keep auth/guards/interceptors consistent with app conventions
|
|
43
|
+
- avoid putting business branching in controller methods when it belongs in the service
|
|
44
|
+
|
|
13
45
|
## Pagination
|
|
14
46
|
|
|
15
47
|
Request priority is cursor, then offset, then page. `BaseController.paginationMode` affects Swagger response shape; runtime selection remains request-driven unless the app service narrows it.
|
|
16
48
|
|
|
49
|
+
Best practice:
|
|
50
|
+
|
|
51
|
+
- Use page pagination for admin tables and simple back-office views.
|
|
52
|
+
- Use offset pagination for mobile-style load-more when the data set is moderate and stable enough.
|
|
53
|
+
- Use cursor pagination for feeds, timelines, frequently inserted lists, or large tables.
|
|
54
|
+
- Do not document cursor support for a resource unless the underlying repository package actually supports it.
|
|
55
|
+
- When using cursor mode, ensure the database layer has stable sort keys and tie-breakers.
|
|
56
|
+
|
|
17
57
|
## Client Lifecycle
|
|
18
58
|
|
|
19
59
|
Use `ClientConfig`, `AbstractClientService`, and `conId` when building or consuming packages that support multiple client connections.
|
|
60
|
+
|
|
61
|
+
Client package checklist:
|
|
62
|
+
|
|
63
|
+
- config class validates all required runtime options
|
|
64
|
+
- service startup fails clearly when the native client cannot initialize
|
|
65
|
+
- shutdown closes native connections only when initialized
|
|
66
|
+
- `conId` is preserved through service/repository calls
|
|
67
|
+
- logs do not leak credentials or full connection strings
|
|
68
|
+
- retries and debug behavior are config-driven
|
|
69
|
+
|
|
70
|
+
## Do Not
|
|
71
|
+
|
|
72
|
+
- Do not import concrete package or app code into `@joktec/core`.
|
|
73
|
+
- Do not bypass shared pagination contracts with ad-hoc response shapes for standard CRUD.
|
|
74
|
+
- Do not add new public symbols without exporting them through `src/index.ts`.
|
|
75
|
+
- Do not silently swallow bootstrap/client initialization failures.
|
|
@@ -6,12 +6,40 @@ Use `@joktec/utils` for common generators, validators, converters, hashing helpe
|
|
|
6
6
|
|
|
7
7
|
Prefer package helpers over app-local reimplementation when behavior should stay consistent across services.
|
|
8
8
|
|
|
9
|
+
Source lookup:
|
|
10
|
+
|
|
11
|
+
- `packages/common/utils/README.md`
|
|
12
|
+
- `packages/common/utils/src/index.ts`
|
|
13
|
+
- `packages/common/utils/src/helpers/*`
|
|
14
|
+
- `packages/common/utils/src/validators/*`
|
|
15
|
+
- `packages/common/utils/src/constants/*`
|
|
16
|
+
|
|
17
|
+
Best practice:
|
|
18
|
+
|
|
19
|
+
- Use shared validators from `@joktec/utils` when building schema-first entity/schema decorators.
|
|
20
|
+
- Use shared generators for IDs, tokens, random values, and hashes when consistency matters.
|
|
21
|
+
- Keep utility usage deterministic in tests; mock time/randomness where needed.
|
|
22
|
+
- Do not add framework-level dependencies to `utils`.
|
|
23
|
+
|
|
9
24
|
## Cron
|
|
10
25
|
|
|
11
26
|
Use `@joktec/cron` when a consumer app needs scheduled jobs, job worker contracts, or decorator-driven cron registration.
|
|
12
27
|
|
|
13
28
|
Keep job business logic in the consumer app. The package provides scheduling abstractions, not domain behavior.
|
|
14
29
|
|
|
30
|
+
Source lookup:
|
|
31
|
+
|
|
32
|
+
- `packages/common/cron/README.md`
|
|
33
|
+
- `packages/common/cron/src/index.ts`
|
|
34
|
+
- cron decorators, models, scheduler services, and worker contracts under `src/`
|
|
35
|
+
|
|
36
|
+
Best practice:
|
|
37
|
+
|
|
38
|
+
- Keep job names, schedules, concurrency, and retry behavior visible in the consumer app.
|
|
39
|
+
- Make cron handlers idempotent.
|
|
40
|
+
- Avoid enabling the same cron owner in multiple processes unless the package/app has explicit locking semantics.
|
|
41
|
+
- Treat cron runtime as infrastructure orchestration; domain writes still belong in app services/repositories.
|
|
42
|
+
|
|
15
43
|
## Types
|
|
16
44
|
|
|
17
45
|
Use `@joktec/types` when a consumer workflow needs generated JokTec package config schema/type artifacts. Treat the framework repository as source-of-truth for the generated schema shape.
|