@cargolift-cdi/types 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +42 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,22 +1,59 @@
1
- # cargolift-types
1
+ # @cargolift-cdi/types
2
2
 
3
- Shared TypeScript types and interfaces for Node.js projects.
3
+ Shared TypeScript types and interfaces for Node.js projects. This package is types-only (no runtime JS).
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm install cargolift-types
8
+ # npm
9
+ npm install -D @cargolift-cdi/types
10
+
11
+ # pnpm
12
+ pnpm add -D @cargolift-cdi/types
13
+
14
+ # yarn
15
+ yarn add -D @cargolift-cdi/types
9
16
  ```
10
17
 
11
18
  ## Usage
12
19
 
20
+ Use type-only imports to avoid emitting runtime code:
21
+
13
22
  ```ts
14
- import { RabbitMQMessage, RabbitMQChannel } from '@cargolift-cdi/types';
23
+ import type { RabbitMQMessage, RabbitMQChannel } from '@cargolift-cdi/types';
24
+
25
+ function handleMessage(msg: RabbitMQMessage, channel: RabbitMQChannel) {
26
+ const correlationId = msg.properties.headers['x-correlation-id'];
27
+ // ...process...
28
+ channel.ack(msg);
29
+ }
30
+ ```
31
+
32
+ Example with amqplib:
33
+
34
+ ```ts
35
+ import amqp from 'amqplib';
36
+ import type { RabbitMQMessage } from '@cargolift-cdi/types';
37
+
38
+ const conn = await amqp.connect(process.env.AMQP_URL!);
39
+ const ch = await conn.createChannel();
40
+ await ch.assertQueue('jobs');
41
+
42
+ ch.consume('jobs', (msg) => {
43
+ if (!msg) return;
44
+ const typedMsg = msg as unknown as RabbitMQMessage;
45
+ // use typedMsg.content, typedMsg.properties.headers, etc.
46
+ ch.ack(msg);
47
+ });
15
48
  ```
16
49
 
17
50
  ## What’s inside
18
51
 
19
- - `rabbitmq.interfaces`: tipos para mensagens e canal RabbitMQ
52
+ - `rabbitmq.interfaces`: tipos para mensagens e canal RabbitMQ.
53
+
54
+ Notes
55
+ - This package ships only `.d.ts` files. There is no runtime code.
56
+ - Prefer `import type` (TS 4.5+) so bundlers/Node don’t try to load a runtime module.
20
57
 
21
58
  ## Development
22
59
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cargolift-cdi/types",
3
- "version": "0.1.0",
4
- "description": "Shared TypeScript types and interfaces for Node.js projects",
3
+ "version": "0.1.1",
4
+ "description": "TypeScript types e interfaces comuns para projetos Cargolift CDI",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "types",