@joktec/skills 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +4 -2
  2. package/dist/claude/skills/advanced-typescript-design/SKILL.md +60 -0
  3. package/dist/claude/skills/advanced-typescript-design/agents/openai.yaml +4 -0
  4. package/dist/claude/skills/advanced-typescript-design/references/advanced.md +219 -0
  5. package/dist/claude/skills/advanced-typescript-design/references/simple.md +149 -0
  6. package/dist/claude/skills/joktec-adapter-skill/SKILL.md +1 -0
  7. package/dist/claude/skills/joktec-adapter-skill/references/adapters.md +28 -0
  8. package/dist/claude/skills/joktec-broker-skill/SKILL.md +1 -0
  9. package/dist/claude/skills/joktec-broker-skill/references/brokers.md +29 -0
  10. package/dist/claude/skills/joktec-common-skill/SKILL.md +1 -0
  11. package/dist/claude/skills/joktec-common-skill/references/core.md +56 -0
  12. package/dist/claude/skills/joktec-common-skill/references/utils-cron.md +28 -0
  13. package/dist/claude/skills/joktec-database-extended-skill/SKILL.md +1 -0
  14. package/dist/claude/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  15. package/dist/claude/skills/joktec-framework-skill/SKILL.md +1 -0
  16. package/dist/claude/skills/joktec-framework-skill/references/framework-map.md +34 -0
  17. package/dist/claude/skills/joktec-integration-skill/SKILL.md +1 -0
  18. package/dist/claude/skills/joktec-integration-skill/references/integrations.md +29 -0
  19. package/dist/claude/skills/joktec-mongo-skill/SKILL.md +9 -1
  20. package/dist/claude/skills/joktec-mongo-skill/references/repository.md +46 -0
  21. package/dist/claude/skills/joktec-mongo-skill/references/schema-and-plugins.md +65 -0
  22. package/dist/claude/skills/joktec-mysql-skill/SKILL.md +6 -1
  23. package/dist/claude/skills/joktec-mysql-skill/references/entities.md +109 -1
  24. package/dist/claude/skills/joktec-mysql-skill/references/repository.md +63 -0
  25. package/dist/claude/skills/joktec-tool-skill/SKILL.md +1 -0
  26. package/dist/claude/skills/joktec-tool-skill/references/tools.md +36 -0
  27. package/dist/codex/skills/advanced-typescript-design/SKILL.md +60 -0
  28. package/dist/codex/skills/advanced-typescript-design/agents/openai.yaml +4 -0
  29. package/dist/codex/skills/advanced-typescript-design/references/advanced.md +219 -0
  30. package/dist/codex/skills/advanced-typescript-design/references/simple.md +149 -0
  31. package/dist/codex/skills/joktec-adapter-skill/SKILL.md +1 -0
  32. package/dist/codex/skills/joktec-adapter-skill/references/adapters.md +28 -0
  33. package/dist/codex/skills/joktec-broker-skill/SKILL.md +1 -0
  34. package/dist/codex/skills/joktec-broker-skill/references/brokers.md +29 -0
  35. package/dist/codex/skills/joktec-common-skill/SKILL.md +1 -0
  36. package/dist/codex/skills/joktec-common-skill/references/core.md +56 -0
  37. package/dist/codex/skills/joktec-common-skill/references/utils-cron.md +28 -0
  38. package/dist/codex/skills/joktec-database-extended-skill/SKILL.md +1 -0
  39. package/dist/codex/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  40. package/dist/codex/skills/joktec-framework-skill/SKILL.md +1 -0
  41. package/dist/codex/skills/joktec-framework-skill/references/framework-map.md +34 -0
  42. package/dist/codex/skills/joktec-integration-skill/SKILL.md +1 -0
  43. package/dist/codex/skills/joktec-integration-skill/references/integrations.md +29 -0
  44. package/dist/codex/skills/joktec-mongo-skill/SKILL.md +9 -1
  45. package/dist/codex/skills/joktec-mongo-skill/references/repository.md +46 -0
  46. package/dist/codex/skills/joktec-mongo-skill/references/schema-and-plugins.md +65 -0
  47. package/dist/codex/skills/joktec-mysql-skill/SKILL.md +6 -1
  48. package/dist/codex/skills/joktec-mysql-skill/references/entities.md +109 -1
  49. package/dist/codex/skills/joktec-mysql-skill/references/repository.md +63 -0
  50. package/dist/codex/skills/joktec-tool-skill/SKILL.md +1 -0
  51. package/dist/codex/skills/joktec-tool-skill/references/tools.md +36 -0
  52. package/dist/copilot/.github/copilot-instructions.md +1003 -3
  53. package/dist/cursor/.cursor/rules/advanced-typescript-design.mdc +437 -0
  54. package/dist/cursor/.cursor/rules/joktec-adapter-skill.mdc +29 -0
  55. package/dist/cursor/.cursor/rules/joktec-broker-skill.mdc +30 -0
  56. package/dist/cursor/.cursor/rules/joktec-common-skill.mdc +85 -0
  57. package/dist/cursor/.cursor/rules/joktec-database-extended-skill.mdc +25 -0
  58. package/dist/cursor/.cursor/rules/joktec-framework-skill.mdc +35 -0
  59. package/dist/cursor/.cursor/rules/joktec-integration-skill.mdc +30 -0
  60. package/dist/cursor/.cursor/rules/joktec-mongo-skill.mdc +120 -1
  61. package/dist/cursor/.cursor/rules/joktec-mysql-skill.mdc +178 -2
  62. package/dist/cursor/.cursor/rules/joktec-tool-skill.mdc +37 -0
  63. package/dist/gemini/GEMINI.md +1005 -3
  64. package/dist/windsurf/.windsurf/rules/advanced-typescript-design.md +433 -0
  65. package/dist/windsurf/.windsurf/rules/joktec-adapter-skill.md +29 -0
  66. package/dist/windsurf/.windsurf/rules/joktec-broker-skill.md +30 -0
  67. package/dist/windsurf/.windsurf/rules/joktec-common-skill.md +85 -0
  68. package/dist/windsurf/.windsurf/rules/joktec-database-extended-skill.md +25 -0
  69. package/dist/windsurf/.windsurf/rules/joktec-framework-skill.md +35 -0
  70. package/dist/windsurf/.windsurf/rules/joktec-integration-skill.md +30 -0
  71. package/dist/windsurf/.windsurf/rules/joktec-mongo-skill.md +120 -1
  72. package/dist/windsurf/.windsurf/rules/joktec-mysql-skill.md +178 -2
  73. package/dist/windsurf/.windsurf/rules/joktec-tool-skill.md +37 -0
  74. package/package.json +6 -3
  75. package/scripts/sync-pack-version.mjs +38 -0
  76. package/skill-pack.json +35 -1
  77. package/skills/advanced-typescript-design/SKILL.md +60 -0
  78. package/skills/advanced-typescript-design/agents/openai.yaml +4 -0
  79. package/skills/advanced-typescript-design/references/advanced.md +219 -0
  80. package/skills/advanced-typescript-design/references/simple.md +149 -0
  81. package/skills/joktec-adapter-skill/SKILL.md +1 -0
  82. package/skills/joktec-adapter-skill/references/adapters.md +28 -0
  83. package/skills/joktec-broker-skill/SKILL.md +1 -0
  84. package/skills/joktec-broker-skill/references/brokers.md +29 -0
  85. package/skills/joktec-common-skill/SKILL.md +1 -0
  86. package/skills/joktec-common-skill/references/core.md +56 -0
  87. package/skills/joktec-common-skill/references/utils-cron.md +28 -0
  88. package/skills/joktec-database-extended-skill/SKILL.md +1 -0
  89. package/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  90. package/skills/joktec-framework-skill/SKILL.md +1 -0
  91. package/skills/joktec-framework-skill/references/framework-map.md +34 -0
  92. package/skills/joktec-integration-skill/SKILL.md +1 -0
  93. package/skills/joktec-integration-skill/references/integrations.md +29 -0
  94. package/skills/joktec-mongo-skill/SKILL.md +9 -1
  95. package/skills/joktec-mongo-skill/references/repository.md +46 -0
  96. package/skills/joktec-mongo-skill/references/schema-and-plugins.md +65 -0
  97. package/skills/joktec-mysql-skill/SKILL.md +6 -1
  98. package/skills/joktec-mysql-skill/references/entities.md +109 -1
  99. package/skills/joktec-mysql-skill/references/repository.md +63 -0
  100. package/skills/joktec-tool-skill/SKILL.md +1 -0
  101. package/skills/joktec-tool-skill/references/tools.md +36 -0
@@ -23,6 +23,7 @@ Use this skill for database clients that are not Mongo or MySQL.
23
23
  - Use package services for client lifecycle and connection config.
24
24
  - Do not claim parity with Mongo/MySQL repository behavior unless the package implements it.
25
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.
26
27
 
27
28
  ## Reference
28
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.
@@ -22,6 +22,7 @@ Use this skill for third-party integration packages.
22
22
  - Use package services instead of direct SDK initialization in app code.
23
23
  - Preserve app-neutral service behavior; consumer apps own domain workflows.
24
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.
25
26
 
26
27
  ## Reference
27
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.
@@ -17,8 +17,16 @@ Use this skill for MongoDB-backed resources that rely on JokTec's Mongoose/Typeg
17
17
  - Keep schema classes, app repositories, and app-specific queries in the consumer app.
18
18
  - Extend `MongoRepo<T, ID>` for app repositories.
19
19
  - Preserve `conId` when the app has multiple Mongo connections.
20
- - Use schema-first decorators when a schema class should be reused as a DTO source.
20
+ - Use schema-first decorators when a schema class should be reused as a DTO source; wrappers should reduce repeated Typegoose, validator, transformer, and Swagger stacks.
21
+ - Use `RefId<T>` for stored reference id fields and `PopulatedRef<T>` for populated virtual fields.
22
+ - Use `@Schema({ kind: 'embedded' })` for value objects without `_id` or timestamps.
23
+ - Use `@Schema({ kind: 'subdocument' })` for embedded documents that need their own `_id` and timestamps.
24
+ - Use `@Prop({ kind: 'virtual', mode: 'getter' })` for computed getters that need expose/Swagger metadata without persistence.
25
+ - Use `@Prop({ ref: () => Target, foreignField, localField })` for populate-one virtuals when inferred defaults are enough.
26
+ - Use `@Prop({ type: () => [Target], ref: () => Target, foreignField, localField })` for populate-array virtuals.
27
+ - Use `@Prop({ kind: 'map', type: Object })` for map/snapshot payloads that must keep their raw shape.
21
28
  - Treat ObjectId casting and regex behavior as safety-sensitive.
29
+ - For real migrations, inspect `node_modules/@joktec/mongo` first, then installed README or GitHub package docs, then GitHub source before assuming APIs.
22
30
 
23
31
  ## References
24
32
 
@@ -1,13 +1,45 @@
1
1
  # Mongo Repository Usage
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked, inspect:
6
+
7
+ - Consumer project first: `node_modules/@joktec/mongo`.
8
+ - Installed docs next: `node_modules/@joktec/mongo/README.md`.
9
+ - GitHub docs next: `https://github.com/joktec/joktec-framework/tree/main/packages/databases/mongo`.
10
+ - GitHub source fallback:
11
+ - `packages/databases/mongo/src/index.ts`
12
+ - `packages/databases/mongo/src/mongo.module.ts`
13
+ - `packages/databases/mongo/src/mongo.service.ts`
14
+ - `packages/databases/mongo/src/mongo.repo.ts`
15
+ - `packages/databases/mongo/src/helpers/mongo.helper.ts`
16
+ - `packages/databases/mongo/src/helpers/mongo.pipeline.ts`
17
+ - `packages/databases/mongo/src/helpers/mongo.utils.ts`
18
+ - `packages/databases/mongo/src/models/*`
19
+
3
20
  ## Module Setup
4
21
 
5
22
  Register schemas with `MongoModule.forRoot({ conId, models: [...] })`. Use the same `conId` in app repositories when using non-default connections.
6
23
 
24
+ Best practice:
25
+
26
+ - Register app schema classes in the consumer app repository module.
27
+ - Use one owner process for index creation in multi-process deployments.
28
+ - Preserve `conId` through service/repo constructors for multi-connection apps.
29
+ - Do not rely on the global mongoose model registry when `MongoService` provides connection-aware resolution.
30
+
7
31
  ## Repository Pattern
8
32
 
9
33
  Extend `MongoRepo` and pass the schema class to the base constructor. Services can then use `BaseService` from `@joktec/core`.
10
34
 
35
+ Repository checklist:
36
+
37
+ - Keep schema-specific query helpers in the app repository, not in controllers.
38
+ - Use repository methods for standard reads so query parsing, soft delete, populate, and pagination stay consistent.
39
+ - Pass transaction/session options through read-modify-write flows when the app uses transactions.
40
+ - Repository read paths should return schema class instances with normalized ObjectId/string values, including populated and deep-populated values.
41
+ - Code that needs raw Mongoose documents should use `MongoService.getModel(...)` or Typegoose/Mongoose APIs directly.
42
+
11
43
  ## Query Safety
12
44
 
13
45
  - Root `id` can act as an API alias for `_id` in query conditions.
@@ -15,6 +47,20 @@ Extend `MongoRepo` and pass the schema class to the base constructor. Services c
15
47
  - `$like`, `$begin`, and `$end` escape regex input by default.
16
48
  - Do not rely on broad conversion when storing raw snapshots, maps, or nested subdocuments.
17
49
 
50
+ Anti-patterns:
51
+
52
+ - Do not convert every nested `id` key into `_id`; only API-facing query aliases should be converted.
53
+ - Do not cast every 24-character hex string into ObjectId; fields like `externalId`, `code`, and `slug` may be strings.
54
+ - Do not inject soft-delete conditions into unknown nested aggregate branches unless the target collection is known.
55
+
18
56
  ## Pagination
19
57
 
20
58
  `MongoRepo.paginate` supports page, offset, and cursor responses. Cursor mode defaults to `_id`; custom `cursorKey` appends `_id` as a tie-breaker.
59
+
60
+ Cursor checklist:
61
+
62
+ - Use `_id` for default Mongo cursor ordering.
63
+ - Use `createdAt` or another indexed stable key when the product requires chronological cursor behavior.
64
+ - Append `_id` as a tie-breaker for non-unique cursor keys.
65
+ - Fetch `limit + 1` records and generate `nextCursor` only when another page exists.
66
+ - Treat cursor tokens as opaque; clients should not parse them.
@@ -1,17 +1,82 @@
1
1
  # Mongo Schema And Plugins
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked, inspect:
6
+
7
+ - Consumer project first: `node_modules/@joktec/mongo`.
8
+ - Package docs next: `node_modules/@joktec/mongo/README.md`.
9
+ - GitHub docs next: `https://github.com/joktec/joktec-framework/tree/main/packages/databases/mongo`.
10
+ - GitHub source fallback:
11
+ - `packages/databases/mongo/src/decorators/schema.decorator.ts`
12
+ - `packages/databases/mongo/src/decorators/schema.options.ts`
13
+ - `packages/databases/mongo/src/decorators/prop.decorator.ts`
14
+ - `packages/databases/mongo/src/decorators/props/*`
15
+ - `packages/databases/mongo/src/models/mongo.ref.ts`
16
+ - `packages/databases/mongo/src/models/object-id.ts`
17
+ - `packages/databases/mongo/src/models/mongo.schema.ts`
18
+ - `packages/databases/mongo/src/plugins/paranoid.plugin.ts`
19
+ - `packages/databases/mongo/src/plugins/strict-reference.plugin.ts`
20
+ - `packages/databases/mongo/src/plugins/transform.plugin.ts`
21
+
3
22
  ## Schema Decorators
4
23
 
5
24
  Use `@Schema` and `@Prop` wrappers from `@joktec/mongo` for Typegoose schema metadata plus validation, transform, and Swagger metadata.
6
25
 
7
26
  Avoid mutating shared option objects across multiple properties.
8
27
 
28
+ Best practice:
29
+
30
+ - Use schema-first decorators when the schema should be reused by DTO mapped types.
31
+ - Keep raw `@prop` or raw Mongoose decorators only when the wrapper cannot express the behavior.
32
+ - Pass custom validators/transforms explicitly rather than adding hidden global behavior.
33
+ - Keep maps, snapshots, and dynamic objects explicit so helper conversion does not alter their shape.
34
+ - Keep app-level reference semantics visible; strict reference plugin checks existence, but the app still owns domain rules.
35
+ - Use `RefId<T>` for persisted id fields and `PopulatedRef<T>` for populated virtual instance fields.
36
+ - Use lazy `type` resolvers such as `type: () => User` or `type: () => [User]` when the wrapper cannot infer the runtime class.
37
+ - Use `@Schema({ kind: 'embedded' })` for value objects without `_id` or timestamps.
38
+ - Use `@Schema({ kind: 'subdocument' })` for embedded documents that need `_id` and timestamps but should not create a collection.
39
+ - Use `@Prop({ kind: 'virtual', mode: 'getter', comment, optional, hidden, expose, swagger })` for computed getters that only need class-transformer and Swagger metadata.
40
+ - Use `@Prop({ ref: () => User, foreignField, localField })` for populate-one virtuals when inferred defaults are enough.
41
+ - Use `@Prop({ type: () => [User], ref: () => User, foreignField, localField })` for populate-array virtuals.
42
+ - Use `@Prop({ kind: 'map', type: Object })` for raw maps/snapshots instead of passing `PropType.MAP` at the call site.
43
+
44
+ Common mappings:
45
+
46
+ | Use case | Preferred shape |
47
+ | --- | --- |
48
+ | Stored single reference id | `fieldId?: RefId<User>` with `@Prop({ type: ObjectId, ref: () => User })` |
49
+ | Stored reference id array | `fieldIds?: RefId<User>[]` with `@Prop({ type: [ObjectId], ref: () => User })` |
50
+ | Embedded value object | `@Schema({ kind: 'embedded' })` on the nested class |
51
+ | Embedded document | `@Schema({ kind: 'subdocument' })` on the nested class |
52
+ | Raw map/snapshot | `@Prop({ kind: 'map', type: Object })` |
53
+ | Populated single virtual | `field?: PopulatedRef<User>` with `@Prop({ ref: () => User, foreignField: '_id', localField: 'fieldId' })` |
54
+ | Populated virtual array | `fields?: PopulatedRef<User>[]` with `@Prop({ type: () => [User], ref: () => User, foreignField: '_id', localField: 'fieldIds' })` |
55
+ | Computed getter | `@Prop({ kind: 'virtual', mode: 'getter', comment: '...' }) get value() { ... }` |
56
+
57
+ Populate inference:
58
+
59
+ - `ref` + `localField` + `foreignField` marks the field as virtual populate.
60
+ - Populate-one can fallback to the same class from `ref`.
61
+ - Populate arrays still need `type: () => [Target]` because runtime reflection only sees `Array`.
62
+ - `justOne` defaults to `true` for non-array populate fields.
63
+ - Swagger examples default to `{}` or `[]` for populated fields unless explicitly overridden.
64
+
9
65
  ## Plugins
10
66
 
11
67
  - Paranoid plugin handles soft delete filtering and must respect aggregate first-stage constraints such as `$geoNear`.
12
68
  - Strict reference plugin validates referenced documents and must resolve models through the active connection.
13
69
  - Transform plugin centralizes common document transformation and should not break Mongo update operators.
14
70
 
71
+ Plugin checklist:
72
+
73
+ - Paranoid aggregate injection must not come before `$geoNear`.
74
+ - Strict reference checks must be connection-aware in multi-connection apps.
75
+ - Transform behavior must preserve update operators such as `$set`, `$inc`, `$push`, and `$addToSet`.
76
+ - Do not treat plugins as a replacement for app authorization or domain validation.
77
+
15
78
  ## Debug Output
16
79
 
17
80
  Use `mongoDebug(collection, method, ...args)` when a Mongoose debug callback should be rendered as a Mongo shell-friendly command.
81
+
82
+ Debug output is for developer diagnostics. Do not log credentials or sensitive document payloads in production logs.
@@ -19,8 +19,13 @@ 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
+ - Use schema-first `@Column`, `@PrimaryColumn`, and `@TimestampColumn` wrappers when an entity also acts as DTO metadata.
23
+ - Use `@Column({ kind: 'virtual' })` for computed getters that need expose/Swagger metadata without persistence.
24
+ - Use `immutable` for API read-only metadata; TypeORM `update: false` remains storage write behavior and is also inferred as Swagger read-only when `immutable` is not set.
25
+ - Do not use `@joktec/mysql` for Mongo/ObjectId columns, even though TypeORM has Mongo-related APIs.
26
+ - For real migrations, inspect the installed `@joktec/mysql` source in the consumer project's `node_modules` first. If that is insufficient, read GitHub package docs, then GitHub source. Use the local `../joktec-framework` checkout only when you are working inside the JokTec development workspace.
22
27
 
23
28
  ## References
24
29
 
25
30
  - 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 dialect guidance.
31
+ - Read `references/entities.md` for `@Tables`, `@Column`, `@PrimaryColumn`, uuidv7, dialect guidance, and legacy decorator migration rules.
@@ -1,14 +1,122 @@
1
1
  # MySQL Entity Decorators
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked in a consumer project, inspect the installed package first:
6
+
7
+ - `node_modules/@joktec/mysql/README.md`
8
+ - `node_modules/@joktec/mysql/AGENTS.md` when published with the package
9
+ - `node_modules/@joktec/mysql/dist/index.d.ts`
10
+ - `node_modules/@joktec/mysql/dist/decorators/column.decorator.d.ts`
11
+ - `node_modules/@joktec/mysql/dist/decorators/columns/column.type.d.ts`
12
+ - `node_modules/@joktec/mysql/dist/decorators/timestamp.decorator.d.ts`
13
+
14
+ If the installed package is missing enough detail, use the GitHub package docs next:
15
+
16
+ - `https://github.com/joktec/joktec-framework/tree/main/packages/databases/mysql`
17
+
18
+ Use GitHub source only after package docs and installed types are not enough:
19
+
20
+ - `packages/databases/mysql/src/decorators/table.decorator.ts`
21
+ - `packages/databases/mysql/src/decorators/column.decorator.ts`
22
+ - `packages/databases/mysql/src/decorators/columns/column.type.ts`
23
+ - `packages/databases/mysql/src/decorators/columns/column.factory.ts`
24
+ - `packages/databases/mysql/src/decorators/columns/primary.column.ts`
25
+ - `packages/databases/mysql/src/decorators/columns/timestamp.column.ts`
26
+ - `packages/databases/mysql/src/decorators/columns/virtual.column.ts`
27
+ - `packages/databases/mysql/src/decorators/columns/object.column.ts`
28
+ - `packages/databases/mysql/src/decorators/columns/string.column.ts`
29
+ - `packages/databases/mysql/src/decorators/columns/number.column.ts`
30
+ - `packages/databases/mysql/src/decorators/columns/transform.column.ts`
31
+ - `packages/databases/mysql/src/decorators/columns/swagger.column.ts`
32
+
3
33
  ## Schema-First Entity Pattern
4
34
 
5
- Use `@Tables`, `@Column`, and `@PrimaryColumn` from `@joktec/mysql` when an entity should also act as the source class for mapped DTOs.
35
+ Use `@Tables`, `@Column`, `@PrimaryColumn`, and `@TimestampColumn` from `@joktec/mysql` when an entity should also act as the source class for mapped DTOs.
36
+
37
+ The new decorators are not thin TypeORM aliases. They are schema-first wrappers that compose:
38
+
39
+ - TypeORM column/primary column metadata.
40
+ - `class-validator` behavior through `@joktec/utils` validators.
41
+ - `class-transformer` expose/exclude behavior.
42
+ - Swagger property metadata.
43
+
44
+ The wrapper can also represent virtual computed getters and nested JSON/jsonb class payloads. Do not use this package for Mongo/ObjectId columns.
45
+
46
+ Wrapper philosophy:
47
+
48
+ - prefer one schema declaration that carries persistence, validation, transform, and Swagger metadata
49
+ - use wrapper options before duplicating `@ApiProperty`, `@Expose`, `@Type`, or common validators
50
+ - use raw TypeORM only for advanced cases that the wrapper does not model cleanly
51
+ - keep storage write behavior and API documentation behavior distinct when needed
52
+
53
+ ## Current Decorator Capabilities
54
+
55
+ Use the package README and actual installed source for full migration details. This skill only keeps the common mappings that help an agent recognize old patterns.
56
+
57
+ Common mappings:
58
+
59
+ | Legacy decorators | New decorator shape |
60
+ | --- | --- |
61
+ | `@PrimaryGeneratedColumn()` | `@PrimaryColumn('increment')` |
62
+ | `@PrimaryGeneratedColumn('uuid')` | `@PrimaryColumn('uuid')` |
63
+ | app-generated ordered UUID id | `@PrimaryColumn('uuidv7')` |
64
+ | `@CreateDateColumn(...)` | `@TimestampColumn('create', ...)` |
65
+ | `@UpdateDateColumn(...)` | `@TimestampColumn('update', ...)` |
66
+ | `@DeleteDateColumn(...)` | `@TimestampColumn('delete', ...)` |
67
+ | TypeORM `@VersionColumn(...)` | `@Column({ kind: 'version', ... })` |
68
+ | TypeORM `@VirtualColumn(...)` | `@Column({ kind: 'virtual', mode: 'sql', query, ... })` |
69
+ | TypeORM `@ViewColumn(...)` | `@Column({ kind: 'view', ... })` |
70
+ | `@Column(...)` | `@Column(...)` from `@joktec/mysql` |
71
+ | `@RelationId(...)` | `@Column({ kind: 'relation-id', relationId })` |
72
+ | `@IsNotEmpty()` | `@Column({ required: true })` |
73
+ | `@IsOptional()` | `@Column({ required: false })` or nullable TypeORM option when storage allows null |
74
+ | `@IsEmail()` | `@Column({ isEmail: true })` |
75
+ | `@IsMobilePhone()` | `@Column({ isPhone: true })` |
76
+ | `@IsInt()` | `@Column({ isInt: true })` or an integer column type |
77
+ | `@IsUUID()` | `@Column({ isUUID: true })` |
78
+ | `@IsObject()` | `@Column({ isObject: true })` or a JSON column |
79
+ | `@IsHexColor()` | `@Column({ isHexColor: true })` |
80
+ | `@IsUrl()` | `@Column({ isUrl: true })` |
81
+ | `@MinLength(n)` | `@Column({ minLength: n })` |
82
+ | `@MaxLength(n)` | `@Column({ maxLength: n })` |
83
+ | `@Min(n)` | `@Column({ min: n })` |
84
+ | `@Max(n)` | `@Column({ max: n })` |
85
+ | `@Expose()` | default behavior of `@Column(...)` |
86
+ | `@Expose({ groups })` | `@Column({ groups })` |
87
+ | `@Exclude({ toPlainOnly: true })` plus hidden Swagger | `@Column({ hidden: true })` |
88
+ | `@ApiProperty(...)` | `@Column({ swagger: ... })`, or native options such as `example`, `comment`, `deprecated`, `min`, `max`, `minLength`, `maxLength` |
89
+ | `@ValidateNested()` + `@Type(() => Preference)` | `@Column('jsonb', { nested: Preference })` |
90
+ | `@ValidateNested({ each: true })` + `@Type(() => Preference)` | `@Column('jsonb', { nested: Preference, each: true })` |
91
+ | `@Expose()` + `@ApiProperty(...)` on a getter | `@Column({ kind: 'virtual', ... })` |
92
+ | Swagger `readOnly: true` | `@Column({ immutable: true })` or TypeORM `update: false` when ORM updates must also be blocked |
93
+
94
+ ## Read-Only Metadata
95
+
96
+ `immutable` is the API read-only hint used by the JokTec MySQL wrapper. TypeORM `update: false` is the ORM write behavior. The wrapper maps both to Swagger `readOnly` when appropriate:
97
+
98
+ - `immutable` has priority over `update: false`
99
+ - `update: false` implies Swagger `readOnly` only when `immutable` is not set
100
+ - `swagger.readOnly` remains the final explicit override
101
+
102
+ Some field kinds default to API read-only because they are system-managed or computed:
103
+
104
+ - primary keys
105
+ - timestamp columns
106
+ - version columns
107
+ - view columns
108
+ - virtual getter and SQL virtual columns
109
+ - relation-id columns
110
+ - tree level columns
6
111
 
7
112
  ## Primary Keys
8
113
 
9
114
  - Prefer numeric auto-increment keys for write-heavy MySQL tables.
10
115
  - Use UUIDs when the app needs globally unique or public identifiers.
11
116
  - Prefer `uuidv7` over random UUIDs when the id participates in ordered indexes or cursor-like access.
117
+ - When switching from UUID v4 to uuidv7, verify downstream code does not assume random UUID ordering.
118
+
119
+ 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
120
 
13
121
  ## Dialects
14
122
 
@@ -1,23 +1,86 @@
1
1
  # MySQL Repository Usage
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked in a consumer project, inspect installed package docs and types first:
6
+
7
+ - `node_modules/@joktec/mysql/README.md`
8
+ - `node_modules/@joktec/mysql/AGENTS.md` when published with the package
9
+ - `node_modules/@joktec/mysql/dist/index.d.ts`
10
+ - `node_modules/@joktec/mysql/dist/mysql.module.d.ts`
11
+ - `node_modules/@joktec/mysql/dist/mysql.service.d.ts`
12
+ - `node_modules/@joktec/mysql/dist/mysql.repo.d.ts`
13
+ - `node_modules/@joktec/mysql/dist/models/mysql.request.d.ts`
14
+
15
+ If the installed package is insufficient, read GitHub package docs next:
16
+
17
+ - `https://github.com/joktec/joktec-framework/tree/main/packages/databases/mysql`
18
+
19
+ Use GitHub source only after installed types and package docs are not enough:
20
+
21
+ - `packages/databases/mysql/README.md`
22
+ - `packages/databases/mysql/AGENTS.md`
23
+ - `packages/databases/mysql/src/index.ts`
24
+ - `packages/databases/mysql/src/mysql.module.ts`
25
+ - `packages/databases/mysql/src/mysql.service.ts`
26
+ - `packages/databases/mysql/src/mysql.repo.ts`
27
+ - `packages/databases/mysql/src/helpers/mysql.helper.ts`
28
+ - `packages/databases/mysql/src/helpers/mysql.finder.ts`
29
+ - `packages/databases/mysql/src/services/mysql.dialect.ts`
30
+ - `packages/databases/mysql/src/models/*`
31
+
3
32
  ## Module Setup
4
33
 
5
34
  Register entities with `MysqlModule.forRoot({ conId, models: [...] })`. Use `conId` for multiple DataSources.
6
35
 
36
+ Best practice:
37
+
38
+ - Register consumer app entities in an app repository module.
39
+ - Keep `sync` disabled in request-facing processes unless the app intentionally owns schema sync.
40
+ - Use one controlled owner process for schema sync/migration in multi-process deployments.
41
+ - Preserve `conId` when resolving repositories or transaction-scoped managers.
42
+
7
43
  ## Repository Pattern
8
44
 
9
45
  Extend `MysqlRepo` and pass the entity class to the base constructor. Services can use `BaseService` when CRUD behavior follows the shared contract.
10
46
 
47
+ Repository checklist:
48
+
49
+ - Keep entity-specific SQL helpers in the app repository, not in controllers.
50
+ - Use `MysqlRepo.qb()` and repository methods for standard reads so field validation, relation loading, soft delete, and pagination stay consistent.
51
+ - Do not add new behavior to `MysqlFinder`; it is deprecated compatibility code.
52
+ - Keep read/write operations in the same transaction context when the app passes a manager or query runner.
53
+
11
54
  ## Query Safety
12
55
 
13
56
  - Validate field paths against TypeORM metadata before interpolating SQL identifiers.
14
57
  - Use parameter binding for values.
15
58
  - Keep logical operators such as `$and` and `$or` grouped through QueryBuilder behavior.
16
59
 
60
+ Anti-patterns:
61
+
62
+ - Do not interpolate user-provided field names or relation names into SQL without TypeORM metadata validation.
63
+ - Do not assume MySQL-only syntax when the package supports MySQL, MariaDB, and Postgres.
64
+ - Do not use a relation/populate path unless it maps to entity metadata.
65
+
17
66
  ## Pagination
18
67
 
19
68
  `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
69
 
70
+ Cursor checklist:
71
+
72
+ - Use `createdAt + primary key` as the default stable cursor.
73
+ - Add primary keys as tie-breakers for non-unique cursor keys.
74
+ - Ensure cursor keys are indexed for hot list endpoints.
75
+ - Validate cursor payload shape before building SQL.
76
+ - Treat cursor tokens as opaque; clients should not parse them.
77
+
21
78
  ## Transactions
22
79
 
23
80
  When using transaction-scoped operations, pass the manager or query runner through repository options so pre-read and write operations use the same context.
81
+
82
+ Transaction checklist:
83
+
84
+ - Use one manager/query runner for read-modify-write flows.
85
+ - Rollback tests should prove that both pre-read dependent writes and writes are transaction-scoped.
86
+ - 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,49 @@
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
+ - `HttpService.buildAgent(proxy, opts)` expects proxy identity in `HttpProxyConfig` and agent tuning in Node `AgentOptions`; inspect the installed source before adapting to proxy-agent major-version changes.
23
+ - Test request behavior with mocks unless the test is an explicit consumer integration scenario.
24
+
7
25
  ## File
8
26
 
9
27
  Use `@joktec/file` for shared file helpers and classification behavior instead of duplicating local utility code.
10
28
 
29
+ Best practice:
30
+
31
+ - Keep filesystem paths and temporary directories environment-specific.
32
+ - Validate upload/file inputs before passing them into business workflows.
33
+ - Use package helpers for MIME/classification behavior when consistency matters across services.
34
+
11
35
  ## Alert
12
36
 
13
37
  Use `@joktec/alert` for Slack-compatible webhook alerts. Keep webhook URLs and credentials out of source control.
38
+
39
+ Best practice:
40
+
41
+ - Treat alert messages as operational notifications, not business workflows.
42
+ - Do not leak secrets, tokens, connection strings, or personal data into alert payloads.
43
+ - `@joktec/alert` is present but less complete than core database/client packages; inspect source before depending on advanced behavior.
44
+
45
+ ## Anti-Patterns
46
+
47
+ - Do not scatter raw Axios instances across the app when `@joktec/http` should own shared behavior.
48
+ - Do not commit webhook URLs or proxy credentials.
49
+ - Do not use tool packages as hidden places for app business rules.