@venizia/ignis-docs 0.0.7-2 → 0.0.8-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/dist/mcp-server/common/paths.d.ts +4 -2
- package/dist/mcp-server/common/paths.d.ts.map +1 -1
- package/dist/mcp-server/common/paths.js +8 -6
- package/dist/mcp-server/common/paths.js.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts +1 -1
- 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 +7 -7
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.js +3 -3
- package/dist/mcp-server/tools/docs/get-package-overview.tool.d.ts +1 -1
- package/dist/mcp-server/tools/docs/get-package-overview.tool.js +1 -1
- package/package.json +1 -1
- package/wiki/best-practices/api-usage-examples.md +9 -9
- package/wiki/best-practices/architectural-patterns.md +19 -3
- package/wiki/best-practices/architecture-decisions.md +6 -6
- package/wiki/best-practices/code-style-standards/advanced-patterns.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 +2 -2
- package/wiki/best-practices/code-style-standards/index.md +2 -2
- package/wiki/best-practices/code-style-standards/naming-conventions.md +1 -1
- package/wiki/best-practices/code-style-standards/route-definitions.md +4 -4
- package/wiki/best-practices/data-modeling.md +1 -1
- package/wiki/best-practices/deployment-strategies.md +1 -1
- package/wiki/best-practices/error-handling.md +2 -2
- package/wiki/best-practices/performance-optimization.md +3 -3
- package/wiki/best-practices/security-guidelines.md +2 -2
- package/wiki/best-practices/troubleshooting-tips.md +1 -1
- package/wiki/{references → extensions}/components/authentication/api.md +12 -20
- package/wiki/{references → extensions}/components/authentication/errors.md +1 -1
- package/wiki/{references → extensions}/components/authentication/index.md +5 -8
- package/wiki/{references → extensions}/components/authentication/usage.md +20 -36
- package/wiki/{references → extensions}/components/authorization/api.md +62 -13
- package/wiki/{references → extensions}/components/authorization/errors.md +12 -7
- package/wiki/{references → extensions}/components/authorization/index.md +93 -6
- package/wiki/{references → extensions}/components/authorization/usage.md +42 -4
- package/wiki/{references → extensions}/components/health-check.md +5 -4
- package/wiki/{references → extensions}/components/index.md +2 -0
- package/wiki/{references → extensions}/components/mail/index.md +1 -1
- package/wiki/{references → extensions}/components/request-tracker.md +1 -1
- package/wiki/{references → extensions}/components/socket-io/api.md +2 -2
- package/wiki/{references → extensions}/components/socket-io/errors.md +2 -0
- package/wiki/{references → extensions}/components/socket-io/index.md +24 -20
- package/wiki/{references → extensions}/components/socket-io/usage.md +2 -2
- package/wiki/{references → extensions}/components/static-asset/api.md +14 -15
- package/wiki/{references → extensions}/components/static-asset/errors.md +3 -1
- package/wiki/{references → extensions}/components/static-asset/index.md +158 -89
- package/wiki/{references → extensions}/components/static-asset/usage.md +8 -5
- package/wiki/{references → extensions}/components/swagger.md +3 -3
- package/wiki/{references → extensions}/components/template/index.md +4 -4
- package/wiki/{references → extensions}/components/template/setup-page.md +1 -1
- package/wiki/{references → extensions}/components/template/single-page.md +1 -1
- package/wiki/{references → extensions}/components/websocket/api.md +7 -6
- package/wiki/{references → extensions}/components/websocket/errors.md +17 -3
- package/wiki/{references → extensions}/components/websocket/index.md +17 -11
- package/wiki/{references → extensions}/components/websocket/usage.md +2 -2
- package/wiki/{references → extensions}/helpers/crypto/index.md +1 -1
- package/wiki/{references → extensions}/helpers/env/index.md +9 -5
- package/wiki/{references → extensions}/helpers/error/index.md +2 -7
- package/wiki/{references → extensions}/helpers/index.md +18 -6
- package/wiki/{references → extensions}/helpers/kafka/admin.md +33 -16
- package/wiki/extensions/helpers/kafka/consumer.md +384 -0
- package/wiki/extensions/helpers/kafka/examples.md +361 -0
- package/wiki/extensions/helpers/kafka/index.md +639 -0
- package/wiki/{references → extensions}/helpers/kafka/producer.md +100 -96
- package/wiki/extensions/helpers/kafka/schema-registry.md +214 -0
- package/wiki/{references → extensions}/helpers/logger/index.md +2 -2
- package/wiki/{references → extensions}/helpers/queue/index.md +400 -4
- package/wiki/{references → extensions}/helpers/storage/api.md +170 -10
- package/wiki/{references → extensions}/helpers/storage/index.md +44 -8
- package/wiki/{references → extensions}/helpers/template/index.md +1 -1
- package/wiki/{references → extensions}/helpers/testing/index.md +4 -4
- package/wiki/{references → extensions}/helpers/types/index.md +63 -16
- package/wiki/{references → extensions}/helpers/websocket/index.md +1 -1
- package/wiki/extensions/index.md +48 -0
- package/wiki/guides/core-concepts/application/bootstrapping.md +55 -37
- package/wiki/guides/core-concepts/application/index.md +95 -35
- package/wiki/guides/core-concepts/components-guide.md +23 -19
- package/wiki/guides/core-concepts/components.md +34 -10
- package/wiki/guides/core-concepts/dependency-injection.md +99 -34
- package/wiki/guides/core-concepts/grpc-controllers.md +295 -0
- package/wiki/guides/core-concepts/persistent/datasources.md +27 -8
- package/wiki/guides/core-concepts/persistent/models.md +43 -1
- package/wiki/guides/core-concepts/persistent/repositories.md +75 -8
- package/wiki/guides/core-concepts/persistent/transactions.md +38 -8
- package/wiki/guides/core-concepts/{controllers.md → rest-controllers.md} +30 -33
- package/wiki/guides/core-concepts/services.md +19 -5
- package/wiki/guides/get-started/5-minute-quickstart.md +6 -7
- package/wiki/guides/get-started/philosophy.md +1 -1
- package/wiki/guides/index.md +2 -2
- package/wiki/guides/reference/glossary.md +7 -7
- package/wiki/guides/reference/mcp-docs-server.md +1 -1
- package/wiki/guides/tutorials/building-a-crud-api.md +2 -2
- package/wiki/guides/tutorials/complete-installation.md +17 -14
- package/wiki/guides/tutorials/ecommerce-api.md +18 -18
- package/wiki/guides/tutorials/realtime-chat.md +8 -8
- package/wiki/guides/tutorials/testing.md +2 -2
- package/wiki/index.md +4 -3
- package/wiki/references/base/application.md +341 -21
- package/wiki/references/base/bootstrapping.md +43 -13
- package/wiki/references/base/components.md +259 -8
- package/wiki/references/base/controllers.md +556 -253
- package/wiki/references/base/datasources.md +159 -79
- package/wiki/references/base/dependency-injection.md +299 -48
- package/wiki/references/base/filter-system/application-usage.md +18 -2
- package/wiki/references/base/filter-system/array-operators.md +14 -6
- package/wiki/references/base/filter-system/comparison-operators.md +9 -3
- package/wiki/references/base/filter-system/default-filter.md +28 -3
- package/wiki/references/base/filter-system/fields-order-pagination.md +17 -13
- package/wiki/references/base/filter-system/index.md +169 -11
- package/wiki/references/base/filter-system/json-filtering.md +51 -18
- package/wiki/references/base/filter-system/list-operators.md +4 -3
- package/wiki/references/base/filter-system/logical-operators.md +7 -2
- package/wiki/references/base/filter-system/null-operators.md +50 -0
- package/wiki/references/base/filter-system/quick-reference.md +82 -243
- package/wiki/references/base/filter-system/range-operators.md +7 -1
- package/wiki/references/base/filter-system/tips.md +34 -7
- package/wiki/references/base/filter-system/use-cases.md +6 -5
- package/wiki/references/base/grpc-controllers.md +984 -0
- package/wiki/references/base/index.md +32 -24
- package/wiki/references/base/middleware.md +347 -0
- package/wiki/references/base/models.md +390 -46
- package/wiki/references/base/providers.md +14 -14
- package/wiki/references/base/repositories/advanced.md +84 -69
- package/wiki/references/base/repositories/index.md +447 -12
- package/wiki/references/base/repositories/mixins.md +103 -98
- package/wiki/references/base/repositories/relations.md +129 -45
- package/wiki/references/base/repositories/soft-deletable.md +104 -23
- package/wiki/references/base/services.md +94 -14
- package/wiki/references/index.md +12 -10
- package/wiki/references/quick-reference.md +98 -65
- package/wiki/references/utilities/crypto.md +21 -4
- package/wiki/references/utilities/date.md +25 -7
- package/wiki/references/utilities/index.md +26 -24
- package/wiki/references/utilities/jsx.md +54 -54
- package/wiki/references/utilities/module.md +8 -6
- package/wiki/references/utilities/parse.md +16 -9
- package/wiki/references/utilities/performance.md +22 -7
- package/wiki/references/utilities/promise.md +19 -16
- package/wiki/references/utilities/request.md +48 -26
- package/wiki/references/utilities/schema.md +69 -6
- package/wiki/references/utilities/statuses.md +131 -140
- package/wiki/references/helpers/kafka/consumer.md +0 -473
- package/wiki/references/helpers/kafka/examples.md +0 -234
- package/wiki/references/helpers/kafka/index.md +0 -482
- /package/wiki/{references → extensions}/components/mail/api.md +0 -0
- /package/wiki/{references → extensions}/components/mail/errors.md +0 -0
- /package/wiki/{references → extensions}/components/mail/usage.md +0 -0
- /package/wiki/{references → extensions}/components/template/api-page.md +0 -0
- /package/wiki/{references → extensions}/components/template/errors-page.md +0 -0
- /package/wiki/{references → extensions}/components/template/usage-page.md +0 -0
- /package/wiki/{references → extensions}/helpers/cron/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/inversion/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/network/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/network/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/redis/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/socket-io/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/socket-io/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/template/single-page.md +0 -0
- /package/wiki/{references → extensions}/helpers/uid/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/websocket/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/worker-thread/index.md +0 -0
- /package/wiki/{references → extensions}/src-details/mcp-server.md +0 -0
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
# Queue
|
|
2
2
|
|
|
3
|
-
Message queuing and asynchronous task management with BullMQ, MQTT, and in-memory solutions.
|
|
3
|
+
Message queuing and asynchronous task management with BullMQ, Kafka, MQTT, and in-memory solutions.
|
|
4
4
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
7
7
|
| Class | Extends | Peer Dependency | Use Case |
|
|
8
8
|
|-------|---------|-----------------|----------|
|
|
9
|
-
| **BullMQHelper** | `BaseHelper` | `bullmq` (^5.
|
|
10
|
-
| **
|
|
9
|
+
| **BullMQHelper** | `BaseHelper` | `bullmq` (^5.70.0) | Redis-backed job queue -- background processing, task scheduling |
|
|
10
|
+
| **KafkaProducerHelper** | `BaseKafkaHelper` | `@platformatic/kafka` (^1.30.0) | Kafka message producer with transaction support |
|
|
11
|
+
| **KafkaConsumerHelper** | `BaseKafkaHelper` | `@platformatic/kafka` (^1.30.0) | Kafka message consumer with lag monitoring |
|
|
12
|
+
| **KafkaAdminHelper** | `BaseKafkaHelper` | `@platformatic/kafka` (^1.30.0) | Kafka admin operations (topic management) |
|
|
13
|
+
| **KafkaSchemaRegistryHelper** | `BaseHelper` | `@platformatic/kafka` (^1.30.0) | Confluent Schema Registry integration |
|
|
14
|
+
| **MQTTClientHelper** | `BaseHelper` | `mqtt` (^5.15.0) | MQTT broker messaging -- real-time events, IoT |
|
|
11
15
|
| **QueueHelper** | `BaseHelper` | None | In-memory generator queue -- sequential tasks, single process |
|
|
12
16
|
|
|
13
17
|
#### Common Operations
|
|
@@ -15,6 +19,7 @@ Message queuing and asynchronous task management with BullMQ, MQTT, and in-memor
|
|
|
15
19
|
| Helper | Subscribe / Consume | Publish / Produce |
|
|
16
20
|
|--------|---------------------|-------------------|
|
|
17
21
|
| **BullMQ** | Create with `role: 'worker'` | `queue.add(name, data)` via the exposed BullMQ `Queue` instance |
|
|
22
|
+
| **Kafka** | `consumer.start({ topics })` | `producer.getProducer().send({ messages })` |
|
|
18
23
|
| **MQTT** | `subscribe({ topics })` | `publish({ topic, message })` |
|
|
19
24
|
| **In-Memory** | `new QueueHelper({ onMessage })` | `enqueue(payload)` |
|
|
20
25
|
|
|
@@ -29,6 +34,33 @@ import type { TQueueStatus, TQueueElement } from '@venizia/ignis-helpers';
|
|
|
29
34
|
import { BullMQHelper } from '@venizia/ignis-helpers/bullmq';
|
|
30
35
|
import type { TBullQueueRole } from '@venizia/ignis-helpers/bullmq';
|
|
31
36
|
|
|
37
|
+
// Kafka (separate export path)
|
|
38
|
+
import {
|
|
39
|
+
KafkaProducerHelper,
|
|
40
|
+
KafkaConsumerHelper,
|
|
41
|
+
KafkaAdminHelper,
|
|
42
|
+
KafkaSchemaRegistryHelper,
|
|
43
|
+
BaseKafkaHelper,
|
|
44
|
+
} from '@venizia/ignis-helpers/kafka';
|
|
45
|
+
import type {
|
|
46
|
+
IKafkaProducerOptions,
|
|
47
|
+
IKafkaConsumerOptions,
|
|
48
|
+
IKafkaAdminOptions,
|
|
49
|
+
IKafkaSchemaRegistryOptions,
|
|
50
|
+
IKafkaConsumeStartOptions,
|
|
51
|
+
IKafkaTransactionContext,
|
|
52
|
+
TKafkaBrokerEventCallback,
|
|
53
|
+
TKafkaMessageCallback,
|
|
54
|
+
TKafkaMessageDoneCallback,
|
|
55
|
+
TKafkaMessageErrorCallback,
|
|
56
|
+
TKafkaGroupJoinCallback,
|
|
57
|
+
TKafkaGroupLeaveCallback,
|
|
58
|
+
TKafkaGroupRebalanceCallback,
|
|
59
|
+
TKafkaHeartbeatErrorCallback,
|
|
60
|
+
TKafkaLagCallback,
|
|
61
|
+
TKafkaLagErrorCallback,
|
|
62
|
+
} from '@venizia/ignis-helpers/kafka';
|
|
63
|
+
|
|
32
64
|
// MQTT (separate export path)
|
|
33
65
|
import { MQTTClientHelper } from '@venizia/ignis-helpers/mqtt';
|
|
34
66
|
import type { IMQTTClientOptions } from '@venizia/ignis-helpers/mqtt';
|
|
@@ -36,7 +68,7 @@ import type { IMQTTClientOptions } from '@venizia/ignis-helpers/mqtt';
|
|
|
36
68
|
|
|
37
69
|
## Creating an Instance
|
|
38
70
|
|
|
39
|
-
All
|
|
71
|
+
All queue helpers extend `BaseHelper` (Kafka helpers via `BaseKafkaHelper`), providing scoped logging via `this.logger`.
|
|
40
72
|
|
|
41
73
|
### BullMQHelper
|
|
42
74
|
|
|
@@ -176,6 +208,178 @@ Each element in the queue is wrapped in a `TQueueElement`:
|
|
|
176
208
|
type TQueueElement<T> = { isLocked: boolean; payload: T };
|
|
177
209
|
```
|
|
178
210
|
|
|
211
|
+
### Kafka Producer
|
|
212
|
+
|
|
213
|
+
The `KafkaProducerHelper` wraps `@platformatic/kafka` Producer with lifecycle management, health tracking, and transaction support.
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { KafkaProducerHelper } from '@venizia/ignis-helpers/kafka';
|
|
217
|
+
|
|
218
|
+
const producer = KafkaProducerHelper.newInstance({
|
|
219
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
220
|
+
clientId: 'my-producer',
|
|
221
|
+
acks: -1,
|
|
222
|
+
idempotent: true,
|
|
223
|
+
onBrokerConnect: ({ broker }) => {
|
|
224
|
+
console.log(`Connected to ${broker.host}:${broker.port}`);
|
|
225
|
+
},
|
|
226
|
+
onBrokerDisconnect: ({ broker }) => {
|
|
227
|
+
console.log(`Disconnected from ${broker.host}:${broker.port}`);
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### IKafkaProducerOptions
|
|
233
|
+
|
|
234
|
+
`IKafkaProducerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>` extends `IKafkaConnectionOptions`.
|
|
235
|
+
|
|
236
|
+
| Option | Type | Default | Description |
|
|
237
|
+
|--------|------|---------|-------------|
|
|
238
|
+
| `bootstrapBrokers` | `string[]` | -- | Kafka broker addresses. |
|
|
239
|
+
| `clientId` | `string` | -- | Client identifier. |
|
|
240
|
+
| `identifier` | `string` | `'kafka-producer'` | Scoped logging identifier. |
|
|
241
|
+
| `acks` | `0 \| 1 \| -1` | -- | Acknowledgment mode. `0` = none, `1` = leader, `-1` = all ISR. |
|
|
242
|
+
| `idempotent` | `boolean` | -- | Enable idempotent producer. |
|
|
243
|
+
| `transactionalId` | `string` | -- | Transactional ID (required for transactions with `idempotent: true`). |
|
|
244
|
+
| `compression` | `CompressionAlgorithmValue` | -- | Message compression algorithm. |
|
|
245
|
+
| `strict` | `boolean` | `true` | Strict mode for topic validation. |
|
|
246
|
+
| `autocreateTopics` | `boolean` | `false` | Auto-create topics on send. |
|
|
247
|
+
| `retries` | `number` | `3` | Number of retries on failure. |
|
|
248
|
+
| `retryDelay` | `number` | `1000` | Delay between retries in milliseconds. |
|
|
249
|
+
| `shutdownTimeout` | `number` | `30000` | Graceful shutdown timeout in milliseconds. |
|
|
250
|
+
| `serializers` | `Partial<Serializers<...>>` | -- | Custom key/value/header serializers. |
|
|
251
|
+
| `registry` | `SchemaRegistry<...>` | -- | Schema registry for serialization. |
|
|
252
|
+
| `sasl` | `SASLOptions` | -- | SASL authentication options. |
|
|
253
|
+
| `tls` | `TLSOptions` | -- | TLS connection options. |
|
|
254
|
+
| `ssl` | `SSLOptions` | -- | SSL connection options. |
|
|
255
|
+
| `connectTimeout` | `number` | -- | Connection timeout in milliseconds. |
|
|
256
|
+
| `requestTimeout` | `number` | -- | Request timeout in milliseconds. |
|
|
257
|
+
| `onBrokerConnect` | `TKafkaBrokerEventCallback` | -- | Callback when a broker connects. |
|
|
258
|
+
| `onBrokerDisconnect` | `TKafkaBrokerEventCallback` | -- | Callback when a broker disconnects. |
|
|
259
|
+
|
|
260
|
+
### Kafka Consumer
|
|
261
|
+
|
|
262
|
+
The `KafkaConsumerHelper` wraps `@platformatic/kafka` Consumer with message processing callbacks, consumer group lifecycle events, and lag monitoring.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import { KafkaConsumerHelper } from '@venizia/ignis-helpers/kafka';
|
|
266
|
+
|
|
267
|
+
const consumer = KafkaConsumerHelper.newInstance({
|
|
268
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
269
|
+
clientId: 'my-consumer',
|
|
270
|
+
groupId: 'my-consumer-group',
|
|
271
|
+
onMessage: async ({ message }) => {
|
|
272
|
+
console.log('Received:', message.value);
|
|
273
|
+
await message.commit();
|
|
274
|
+
},
|
|
275
|
+
onMessageError: ({ error }) => {
|
|
276
|
+
console.error('Error:', error);
|
|
277
|
+
},
|
|
278
|
+
onGroupJoin: ({ groupId, memberId }) => {
|
|
279
|
+
console.log(`Joined ${groupId} as ${memberId}`);
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### IKafkaConsumerOptions
|
|
285
|
+
|
|
286
|
+
`IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>` extends `IKafkaConnectionOptions`.
|
|
287
|
+
|
|
288
|
+
| Option | Type | Default | Description |
|
|
289
|
+
|--------|------|---------|-------------|
|
|
290
|
+
| `bootstrapBrokers` | `string[]` | -- | Kafka broker addresses. |
|
|
291
|
+
| `clientId` | `string` | -- | Client identifier. |
|
|
292
|
+
| `groupId` | `string` | -- | Consumer group ID. Required. |
|
|
293
|
+
| `identifier` | `string` | `'kafka-consumer'` | Scoped logging identifier. |
|
|
294
|
+
| `groupProtocol` | `'classic' \| 'consumer'` | `'classic'` | Consumer group protocol. |
|
|
295
|
+
| `groupInstanceId` | `string` | -- | Static group membership instance ID. |
|
|
296
|
+
| `autocommit` | `boolean \| number` | `false` | Auto-commit offsets. `false` = manual, `true` or number = interval. |
|
|
297
|
+
| `sessionTimeout` | `number` | `30000` | Session timeout in milliseconds. |
|
|
298
|
+
| `heartbeatInterval` | `number` | `3000` | Heartbeat interval in milliseconds. |
|
|
299
|
+
| `rebalanceTimeout` | `number` | `sessionTimeout` | Rebalance timeout in milliseconds. |
|
|
300
|
+
| `highWaterMark` | `number` | `1024` | Stream high water mark. |
|
|
301
|
+
| `minBytes` | `number` | `1` | Minimum bytes to fetch per request. |
|
|
302
|
+
| `maxBytes` | `number` | -- | Maximum bytes to fetch per request. |
|
|
303
|
+
| `maxWaitTime` | `number` | -- | Maximum wait time for fetch in milliseconds. |
|
|
304
|
+
| `metadataMaxAge` | `number` | `300000` | Metadata cache max age in milliseconds. |
|
|
305
|
+
| `retries` | `number` | `3` | Number of retries on failure. |
|
|
306
|
+
| `retryDelay` | `number` | `1000` | Delay between retries in milliseconds. |
|
|
307
|
+
| `shutdownTimeout` | `number` | `30000` | Graceful shutdown timeout in milliseconds. |
|
|
308
|
+
| `deserializers` | `Partial<Deserializers<...>>` | -- | Custom key/value/header deserializers. |
|
|
309
|
+
| `registry` | `SchemaRegistry<...>` | -- | Schema registry for deserialization. |
|
|
310
|
+
| `onBrokerConnect` | `TKafkaBrokerEventCallback` | -- | Callback when a broker connects. |
|
|
311
|
+
| `onBrokerDisconnect` | `TKafkaBrokerEventCallback` | -- | Callback when a broker disconnects. |
|
|
312
|
+
| `onMessage` | `TKafkaMessageCallback` | -- | Message processing callback. |
|
|
313
|
+
| `onMessageDone` | `TKafkaMessageDoneCallback` | -- | Callback after message processing completes. |
|
|
314
|
+
| `onMessageError` | `TKafkaMessageErrorCallback` | -- | Callback on message processing error. |
|
|
315
|
+
| `onGroupJoin` | `TKafkaGroupJoinCallback` | -- | Callback when consumer joins the group. |
|
|
316
|
+
| `onGroupLeave` | `TKafkaGroupLeaveCallback` | -- | Callback when consumer leaves the group. |
|
|
317
|
+
| `onGroupRebalance` | `TKafkaGroupRebalanceCallback` | -- | Callback on group rebalance. |
|
|
318
|
+
| `onHeartbeatError` | `TKafkaHeartbeatErrorCallback` | -- | Callback on heartbeat error. |
|
|
319
|
+
| `onLag` | `TKafkaLagCallback` | -- | Callback with lag offset data. |
|
|
320
|
+
| `onLagError` | `TKafkaLagErrorCallback` | -- | Callback on lag monitoring error. |
|
|
321
|
+
|
|
322
|
+
### Kafka Admin
|
|
323
|
+
|
|
324
|
+
The `KafkaAdminHelper` wraps `@platformatic/kafka` Admin for topic and cluster management.
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import { KafkaAdminHelper } from '@venizia/ignis-helpers/kafka';
|
|
328
|
+
|
|
329
|
+
const admin = KafkaAdminHelper.newInstance({
|
|
330
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
331
|
+
clientId: 'my-admin',
|
|
332
|
+
onBrokerConnect: ({ broker }) => {
|
|
333
|
+
console.log(`Connected to ${broker.host}:${broker.port}`);
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// Access the full Admin API directly
|
|
338
|
+
const adminClient = admin.getAdmin();
|
|
339
|
+
await adminClient.createTopics({ topics: ['my-topic'], partitions: 3, replicas: 1 });
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
#### IKafkaAdminOptions
|
|
343
|
+
|
|
344
|
+
| Option | Type | Default | Description |
|
|
345
|
+
|--------|------|---------|-------------|
|
|
346
|
+
| `bootstrapBrokers` | `string[]` | -- | Kafka broker addresses. |
|
|
347
|
+
| `clientId` | `string` | -- | Client identifier. |
|
|
348
|
+
| `identifier` | `string` | `'kafka-admin'` | Scoped logging identifier. |
|
|
349
|
+
| `retries` | `number` | `3` | Number of retries on failure. |
|
|
350
|
+
| `retryDelay` | `number` | `1000` | Delay between retries in milliseconds. |
|
|
351
|
+
| `shutdownTimeout` | `number` | `30000` | Graceful shutdown timeout in milliseconds. |
|
|
352
|
+
| `onBrokerConnect` | `TKafkaBrokerEventCallback` | -- | Callback when a broker connects. |
|
|
353
|
+
| `onBrokerDisconnect` | `TKafkaBrokerEventCallback` | -- | Callback when a broker disconnects. |
|
|
354
|
+
|
|
355
|
+
### Kafka Schema Registry
|
|
356
|
+
|
|
357
|
+
The `KafkaSchemaRegistryHelper` wraps `@platformatic/kafka` ConfluentSchemaRegistry for Avro/Protobuf/JSON schema integration with producer and consumer helpers.
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
import { KafkaSchemaRegistryHelper, KafkaProducerHelper } from '@venizia/ignis-helpers/kafka';
|
|
361
|
+
|
|
362
|
+
const schemaRegistry = KafkaSchemaRegistryHelper.newInstance({
|
|
363
|
+
url: 'http://localhost:8081',
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const producer = KafkaProducerHelper.newInstance({
|
|
367
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
368
|
+
clientId: 'my-producer',
|
|
369
|
+
registry: schemaRegistry.getRegistry(),
|
|
370
|
+
});
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### IKafkaSchemaRegistryOptions
|
|
374
|
+
|
|
375
|
+
| Option | Type | Default | Description |
|
|
376
|
+
|--------|------|---------|-------------|
|
|
377
|
+
| `url` | `string` | -- | Schema Registry URL. |
|
|
378
|
+
| `identifier` | `string` | `'kafka-schema-registry'` | Scoped logging identifier. |
|
|
379
|
+
| `auth` | `object` | -- | Authentication credentials. |
|
|
380
|
+
| `protobufTypeMapper` | `function` | -- | Protobuf type mapping function. |
|
|
381
|
+
| `jsonValidateSend` | `boolean` | -- | Validate JSON schemas on send. |
|
|
382
|
+
|
|
179
383
|
## Usage
|
|
180
384
|
|
|
181
385
|
### BullMQ -- Adding Jobs
|
|
@@ -334,6 +538,152 @@ const client = new MQTTClientHelper({
|
|
|
334
538
|
});
|
|
335
539
|
```
|
|
336
540
|
|
|
541
|
+
### Kafka -- Producing Messages
|
|
542
|
+
|
|
543
|
+
Use `getProducer()` to access the underlying `@platformatic/kafka` Producer and send messages.
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
const producer = KafkaProducerHelper.newInstance({
|
|
547
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
548
|
+
clientId: 'my-producer',
|
|
549
|
+
acks: -1,
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// Send messages via the underlying producer
|
|
553
|
+
await producer.getProducer().send({
|
|
554
|
+
messages: [
|
|
555
|
+
{ topic: 'orders', key: 'order-1', value: JSON.stringify({ item: 'widget' }) },
|
|
556
|
+
],
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
// Health check
|
|
560
|
+
producer.isHealthy(); // true when connected to a broker
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Kafka -- Consuming Messages
|
|
564
|
+
|
|
565
|
+
Call `start()` to begin consuming from topics. Messages are delivered via the `onMessage` callback.
|
|
566
|
+
|
|
567
|
+
```typescript
|
|
568
|
+
const consumer = KafkaConsumerHelper.newInstance({
|
|
569
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
570
|
+
clientId: 'my-consumer',
|
|
571
|
+
groupId: 'my-group',
|
|
572
|
+
onMessage: async ({ message }) => {
|
|
573
|
+
console.log('Key:', message.key, 'Value:', message.value);
|
|
574
|
+
await message.commit();
|
|
575
|
+
},
|
|
576
|
+
onMessageDone: async ({ message }) => {
|
|
577
|
+
console.log('Processing complete for offset:', message.offset);
|
|
578
|
+
},
|
|
579
|
+
onMessageError: ({ error, message }) => {
|
|
580
|
+
console.error('Processing failed:', error.message);
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
await consumer.start({
|
|
585
|
+
topics: ['orders'],
|
|
586
|
+
mode: 'committed', // Default: 'committed'
|
|
587
|
+
fallbackMode: 'latest', // Default: 'latest'
|
|
588
|
+
});
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
#### IKafkaConsumeStartOptions
|
|
592
|
+
|
|
593
|
+
| Option | Type | Default | Description |
|
|
594
|
+
|--------|------|---------|-------------|
|
|
595
|
+
| `topics` | `string[]` | -- | Topics to consume from. |
|
|
596
|
+
| `mode` | `MessagesStreamModeValue` | `'committed'` | Consume mode. |
|
|
597
|
+
| `fallbackMode` | `MessagesStreamFallbackModeValue` | `'latest'` | Fallback mode when no committed offset exists. |
|
|
598
|
+
|
|
599
|
+
### Kafka -- Lag Monitoring
|
|
600
|
+
|
|
601
|
+
Monitor consumer lag to detect processing delays.
|
|
602
|
+
|
|
603
|
+
```typescript
|
|
604
|
+
consumer.startLagMonitoring({
|
|
605
|
+
topics: ['orders'],
|
|
606
|
+
interval: 30_000, // Default: 30 seconds
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// Stop monitoring
|
|
610
|
+
consumer.stopLagMonitoring();
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
Use the `onLag` and `onLagError` callbacks to react to lag data:
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
const consumer = KafkaConsumerHelper.newInstance({
|
|
617
|
+
// ...
|
|
618
|
+
onLag: ({ lag }) => {
|
|
619
|
+
console.log('Current lag offsets:', lag);
|
|
620
|
+
},
|
|
621
|
+
onLagError: ({ error }) => {
|
|
622
|
+
console.error('Lag monitoring error:', error);
|
|
623
|
+
},
|
|
624
|
+
});
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Kafka -- Transactions
|
|
628
|
+
|
|
629
|
+
The `KafkaProducerHelper` supports exactly-once semantics via transactions. Requires `transactionalId` and `idempotent: true`.
|
|
630
|
+
|
|
631
|
+
```typescript
|
|
632
|
+
const producer = KafkaProducerHelper.newInstance({
|
|
633
|
+
bootstrapBrokers: ['127.0.0.1:29092'],
|
|
634
|
+
clientId: 'transactional-producer',
|
|
635
|
+
transactionalId: 'my-tx-id',
|
|
636
|
+
idempotent: true,
|
|
637
|
+
acks: -1,
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
const result = await producer.runInTransaction(async ({ send, addConsumer, addOffset }) => {
|
|
641
|
+
return send({
|
|
642
|
+
messages: [
|
|
643
|
+
{ topic: 'orders', key: 'o1', value: JSON.stringify({ status: 'created' }) },
|
|
644
|
+
],
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
The transaction context provides:
|
|
650
|
+
|
|
651
|
+
| Method | Description |
|
|
652
|
+
|--------|-------------|
|
|
653
|
+
| `send(opts)` | Send messages within the transaction. Returns `ProduceResult`. |
|
|
654
|
+
| `addConsumer(consumer)` | Add a consumer to the transaction for read-process-write patterns. |
|
|
655
|
+
| `addOffset(message)` | Commit consumer offsets as part of the transaction. |
|
|
656
|
+
| `transaction` | The underlying transaction object for advanced operations. |
|
|
657
|
+
|
|
658
|
+
If the callback throws, the transaction is automatically aborted.
|
|
659
|
+
|
|
660
|
+
### Kafka -- Health Checks
|
|
661
|
+
|
|
662
|
+
All Kafka helpers provide health checking via `BaseKafkaHelper`:
|
|
663
|
+
|
|
664
|
+
```typescript
|
|
665
|
+
producer.isHealthy(); // true when connected
|
|
666
|
+
consumer.isReady(); // true when connected AND active (consuming)
|
|
667
|
+
admin.getHealthStatus(); // 'connected' | 'disconnected' | 'unknown'
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### Kafka -- Graceful Shutdown
|
|
671
|
+
|
|
672
|
+
All Kafka helpers support graceful shutdown with an optional force flag and configurable timeout (default: 30 seconds).
|
|
673
|
+
|
|
674
|
+
```typescript
|
|
675
|
+
// Graceful shutdown (waits up to shutdownTimeout, then forces)
|
|
676
|
+
await producer.close();
|
|
677
|
+
await consumer.close();
|
|
678
|
+
await admin.close();
|
|
679
|
+
|
|
680
|
+
// Force immediate shutdown
|
|
681
|
+
await producer.close({ isForce: true });
|
|
682
|
+
await consumer.close({ isForce: true });
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
For consumers, `close()` also stops lag monitoring and closes the message stream before closing the client.
|
|
686
|
+
|
|
337
687
|
### In-Memory Queue -- Enqueueing and Processing
|
|
338
688
|
|
|
339
689
|
With `autoDispatch: true` (default), elements are processed automatically as they are enqueued.
|
|
@@ -463,6 +813,51 @@ queue.close();
|
|
|
463
813
|
| `queue` | `Queue<TQueueElement, TQueueResult>` | BullMQ `Queue` instance (available when `role: 'queue'`). |
|
|
464
814
|
| `worker` | `Worker<TQueueElement, TQueueResult>` | BullMQ `Worker` instance (available when `role: 'worker'`). |
|
|
465
815
|
|
|
816
|
+
### KafkaProducerHelper
|
|
817
|
+
|
|
818
|
+
| Method | Returns | Description |
|
|
819
|
+
|--------|---------|-------------|
|
|
820
|
+
| `static newInstance(opts)` | `KafkaProducerHelper` | Factory method. |
|
|
821
|
+
| `getProducer()` | `Producer` | Access the underlying `@platformatic/kafka` Producer. |
|
|
822
|
+
| `runInTransaction(callback)` | `Promise<ResultType>` | Execute a callback within a Kafka transaction. Auto-commits or aborts. |
|
|
823
|
+
| `isHealthy()` | `boolean` | Returns `true` when connected to a broker. |
|
|
824
|
+
| `getHealthStatus()` | `TKafkaHealthStatus` | Returns `'connected'`, `'disconnected'`, or `'unknown'`. |
|
|
825
|
+
| `close(opts?)` | `Promise<void>` | Graceful shutdown. `opts: { isForce?: boolean }` |
|
|
826
|
+
|
|
827
|
+
### KafkaConsumerHelper
|
|
828
|
+
|
|
829
|
+
| Method | Returns | Description |
|
|
830
|
+
|--------|---------|-------------|
|
|
831
|
+
| `static newInstance(opts)` | `KafkaConsumerHelper` | Factory method. |
|
|
832
|
+
| `getConsumer()` | `Consumer` | Access the underlying `@platformatic/kafka` Consumer. |
|
|
833
|
+
| `getStream()` | `MessagesStream \| null` | Access the current message stream (null if not started). |
|
|
834
|
+
| `start(opts)` | `Promise<void>` | Start consuming. `opts: { topics, mode?, fallbackMode? }` |
|
|
835
|
+
| `isReady()` | `boolean` | Returns `true` when connected AND actively consuming. |
|
|
836
|
+
| `isHealthy()` | `boolean` | Returns `true` when connected to a broker. |
|
|
837
|
+
| `getHealthStatus()` | `TKafkaHealthStatus` | Returns `'connected'`, `'disconnected'`, or `'unknown'`. |
|
|
838
|
+
| `startLagMonitoring(opts)` | `void` | Start lag monitoring. `opts: { topics, interval? }` |
|
|
839
|
+
| `stopLagMonitoring()` | `void` | Stop lag monitoring. |
|
|
840
|
+
| `close(opts?)` | `Promise<void>` | Graceful shutdown. Stops monitoring, closes stream, then client. |
|
|
841
|
+
|
|
842
|
+
### KafkaAdminHelper
|
|
843
|
+
|
|
844
|
+
| Method | Returns | Description |
|
|
845
|
+
|--------|---------|-------------|
|
|
846
|
+
| `static newInstance(opts)` | `KafkaAdminHelper` | Factory method. |
|
|
847
|
+
| `getAdmin()` | `Admin` | Access the underlying `@platformatic/kafka` Admin. |
|
|
848
|
+
| `isHealthy()` | `boolean` | Returns `true` when connected to a broker. |
|
|
849
|
+
| `getHealthStatus()` | `TKafkaHealthStatus` | Returns `'connected'`, `'disconnected'`, or `'unknown'`. |
|
|
850
|
+
| `close(opts?)` | `Promise<void>` | Graceful shutdown. `opts: { isForce?: boolean }` |
|
|
851
|
+
|
|
852
|
+
### KafkaSchemaRegistryHelper
|
|
853
|
+
|
|
854
|
+
| Method | Returns | Description |
|
|
855
|
+
|--------|---------|-------------|
|
|
856
|
+
| `static newInstance(opts)` | `KafkaSchemaRegistryHelper` | Factory method. |
|
|
857
|
+
| `getRegistry()` | `ConfluentSchemaRegistry` | Access the underlying schema registry. |
|
|
858
|
+
| `getSerializers()` | `Serializers` | Get serializers for use with a producer. |
|
|
859
|
+
| `getDeserializers()` | `Deserializers` | Get deserializers for use with a consumer. |
|
|
860
|
+
|
|
466
861
|
### MQTTClientHelper
|
|
467
862
|
|
|
468
863
|
| Method | Returns | Description |
|
|
@@ -587,3 +982,4 @@ const newQueue = new QueueHelper<string>({
|
|
|
587
982
|
- **External Resources:**
|
|
588
983
|
- [BullMQ Documentation](https://docs.bullmq.io/) -- BullMQ queue library
|
|
589
984
|
- [MQTT.js](https://github.com/mqttjs/MQTT.js) -- MQTT client library
|
|
985
|
+
- [@platformatic/kafka](https://github.com/platformatic/kafka) -- Kafka client library
|
|
@@ -7,7 +7,8 @@ The storage system uses a class hierarchy with an abstract base class providing
|
|
|
7
7
|
```
|
|
8
8
|
BaseHelper
|
|
9
9
|
├── BaseStorageHelper (abstract, implements IStorageHelper)
|
|
10
|
-
│ ├── MinioHelper -- S3-compatible object storage
|
|
10
|
+
│ ├── MinioHelper -- S3-compatible object storage (minio SDK)
|
|
11
|
+
│ ├── BunS3Helper -- S3-compatible object storage (Bun-native S3Client)
|
|
11
12
|
│ └── DiskHelper -- Local filesystem storage
|
|
12
13
|
└── MemoryStorageHelper -- In-memory key-value store
|
|
13
14
|
```
|
|
@@ -117,7 +118,7 @@ Categorizes a MIME type into a broad file type group using the `MimeTypes` const
|
|
|
117
118
|
|
|
118
119
|
### Abstract Methods
|
|
119
120
|
|
|
120
|
-
The following methods are declared abstract in `BaseStorageHelper` and implemented by `MinioHelper` and `DiskHelper`:
|
|
121
|
+
The following methods are declared abstract in `BaseStorageHelper` and implemented by `MinioHelper`, `BunS3Helper`, and `DiskHelper`:
|
|
121
122
|
|
|
122
123
|
```typescript
|
|
123
124
|
abstract isBucketExists(opts: { name: string }): Promise<boolean>;
|
|
@@ -173,12 +174,6 @@ interface IMinioHelperOptions extends IStorageHelperOptions, ClientOptions {}
|
|
|
173
174
|
|
|
174
175
|
All additional `minio.ClientOptions` properties are also accepted and passed to the underlying client.
|
|
175
176
|
|
|
176
|
-
### Properties
|
|
177
|
-
|
|
178
|
-
| Property | Type | Description |
|
|
179
|
-
|----------|------|-------------|
|
|
180
|
-
| `client` | `minio.Client` | The underlying MinIO client instance. Accessible for direct SDK operations. |
|
|
181
|
-
|
|
182
177
|
### Methods
|
|
183
178
|
|
|
184
179
|
#### isBucketExists
|
|
@@ -322,6 +317,159 @@ Lists objects in a bucket using a streaming approach via `client.listObjects()`.
|
|
|
322
317
|
| `opts.useRecursive` | `boolean` | `false` | List recursively through subdirectories. |
|
|
323
318
|
| `opts.maxKeys` | `number` | `undefined` | Maximum number of objects to return. |
|
|
324
319
|
|
|
320
|
+
## BunS3Helper
|
|
321
|
+
|
|
322
|
+
S3-compatible object storage using Bun's native `S3Client`. Extends `BaseStorageHelper`. Requires the Bun runtime.
|
|
323
|
+
|
|
324
|
+
Bucket management operations (list, create, delete) use AWS Signature V4 signed requests built from scratch via the `buildSignedRequest` utility. Object operations (upload, get, stat, delete, list) use Bun's native S3 API.
|
|
325
|
+
|
|
326
|
+
### Constructor
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
constructor(options: IBunS3HelperOptions)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Creates a Bun `S3Client` internally and stores credentials for bucket management requests.
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
interface IBunS3HelperOptions extends IStorageHelperOptions {
|
|
336
|
+
accessKey: string;
|
|
337
|
+
secretKey: string;
|
|
338
|
+
endpoint: string;
|
|
339
|
+
region?: string;
|
|
340
|
+
sessionToken?: string;
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
| Parameter | Type | Default | Description |
|
|
345
|
+
|-----------|------|---------|-------------|
|
|
346
|
+
| `options.accessKey` | `string` | -- | S3 access key credential. |
|
|
347
|
+
| `options.secretKey` | `string` | -- | S3 secret key credential. |
|
|
348
|
+
| `options.endpoint` | `string` | -- | S3-compatible endpoint URL. |
|
|
349
|
+
| `options.region` | `string` | `'us-east-1'` | AWS region for signing. |
|
|
350
|
+
| `options.sessionToken` | `string` | -- | Optional session token for temporary credentials. |
|
|
351
|
+
| `options.scope` | `string` | `'BunS3Helper'` | Logger scope name. |
|
|
352
|
+
| `options.identifier` | `string` | `'BunS3Helper'` | Helper identifier. |
|
|
353
|
+
|
|
354
|
+
### Methods
|
|
355
|
+
|
|
356
|
+
#### isBucketExists
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
async isBucketExists(opts: { name: string }): Promise<boolean>
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Returns `false` if the name fails `isValidName()`. Otherwise attempts a `list({ maxKeys: 1 })` against the bucket. Returns `false` on any error.
|
|
363
|
+
|
|
364
|
+
#### getBuckets
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
async getBuckets(): Promise<IBucketInfo[]>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Lists all buckets via a signed `GET /` request. Parses the XML response to extract bucket names and creation dates.
|
|
371
|
+
|
|
372
|
+
#### getBucket
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
async getBucket(opts: { name: string }): Promise<IBucketInfo | null>
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Returns the bucket info from the full bucket list, or `null` if not found.
|
|
379
|
+
|
|
380
|
+
#### createBucket
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
async createBucket(opts: { name: string }): Promise<IBucketInfo | null>
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Creates a bucket via a signed `PUT /{name}` request. Throws if the name fails validation or the S3 request fails.
|
|
387
|
+
|
|
388
|
+
#### removeBucket
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
async removeBucket(opts: { name: string }): Promise<boolean>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Removes a bucket via a signed `DELETE /{name}` request. Throws if the name fails validation or the S3 request fails.
|
|
395
|
+
|
|
396
|
+
#### upload
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
async upload(opts: {
|
|
400
|
+
bucket: string;
|
|
401
|
+
files: IUploadFile[];
|
|
402
|
+
normalizeNameFn?: (opts: { originalName: string; folderPath?: string }) => string;
|
|
403
|
+
normalizeLinkFn?: (opts: { bucketName: string; normalizeName: string }) => string;
|
|
404
|
+
}): Promise<IUploadResult[]>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Uploads files using `client.write(name, buffer, { bucket, type })`. Same validation and normalization behavior as MinioHelper.
|
|
408
|
+
|
|
409
|
+
**Default link format:** `/static-assets/{bucket}/{encodeURIComponent(normalizeName)}`
|
|
410
|
+
|
|
411
|
+
#### getFile
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
async getFile(opts: { bucket: string; name: string; options?: any }): Promise<Readable>
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Returns a `Readable` stream by converting the Bun S3 file's web stream via `Readable.fromWeb()`.
|
|
418
|
+
|
|
419
|
+
#### getStat
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
async getStat(opts: { bucket: string; name: string }): Promise<IFileStat>
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Returns file metadata via `client.stat()`.
|
|
426
|
+
|
|
427
|
+
**Returns:**
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
{
|
|
431
|
+
size: number;
|
|
432
|
+
lastModified: Date;
|
|
433
|
+
metadata: {
|
|
434
|
+
contentType: string;
|
|
435
|
+
mimetype: string;
|
|
436
|
+
};
|
|
437
|
+
etag: string;
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
#### removeObject
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
async removeObject(opts: { bucket: string; name: string }): Promise<void>
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Removes a single object via `client.delete()`.
|
|
448
|
+
|
|
449
|
+
#### removeObjects
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
async removeObjects(opts: { bucket: string; names: string[] }): Promise<void>
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Removes multiple objects in parallel via `Promise.all()`.
|
|
456
|
+
|
|
457
|
+
#### listObjects
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
async listObjects(opts: {
|
|
461
|
+
bucket: string;
|
|
462
|
+
prefix?: string;
|
|
463
|
+
useRecursive?: boolean;
|
|
464
|
+
maxKeys?: number;
|
|
465
|
+
}): Promise<IObjectInfo[]>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Lists objects using `client.list()`. Returns objects with `name` (from `key`), `size`, `lastModified`, and `etag` (from `eTag`).
|
|
469
|
+
|
|
470
|
+
> [!NOTE]
|
|
471
|
+
> The `useRecursive` parameter is accepted for interface compatibility but is not used -- Bun's S3 `list()` does not support recursive mode directly.
|
|
472
|
+
|
|
325
473
|
## DiskHelper
|
|
326
474
|
|
|
327
475
|
Local filesystem storage using directory-based buckets. Extends `BaseStorageHelper`.
|
|
@@ -574,7 +722,7 @@ Returns the underlying container object.
|
|
|
574
722
|
|
|
575
723
|
### IStorageHelper
|
|
576
724
|
|
|
577
|
-
The unified interface implemented by `MinioHelper` and `DiskHelper`:
|
|
725
|
+
The unified interface implemented by `MinioHelper`, `BunS3Helper`, and `DiskHelper`:
|
|
578
726
|
|
|
579
727
|
```typescript
|
|
580
728
|
interface IStorageHelper {
|
|
@@ -698,8 +846,20 @@ interface IMinioHelperOptions extends IStorageHelperOptions, ClientOptions {}
|
|
|
698
846
|
|
|
699
847
|
Inherits all `minio.ClientOptions` properties: `endPoint`, `port`, `useSSL`, `accessKey`, `secretKey`, `region`, `transport`, `sessionToken`, `partSize`, `pathStyle`, and others.
|
|
700
848
|
|
|
849
|
+
### IBunS3HelperOptions
|
|
850
|
+
|
|
851
|
+
```typescript
|
|
852
|
+
interface IBunS3HelperOptions extends IStorageHelperOptions {
|
|
853
|
+
accessKey: string;
|
|
854
|
+
secretKey: string;
|
|
855
|
+
endpoint: string;
|
|
856
|
+
region?: string; // Default: 'us-east-1'
|
|
857
|
+
sessionToken?: string;
|
|
858
|
+
}
|
|
859
|
+
```
|
|
860
|
+
|
|
701
861
|
## See Also
|
|
702
862
|
|
|
703
863
|
- [Setup & Usage](./) -- Getting started, examples, and troubleshooting
|
|
704
864
|
- [Helpers Index](../index) -- All available helpers
|
|
705
|
-
- [Static Asset Component](/
|
|
865
|
+
- [Static Asset Component](/extensions/components/static-asset/) -- Serving stored files via HTTP
|