@joktec/skills 0.1.3 → 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/dist/claude/skills/joktec-adapter-skill/SKILL.md +1 -0
- package/dist/claude/skills/joktec-adapter-skill/references/adapters.md +28 -0
- package/dist/claude/skills/joktec-broker-skill/SKILL.md +1 -0
- package/dist/claude/skills/joktec-broker-skill/references/brokers.md +29 -0
- package/dist/claude/skills/joktec-common-skill/SKILL.md +1 -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 +1 -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 +1 -0
- package/dist/claude/skills/joktec-integration-skill/references/integrations.md +29 -0
- package/dist/claude/skills/joktec-mongo-skill/SKILL.md +1 -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 +3 -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 +1 -0
- package/dist/claude/skills/joktec-tool-skill/references/tools.md +35 -0
- package/dist/codex/skills/joktec-adapter-skill/SKILL.md +1 -0
- package/dist/codex/skills/joktec-adapter-skill/references/adapters.md +28 -0
- package/dist/codex/skills/joktec-broker-skill/SKILL.md +1 -0
- package/dist/codex/skills/joktec-broker-skill/references/brokers.md +29 -0
- package/dist/codex/skills/joktec-common-skill/SKILL.md +1 -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 +1 -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 +1 -0
- package/dist/codex/skills/joktec-integration-skill/references/integrations.md +29 -0
- package/dist/codex/skills/joktec-mongo-skill/SKILL.md +1 -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 +3 -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 +1 -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/skills/joktec-adapter-skill/SKILL.md +1 -0
- package/skills/joktec-adapter-skill/references/adapters.md +28 -0
- package/skills/joktec-broker-skill/SKILL.md +1 -0
- package/skills/joktec-broker-skill/references/brokers.md +29 -0
- package/skills/joktec-common-skill/SKILL.md +1 -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 +1 -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 +1 -0
- package/skills/joktec-integration-skill/references/integrations.md +29 -0
- package/skills/joktec-mongo-skill/SKILL.md +1 -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 +3 -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 +1 -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.
|
|
@@ -19,8 +19,10 @@ Use this skill for relational resources backed by JokTec's TypeORM wrapper.
|
|
|
19
19
|
- Treat `mysql`, `mariadb`, and `postgres` as the first-class dialects.
|
|
20
20
|
- Keep `sync` explicit and normally enabled only by an owner process or development bootstrap.
|
|
21
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.
|
|
22
24
|
|
|
23
25
|
## References
|
|
24
26
|
|
|
25
27
|
- Read `references/repository.md` for connection lifecycle, repository usage, query safety, transaction, and cursor behavior.
|
|
26
|
-
- 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.
|
|
@@ -23,6 +23,7 @@ Use this skill for reusable utility services.
|
|
|
23
23
|
- Use config-driven clients instead of direct ad hoc setup in app code.
|
|
24
24
|
- Preserve retry, metrics, proxy, and upload behavior where the package exposes it.
|
|
25
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.
|
|
26
27
|
|
|
27
28
|
## Reference
|
|
28
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.
|