ultravisor-beacon-capability 1.0.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 +106 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +103 -0
- package/docs/_brand.json +18 -0
- package/docs/_cover.md +13 -0
- package/docs/_sidebar.md +31 -0
- package/docs/_topbar.md +5 -0
- package/docs/_version.json +7 -0
- package/docs/api/README.md +44 -0
- package/docs/api/action-convention.md +148 -0
- package/docs/api/add-action.md +68 -0
- package/docs/api/beacon-capability.md +89 -0
- package/docs/api/build-action-map.md +88 -0
- package/docs/api/connect.md +81 -0
- package/docs/api/disconnect.md +50 -0
- package/docs/api/is-connected.md +33 -0
- package/docs/api/lifecycle-hooks.md +115 -0
- package/docs/architecture.md +237 -0
- package/docs/css/docuserve.css +327 -0
- package/docs/examples/README.md +58 -0
- package/docs/examples/certificate-expiry-monitor.md +212 -0
- package/docs/examples/docker-container-management.md +265 -0
- package/docs/examples/log-archive-and-upload.md +214 -0
- package/docs/examples/log-file-cleanup.md +199 -0
- package/docs/examples/mysql-maintenance.md +253 -0
- package/docs/examples/postgresql-aggregation.md +247 -0
- package/docs/examples/rest-api-health-check.md +213 -0
- package/docs/examples/rest-endpoint-sync.md +240 -0
- package/docs/examples/server-metrics-collection.md +199 -0
- package/docs/examples/shell-commands.md +176 -0
- package/docs/index.html +39 -0
- package/docs/quickstart.md +199 -0
- package/docs/retold-catalog.json +85 -0
- package/docs/retold-keyword-index.json +10642 -0
- package/package.json +33 -0
- package/source/Ultravisor-Beacon-Capability-ActionMap.cjs +132 -0
- package/source/Ultravisor-Beacon-Capability.cjs +276 -0
- package/test/Ultravisor-Beacon-Capability_tests.js +744 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
This guide walks through building your first beacon capability, connecting it to an Ultravisor server, and verifying the actions are registered.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 18+
|
|
8
|
+
- An Ultravisor server running (default: `http://localhost:54321`)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install ultravisor-beacon-capability
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This installs `ultravisor-beacon-capability` along with its dependencies `ultravisor-beacon` and `fable-serviceproviderbase`.
|
|
17
|
+
|
|
18
|
+
## Step 1: Define a Capability Class
|
|
19
|
+
|
|
20
|
+
Create a file `my-capability.js`:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
const libBeaconCapability = require('ultravisor-beacon-capability');
|
|
24
|
+
|
|
25
|
+
class FileOperations extends libBeaconCapability
|
|
26
|
+
{
|
|
27
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
28
|
+
{
|
|
29
|
+
super(pFable, pOptions, pServiceHash);
|
|
30
|
+
this.serviceType = 'FileOperations';
|
|
31
|
+
this.capabilityName = 'FileOperations';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// --- Action: ListFiles ---
|
|
35
|
+
|
|
36
|
+
get actionListFiles_Description()
|
|
37
|
+
{
|
|
38
|
+
return 'List files in a directory with optional pattern filter';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get actionListFiles_Schema()
|
|
42
|
+
{
|
|
43
|
+
return [
|
|
44
|
+
{ Name: 'Directory', DataType: 'String', Required: true },
|
|
45
|
+
{ Name: 'Pattern', DataType: 'String', Required: false }
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
actionListFiles(pSettings, pWorkItem, fCallback)
|
|
50
|
+
{
|
|
51
|
+
let tmpCmd = `ls -la ${pSettings.Directory}`;
|
|
52
|
+
if (pSettings.Pattern)
|
|
53
|
+
{
|
|
54
|
+
tmpCmd += ` | grep '${pSettings.Pattern}'`;
|
|
55
|
+
}
|
|
56
|
+
require('child_process').exec(tmpCmd, (pError, pStdOut) =>
|
|
57
|
+
{
|
|
58
|
+
if (pError) return fCallback(pError);
|
|
59
|
+
return fCallback(null, {
|
|
60
|
+
Outputs: { FileList: pStdOut },
|
|
61
|
+
Log: [`Listed files in ${pSettings.Directory}`]
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// --- Action: DiskUsage ---
|
|
67
|
+
|
|
68
|
+
get actionDiskUsage_Description()
|
|
69
|
+
{
|
|
70
|
+
return 'Report disk usage for a path';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get actionDiskUsage_Schema()
|
|
74
|
+
{
|
|
75
|
+
return [
|
|
76
|
+
{ Name: 'Path', DataType: 'String', Required: true },
|
|
77
|
+
{ Name: 'MaxDepth', DataType: 'Integer', Required: false }
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
actionDiskUsage(pSettings, pWorkItem, fCallback)
|
|
82
|
+
{
|
|
83
|
+
let tmpDepth = pSettings.MaxDepth || 1;
|
|
84
|
+
let tmpCmd = `du -h --max-depth=${tmpDepth} ${pSettings.Path}`;
|
|
85
|
+
require('child_process').exec(tmpCmd, (pError, pStdOut) =>
|
|
86
|
+
{
|
|
87
|
+
if (pError) return fCallback(pError);
|
|
88
|
+
return fCallback(null, {
|
|
89
|
+
Outputs: { Usage: pStdOut },
|
|
90
|
+
Log: [`Disk usage for ${pSettings.Path}`]
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = FileOperations;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Step 2: Connect to Ultravisor
|
|
100
|
+
|
|
101
|
+
Create a file `start.js`:
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
const libFable = require('fable');
|
|
105
|
+
const libFileOperations = require('./my-capability.js');
|
|
106
|
+
|
|
107
|
+
let tmpFable = new libFable({
|
|
108
|
+
Product: 'FileOps',
|
|
109
|
+
ProductVersion: '1.0.0'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Register and instantiate the capability
|
|
113
|
+
tmpFable.addServiceType('FileOperations', libFileOperations);
|
|
114
|
+
let tmpCapability = tmpFable.instantiateServiceProvider('FileOperations');
|
|
115
|
+
|
|
116
|
+
// Connect to Ultravisor
|
|
117
|
+
tmpCapability.connect(
|
|
118
|
+
{
|
|
119
|
+
ServerURL: 'http://localhost:54321',
|
|
120
|
+
Name: 'file-ops-worker',
|
|
121
|
+
MaxConcurrent: 2,
|
|
122
|
+
Tags: { host: require('os').hostname() }
|
|
123
|
+
},
|
|
124
|
+
(pError, pBeaconInfo) =>
|
|
125
|
+
{
|
|
126
|
+
if (pError)
|
|
127
|
+
{
|
|
128
|
+
console.error('Connection failed:', pError.message);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
console.log('Beacon online:', pBeaconInfo.BeaconID);
|
|
132
|
+
console.log('Registered actions: ListFiles, DiskUsage');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Graceful shutdown
|
|
136
|
+
process.on('SIGTERM', () =>
|
|
137
|
+
{
|
|
138
|
+
tmpCapability.disconnect(() =>
|
|
139
|
+
{
|
|
140
|
+
console.log('Beacon disconnected.');
|
|
141
|
+
process.exit(0);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Run it:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
node start.js
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Step 3: Verify Registration
|
|
153
|
+
|
|
154
|
+
Once connected, the Ultravisor server creates two task types:
|
|
155
|
+
|
|
156
|
+
- `beacon-fileoperations-listfiles`
|
|
157
|
+
- `beacon-fileoperations-diskusage`
|
|
158
|
+
|
|
159
|
+
You can verify by querying the Ultravisor API:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
curl http://localhost:54321/Beacon/Actions | jq
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The response will include your actions with their schemas and descriptions.
|
|
166
|
+
|
|
167
|
+
## Step 4: Trigger an Action
|
|
168
|
+
|
|
169
|
+
From the Ultravisor dashboard or via the API:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
curl -X POST http://localhost:54321/Beacon/Work/Dispatch \
|
|
173
|
+
-H 'Content-Type: application/json' \
|
|
174
|
+
-d '{
|
|
175
|
+
"Capability": "FileOperations",
|
|
176
|
+
"Action": "ListFiles",
|
|
177
|
+
"Settings": { "Directory": "/var/log", "Pattern": ".log" }
|
|
178
|
+
}'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The result will contain the output in `Outputs.FileList`.
|
|
182
|
+
|
|
183
|
+
## Configuration Reference
|
|
184
|
+
|
|
185
|
+
| Option | Type | Default | Description |
|
|
186
|
+
|--------|------|---------|-------------|
|
|
187
|
+
| `ServerURL` | `string` | -- | Ultravisor server endpoint (required) |
|
|
188
|
+
| `Name` | `string` | `capabilityName` | Beacon name for registration |
|
|
189
|
+
| `Password` | `string` | `''` | Authentication password |
|
|
190
|
+
| `MaxConcurrent` | `number` | `1` | Maximum parallel work items |
|
|
191
|
+
| `StagingPath` | `string` | `process.cwd()` | Working directory for file transfer |
|
|
192
|
+
| `Tags` | `object` | `{}` | Metadata tags sent to coordinator |
|
|
193
|
+
| `BindAddresses` | `array` | `[]` | Network addresses to advertise |
|
|
194
|
+
|
|
195
|
+
## Next Steps
|
|
196
|
+
|
|
197
|
+
- [Architecture](architecture.md) -- Understand the component design
|
|
198
|
+
- [API Reference](api/README.md) -- Complete method documentation
|
|
199
|
+
- [Examples](examples/README.md) -- Real-world usage patterns
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Generated": "2026-04-10T17:19:46.586Z",
|
|
3
|
+
"GitHubOrg": "stevenvelozo",
|
|
4
|
+
"DefaultBranch": "master",
|
|
5
|
+
"Groups": [
|
|
6
|
+
{
|
|
7
|
+
"Name": "Dist",
|
|
8
|
+
"Key": "dist",
|
|
9
|
+
"Description": "",
|
|
10
|
+
"Modules": [
|
|
11
|
+
{
|
|
12
|
+
"Name": "indoctrinate_content_staging",
|
|
13
|
+
"Repo": "indoctrinate_content_staging",
|
|
14
|
+
"Group": "dist",
|
|
15
|
+
"Branch": "master",
|
|
16
|
+
"HasDocs": false,
|
|
17
|
+
"HasCover": false,
|
|
18
|
+
"Sidebar": [],
|
|
19
|
+
"DocFiles": []
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"Name": "Docs",
|
|
25
|
+
"Key": "docs",
|
|
26
|
+
"Description": "",
|
|
27
|
+
"Modules": [
|
|
28
|
+
{
|
|
29
|
+
"Name": "api",
|
|
30
|
+
"Repo": "api",
|
|
31
|
+
"Group": "docs",
|
|
32
|
+
"Branch": "master",
|
|
33
|
+
"HasDocs": true,
|
|
34
|
+
"HasCover": false,
|
|
35
|
+
"Sidebar": [],
|
|
36
|
+
"DocFiles": [
|
|
37
|
+
"api/README.md",
|
|
38
|
+
"api/action-convention.md",
|
|
39
|
+
"api/add-action.md",
|
|
40
|
+
"api/beacon-capability.md",
|
|
41
|
+
"api/build-action-map.md",
|
|
42
|
+
"api/connect.md",
|
|
43
|
+
"api/disconnect.md",
|
|
44
|
+
"api/is-connected.md",
|
|
45
|
+
"api/lifecycle-hooks.md"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"Name": "css",
|
|
50
|
+
"Repo": "css",
|
|
51
|
+
"Group": "docs",
|
|
52
|
+
"Branch": "master",
|
|
53
|
+
"HasDocs": true,
|
|
54
|
+
"HasCover": false,
|
|
55
|
+
"Sidebar": [],
|
|
56
|
+
"DocFiles": [
|
|
57
|
+
"css/docuserve.css"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"Name": "examples",
|
|
62
|
+
"Repo": "examples",
|
|
63
|
+
"Group": "docs",
|
|
64
|
+
"Branch": "master",
|
|
65
|
+
"HasDocs": true,
|
|
66
|
+
"HasCover": false,
|
|
67
|
+
"Sidebar": [],
|
|
68
|
+
"DocFiles": [
|
|
69
|
+
"examples/README.md",
|
|
70
|
+
"examples/certificate-expiry-monitor.md",
|
|
71
|
+
"examples/docker-container-management.md",
|
|
72
|
+
"examples/log-archive-and-upload.md",
|
|
73
|
+
"examples/log-file-cleanup.md",
|
|
74
|
+
"examples/mysql-maintenance.md",
|
|
75
|
+
"examples/postgresql-aggregation.md",
|
|
76
|
+
"examples/rest-api-health-check.md",
|
|
77
|
+
"examples/rest-endpoint-sync.md",
|
|
78
|
+
"examples/server-metrics-collection.md",
|
|
79
|
+
"examples/shell-commands.md"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|