@venizia/ignis-docs 0.0.6-2 → 0.0.7-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -388
- package/dist/mcp-server/common/config.d.ts +0 -21
- package/dist/mcp-server/common/config.d.ts.map +1 -1
- package/dist/mcp-server/common/config.js +1 -36
- package/dist/mcp-server/common/config.js.map +1 -1
- package/dist/mcp-server/helpers/docs.helper.d.ts +0 -24
- package/dist/mcp-server/helpers/docs.helper.d.ts.map +1 -1
- package/dist/mcp-server/helpers/docs.helper.js +0 -25
- package/dist/mcp-server/helpers/docs.helper.js.map +1 -1
- package/dist/mcp-server/helpers/github.helper.d.ts +0 -13
- package/dist/mcp-server/helpers/github.helper.d.ts.map +1 -1
- package/dist/mcp-server/helpers/github.helper.js +3 -20
- package/dist/mcp-server/helpers/github.helper.js.map +1 -1
- package/dist/mcp-server/index.js +1 -20
- package/dist/mcp-server/index.js.map +1 -1
- package/dist/mcp-server/tools/base.tool.d.ts +4 -85
- package/dist/mcp-server/tools/base.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/base.tool.js +1 -38
- package/dist/mcp-server/tools/base.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts +8 -2
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.js +1 -10
- package/dist/mcp-server/tools/docs/get-document-content.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.d.ts +13 -2
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.js +1 -10
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/get-package-overview.tool.d.ts +16 -8
- package/dist/mcp-server/tools/docs/get-package-overview.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/get-package-overview.tool.js +2 -25
- package/dist/mcp-server/tools/docs/get-package-overview.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/list-categories.tool.d.ts +5 -2
- package/dist/mcp-server/tools/docs/list-categories.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/list-categories.tool.js +1 -10
- package/dist/mcp-server/tools/docs/list-categories.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/list-documents.tool.d.ts +11 -2
- package/dist/mcp-server/tools/docs/list-documents.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/list-documents.tool.js +1 -10
- package/dist/mcp-server/tools/docs/list-documents.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/search-documents.tool.d.ts +13 -2
- package/dist/mcp-server/tools/docs/search-documents.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/search-documents.tool.js +1 -10
- package/dist/mcp-server/tools/docs/search-documents.tool.js.map +1 -1
- package/dist/mcp-server/tools/github/list-project-files.tool.d.ts +9 -2
- package/dist/mcp-server/tools/github/list-project-files.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/list-project-files.tool.js +1 -10
- package/dist/mcp-server/tools/github/list-project-files.tool.js.map +1 -1
- package/dist/mcp-server/tools/github/search-code.tool.d.ts +16 -2
- package/dist/mcp-server/tools/github/search-code.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/search-code.tool.js +2 -14
- package/dist/mcp-server/tools/github/search-code.tool.js.map +1 -1
- package/dist/mcp-server/tools/github/verify-dependencies.tool.d.ts +19 -6
- package/dist/mcp-server/tools/github/verify-dependencies.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/verify-dependencies.tool.js +2 -19
- package/dist/mcp-server/tools/github/verify-dependencies.tool.js.map +1 -1
- package/dist/mcp-server/tools/github/view-source-file.tool.d.ts +8 -2
- package/dist/mcp-server/tools/github/view-source-file.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/view-source-file.tool.js +1 -10
- package/dist/mcp-server/tools/github/view-source-file.tool.js.map +1 -1
- package/dist/mcp-server/tools/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/index.js +0 -2
- package/dist/mcp-server/tools/index.js.map +1 -1
- package/package.json +68 -54
- package/wiki/best-practices/api-usage-examples.md +7 -5
- package/wiki/best-practices/code-style-standards/advanced-patterns.md +1 -1
- package/wiki/best-practices/code-style-standards/constants-configuration.md +1 -1
- package/wiki/best-practices/code-style-standards/control-flow.md +1 -1
- package/wiki/best-practices/code-style-standards/function-patterns.md +1 -1
- package/wiki/best-practices/common-pitfalls.md +1 -1
- package/wiki/best-practices/data-modeling.md +33 -1
- package/wiki/best-practices/error-handling.md +7 -4
- package/wiki/best-practices/performance-optimization.md +1 -1
- package/wiki/best-practices/security-guidelines.md +5 -4
- package/wiki/guides/core-concepts/components-guide.md +1 -1
- package/wiki/guides/core-concepts/controllers.md +14 -8
- package/wiki/guides/core-concepts/persistent/models.md +32 -0
- package/wiki/guides/core-concepts/services.md +2 -1
- package/wiki/guides/get-started/5-minute-quickstart.md +1 -1
- package/wiki/guides/reference/mcp-docs-server.md +0 -134
- package/wiki/guides/tutorials/building-a-crud-api.md +2 -1
- package/wiki/guides/tutorials/complete-installation.md +2 -2
- package/wiki/guides/tutorials/ecommerce-api.md +3 -3
- package/wiki/guides/tutorials/realtime-chat.md +7 -6
- package/wiki/index.md +2 -1
- package/wiki/references/base/components.md +2 -1
- package/wiki/references/base/controllers.md +19 -12
- package/wiki/references/base/middlewares.md +2 -1
- package/wiki/references/base/models.md +11 -2
- package/wiki/references/base/services.md +2 -1
- package/wiki/references/components/authentication/api.md +525 -205
- package/wiki/references/components/authentication/errors.md +502 -105
- package/wiki/references/components/authentication/index.md +388 -75
- package/wiki/references/components/authentication/usage.md +428 -266
- package/wiki/references/components/authorization/api.md +1213 -0
- package/wiki/references/components/authorization/errors.md +387 -0
- package/wiki/references/components/authorization/index.md +712 -0
- package/wiki/references/components/authorization/usage.md +758 -0
- package/wiki/references/components/health-check.md +2 -1
- package/wiki/references/components/index.md +2 -0
- package/wiki/references/components/socket-io/index.md +9 -4
- package/wiki/references/components/socket-io/usage.md +1 -1
- package/wiki/references/components/static-asset/index.md +3 -5
- package/wiki/references/components/swagger.md +2 -1
- package/wiki/references/configuration/environment-variables.md +2 -1
- package/wiki/references/configuration/index.md +2 -1
- package/wiki/references/helpers/error/index.md +1 -1
- package/wiki/references/helpers/index.md +1 -0
- package/wiki/references/helpers/inversion/index.md +1 -1
- package/wiki/references/helpers/kafka/index.md +305 -0
- package/wiki/references/helpers/redis/index.md +2 -9
- package/wiki/references/quick-reference.md +3 -5
- package/wiki/references/utilities/crypto.md +2 -2
- package/wiki/references/utilities/date.md +5 -5
- package/wiki/references/utilities/index.md +3 -11
- package/wiki/references/utilities/jsx.md +4 -2
- package/wiki/references/utilities/module.md +1 -1
- package/wiki/references/utilities/parse.md +4 -4
- package/wiki/references/utilities/performance.md +2 -2
- package/wiki/references/utilities/promise.md +4 -4
- package/wiki/references/utilities/request.md +2 -2
|
@@ -214,8 +214,9 @@ The controller uses `this.definitions = RouteConfigs` to store route configurati
|
|
|
214
214
|
```typescript
|
|
215
215
|
import {
|
|
216
216
|
BaseController, IControllerOptions, TRouteContext,
|
|
217
|
-
api, jsonContent, jsonResponse,
|
|
217
|
+
api, jsonContent, jsonResponse, z,
|
|
218
218
|
} from '@venizia/ignis';
|
|
219
|
+
import { HTTP } from '@venizia/ignis-helpers';
|
|
219
220
|
|
|
220
221
|
const RouteConfigs = {
|
|
221
222
|
ROOT: {
|
|
@@ -7,6 +7,7 @@ Reusable, pluggable modules that group together related features. A component ca
|
|
|
7
7
|
| Component | Purpose | Key Features |
|
|
8
8
|
|-----------|---------|--------------|
|
|
9
9
|
| [Authentication](./authentication/) | JWT/Basic auth | Token generation, protected routes, multi-strategy |
|
|
10
|
+
| [Authorization](./authorization/) <Badge type="warning" text="Experimental" /> | Enforcer-based authz | RBAC, ABAC, voters, Casbin integration, role shortcuts |
|
|
10
11
|
| [Health Check](./health-check) | Monitoring endpoint | `/health` endpoint, ping/pong functionality |
|
|
11
12
|
| [Mail](./mail/) | Email sending system | Multiple transports, templating, queue-based processing |
|
|
12
13
|
| [Request Tracker](./request-tracker) | Request logging | Request ID generation, timing, structured logging |
|
|
@@ -72,6 +73,7 @@ Using components is a great way to organize your application's features into mod
|
|
|
72
73
|
|
|
73
74
|
- **Built-in Components:**
|
|
74
75
|
- [Authentication](./authentication/) - JWT/Basic authentication
|
|
76
|
+
- [Authorization](./authorization/) - Enforcer-based authorization
|
|
75
77
|
- [Health Check](./health-check) - Health check endpoints
|
|
76
78
|
- [Mail](./mail/) - Email functionality
|
|
77
79
|
- [Request Tracker](./request-tracker) - Request tracking
|
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
import {
|
|
19
19
|
SocketIOComponent,
|
|
20
20
|
SocketIOBindingKeys,
|
|
21
|
+
} from '@venizia/ignis';
|
|
22
|
+
|
|
23
|
+
import {
|
|
21
24
|
SocketIOServerHelper,
|
|
22
25
|
RedisHelper,
|
|
23
|
-
} from '@venizia/ignis';
|
|
26
|
+
} from '@venizia/ignis-helpers';
|
|
24
27
|
|
|
25
28
|
import {
|
|
26
29
|
SocketIOClientHelper,
|
|
@@ -70,11 +73,13 @@ import {
|
|
|
70
73
|
BaseApplication,
|
|
71
74
|
SocketIOComponent,
|
|
72
75
|
SocketIOBindingKeys,
|
|
73
|
-
|
|
76
|
+
ValueOrPromise,
|
|
77
|
+
} from '@venizia/ignis';
|
|
78
|
+
import { RedisHelper } from '@venizia/ignis-helpers';
|
|
79
|
+
import type {
|
|
74
80
|
TSocketIOAuthenticateFn,
|
|
75
81
|
TSocketIOValidateRoomFn,
|
|
76
82
|
TSocketIOClientConnectedFn,
|
|
77
|
-
ValueOrPromise,
|
|
78
83
|
} from '@venizia/ignis';
|
|
79
84
|
|
|
80
85
|
export class Application extends BaseApplication {
|
|
@@ -146,7 +151,7 @@ The `RedisHelper` is created with `autoConnect: false` because the server helper
|
|
|
146
151
|
You can use either `RedisHelper` (single Redis instance) or `RedisClusterHelper` (Redis Cluster mode). Both extend `DefaultRedisHelper`, which is the type the component validates against:
|
|
147
152
|
|
|
148
153
|
```typescript
|
|
149
|
-
import { RedisClusterHelper } from '@venizia/ignis';
|
|
154
|
+
import { RedisClusterHelper } from '@venizia/ignis-helpers';
|
|
150
155
|
|
|
151
156
|
// For Redis Cluster deployments
|
|
152
157
|
const redisHelper = new RedisClusterHelper({
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
BaseService,
|
|
14
14
|
inject,
|
|
15
15
|
SocketIOBindingKeys,
|
|
16
|
-
SocketIOServerHelper,
|
|
17
16
|
CoreBindings,
|
|
18
17
|
BaseApplication,
|
|
19
18
|
} from '@venizia/ignis';
|
|
19
|
+
import { SocketIOServerHelper } from '@venizia/ignis-helpers';
|
|
20
20
|
|
|
21
21
|
export class NotificationService extends BaseService {
|
|
22
22
|
// Lazy getter pattern -- helper is bound AFTER server starts
|
|
@@ -17,9 +17,8 @@ import {
|
|
|
17
17
|
StaticAssetComponent,
|
|
18
18
|
StaticAssetComponentBindingKeys,
|
|
19
19
|
StaticAssetStorageTypes,
|
|
20
|
-
DiskHelper,
|
|
21
|
-
MinioHelper,
|
|
22
20
|
} from '@venizia/ignis';
|
|
21
|
+
import { DiskHelper, MinioHelper } from '@venizia/ignis-helpers';
|
|
23
22
|
import type {
|
|
24
23
|
TStaticAssetsComponentOptions,
|
|
25
24
|
TMetaLinkConfig,
|
|
@@ -46,12 +45,11 @@ import type {
|
|
|
46
45
|
```typescript
|
|
47
46
|
import {
|
|
48
47
|
BaseApplication,
|
|
49
|
-
DiskHelper,
|
|
50
|
-
MinioHelper,
|
|
51
48
|
StaticAssetComponentBindingKeys,
|
|
52
49
|
StaticAssetStorageTypes,
|
|
53
|
-
TStaticAssetsComponentOptions,
|
|
54
50
|
} from '@venizia/ignis';
|
|
51
|
+
import { DiskHelper, MinioHelper } from '@venizia/ignis-helpers';
|
|
52
|
+
import type { TStaticAssetsComponentOptions } from '@venizia/ignis';
|
|
55
53
|
|
|
56
54
|
export class Application extends BaseApplication {
|
|
57
55
|
preConfigure() {
|
|
@@ -67,7 +67,8 @@ To get the most out of the documentation, define your routes with `zod` schemas:
|
|
|
67
67
|
```typescript
|
|
68
68
|
// src/controllers/hello.controller.ts
|
|
69
69
|
import { z } from '@hono/zod-openapi';
|
|
70
|
-
import { BaseController, controller,
|
|
70
|
+
import { BaseController, controller, jsonContent, ValueOrPromise } from '@venizia/ignis';
|
|
71
|
+
import { HTTP } from '@venizia/ignis-helpers';
|
|
71
72
|
|
|
72
73
|
@controller({ path: '/hello' })
|
|
73
74
|
export class HelloController extends BaseController {
|
|
@@ -22,7 +22,8 @@ POSTGRES_HOST=localhost
|
|
|
22
22
|
const host = process.env.APP_ENV_POSTGRES_HOST;
|
|
23
23
|
|
|
24
24
|
// Using applicationEnvironment helper (recommended)
|
|
25
|
-
import { applicationEnvironment
|
|
25
|
+
import { applicationEnvironment } from '@venizia/ignis-helpers';
|
|
26
|
+
import { EnvironmentKeys } from '@venizia/ignis';
|
|
26
27
|
const host = applicationEnvironment.get<string>(EnvironmentKeys.APP_ENV_POSTGRES_HOST);
|
|
27
28
|
```
|
|
28
29
|
|
|
@@ -52,7 +52,8 @@ APP_ENV_POSTGRES_DATABASE=my_database
|
|
|
52
52
|
const host = process.env.APP_ENV_POSTGRES_HOST;
|
|
53
53
|
|
|
54
54
|
// 2. Using helper (recommended)
|
|
55
|
-
import { applicationEnvironment
|
|
55
|
+
import { applicationEnvironment } from '@venizia/ignis-helpers';
|
|
56
|
+
import { EnvironmentKeys } from '@venizia/ignis';
|
|
56
57
|
const host = applicationEnvironment.get<string>(EnvironmentKeys.APP_ENV_POSTGRES_HOST);
|
|
57
58
|
```
|
|
58
59
|
|
|
@@ -20,7 +20,7 @@ import type { TError } from '@venizia/ignis-helpers';
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
> [!NOTE]
|
|
23
|
-
> `ApplicationError`, `getError`, `ErrorSchema`, and `TError` are also available from `@venizia/ignis-inversion
|
|
23
|
+
> `ApplicationError`, `getError`, `ErrorSchema`, and `TError` are also available from `@venizia/ignis-inversion`. Their types are re-exported through `@venizia/ignis` (via `export type *`), but for runtime usage, import directly from `@venizia/ignis-helpers` or `@venizia/ignis-inversion`.
|
|
24
24
|
|
|
25
25
|
## Creating an Instance
|
|
26
26
|
|
|
@@ -14,6 +14,7 @@ Reusable classes and functions providing common functionality - designed for eas
|
|
|
14
14
|
| [Inversion](./inversion/) | Dependency injection | DI container implementation |
|
|
15
15
|
| [Logger](./logger/) | Logging | Winston-based, multiple transports, scopes |
|
|
16
16
|
| [Network](./network/) | Network requests | HTTP, TCP, UDP helpers |
|
|
17
|
+
| Kafka <Badge type="warning" text="Experimental" /> | Event streaming | Apache Kafka producer/consumer |
|
|
17
18
|
| [Queue](./queue/) | Message queues | BullMQ, MQTT support |
|
|
18
19
|
| [Redis](./redis/) | Redis operations | Single/cluster, key-value, hashes, JSON, pub/sub |
|
|
19
20
|
| [Socket.IO](./socket-io/) | Real-time communication | Socket.IO client/server helpers |
|
|
@@ -50,7 +50,7 @@ import type {
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
> [!NOTE]
|
|
53
|
-
> The framework package `@venizia/ignis` re-exports
|
|
53
|
+
> The framework package `@venizia/ignis` re-exports DI-specific symbols (`Binding`, `BindingKeys`, `BindingScopes`, `BindingValueTypes`, `IProvider`, `isClass`, `isClassProvider`, `isClassConstructor`, `TBindingScope`, `TBindingValueType`, `IBindingTag`) from `@venizia/ignis-inversion` and adds higher-level helpers (`app.controller()`, `app.service()`, etc.). All types from inversion are also available via type-only re-exports.
|
|
54
54
|
|
|
55
55
|
## Creating an Instance
|
|
56
56
|
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# Kafka <Badge type="warning" text="Experimental" />
|
|
2
|
+
|
|
3
|
+
Apache Kafka event streaming with producer, consumer, and admin helpers. Built on [`@platformatic/kafka`](https://github.com/platformatic/kafka).
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> This helper is **experimental**. The API may change in future releases.
|
|
7
|
+
|
|
8
|
+
## Quick Reference
|
|
9
|
+
|
|
10
|
+
| Class | Extends | Peer Dependency | Use Case |
|
|
11
|
+
|-------|---------|-----------------|----------|
|
|
12
|
+
| **KafkaProducerHelper** | `BaseHelper` | `@platformatic/kafka` | Publish messages to Kafka topics |
|
|
13
|
+
| **KafkaConsumerHelper** | `BaseHelper` | `@platformatic/kafka` | Consume messages from Kafka topics with consumer groups |
|
|
14
|
+
| **KafkaAdminHelper** | `BaseHelper` | `@platformatic/kafka` | Manage topics, partitions, consumer groups, and configs |
|
|
15
|
+
|
|
16
|
+
### Import Path
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import {
|
|
20
|
+
KafkaProducerHelper,
|
|
21
|
+
KafkaConsumerHelper,
|
|
22
|
+
KafkaAdminHelper,
|
|
23
|
+
KafkaDefaults,
|
|
24
|
+
KafkaAcks,
|
|
25
|
+
KafkaConfigResourceTypes,
|
|
26
|
+
} from '@venizia/ignis-helpers/kafka';
|
|
27
|
+
|
|
28
|
+
import type {
|
|
29
|
+
IKafkaConnectionOptions,
|
|
30
|
+
IKafkaProducerOptions,
|
|
31
|
+
IKafkaConsumerOptions,
|
|
32
|
+
IKafkaAdminOptions,
|
|
33
|
+
IKafkaProduceMessage,
|
|
34
|
+
IKafkaSendOptions,
|
|
35
|
+
IKafkaConsumedMessage,
|
|
36
|
+
IKafkaCommitOptions,
|
|
37
|
+
} from '@venizia/ignis-helpers/kafka';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun add @platformatic/kafka
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Producer
|
|
47
|
+
|
|
48
|
+
The `KafkaProducerHelper` wraps `@platformatic/kafka`'s `Producer` for publishing messages to Kafka topics.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { KafkaProducerHelper, KafkaAcks } from '@venizia/ignis-helpers/kafka';
|
|
52
|
+
|
|
53
|
+
const producer = new KafkaProducerHelper({
|
|
54
|
+
identifier: 'order-producer',
|
|
55
|
+
bootstrapBrokers: ['localhost:9092'],
|
|
56
|
+
acks: KafkaAcks.ALL,
|
|
57
|
+
autocreateTopics: true,
|
|
58
|
+
onConnected: () => console.log('Producer connected'),
|
|
59
|
+
onError: ({ error }) => console.error('Producer error:', error),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Send messages
|
|
63
|
+
await producer.send({
|
|
64
|
+
messages: [
|
|
65
|
+
{ topic: 'orders', key: 'order-123', value: JSON.stringify({ status: 'created' }) },
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Send batch across multiple topics
|
|
70
|
+
await producer.sendBatch({
|
|
71
|
+
topicMessages: [
|
|
72
|
+
{ topic: 'orders', messages: [{ key: 'o1', value: '...' }] },
|
|
73
|
+
{ topic: 'notifications', messages: [{ key: 'n1', value: '...' }] },
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Graceful shutdown
|
|
78
|
+
await producer.close();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### IKafkaProducerOptions
|
|
82
|
+
|
|
83
|
+
| Option | Type | Default | Description |
|
|
84
|
+
|--------|------|---------|-------------|
|
|
85
|
+
| `bootstrapBrokers` | `string[]` | -- | Kafka broker addresses (required) |
|
|
86
|
+
| `identifier` | `string` | -- | Scoped logging identifier |
|
|
87
|
+
| `clientId` | `string` | `'ignis-kafka'` | Kafka client ID |
|
|
88
|
+
| `acks` | `number` | -- | Acknowledgment level (`KafkaAcks.NONE`, `LEADER`, `ALL`) |
|
|
89
|
+
| `autocreateTopics` | `boolean` | -- | Auto-create topics on first produce |
|
|
90
|
+
| `timeout` | `number` | -- | Connection timeout in ms |
|
|
91
|
+
| `retries` | `number \| boolean` | -- | Retry configuration |
|
|
92
|
+
| `retryDelay` | `number` | -- | Delay between retries in ms |
|
|
93
|
+
| `serializers` | `Partial<Serializers>` | -- | Custom key/value/header serializers |
|
|
94
|
+
| `onConnected` | `() => void` | -- | Broker connect callback |
|
|
95
|
+
| `onDisconnected` | `() => void` | -- | Broker disconnect callback |
|
|
96
|
+
| `onError` | `(opts: { error: Error }) => void` | -- | Error callback |
|
|
97
|
+
|
|
98
|
+
### Producer API
|
|
99
|
+
|
|
100
|
+
| Method | Returns | Description |
|
|
101
|
+
|--------|---------|-------------|
|
|
102
|
+
| `send(opts)` | `Promise<void>` | Send messages. `opts: { messages: IKafkaProduceMessage[]; acks? }` |
|
|
103
|
+
| `sendBatch(opts)` | `Promise<void>` | Send to multiple topics. `opts: { topicMessages: Array<{ topic; messages }> }` |
|
|
104
|
+
| `getProducer()` | `Producer` | Access the underlying `@platformatic/kafka` Producer |
|
|
105
|
+
| `close()` | `Promise<void>` | Gracefully close the producer connection |
|
|
106
|
+
| `static newInstance(opts)` | `KafkaProducerHelper` | Factory method |
|
|
107
|
+
|
|
108
|
+
## Consumer
|
|
109
|
+
|
|
110
|
+
The `KafkaConsumerHelper` provides a stream-based consumer with consumer group support, pause/resume, manual commit, and lag monitoring.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { KafkaConsumerHelper } from '@venizia/ignis-helpers/kafka';
|
|
114
|
+
|
|
115
|
+
const consumer = new KafkaConsumerHelper({
|
|
116
|
+
identifier: 'order-consumer',
|
|
117
|
+
bootstrapBrokers: ['localhost:9092'],
|
|
118
|
+
groupId: 'order-processing-group',
|
|
119
|
+
topics: ['orders'],
|
|
120
|
+
mode: 'latest',
|
|
121
|
+
autocommit: true,
|
|
122
|
+
onMessage: async ({ message }) => {
|
|
123
|
+
console.log(`Topic: ${message.topic}, Partition: ${message.partition}`);
|
|
124
|
+
console.log(`Key: ${message.key}, Value: ${message.value}`);
|
|
125
|
+
},
|
|
126
|
+
onConnected: () => console.log('Consumer connected'),
|
|
127
|
+
onGroupJoin: ({ groupId, memberId }) => {
|
|
128
|
+
console.log(`Joined group ${groupId} as ${memberId}`);
|
|
129
|
+
},
|
|
130
|
+
onError: ({ error }) => console.error('Consumer error:', error),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Start consuming
|
|
134
|
+
await consumer.start();
|
|
135
|
+
|
|
136
|
+
// Pause/resume
|
|
137
|
+
consumer.pause();
|
|
138
|
+
consumer.resume();
|
|
139
|
+
|
|
140
|
+
// Graceful shutdown
|
|
141
|
+
await consumer.close();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### IKafkaConsumerOptions
|
|
145
|
+
|
|
146
|
+
| Option | Type | Default | Description |
|
|
147
|
+
|--------|------|---------|-------------|
|
|
148
|
+
| `bootstrapBrokers` | `string[]` | -- | Kafka broker addresses (required) |
|
|
149
|
+
| `groupId` | `string` | -- | Consumer group ID (required) |
|
|
150
|
+
| `topics` | `string[]` | -- | Topics to consume (required) |
|
|
151
|
+
| `identifier` | `string` | -- | Scoped logging identifier |
|
|
152
|
+
| `clientId` | `string` | `'ignis-kafka'` | Kafka client ID |
|
|
153
|
+
| `mode` | `'latest' \| 'earliest' \| 'committed'` | `'latest'` | Offset reset strategy |
|
|
154
|
+
| `autocommit` | `boolean \| number` | `true` | Auto-commit offsets (or interval in ms) |
|
|
155
|
+
| `sessionTimeout` | `number` | `30000` | Session timeout in ms |
|
|
156
|
+
| `heartbeatInterval` | `number` | `3000` | Heartbeat interval in ms |
|
|
157
|
+
| `highWaterMark` | `number` | `1024` | Stream high water mark |
|
|
158
|
+
| `maxWaitTime` | `number` | `5000` | Max wait time for fetch in ms |
|
|
159
|
+
| `deserializers` | `Partial<Deserializers>` | -- | Custom key/value/header deserializers |
|
|
160
|
+
| `onMessage` | `(opts: { message }) => ValueOrPromise<void>` | -- | Message handler |
|
|
161
|
+
| `onConnected` | `() => void` | -- | Broker connect callback |
|
|
162
|
+
| `onDisconnected` | `() => void` | -- | Broker disconnect callback |
|
|
163
|
+
| `onGroupJoin` | `(opts: { groupId; memberId }) => void` | -- | Consumer group join callback |
|
|
164
|
+
| `onGroupLeave` | `() => void` | -- | Consumer group leave callback |
|
|
165
|
+
| `onRebalance` | `() => void` | -- | Group rebalance callback |
|
|
166
|
+
| `onLag` | `(opts: { offsets }) => void` | -- | Consumer lag callback |
|
|
167
|
+
| `onError` | `(opts: { error: Error }) => void` | -- | Error callback |
|
|
168
|
+
|
|
169
|
+
### Consumer API
|
|
170
|
+
|
|
171
|
+
| Method | Returns | Description |
|
|
172
|
+
|--------|---------|-------------|
|
|
173
|
+
| `start()` | `Promise<void>` | Start consuming messages (fires async consume loop) |
|
|
174
|
+
| `pause()` | `void` | Pause the message stream |
|
|
175
|
+
| `resume()` | `void` | Resume the message stream |
|
|
176
|
+
| `isPaused()` | `boolean` | Check if the stream is paused |
|
|
177
|
+
| `isConsuming()` | `boolean` | Check if the consumer is running |
|
|
178
|
+
| `commit(opts)` | `Promise<void>` | Manually commit offsets |
|
|
179
|
+
| `startLagMonitoring(opts)` | `void` | Start lag monitoring. `opts: { interval: number }` |
|
|
180
|
+
| `stopLagMonitoring()` | `void` | Stop lag monitoring |
|
|
181
|
+
| `getConsumer()` | `Consumer` | Access the underlying `@platformatic/kafka` Consumer |
|
|
182
|
+
| `close()` | `Promise<void>` | Abort consume loop, close stream and consumer |
|
|
183
|
+
| `static newInstance(opts)` | `KafkaConsumerHelper` | Factory method |
|
|
184
|
+
|
|
185
|
+
### Manual Commit
|
|
186
|
+
|
|
187
|
+
When `autocommit` is `false`, commit offsets explicitly:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const consumer = new KafkaConsumerHelper({
|
|
191
|
+
// ...
|
|
192
|
+
autocommit: false,
|
|
193
|
+
onMessage: async ({ message }) => {
|
|
194
|
+
await processMessage(message);
|
|
195
|
+
// Commit after successful processing
|
|
196
|
+
await consumer.commit({
|
|
197
|
+
offsets: [{
|
|
198
|
+
topic: message.topic,
|
|
199
|
+
partition: message.partition,
|
|
200
|
+
offset: message.offset,
|
|
201
|
+
leaderEpoch: 0,
|
|
202
|
+
}],
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Admin
|
|
209
|
+
|
|
210
|
+
The `KafkaAdminHelper` provides topic, partition, consumer group, and config management.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { KafkaAdminHelper, KafkaConfigResourceTypes } from '@venizia/ignis-helpers/kafka';
|
|
214
|
+
|
|
215
|
+
const admin = new KafkaAdminHelper({
|
|
216
|
+
identifier: 'kafka-admin',
|
|
217
|
+
bootstrapBrokers: ['localhost:9092'],
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Topic management
|
|
221
|
+
await admin.createTopics({ topics: ['orders', 'notifications'], partitions: 3, replicas: 1 });
|
|
222
|
+
const topics = await admin.listTopics();
|
|
223
|
+
await admin.deleteTopics({ topics: ['old-topic'] });
|
|
224
|
+
|
|
225
|
+
// Partition management
|
|
226
|
+
await admin.createPartitions({ topics: [{ name: 'orders', count: 6 }] });
|
|
227
|
+
|
|
228
|
+
// Consumer group management
|
|
229
|
+
const groups = await admin.listGroups();
|
|
230
|
+
const groupDetails = await admin.describeGroups({ groups: ['order-processing-group'] });
|
|
231
|
+
await admin.deleteGroups({ groups: ['stale-group'] });
|
|
232
|
+
|
|
233
|
+
// Config management
|
|
234
|
+
const configs = await admin.describeConfigs({
|
|
235
|
+
resources: [{
|
|
236
|
+
resourceType: KafkaConfigResourceTypes.TOPIC,
|
|
237
|
+
resourceName: 'orders',
|
|
238
|
+
}],
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Metadata
|
|
242
|
+
const meta = await admin.metadata({ topics: ['orders'] });
|
|
243
|
+
|
|
244
|
+
// Cleanup
|
|
245
|
+
await admin.close();
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Admin API
|
|
249
|
+
|
|
250
|
+
| Method | Returns | Description |
|
|
251
|
+
|--------|---------|-------------|
|
|
252
|
+
| `createTopics(opts)` | `Promise<any>` | Create topics with partitions and replicas |
|
|
253
|
+
| `deleteTopics(opts)` | `Promise<void>` | Delete topics |
|
|
254
|
+
| `listTopics(opts?)` | `Promise<string[]>` | List topics (optionally include internals) |
|
|
255
|
+
| `metadata(opts?)` | `Promise<any>` | Fetch cluster/topic metadata |
|
|
256
|
+
| `listGroups(opts?)` | `Promise<any>` | List consumer groups (filter by state) |
|
|
257
|
+
| `describeGroups(opts)` | `Promise<any>` | Describe consumer groups |
|
|
258
|
+
| `deleteGroups(opts)` | `Promise<void>` | Delete consumer groups |
|
|
259
|
+
| `listConsumerGroupOffsets(opts)` | `Promise<any>` | List offsets for consumer groups |
|
|
260
|
+
| `alterConsumerGroupOffsets(opts)` | `Promise<void>` | Alter consumer group offsets |
|
|
261
|
+
| `createPartitions(opts)` | `Promise<void>` | Create partitions for topics |
|
|
262
|
+
| `describeConfigs(opts)` | `Promise<any>` | Describe resource configs |
|
|
263
|
+
| `alterConfigs(opts)` | `Promise<void>` | Alter resource configs |
|
|
264
|
+
| `getAdmin()` | `Admin` | Access the underlying `@platformatic/kafka` Admin |
|
|
265
|
+
| `close()` | `Promise<void>` | Close the admin connection |
|
|
266
|
+
| `static newInstance(opts)` | `KafkaAdminHelper` | Factory method |
|
|
267
|
+
|
|
268
|
+
## Constants
|
|
269
|
+
|
|
270
|
+
### KafkaDefaults
|
|
271
|
+
|
|
272
|
+
| Constant | Value | Description |
|
|
273
|
+
|----------|-------|-------------|
|
|
274
|
+
| `CLIENT_ID` | `'ignis-kafka'` | Default Kafka client ID |
|
|
275
|
+
| `SESSION_TIMEOUT` | `30000` | Session timeout (ms) |
|
|
276
|
+
| `HEARTBEAT_INTERVAL` | `3000` | Heartbeat interval (ms) |
|
|
277
|
+
| `MAX_WAIT_TIME` | `5000` | Max fetch wait time (ms) |
|
|
278
|
+
| `HIGH_WATER_MARK` | `1024` | Stream high water mark |
|
|
279
|
+
| `AUTOCOMMIT_INTERVAL` | `100` | Auto-commit interval (ms) |
|
|
280
|
+
|
|
281
|
+
### KafkaAcks
|
|
282
|
+
|
|
283
|
+
| Constant | Value | Description |
|
|
284
|
+
|----------|-------|-------------|
|
|
285
|
+
| `NONE` | `0` | No acknowledgment |
|
|
286
|
+
| `LEADER` | `1` | Leader acknowledgment only |
|
|
287
|
+
| `ALL` | `-1` | All replicas must acknowledge |
|
|
288
|
+
|
|
289
|
+
### KafkaConfigResourceTypes
|
|
290
|
+
|
|
291
|
+
| Constant | Value | Description |
|
|
292
|
+
|----------|-------|-------------|
|
|
293
|
+
| `UNKNOWN` | `0` | Unknown resource type |
|
|
294
|
+
| `TOPIC` | `2` | Topic resource |
|
|
295
|
+
| `BROKER` | `4` | Broker resource |
|
|
296
|
+
| `BROKER_LOGGER` | `8` | Broker logger resource |
|
|
297
|
+
|
|
298
|
+
## See Also
|
|
299
|
+
|
|
300
|
+
- **Other Helpers:**
|
|
301
|
+
- [Queue Helper](../queue/) -- BullMQ, MQTT, and in-memory queues
|
|
302
|
+
- [Redis Helper](../redis/) -- Redis connection management
|
|
303
|
+
|
|
304
|
+
- **External Resources:**
|
|
305
|
+
- [@platformatic/kafka](https://github.com/platformatic/kafka) -- Underlying Kafka client library
|
|
@@ -20,21 +20,14 @@ import {
|
|
|
20
20
|
RedisClusterHelper,
|
|
21
21
|
} from '@venizia/ignis-helpers';
|
|
22
22
|
|
|
23
|
-
//
|
|
24
|
-
import {
|
|
25
|
-
DefaultRedisHelper,
|
|
26
|
-
RedisHelper,
|
|
27
|
-
RedisClusterHelper,
|
|
28
|
-
} from '@venizia/ignis';
|
|
29
|
-
|
|
30
|
-
// Types
|
|
23
|
+
// Types are also available from the core package (via type-only re-export)
|
|
31
24
|
import type {
|
|
32
25
|
IRedisHelperOptions,
|
|
33
26
|
IRedisClusterHelperOptions,
|
|
34
27
|
IRedisHelperCallbacks,
|
|
35
28
|
IRedisHelperProps,
|
|
36
29
|
IRedisClusterHelperProps,
|
|
37
|
-
} from '@venizia/ignis-helpers';
|
|
30
|
+
} from '@venizia/ignis-helpers'; // or from '@venizia/ignis'
|
|
38
31
|
```
|
|
39
32
|
|
|
40
33
|
## Creating an Instance
|
|
@@ -118,6 +118,7 @@ class User extends BaseEntity {
|
|
|
118
118
|
**Key Properties:**
|
|
119
119
|
- `static tableName` - Database table name
|
|
120
120
|
- `static schema` - Drizzle schema definition
|
|
121
|
+
- `static AUTHORIZATION_SUBJECT` - Authorization principal (auto-set from `@model` settings `authorize.principal`)
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
## Route Decorators
|
|
@@ -396,11 +397,8 @@ import { MinIOHelper } from '@venizia/ignis-helpers/minio';
|
|
|
396
397
|
### Dependency Injection
|
|
397
398
|
|
|
398
399
|
```typescript
|
|
399
|
-
import {
|
|
400
|
-
|
|
401
|
-
BindingKeys,
|
|
402
|
-
BindingNamespaces,
|
|
403
|
-
} from '@venizia/ignis-inversion';
|
|
400
|
+
import { Container, BindingKeys } from '@venizia/ignis-inversion';
|
|
401
|
+
import { BindingNamespaces } from '@venizia/ignis';
|
|
404
402
|
```
|
|
405
403
|
|
|
406
404
|
|
|
@@ -19,7 +19,7 @@ The `hash` function allows you to create a hash of a string using either `SHA256
|
|
|
19
19
|
**MD5 Hash**
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import { hash } from '@venizia/ignis';
|
|
22
|
+
import { hash } from '@venizia/ignis-helpers';
|
|
23
23
|
|
|
24
24
|
const md5Hash = hash('some text', { algorithm: 'MD5', outputType: 'hex' });
|
|
25
25
|
// => '552e21cd4cd99186789c2370c7482837'
|
|
@@ -28,7 +28,7 @@ const md5Hash = hash('some text', { algorithm: 'MD5', outputType: 'hex' });
|
|
|
28
28
|
**SHA256 HMAC**
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import { hash } from '@venizia/ignis';
|
|
31
|
+
import { hash } from '@venizia/ignis-helpers';
|
|
32
32
|
|
|
33
33
|
const sha256Hash = hash('some text', {
|
|
34
34
|
algorithm: 'SHA256',
|
|
@@ -7,7 +7,7 @@ The Date utility provides a set of functions for date and time manipulation, bui
|
|
|
7
7
|
The `dayjs` object is re-exported, so you can use it directly for any date and time operations. It is pre-configured with the following plugins: `CustomParseFormat`, `UTC`, `Timezone`, `Weekday`, and `IsoWeek`.
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
import { dayjs } from '@venizia/ignis';
|
|
10
|
+
import { dayjs } from '@venizia/ignis-helpers';
|
|
11
11
|
|
|
12
12
|
// Get the current date and time
|
|
13
13
|
const now = dayjs();
|
|
@@ -21,7 +21,7 @@ const formatted = now.format('YYYY-MM-DD HH:mm:ss');
|
|
|
21
21
|
The `sleep` function pauses execution for a specified number of milliseconds.
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
|
-
import { sleep } from '@venizia/ignis';
|
|
24
|
+
import { sleep } from '@venizia/ignis-helpers';
|
|
25
25
|
|
|
26
26
|
async function myAsyncFunction() {
|
|
27
27
|
console.log('Start');
|
|
@@ -37,7 +37,7 @@ async function myAsyncFunction() {
|
|
|
37
37
|
- **`getNextWeekday(opts)`**: Returns the next weekday from a given date.
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
|
-
import { isWeekday, getPreviousWeekday } from '@venizia/ignis';
|
|
40
|
+
import { isWeekday, getPreviousWeekday } from '@venizia/ignis-helpers';
|
|
41
41
|
|
|
42
42
|
const isTodayWeekday = isWeekday(new Date());
|
|
43
43
|
|
|
@@ -49,7 +49,7 @@ const lastBusinessDay = getPreviousWeekday();
|
|
|
49
49
|
The `getDateTz` function allows you to get a `dayjs` object in a specific timezone, with an optional offset.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
import { getDateTz } from '@venizia/ignis';
|
|
52
|
+
import { getDateTz } from '@venizia/ignis-helpers';
|
|
53
53
|
|
|
54
54
|
const tokyoTime = getDateTz({
|
|
55
55
|
date: '2023-10-27T10:00:00Z',
|
|
@@ -62,7 +62,7 @@ const tokyoTime = getDateTz({
|
|
|
62
62
|
The `hrTime` function returns a high-resolution time measurement in seconds, useful for performance benchmarking.
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
|
-
import { hrTime } from '@venizia/ignis';
|
|
65
|
+
import { hrTime } from '@venizia/ignis-helpers';
|
|
66
66
|
|
|
67
67
|
const start = hrTime();
|
|
68
68
|
// ... some long-running operation
|
|
@@ -43,19 +43,11 @@ Pure, standalone functions providing common, reusable logic for the Ignis framew
|
|
|
43
43
|
|
|
44
44
|
## Usage Pattern
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Utilities are imported from `@venizia/ignis` (schema, JSX, and status helpers) or `@venizia/ignis-helpers` (runtime utilities):
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
compare,
|
|
52
|
-
formatDate,
|
|
53
|
-
toBoolean,
|
|
54
|
-
jsonContent,
|
|
55
|
-
jsonResponse,
|
|
56
|
-
htmlResponse,
|
|
57
|
-
Statuses,
|
|
58
|
-
} from '@venizia/ignis';
|
|
49
|
+
import { jsonContent, jsonResponse, htmlResponse, Statuses } from '@venizia/ignis';
|
|
50
|
+
import { hash, compare, formatDate, toBoolean } from '@venizia/ignis-helpers';
|
|
59
51
|
|
|
60
52
|
// Crypto
|
|
61
53
|
const hashed = await hash({ value: 'password123' });
|
|
@@ -184,7 +184,8 @@ export class PageController extends BaseController {
|
|
|
184
184
|
### HTML Email Preview
|
|
185
185
|
|
|
186
186
|
```typescript
|
|
187
|
-
import { BaseController, get, htmlResponse, TRouteContext,
|
|
187
|
+
import { BaseController, get, htmlResponse, TRouteContext, z } from '@venizia/ignis';
|
|
188
|
+
import { HTTP } from '@venizia/ignis-helpers';
|
|
188
189
|
|
|
189
190
|
const EmailRoutes = {
|
|
190
191
|
PREVIEW: {
|
|
@@ -222,7 +223,8 @@ export class EmailController extends BaseController {
|
|
|
222
223
|
### Documentation Page
|
|
223
224
|
|
|
224
225
|
```typescript
|
|
225
|
-
import { BaseController, get, htmlResponse, TRouteContext,
|
|
226
|
+
import { BaseController, get, htmlResponse, TRouteContext, z } from '@venizia/ignis';
|
|
227
|
+
import { HTTP } from '@venizia/ignis-helpers';
|
|
226
228
|
|
|
227
229
|
const DocsRoutes = {
|
|
228
230
|
GET_SECTION: {
|
|
@@ -17,7 +17,7 @@ The `validateModule` function checks if a list of modules can be resolved. If a
|
|
|
17
17
|
The `SwaggerComponent` uses `validateModule` to ensure that `@hono/swagger-ui` is installed before attempting to use it.
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { validateModule } from '@venizia/ignis';
|
|
20
|
+
import { validateModule } from '@venizia/ignis-helpers';
|
|
21
21
|
|
|
22
22
|
export class SwaggerComponent extends BaseComponent {
|
|
23
23
|
// ...
|