@omicron-x/daedalus-sdk 1.0.0 → 1.0.2
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 +108 -34
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -1,63 +1,137 @@
|
|
|
1
|
-
# Daedalus Node.js Worker SDK
|
|
1
|
+
# Daedalus Node.js Worker SDK 👷⚙️
|
|
2
2
|
|
|
3
|
-
Node.js/TypeScript SDK for interacting with the Daedalus Orchestrator
|
|
3
|
+
Node.js/TypeScript SDK for interacting with the **Daedalus Orchestrator**.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
cd sdk/nodejs-sdk
|
|
9
|
-
npm install
|
|
10
|
-
```
|
|
7
|
+
## 📦 Installation
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
You can compile the SDK using Nx from the project root:
|
|
9
|
+
To install the SDK as a dependency in your project:
|
|
15
10
|
|
|
16
11
|
```bash
|
|
17
|
-
|
|
12
|
+
npm install @omicron-x/daedalus-sdk
|
|
18
13
|
```
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 🚀 Quick Start (Usage Example)
|
|
18
|
+
|
|
19
|
+
Here is a basic example of how to connect and create a worker to process messages using the SDK:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { DaedalusSDK } from '@omicron-x/daedalus-sdk';
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
// 1. Initialize the SDK
|
|
26
|
+
const sdk = new DaedalusSDK({
|
|
27
|
+
uri: 'http://localhost:4000', // Orchestrator gRPC/HTTP endpoint
|
|
28
|
+
username: 'admin',
|
|
29
|
+
password: 'admin'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 2. Connect to the Orchestrator
|
|
33
|
+
await sdk.connect();
|
|
34
|
+
|
|
35
|
+
// 3. Register a worker to consume tasks
|
|
36
|
+
await sdk.createWorker({
|
|
37
|
+
workerName: 'my-custom-worker',
|
|
38
|
+
intervalMs: 500,
|
|
39
|
+
capacityPolicies: [
|
|
40
|
+
{
|
|
41
|
+
maxQueueMessages: 10,
|
|
42
|
+
claimWorkFilter: {}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
onMessage: async (message, ack) => {
|
|
46
|
+
console.log('👷 Processing message:', message.message.content);
|
|
47
|
+
|
|
48
|
+
// Your message processing logic here...
|
|
49
|
+
|
|
50
|
+
// Acknowledge the message when finished
|
|
51
|
+
await ack();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log('✅ Worker is running. Press Ctrl+C to stop.');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main().catch(err => {
|
|
59
|
+
console.error('💥 Fatal error:', err);
|
|
60
|
+
});
|
|
24
61
|
```
|
|
25
62
|
|
|
26
|
-
|
|
63
|
+
> [!NOTE]
|
|
64
|
+
> **Protobuf Dependency Note:** Currently, the SDK resolves gRPC protobuf definitions relative to the monorepo directory structure (looking for `server/internal/infrastructure/server/grpc/proto/definitions` three levels up from the package folder). If you use this package standalone outside the monorepo, make sure to place or symlink the protobuf definitions at the expected relative path, or install the package within the monorepo context.
|
|
27
65
|
|
|
28
|
-
|
|
66
|
+
---
|
|
29
67
|
|
|
30
|
-
|
|
68
|
+
## 🛠️ Monorepo Development & Contribution
|
|
31
69
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
70
|
+
If you are developing inside the [Daedalus Orchestrator Monorepo](file:///Users/angel/Documents/daedalus-orchestrator-project/daedalus-orchestrator), follow these steps to build and run the SDK.
|
|
71
|
+
|
|
72
|
+
### Prerequisites
|
|
35
73
|
|
|
36
|
-
|
|
74
|
+
To execute build tasks and run examples inside the monorepo, you must have **Nx** installed globally (or run using `npx nx`):
|
|
37
75
|
|
|
38
76
|
```bash
|
|
39
|
-
|
|
40
|
-
npx ts-node examples/simple-worker/index.ts
|
|
77
|
+
npm install -g nx
|
|
41
78
|
```
|
|
42
79
|
|
|
43
|
-
###
|
|
80
|
+
### How to Build the SDK
|
|
44
81
|
|
|
45
|
-
|
|
82
|
+
Compile the SDK from the project root directory:
|
|
46
83
|
|
|
47
84
|
```bash
|
|
48
|
-
nx run server:
|
|
85
|
+
nx run server:build-sdk-nodejs
|
|
49
86
|
```
|
|
50
87
|
|
|
51
|
-
|
|
88
|
+
Alternatively, you can compile manually within the `sdk/nodejs-sdk` folder:
|
|
52
89
|
|
|
53
90
|
```bash
|
|
54
91
|
cd sdk/nodejs-sdk
|
|
55
|
-
npm
|
|
92
|
+
npm install
|
|
93
|
+
npm run build
|
|
56
94
|
```
|
|
57
95
|
|
|
58
|
-
|
|
96
|
+
---
|
|
59
97
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
98
|
+
## 📚 Examples Reference
|
|
99
|
+
|
|
100
|
+
We provide fully functional examples in the [examples/](file:///Users/angel/Documents/daedalus-orchestrator-project/daedalus-orchestrator/sdk/nodejs-sdk/examples) folder:
|
|
101
|
+
|
|
102
|
+
- **[Simple Worker](file:///Users/angel/Documents/daedalus-orchestrator-project/daedalus-orchestrator/sdk/nodejs-sdk/examples/simple-worker/index.ts)**: A basic worker showing connection and message consumption.
|
|
103
|
+
- **[Assert Resources](file:///Users/angel/Documents/daedalus-orchestrator-project/daedalus-orchestrator/sdk/nodejs-sdk/examples/assert-resources/index.ts)**: A comprehensive example demonstrating how to upsert a tenant, exchange, queue, and binding, plus publishing and enqueueing messages.
|
|
104
|
+
|
|
105
|
+
### Running the Examples
|
|
106
|
+
|
|
107
|
+
#### Option A: Running from the Monorepo Root (Using Nx)
|
|
108
|
+
|
|
109
|
+
Run the examples directly using Nx:
|
|
110
|
+
|
|
111
|
+
- **Simple Worker**:
|
|
112
|
+
```bash
|
|
113
|
+
nx run server:run-nodejs-simple-worker
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- **Assert Resources**:
|
|
117
|
+
```bash
|
|
118
|
+
nx run server:run-nodejs-assert-resources
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Option B: Running from the SDK Directory
|
|
122
|
+
|
|
123
|
+
Navigate to `sdk/nodejs-sdk` first, then run:
|
|
124
|
+
|
|
125
|
+
- **Simple Worker**:
|
|
126
|
+
```bash
|
|
127
|
+
npm run example:simple-worker
|
|
128
|
+
# or manually:
|
|
129
|
+
npx ts-node examples/simple-worker/index.ts
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- **Assert Resources**:
|
|
133
|
+
```bash
|
|
134
|
+
npm run example:assert-resources
|
|
135
|
+
# or manually:
|
|
136
|
+
npx ts-node examples/assert-resources/index.ts
|
|
137
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omicron-x/daedalus-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Daedalus Orchestrator Node.js Worker",
|
|
5
|
+
"homepage": "https://github.com/angel-zguerrero/daedalus-orchestrator/tree/main/sdk/nodejs-sdk",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/angel-zguerrero/daedalus-orchestrator.git",
|
|
9
|
+
"directory": "sdk/nodejs-sdk"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/angel-zguerrero/daedalus-orchestrator/issues"
|
|
13
|
+
},
|
|
5
14
|
"main": "dist/src/index.js",
|
|
6
15
|
"types": "dist/src/index.d.ts",
|
|
7
16
|
"files": [
|