@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,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-database-extended-skill
|
|
3
3
|
description: Use when working with extended JokTec database packages @joktec/elastic, @joktec/arango, or @joktec/bigquery in a consumer app, including app-neutral client setup, config-driven lifecycle, and package-specific query/service usage.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec Extended Database Skill
|
|
@@ -19,6 +23,7 @@ Use this skill for database clients that are not Mongo or MySQL.
|
|
|
19
23
|
- Use package services for client lifecycle and connection config.
|
|
20
24
|
- Do not claim parity with Mongo/MySQL repository behavior unless the package implements it.
|
|
21
25
|
- Use package README and source as final truth before adding advanced behavior.
|
|
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,5 +1,15 @@
|
|
|
1
1
|
# Extended Database Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/databases/README.md`
|
|
8
|
+
- `packages/databases/AGENTS.md`
|
|
9
|
+
- `packages/databases/<package>/README.md`
|
|
10
|
+
- `packages/databases/<package>/src/index.ts`
|
|
11
|
+
- package config/module/service files under `src/`
|
|
12
|
+
|
|
3
13
|
## Package Boundaries
|
|
4
14
|
|
|
5
15
|
Extended database packages expose reusable clients and helpers for specific data systems. They should not contain consumer app schemas or business-specific query policy.
|
|
@@ -9,3 +19,17 @@ Extended database packages expose reusable clients and helpers for specific data
|
|
|
9
19
|
- Elastic may depend on `@joktec/http` for HTTP-backed behavior.
|
|
10
20
|
- Arango and BigQuery are separate client packages; verify the README/source before assuming repository-like CRUD support.
|
|
11
21
|
- Use local package tests or consumer harnesses only when the target service stack is available.
|
|
22
|
+
|
|
23
|
+
## Best Practices
|
|
24
|
+
|
|
25
|
+
- Treat these packages as client wrappers unless source explicitly exposes a repository abstraction.
|
|
26
|
+
- Keep index names, dataset names, query templates, and domain-specific projections in the consumer app.
|
|
27
|
+
- Validate credentials and endpoints through config; never commit service account data.
|
|
28
|
+
- Keep retries, timeouts, and debug logging visible in config.
|
|
29
|
+
- Use provider-specific tests/mocks for package logic and live stack tests only when credentials/services are intentionally available.
|
|
30
|
+
|
|
31
|
+
## Anti-Patterns
|
|
32
|
+
|
|
33
|
+
- Do not apply MongoRepo/MysqlRepo assumptions to Elastic/Arango/BigQuery.
|
|
34
|
+
- Do not introduce app schemas or business query policy into reusable database clients.
|
|
35
|
+
- Do not claim support for a provider feature unless the package source or README shows it.
|
|
@@ -25,6 +25,7 @@ Start here when a task mentions JokTec generally, multiple `@joktec/*` packages,
|
|
|
25
25
|
- Prefer config-driven module setup and `conId` when a package supports multiple clients.
|
|
26
26
|
- Preserve NestJS module boundaries, dependency injection, lifecycle hooks, and exported package APIs.
|
|
27
27
|
- Do not invent behavior for unfinished or missing packages.
|
|
28
|
+
- If a focused skill is loaded without this entrypoint, still apply source-first lookup before assuming APIs.
|
|
28
29
|
|
|
29
30
|
## Reference
|
|
30
31
|
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# JokTec Framework Map
|
|
2
2
|
|
|
3
|
+
## Source-First Operating Protocol
|
|
4
|
+
|
|
5
|
+
Treat this skill pack as curated guidance, not the final implementation truth. When a task is unclear, or when a package API seems different from the skill text:
|
|
6
|
+
|
|
7
|
+
1. Inspect the consumer project first to understand the package versions and local usage pattern.
|
|
8
|
+
2. Prefer local framework source at `../joktec-framework` when available.
|
|
9
|
+
3. Read package `README.md`, nearest `AGENTS.md`, and `src/index.ts` before changing code.
|
|
10
|
+
4. If local source is unavailable, use `https://github.com/joktec/joktec-framework` as fallback.
|
|
11
|
+
5. Do not invent behavior that is not visible in framework source or package docs.
|
|
12
|
+
6. If package docs and source conflict, source code wins and the mismatch should be treated as documentation drift.
|
|
13
|
+
|
|
14
|
+
High-value source files:
|
|
15
|
+
|
|
16
|
+
- `AGENTS.md` and `docs/agents/*` for framework-level architecture and runtime policy.
|
|
17
|
+
- `packages/<family>/AGENTS.md` for family boundaries.
|
|
18
|
+
- `packages/<family>/<package>/README.md` for developer-facing usage.
|
|
19
|
+
- `packages/<family>/<package>/src/index.ts` for public API.
|
|
20
|
+
- Package config/module/service/repository files for real runtime behavior.
|
|
21
|
+
|
|
3
22
|
## Package Families
|
|
4
23
|
|
|
5
24
|
- `@joktec/core`: bootstrap, config, logger, metrics, guards, base abstractions, transports, pagination, Bull.
|
|
@@ -17,9 +36,24 @@
|
|
|
17
36
|
|
|
18
37
|
Consumer apps depend on concrete `@joktec/*` packages. Concrete packages usually depend on `@joktec/core` and `@joktec/utils`. Keep app-specific schemas, handlers, and business semantics outside reusable packages.
|
|
19
38
|
|
|
39
|
+
Do not reverse the dependency direction:
|
|
40
|
+
|
|
41
|
+
- reusable packages must not import from `apps/`
|
|
42
|
+
- `common` packages must not depend on concrete adapters/brokers/databases
|
|
43
|
+
- consumer apps own business workflows, DTO composition, schemas/entities, queue names, topics, and provider credentials
|
|
44
|
+
|
|
20
45
|
## Common Consumer App Pattern
|
|
21
46
|
|
|
22
47
|
1. Register package modules in the app module or repository module.
|
|
23
48
|
2. Keep app schemas/entities and app repositories in the consumer app.
|
|
24
49
|
3. Extend the package repository base class when the package provides one.
|
|
25
50
|
4. Use `BaseService`, `BaseController`, or transport helpers from `@joktec/core` when the app follows standard CRUD or message patterns.
|
|
51
|
+
|
|
52
|
+
## Skill Selection
|
|
53
|
+
|
|
54
|
+
- Use `joktec-common-skill` for BaseController/BaseService/config/pagination/client lifecycle/utils/cron.
|
|
55
|
+
- Use `joktec-mongo-skill` when the resource uses Mongo schemas, MongoRepo, Typegoose decorators, plugins, or ObjectId-safe queries.
|
|
56
|
+
- Use `joktec-mysql-skill` when the resource uses TypeORM entities, MysqlRepo, SQL dialect behavior, transactions, or schema-first column decorators.
|
|
57
|
+
- Use broker/adapter/integration/tool skills for provider wiring; keep business semantics in the consumer app.
|
|
58
|
+
|
|
59
|
+
When using the ecosystem `npx skills` installer, install `joktec-framework-skill` and `joktec-common-skill` together with any focused package skill. The current ecosystem installer does not auto-resolve dependencies from frontmatter.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-integration-skill
|
|
3
3
|
description: Use when wiring or using JokTec integration packages @joktec/firebase or @joktec/gpt, including validated config, SDK client lifecycle, app-neutral integration services, credentials handling, and consumer app composition.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec Integration Skill
|
|
@@ -18,6 +22,7 @@ Use this skill for third-party integration packages.
|
|
|
18
22
|
- Use package services instead of direct SDK initialization in app code.
|
|
19
23
|
- Preserve app-neutral service behavior; consumer apps own domain workflows.
|
|
20
24
|
- Verify current package README/source before relying on advanced provider features.
|
|
25
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
21
26
|
|
|
22
27
|
## Reference
|
|
23
28
|
|
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
# Integration Usage
|
|
2
2
|
|
|
3
|
+
## Source Lookup
|
|
4
|
+
|
|
5
|
+
When blocked, inspect:
|
|
6
|
+
|
|
7
|
+
- `packages/integrations/README.md`
|
|
8
|
+
- `packages/integrations/AGENTS.md`
|
|
9
|
+
- `packages/integrations/<package>/README.md`
|
|
10
|
+
- `packages/integrations/<package>/src/index.ts`
|
|
11
|
+
- package config/module/service files under `src/`
|
|
12
|
+
|
|
3
13
|
## Firebase
|
|
4
14
|
|
|
5
15
|
Use the integration module and service to initialize Firebase Admin clients from validated config. Keep credential files local or environment-provided.
|
|
6
16
|
|
|
17
|
+
Best practice:
|
|
18
|
+
|
|
19
|
+
- Keep service account JSON, private keys, and project credentials out of git.
|
|
20
|
+
- Prefer environment-specific config or ignored local credential files.
|
|
21
|
+
- Keep notification/user/storage/product semantics in the consumer app.
|
|
22
|
+
- Mock Firebase Admin SDK in package tests; use live credentials only in explicit integration environments.
|
|
23
|
+
|
|
7
24
|
## GPT
|
|
8
25
|
|
|
9
26
|
Use the integration package for reusable GPT client setup. Keep prompt/business policy in the consumer app, not in the generic package.
|
|
27
|
+
|
|
28
|
+
Best practice:
|
|
29
|
+
|
|
30
|
+
- Keep prompts, model choice policy, tool schemas, and product safety rules in the consumer app.
|
|
31
|
+
- Keep API keys in secret management or environment config.
|
|
32
|
+
- Verify current package completeness before relying on advanced APIs; `@joktec/gpt` may lag behind provider SDK changes.
|
|
33
|
+
|
|
34
|
+
## Anti-Patterns
|
|
35
|
+
|
|
36
|
+
- Do not commit real credential files.
|
|
37
|
+
- Do not encode product-specific prompts or notification logic into the reusable integration package.
|
|
38
|
+
- Do not assume provider SDK behavior without checking package source and provider docs when APIs are unstable.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: joktec-mongo-skill
|
|
3
3
|
description: Use when working with @joktec/mongo in a consumer app, including MongoModule setup, Typegoose schema decorators, MongoRepo, MongoService, MongoHelper, plugins, ObjectId/query safety, soft delete, strict references, and cursor pagination.
|
|
4
|
+
metadata:
|
|
5
|
+
dependencies:
|
|
6
|
+
- joktec-framework-skill
|
|
7
|
+
- joktec-common-skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# JokTec Mongo Skill
|
|
@@ -15,6 +19,7 @@ Use this skill for MongoDB-backed resources that rely on JokTec's Mongoose/Typeg
|
|
|
15
19
|
- Preserve `conId` when the app has multiple Mongo connections.
|
|
16
20
|
- Use schema-first decorators when a schema class should be reused as a DTO source.
|
|
17
21
|
- Treat ObjectId casting and regex behavior as safety-sensitive.
|
|
22
|
+
- If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
|
|
18
23
|
|
|
19
24
|
## References
|
|
20
25
|
|
|
@@ -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.
|