@fdm-monster/server 1.8.1 → 1.8.3
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/.yarn/install-state.gz +0 -0
- package/.yarn/releases/{yarn-4.5.3.cjs → yarn-4.7.0.cjs} +256 -255
- package/.yarnrc.yml +1 -1
- package/README.md +14 -4
- package/RELEASE_NOTES.MD +35 -4
- package/dist/consoles/http-file-receiver.console.js +81 -0
- package/dist/consoles/http-file-receiver.console.js.map +1 -0
- package/dist/constants/event.constants.js +8 -0
- package/dist/constants/event.constants.js.map +1 -1
- package/dist/container.js +2 -14
- package/dist/container.js.map +1 -1
- package/dist/container.tokens.js +1 -3
- package/dist/container.tokens.js.map +1 -1
- package/dist/controllers/plugin-firmware-update.controller.js +4 -6
- package/dist/controllers/plugin-firmware-update.controller.js.map +1 -1
- package/dist/controllers/printer-files.controller.js +19 -22
- package/dist/controllers/printer-files.controller.js.map +1 -1
- package/dist/controllers/printer-settings.controller.js +3 -3
- package/dist/controllers/printer-settings.controller.js.map +1 -1
- package/dist/controllers/printer.controller.js +14 -8
- package/dist/controllers/printer.controller.js.map +1 -1
- package/dist/controllers/server-private.controller.js +2 -16
- package/dist/controllers/server-private.controller.js.map +1 -1
- package/dist/controllers/server-public.controller.js +0 -2
- package/dist/controllers/server-public.controller.js.map +1 -1
- package/dist/handlers/validators.js +9 -6
- package/dist/handlers/validators.js.map +1 -1
- package/dist/server.constants.js +1 -2
- package/dist/server.constants.js.map +1 -1
- package/dist/server.env.js +3 -25
- package/dist/server.env.js.map +1 -1
- package/dist/server.host.js +3 -1
- package/dist/server.host.js.map +1 -1
- package/dist/services/core/http-client.factory.js +40 -0
- package/dist/services/core/http-client.factory.js.map +1 -0
- package/dist/services/core/logs-manager.service.js +4 -3
- package/dist/services/core/logs-manager.service.js.map +1 -1
- package/dist/services/core/multer.service.js +72 -22
- package/dist/services/core/multer.service.js.map +1 -1
- package/dist/services/interfaces/file-upload-tracker.interface.js +6 -0
- package/dist/services/interfaces/file-upload-tracker.interface.js.map +1 -0
- package/dist/services/interfaces/printer.dto.js +6 -0
- package/dist/services/interfaces/printer.dto.js.map +1 -1
- package/dist/services/mongoose/printer.service.js +10 -3
- package/dist/services/mongoose/printer.service.js.map +1 -1
- package/dist/services/moonraker/moonraker-websocket.adapter.js +6 -2
- package/dist/services/moonraker/moonraker-websocket.adapter.js.map +1 -1
- package/dist/services/moonraker/moonraker.client.js +196 -156
- package/dist/services/moonraker/moonraker.client.js.map +1 -1
- package/dist/services/octoprint/dto/plugin.dto.js +6 -0
- package/dist/services/octoprint/dto/plugin.dto.js.map +1 -0
- package/dist/services/octoprint/octoprint-api.routes.js +0 -61
- package/dist/services/octoprint/octoprint-api.routes.js.map +1 -1
- package/dist/services/octoprint/octoprint-websocket.adapter.js +11 -5
- package/dist/services/octoprint/octoprint-websocket.adapter.js.map +1 -1
- package/dist/services/octoprint/octoprint.client.js +118 -201
- package/dist/services/octoprint/octoprint.client.js.map +1 -1
- package/dist/services/octoprint/plugin-base.service.js +15 -15
- package/dist/services/octoprint/plugin-base.service.js.map +1 -1
- package/dist/services/octoprint/plugin-firmware-update.service.js +1 -1
- package/dist/services/octoprint/plugin-firmware-update.service.js.map +1 -1
- package/dist/services/octoprint/plugin-repository.cache.js +2 -1
- package/dist/services/octoprint/plugin-repository.cache.js.map +1 -1
- package/dist/services/octoprint/utils/octoprint-http-client.builder.js +31 -0
- package/dist/services/octoprint/utils/octoprint-http-client.builder.js.map +1 -0
- package/dist/services/octoprint.api.js +6 -4
- package/dist/services/octoprint.api.js.map +1 -1
- package/dist/services/orm/printer.service.js +8 -3
- package/dist/services/orm/printer.service.js.map +1 -1
- package/dist/shared/default-http-client.builder.js +94 -0
- package/dist/shared/default-http-client.builder.js.map +1 -0
- package/dist/shared/websocket.adapter.js.map +1 -1
- package/dist/state/file-upload-tracker.cache.js +30 -40
- package/dist/state/file-upload-tracker.cache.js.map +1 -1
- package/dist/state/settings.store.js +4 -1
- package/dist/state/settings.store.js.map +1 -1
- package/dist/state/test-printer-socket.store.js.map +1 -1
- package/dist/state/validation/create-test-printer.validation.js +1 -0
- package/dist/state/validation/create-test-printer.validation.js.map +1 -1
- package/dist/tasks/boot.task.js +1 -2
- package/dist/tasks/boot.task.js.map +1 -1
- package/dist/tasks/printer-websocket-restore.task.js +1 -1
- package/dist/tasks/printer-websocket-restore.task.js.map +1 -1
- package/dist/tasks/socketio.task.js +2 -2
- package/dist/tasks/socketio.task.js.map +1 -1
- package/dist/tasks.js.map +1 -1
- package/dist/utils/env.utils.js +0 -42
- package/dist/utils/env.utils.js.map +1 -1
- package/dist/utils/normalize-url.js +3 -1
- package/dist/utils/normalize-url.js.map +1 -1
- package/dist/utils/pretty-print.utils.js +1 -1
- package/dist/utils/pretty-print.utils.js.map +1 -1
- package/dist/utils/url.utils.js +12 -14
- package/dist/utils/url.utils.js.map +1 -1
- package/package.json +40 -55
- package/dist/services/core/server-update.service.js +0 -71
- package/dist/services/core/server-update.service.js.map +0 -1
- package/requests/moonraker/api_job.http +0 -5
- package/requests/moonraker/api_printer.http +0 -5
- package/requests/moonraker/api_settings.http +0 -5
- package/requests/moonraker/printer_info.http +0 -5
- package/requests/moonraker/printer_objects_list.http +0 -6
- package/requests/moonraker/printer_objects_pause_resume.http +0 -6
- package/requests/moonraker/printer_objects_print_stats.http +0 -6
- package/requests/moonraker/printer_objects_webhooks.http +0 -6
- package/requests/moonraker/server_info.http +0 -5
- package/requests/octoprint/octoprint-api-printer-current.http +0 -7
- package/requests/octoprint/octoprint-pluginmanager-plugins.http +0 -7
- package/requests/printer-file/get-partial-file-moonraker.http +0 -5
- package/requests/printer-file/get-thumbnails.http +0 -5
- package/requests/printer-file/reload-printer-thumbnails.http +0 -10
- package/requests/printer-file/testfile.gcode +0 -5665
- package/requests/printer-file/upload-file.http +0 -11
- package/requests/printer-file/upload-slicer-file.http +0 -11
- package/requests/printers/list.http +0 -5
|
@@ -8,44 +8,47 @@ Object.defineProperty(exports, "MoonrakerClient", {
|
|
|
8
8
|
return MoonrakerClient;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
12
11
|
const _formdata = /*#__PURE__*/ _interop_require_default(require("form-data"));
|
|
13
12
|
const _fs = require("fs");
|
|
14
13
|
const _eventconstants = require("../../constants/event.constants");
|
|
14
|
+
const _defaulthttpclientbuilder = require("../../shared/default-http-client.builder");
|
|
15
|
+
const _runtimeexceptions = require("../../exceptions/runtime.exceptions");
|
|
15
16
|
function _interop_require_default(obj) {
|
|
16
17
|
return obj && obj.__esModule ? obj : {
|
|
17
18
|
default: obj
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
class MoonrakerClient {
|
|
21
|
-
|
|
22
|
+
httpClientFactory;
|
|
22
23
|
eventEmitter2;
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
logger;
|
|
25
|
+
constructor({ httpClientFactory, loggerFactory, eventEmitter2 }){
|
|
26
|
+
this.httpClientFactory = httpClientFactory;
|
|
25
27
|
this.eventEmitter2 = eventEmitter2;
|
|
28
|
+
this.logger = loggerFactory(MoonrakerClient.name);
|
|
26
29
|
}
|
|
27
30
|
async getServerInfo(login) {
|
|
28
|
-
return this.
|
|
31
|
+
return this.createClient(login).get("/server/info");
|
|
29
32
|
}
|
|
30
33
|
async getServerConfig(login) {
|
|
31
|
-
return this.
|
|
34
|
+
return this.createClient(login).get("/server/config");
|
|
32
35
|
}
|
|
33
36
|
async getTemperatureStore(login, includeMonitors = false) {
|
|
34
|
-
return this.
|
|
37
|
+
return this.createClient(login).get(`/server/temperature_store?include_monitors=${!!includeMonitors}`);
|
|
35
38
|
}
|
|
36
39
|
async getGcodeStore(login, count = 100) {
|
|
37
|
-
return this.
|
|
40
|
+
return this.createClient(login).get(`/server/gcode_store?count=${count}`);
|
|
38
41
|
}
|
|
39
42
|
async postRolloverLogs(login, application = "") {
|
|
40
|
-
return this.
|
|
43
|
+
return this.createClient(login).post(`server/logs/rollover`, {
|
|
41
44
|
application
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
async postRestartServer(login) {
|
|
45
|
-
return this.
|
|
48
|
+
return this.createClient(login).post(`server/restart`);
|
|
46
49
|
}
|
|
47
50
|
async postJsonRpc(login, method, params, id) {
|
|
48
|
-
return this.
|
|
51
|
+
return this.createClient(login).post(`server/jsonrpc`, {
|
|
49
52
|
jsonrpc: "2.0",
|
|
50
53
|
id: id ? id : 0,
|
|
51
54
|
method,
|
|
@@ -53,27 +56,27 @@ class MoonrakerClient {
|
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
async getPrinterInfo(login) {
|
|
56
|
-
return this.
|
|
59
|
+
return this.createClient(login).post(`printer/info`);
|
|
57
60
|
}
|
|
58
61
|
async postQuickStop(login) {
|
|
59
|
-
return this.
|
|
62
|
+
return this.createClient(login).post(`printer/emergency_stop`);
|
|
60
63
|
}
|
|
61
64
|
async postHostRestart(login) {
|
|
62
|
-
return this.
|
|
65
|
+
return this.createClient(login).post(`printer/restart`);
|
|
63
66
|
}
|
|
64
67
|
async postFirmwareRestart(login) {
|
|
65
|
-
return this.
|
|
68
|
+
return this.createClient(login).post(`printer/firmware_restart`);
|
|
66
69
|
}
|
|
67
70
|
async getPrinterObjectsList(login) {
|
|
68
|
-
return this.
|
|
71
|
+
return this.createClient(login).get(`printer/objects/list`);
|
|
69
72
|
}
|
|
70
73
|
async getPrinterObjectsQuery(login, query) {
|
|
71
74
|
const queryString = this.convertToQueryString(query);
|
|
72
|
-
return this.
|
|
75
|
+
return this.createClient(login).get(`printer/objects/query?${queryString}`);
|
|
73
76
|
}
|
|
74
77
|
postSubscribePrinterObjects(login, connectionId, query) {
|
|
75
78
|
const queryString = this.convertToQueryString(query);
|
|
76
|
-
return this.
|
|
79
|
+
return this.createClient(login).post(`printer/objects/subscribe?connection_id=${connectionId}&${queryString}`);
|
|
77
80
|
}
|
|
78
81
|
convertToQueryString(query) {
|
|
79
82
|
return Object.entries(query).reduce((acc, [key, value])=>{
|
|
@@ -86,117 +89,117 @@ class MoonrakerClient {
|
|
|
86
89
|
}, []).join("&");
|
|
87
90
|
}
|
|
88
91
|
async getPrinterQueryEndstops(login) {
|
|
89
|
-
return this.
|
|
92
|
+
return this.createClient(login).get(`printer/query-endstops`);
|
|
90
93
|
}
|
|
91
94
|
async postGcodeScript(login, script = "G28") {
|
|
92
|
-
return this.
|
|
95
|
+
return this.createClient(login).get(`printer/gcode/script?script=${script}`);
|
|
93
96
|
}
|
|
94
97
|
async getGcodeHelp(login) {
|
|
95
|
-
return this.
|
|
98
|
+
return this.createClient(login).get(`printer/gcode/help`);
|
|
96
99
|
}
|
|
97
100
|
async postPrintStart(login, filename) {
|
|
98
|
-
return this.
|
|
101
|
+
return this.createClient(login).post(`printer/print/start?filename=${filename}`);
|
|
99
102
|
}
|
|
100
103
|
async postPrintPause(login) {
|
|
101
|
-
return this.
|
|
104
|
+
return this.createClient(login).post(`printer/print/pause`);
|
|
102
105
|
}
|
|
103
106
|
async postPrintResume(login) {
|
|
104
|
-
return this.
|
|
107
|
+
return this.createClient(login).post(`printer/print/resume`);
|
|
105
108
|
}
|
|
106
109
|
async postPrintCancel(login) {
|
|
107
|
-
return this.
|
|
110
|
+
return this.createClient(login).post(`printer/print/cancel`);
|
|
108
111
|
}
|
|
109
112
|
async getMachineSystemInfo(login) {
|
|
110
|
-
return this.
|
|
113
|
+
return this.createClient(login).get(`machine/system_info`);
|
|
111
114
|
}
|
|
112
115
|
async postMachineShutdown(login) {
|
|
113
|
-
return this.
|
|
116
|
+
return this.createClient(login).post(`machine/shutdown`);
|
|
114
117
|
}
|
|
115
118
|
async postMachineReboot(login) {
|
|
116
|
-
return this.
|
|
119
|
+
return this.createClient(login).post(`machine/reboot`);
|
|
117
120
|
}
|
|
118
121
|
async postMachineRestartService(login, service) {
|
|
119
|
-
return this.
|
|
122
|
+
return this.createClient(login).post(`machine/services/restart?service=${service}`);
|
|
120
123
|
}
|
|
121
124
|
async postMachineStartService(login, service) {
|
|
122
|
-
return this.
|
|
125
|
+
return this.createClient(login).post(`machine/services/restart?service=${service}`);
|
|
123
126
|
}
|
|
124
127
|
async postMachineProcessStats(login) {
|
|
125
|
-
return this.
|
|
128
|
+
return this.createClient(login).post(`machine/proc_stats`);
|
|
126
129
|
}
|
|
127
130
|
async getMachineSudoInfo(login, checkAccess = false) {
|
|
128
|
-
return this.
|
|
131
|
+
return this.createClient(login).get(`machine/sudo/info?check_access=${checkAccess}`);
|
|
129
132
|
}
|
|
130
133
|
async postMachineSetSudoPassword(login, password) {
|
|
131
|
-
return this.
|
|
134
|
+
return this.createClient(login).post(`machine/sudo/password`, {
|
|
132
135
|
password
|
|
133
136
|
});
|
|
134
137
|
}
|
|
135
138
|
async getMachineListPeripheralsUsb(login) {
|
|
136
|
-
return this.
|
|
139
|
+
return this.createClient(login).get(`machine/peripherals/usb`);
|
|
137
140
|
}
|
|
138
141
|
async getMachineListPeripheralsSerial(login) {
|
|
139
|
-
return this.
|
|
142
|
+
return this.createClient(login).get(`machine/peripherals/serial`);
|
|
140
143
|
}
|
|
141
144
|
async getMachineListPeripheralsVideo(login) {
|
|
142
|
-
return this.
|
|
145
|
+
return this.createClient(login).get(`machine/peripherals/video`);
|
|
143
146
|
}
|
|
144
147
|
async getMachineListPeripheralsCanbus(login, canInterface = "can0") {
|
|
145
|
-
return this.
|
|
148
|
+
return this.createClient(login).get(`machine/peripherals/canbus?interface=${canInterface}`);
|
|
146
149
|
}
|
|
147
150
|
async getServerFilesList(login, rootFolder = "") {
|
|
148
151
|
const paramString = rootFolder?.length ? `?root=${rootFolder}` : "";
|
|
149
|
-
return this.
|
|
152
|
+
return this.createClient(login).get(`server/files/list${paramString}`);
|
|
150
153
|
}
|
|
151
154
|
async getServerFilesRoots(login) {
|
|
152
|
-
return this.
|
|
155
|
+
return this.createClient(login).get(`server/files/roots`);
|
|
153
156
|
}
|
|
154
157
|
async getServerFileMetadata(login, filename) {
|
|
155
|
-
return this.
|
|
158
|
+
return this.createClient(login).get(`server/files/metadata?filename=${filename}`);
|
|
156
159
|
}
|
|
157
160
|
async getServerFileMetadataScan(login, filename) {
|
|
158
|
-
return this.
|
|
161
|
+
return this.createClient(login).get(`server/files/metascan?filename=${filename}`);
|
|
159
162
|
}
|
|
160
163
|
async getServerFilesThumbnails(login, filename) {
|
|
161
|
-
return this.
|
|
164
|
+
return this.createClient(login).get(`server/files/thumbnails?filename=${filename}`);
|
|
162
165
|
}
|
|
163
166
|
async getServerFilesDirectoryInfo(login, path, extended) {
|
|
164
|
-
return this.
|
|
167
|
+
return this.createClient(login).get(`server/files/directory?path=${path}&extended=${extended}`);
|
|
165
168
|
}
|
|
166
169
|
async postServerFilesDirectory(login, path) {
|
|
167
|
-
return this.
|
|
170
|
+
return this.createClient(login).post(`server/files/directory`, {
|
|
168
171
|
path
|
|
169
172
|
});
|
|
170
173
|
}
|
|
171
174
|
async deleteServerFilesDirectory(login, path, force) {
|
|
172
|
-
return this.
|
|
175
|
+
return this.createClient(login).delete(`server/files/directory?path=${path}&force=${!!force}`);
|
|
173
176
|
}
|
|
174
177
|
async postServerFilesMove(login, source, dest) {
|
|
175
|
-
return this.
|
|
178
|
+
return this.createClient(login).post(`server/files/directory`, {
|
|
176
179
|
source,
|
|
177
180
|
dest
|
|
178
181
|
});
|
|
179
182
|
}
|
|
180
183
|
async postServerFilesCopy(login, source, dest) {
|
|
181
|
-
return this.
|
|
184
|
+
return this.createClient(login).post(`server/files/copy`, {
|
|
182
185
|
source,
|
|
183
186
|
dest
|
|
184
187
|
});
|
|
185
188
|
}
|
|
186
189
|
async postServerFilesZip(login, items, dest, store_only) {
|
|
187
|
-
return this.
|
|
190
|
+
return this.createClient(login).post(`server/files/zip`, {
|
|
188
191
|
items,
|
|
189
192
|
store_only,
|
|
190
193
|
dest
|
|
191
194
|
});
|
|
192
195
|
}
|
|
193
196
|
async getServerFilesDownload(login, root, filename) {
|
|
194
|
-
return await this.
|
|
197
|
+
return await this.createClient(login).get(`server/files/${root}/${filename}`, {
|
|
195
198
|
responseType: "stream"
|
|
196
199
|
});
|
|
197
200
|
}
|
|
198
201
|
async getServerFilesDownloadChunk(login, root, filename, startBytes, endBytes) {
|
|
199
|
-
return await this.
|
|
202
|
+
return await this.createClient(login).get(`server/files/${root}/${filename}`, {
|
|
200
203
|
headers: {
|
|
201
204
|
Range: `bytes=${startBytes}-${endBytes}`
|
|
202
205
|
}
|
|
@@ -213,287 +216,308 @@ class MoonrakerClient {
|
|
|
213
216
|
if (checksum?.length) {
|
|
214
217
|
formData.append("checksum", checksum);
|
|
215
218
|
}
|
|
216
|
-
let
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
219
|
-
|
|
219
|
+
let fileBuffer = multerFileOrBuffer.buffer;
|
|
220
|
+
const filename = multerFileOrBuffer.originalname;
|
|
221
|
+
if (fileBuffer) {
|
|
222
|
+
this.logger.log("Attaching file from memory buffer to formdata for upload");
|
|
223
|
+
formData.append("file", fileBuffer, {
|
|
224
|
+
filename
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
const filePath = multerFileOrBuffer.path;
|
|
228
|
+
const fileStream = (0, _fs.createReadStream)(filePath);
|
|
229
|
+
this.logger.log(`Attaching file from disk to formdata for upload`);
|
|
230
|
+
formData.append("file", fileStream, {
|
|
231
|
+
filename
|
|
232
|
+
});
|
|
220
233
|
}
|
|
221
|
-
formData.append("file", source, {
|
|
222
|
-
filename: multerFileOrBuffer.originalname
|
|
223
|
-
});
|
|
224
234
|
const result = await new Promise((resolve, reject)=>{
|
|
225
235
|
return formData.getLength((err, length)=>{
|
|
226
236
|
if (err) resolve(null);
|
|
227
237
|
resolve(length);
|
|
228
238
|
});
|
|
229
239
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
try {
|
|
241
|
+
const response = await this.createClient(login, (b)=>{
|
|
242
|
+
b.withMultiPartFormData().withHeaders({
|
|
243
|
+
...formData.getHeaders(),
|
|
244
|
+
"Content-Length": result.toString()
|
|
245
|
+
}).withOnUploadProgress((p)=>{
|
|
246
|
+
if (progressToken) {
|
|
247
|
+
this.eventEmitter2.emit(`${(0, _eventconstants.uploadProgressEvent)(progressToken)}`, progressToken, p);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}).post(`server/files/upload`, formData);
|
|
251
|
+
this.eventEmitter2.emit(`${(0, _eventconstants.uploadDoneEvent)(progressToken)}`, progressToken);
|
|
252
|
+
return response.data;
|
|
253
|
+
} catch (e) {
|
|
254
|
+
this.eventEmitter2.emit(`${(0, _eventconstants.uploadFailedEvent)(progressToken)}`, progressToken, e?.message);
|
|
255
|
+
let data;
|
|
256
|
+
try {
|
|
257
|
+
data = JSON.parse(e.response?.body);
|
|
258
|
+
} catch {
|
|
259
|
+
data = e.response?.body;
|
|
243
260
|
}
|
|
244
|
-
|
|
261
|
+
throw new _runtimeexceptions.ExternalServiceError({
|
|
262
|
+
error: e.message,
|
|
263
|
+
statusCode: e.response?.statusCode,
|
|
264
|
+
data,
|
|
265
|
+
success: false,
|
|
266
|
+
stack: e.stack
|
|
267
|
+
}, "Moonraker");
|
|
268
|
+
}
|
|
245
269
|
}
|
|
246
270
|
async deleteServerFile(login, root, path) {
|
|
247
|
-
const url =
|
|
248
|
-
return this.
|
|
271
|
+
const url = `server/files/${root}/${path}`;
|
|
272
|
+
return this.createClient(login).delete(url);
|
|
249
273
|
}
|
|
250
274
|
async getServerFileKlippyLogDownload(login) {
|
|
251
|
-
return this.
|
|
275
|
+
return this.createClient(login).get(`server/files/klippy.log`);
|
|
252
276
|
}
|
|
253
277
|
async getServerFileMoonrakerLogDownload(login) {
|
|
254
|
-
return this.
|
|
278
|
+
return this.createClient(login).get(`server/files/moonraker.log`);
|
|
255
279
|
}
|
|
256
280
|
async postAccessLoginUser(login, username, password, source = "moonraker") {
|
|
257
|
-
return this.
|
|
281
|
+
return this.createClient(login).post("/access/login", {
|
|
258
282
|
username,
|
|
259
283
|
password,
|
|
260
284
|
source
|
|
261
285
|
});
|
|
262
286
|
}
|
|
263
287
|
async postAccessLogoutUser(login) {
|
|
264
|
-
return this.
|
|
288
|
+
return this.createClient(login).post(`access/logout`);
|
|
265
289
|
}
|
|
266
290
|
async getAccessUser(login) {
|
|
267
|
-
return this.
|
|
291
|
+
return this.createClient(login).get(`access/user`);
|
|
268
292
|
}
|
|
269
293
|
async postAccessCreateUser(login, username, password) {
|
|
270
|
-
return this.
|
|
294
|
+
return this.createClient(login).post(`access/login`, {
|
|
271
295
|
username,
|
|
272
296
|
password
|
|
273
297
|
});
|
|
274
298
|
}
|
|
275
299
|
async deleteAccessUser(login, username) {
|
|
276
|
-
return this.
|
|
300
|
+
return this.createClient(login).delete(`access/user`, {
|
|
277
301
|
data: {
|
|
278
302
|
username
|
|
279
303
|
}
|
|
280
304
|
});
|
|
281
305
|
}
|
|
282
306
|
async listAccessUsers(login) {
|
|
283
|
-
return this.
|
|
307
|
+
return this.createClient(login).get(`access/user/list`);
|
|
284
308
|
}
|
|
285
309
|
async postAccessResetPassword(login, refresh_token) {
|
|
286
|
-
return this.
|
|
310
|
+
return this.createClient(login).post(`access/refresh_jwt`, {
|
|
287
311
|
refresh_token
|
|
288
312
|
});
|
|
289
313
|
}
|
|
290
314
|
async getAccessOneshotToken(login) {
|
|
291
|
-
return this.
|
|
315
|
+
return this.createClient(login).get(`access/oneshot_token`);
|
|
292
316
|
}
|
|
293
317
|
async getAccessInfo(login) {
|
|
294
|
-
return this.
|
|
318
|
+
return this.createClient(login).get(`access/info`);
|
|
295
319
|
}
|
|
296
320
|
async getAccessApiKey(login) {
|
|
297
|
-
return this.
|
|
321
|
+
return this.createClient(login).get(`access/api_key`);
|
|
298
322
|
}
|
|
299
323
|
async postAccessApiKeyCreate(login) {
|
|
300
|
-
return this.
|
|
324
|
+
return this.createClient(login).post(`access/api_key`);
|
|
301
325
|
}
|
|
302
326
|
async getDatabaseNamespaceList(login) {
|
|
303
|
-
return this.
|
|
327
|
+
return this.createClient(login).get(`database/list`);
|
|
304
328
|
}
|
|
305
329
|
async getDatabaseNamespaceItem(login, namespace, key) {
|
|
306
|
-
return this.
|
|
330
|
+
return this.createClient(login).get(`database/item?namespace=${namespace}&key=${key}`);
|
|
307
331
|
}
|
|
308
332
|
async postDatabaseNamespaceItem(login, namespace, key, value, typeHint) {
|
|
309
333
|
const typeHintParam = typeHint?.length ? `:${typeHint}` : "";
|
|
310
|
-
return this.
|
|
334
|
+
return this.createClient(login).post(`database/item?namespace=${namespace}&key=${key}&value${typeHintParam}=${value}`);
|
|
311
335
|
}
|
|
312
336
|
async deleteDatabaseNamespaceItem(login, namespace, key) {
|
|
313
|
-
return this.
|
|
337
|
+
return this.createClient(login).delete(`database/item?namespace=${namespace}&key=${key}`);
|
|
314
338
|
}
|
|
315
339
|
async getJobQueueStatus(login) {
|
|
316
|
-
return this.
|
|
340
|
+
return this.createClient(login).get(`job_queue/status`);
|
|
317
341
|
}
|
|
318
342
|
async postJobQueueJob(login, filenames, reset) {
|
|
319
|
-
return this.
|
|
343
|
+
return this.createClient(login).post(`job_queue/job`, {
|
|
320
344
|
filenames,
|
|
321
345
|
reset
|
|
322
346
|
});
|
|
323
347
|
}
|
|
324
348
|
async deleteJobQueueJob(login, jobIds, all) {
|
|
325
|
-
const base =
|
|
349
|
+
const base = `job_queue/job`;
|
|
326
350
|
const url = !!all ? `${base}?all=true` : `${base}?job_ids=${jobIds.join(",")}`;
|
|
327
|
-
return this.
|
|
351
|
+
return this.createClient(login).delete(url);
|
|
328
352
|
}
|
|
329
353
|
async postJobQueuePause(login) {
|
|
330
|
-
return this.
|
|
354
|
+
return this.createClient(login).post(`job_queue/pause`);
|
|
331
355
|
}
|
|
332
356
|
async postJobQueueStart(login) {
|
|
333
|
-
return this.
|
|
357
|
+
return this.createClient(login).post(`job_queue/start`);
|
|
334
358
|
}
|
|
335
359
|
async postJobQueueJump(login, jobId) {
|
|
336
|
-
return this.
|
|
360
|
+
return this.createClient(login).post(`job_queue/jump?job_id=${jobId}`);
|
|
337
361
|
}
|
|
338
362
|
async getAnnouncementsList(login, includeDismissed) {
|
|
339
|
-
return this.
|
|
363
|
+
return this.createClient(login).get(`server/announcements/list?include_dismissed=${includeDismissed}`);
|
|
340
364
|
}
|
|
341
365
|
async postAnnouncementsUpdate(login) {
|
|
342
|
-
return this.
|
|
366
|
+
return this.createClient(login).post(`server/announcements/update`);
|
|
343
367
|
}
|
|
344
368
|
async postAnnouncementsDismiss(login, entryId, wakeTime) {
|
|
345
|
-
return this.
|
|
369
|
+
return this.createClient(login).post(`server/announcements/dismiss?entry_id=${encodeURIComponent(entryId)}&wake_time=${wakeTime}`);
|
|
346
370
|
}
|
|
347
371
|
async getAnnouncementsFeeds(login) {
|
|
348
|
-
return this.
|
|
372
|
+
return this.createClient(login).get(`server/announcements/feeds`);
|
|
349
373
|
}
|
|
350
374
|
async postAnnouncementsFeedAdd(login, name) {
|
|
351
|
-
return this.
|
|
375
|
+
return this.createClient(login).get(`server/announcements/feeds?name=${name}`);
|
|
352
376
|
}
|
|
353
377
|
async deleteAnnouncementsFeedRemove(login, name) {
|
|
354
|
-
return this.
|
|
378
|
+
return this.createClient(login).delete(`server/announcements/feeds?name=${name}`);
|
|
355
379
|
}
|
|
356
380
|
async getWebcamList(login) {
|
|
357
|
-
return this.
|
|
381
|
+
return this.createClient(login).get(`server/webcams/list`);
|
|
358
382
|
}
|
|
359
383
|
async getWebcamItem(login, uid, name) {
|
|
360
|
-
const base =
|
|
384
|
+
const base = `server/webcams/get_item`;
|
|
361
385
|
const url = !!uid?.length ? `${base}?uid=${uid}` : `${base}?name=${name}`;
|
|
362
|
-
return this.
|
|
386
|
+
return this.createClient(login).get(url);
|
|
363
387
|
}
|
|
364
388
|
async postWebcamItemUpdate(login, webcam) {
|
|
365
|
-
return this.
|
|
389
|
+
return this.createClient(login).post(`server/webcams/post_item`, webcam);
|
|
366
390
|
}
|
|
367
391
|
async deleteWebcamItem(login, uid, name) {
|
|
368
|
-
const base =
|
|
392
|
+
const base = `server/webcams/delete_item`;
|
|
369
393
|
const url = !!uid?.length ? `${base}?uid=${uid}` : `${base}?name=${name}`;
|
|
370
|
-
return this.
|
|
394
|
+
return this.createClient(login).get(url);
|
|
371
395
|
}
|
|
372
396
|
async postWebcamTest(login, uid, name) {
|
|
373
|
-
const base =
|
|
397
|
+
const base = `server/webcams/test`;
|
|
374
398
|
const url = !!uid?.length ? `${base}?uid=${uid}` : `${base}?name=${name}`;
|
|
375
|
-
return this.
|
|
399
|
+
return this.createClient(login).get(url);
|
|
376
400
|
}
|
|
377
401
|
async getNotifierList(login) {
|
|
378
|
-
return this.
|
|
402
|
+
return this.createClient(login).get(`server/notifiers/list`);
|
|
379
403
|
}
|
|
380
404
|
async postMachineUpdateStatus(login) {
|
|
381
|
-
return this.
|
|
405
|
+
return this.createClient(login).post(`machine/update/status`);
|
|
382
406
|
}
|
|
383
407
|
async postMachineUpdateRefresh(login, name) {
|
|
384
|
-
const base =
|
|
408
|
+
const base = `machine/update/refresh`;
|
|
385
409
|
const url = !!name ? `${base}` : `${base}?name=${name}`;
|
|
386
|
-
return this.
|
|
410
|
+
return this.createClient(login).post(url);
|
|
387
411
|
}
|
|
388
412
|
async postMachineUpdateFull(login) {
|
|
389
|
-
return this.
|
|
413
|
+
return this.createClient(login).post(`machine/update/full`);
|
|
390
414
|
}
|
|
391
415
|
async postMachineUpdateMoonraker(login) {
|
|
392
|
-
return this.
|
|
416
|
+
return this.createClient(login).post(`machine/update/moonraker`);
|
|
393
417
|
}
|
|
394
418
|
async postMachineUpdateKlipper(login) {
|
|
395
|
-
return this.
|
|
419
|
+
return this.createClient(login).post(`machine/update/klipper`);
|
|
396
420
|
}
|
|
397
421
|
async postMachineUpdateClient(login, name) {
|
|
398
|
-
return this.
|
|
422
|
+
return this.createClient(login).post(`machine/update/client?name=${name}`);
|
|
399
423
|
}
|
|
400
424
|
async postMachineUpdateSystem(login) {
|
|
401
|
-
return this.
|
|
425
|
+
return this.createClient(login).post(`machine/update/system`);
|
|
402
426
|
}
|
|
403
427
|
async postMachineUpdateRecover(login, name, hard = false) {
|
|
404
|
-
return this.
|
|
428
|
+
return this.createClient(login).post(`machine/update/recover?name=${name}&hard=${hard}`);
|
|
405
429
|
}
|
|
406
430
|
async postMachineUpdateRollback(login, name) {
|
|
407
|
-
return this.
|
|
431
|
+
return this.createClient(login).post(`machine/update/rollback?name=${name}`);
|
|
408
432
|
}
|
|
409
433
|
async getMachineDevicePowerDevices(login) {
|
|
410
|
-
return this.
|
|
434
|
+
return this.createClient(login).get(`machine/device_power/devices`);
|
|
411
435
|
}
|
|
412
436
|
async getMachineDevicePowerDeviceState(login, device) {
|
|
413
|
-
return this.
|
|
437
|
+
return this.createClient(login).get(`machine/device_power/device?device=${device}`);
|
|
414
438
|
}
|
|
415
439
|
async postMachineDevicePowerDeviceState(login, device, action) {
|
|
416
|
-
return this.
|
|
440
|
+
return this.createClient(login).post(`machine/device_power/device?device=${device}&action=${action}`);
|
|
417
441
|
}
|
|
418
442
|
async getMachineDevicePowerBatchDeviceState(login, devices) {
|
|
419
|
-
return this.
|
|
443
|
+
return this.createClient(login).get(`machine/device_power/status?${devices.join("&")}`);
|
|
420
444
|
}
|
|
421
445
|
async postMachineDevicePowerBatchPowerOn(login, device) {
|
|
422
|
-
return this.
|
|
446
|
+
return this.createClient(login).post(`machine/device_power/on?device=${device}`);
|
|
423
447
|
}
|
|
424
448
|
async postMachineDevicePowerBatchPowerOff(login, device) {
|
|
425
|
-
return this.
|
|
449
|
+
return this.createClient(login).post(`machine/device_power/off?device=${device}`);
|
|
426
450
|
}
|
|
427
451
|
async getMachineWledStrips(login) {
|
|
428
|
-
return this.
|
|
452
|
+
return this.createClient(login).get(`machine/wled/strips`);
|
|
429
453
|
}
|
|
430
454
|
async getMachineWledStatuses(login, strips) {
|
|
431
|
-
return this.
|
|
455
|
+
return this.createClient(login).get(`machine/wled/status?${strips.join("&")}`);
|
|
432
456
|
}
|
|
433
457
|
async postMachineWledPowerOn(login, strips) {
|
|
434
|
-
return this.
|
|
458
|
+
return this.createClient(login).post(`machine/wled/on?${strips.join("&")}`);
|
|
435
459
|
}
|
|
436
460
|
async postMachineWledPowerOff(login, strips) {
|
|
437
|
-
return this.
|
|
461
|
+
return this.createClient(login).post(`machine/wled/off?${strips.join("&")}`);
|
|
438
462
|
}
|
|
439
463
|
async postMachineWledPowerStripAction(login, strips) {
|
|
440
|
-
return this.
|
|
464
|
+
return this.createClient(login).post(`machine/wled/toggle?${strips.join("&")}`);
|
|
441
465
|
}
|
|
442
466
|
async getMachineWledStripAction(login, strip, action, controlParams) {
|
|
443
467
|
const queryParams = Object.entries(controlParams).map(([k, v])=>`${k}=${v}`).join("&");
|
|
444
|
-
return this.
|
|
468
|
+
return this.createClient(login).get(`machine/wled/strip?strip=${strip}&action=${action}&${queryParams}`);
|
|
445
469
|
}
|
|
446
470
|
async getServerSensorsList(login) {
|
|
447
|
-
return this.
|
|
471
|
+
return this.createClient(login).get(`server/sensors/list`);
|
|
448
472
|
}
|
|
449
473
|
async getServerSensorItem(login, sensor) {
|
|
450
|
-
return this.
|
|
474
|
+
return this.createClient(login).get(`server/sensors/info?sensor=${sensor}`);
|
|
451
475
|
}
|
|
452
476
|
async getServerSensorMeasurements(login, sensor) {
|
|
453
|
-
return this.
|
|
477
|
+
return this.createClient(login).get(`server/sensors/measurements?sensor=${sensor}`);
|
|
454
478
|
}
|
|
455
479
|
async getServerSensorMeasurementsBatch(login) {
|
|
456
|
-
return this.
|
|
480
|
+
return this.createClient(login).get(`server/sensors/measurements`);
|
|
457
481
|
}
|
|
458
482
|
async getServerSpoolmanStatus(login) {
|
|
459
|
-
return this.
|
|
483
|
+
return this.createClient(login).get(`server/spoolman/status`);
|
|
460
484
|
}
|
|
461
485
|
async postServerSpoolmanActiveSpool(login, spoolId) {
|
|
462
|
-
return this.
|
|
486
|
+
return this.createClient(login).post(`server/spoolman/spool_id`, {
|
|
463
487
|
spool_id: spoolId
|
|
464
488
|
});
|
|
465
489
|
}
|
|
466
490
|
async getServerSpoolmanActiveSpool(login) {
|
|
467
|
-
return this.
|
|
491
|
+
return this.createClient(login).get(`server/spoolman/spool_id`);
|
|
468
492
|
}
|
|
469
493
|
async postServerSpoolmanProxyRequest(login, body) {
|
|
470
|
-
return this.
|
|
494
|
+
return this.createClient(login).post(`server/spoolman/proxy`, body);
|
|
471
495
|
}
|
|
472
496
|
async getApiVersion(login) {
|
|
473
|
-
return this.
|
|
497
|
+
return this.createClient(login).get(`api/version`);
|
|
474
498
|
}
|
|
475
499
|
async getServerVersion(login) {
|
|
476
|
-
return this.
|
|
500
|
+
return this.createClient(login).get(`api/server`);
|
|
477
501
|
}
|
|
478
502
|
async getApiLogin(login) {
|
|
479
|
-
return this.
|
|
503
|
+
return this.createClient(login).get(`api/login`);
|
|
480
504
|
}
|
|
481
505
|
async getApiSettings(login) {
|
|
482
|
-
return this.
|
|
506
|
+
return this.createClient(login).get(`api/settings`);
|
|
483
507
|
}
|
|
484
508
|
async getApiJob(login) {
|
|
485
|
-
return this.
|
|
509
|
+
return this.createClient(login).get(`api/job`);
|
|
486
510
|
}
|
|
487
511
|
async getApiPrinter(login) {
|
|
488
|
-
return this.
|
|
512
|
+
return this.createClient(login).get(`api/printer`);
|
|
489
513
|
}
|
|
490
514
|
async postApiPrinterCommand(login, commands) {
|
|
491
|
-
return this.
|
|
515
|
+
return this.createClient(login).post(`api/command`, {
|
|
492
516
|
commands
|
|
493
517
|
});
|
|
494
518
|
}
|
|
495
519
|
async getApiProfiles(login) {
|
|
496
|
-
return this.
|
|
520
|
+
return this.createClient(login).get(`api/printerprofiles`);
|
|
497
521
|
}
|
|
498
522
|
async getServerHistoryList(login, limit, start, since, before, order = "desc") {
|
|
499
523
|
let params = `limit=${limit}&start=${start}&order=${order}`;
|
|
@@ -503,21 +527,37 @@ class MoonrakerClient {
|
|
|
503
527
|
if (!!since || since === 0) {
|
|
504
528
|
params += "&since=" + since;
|
|
505
529
|
}
|
|
506
|
-
return this.
|
|
530
|
+
return this.createClient(login).get(`server/history/list?${params}`);
|
|
507
531
|
}
|
|
508
532
|
async getServerHistoryTotals(login) {
|
|
509
|
-
return this.
|
|
533
|
+
return this.createClient(login).get(`server/history/totals`);
|
|
510
534
|
}
|
|
511
535
|
async postServerHistoryResetTotals(login) {
|
|
512
|
-
return this.
|
|
536
|
+
return this.createClient(login).post(`server/history/reset_totals`);
|
|
513
537
|
}
|
|
514
538
|
async getServerHistoryJob(login, uid) {
|
|
515
|
-
return this.
|
|
539
|
+
return this.createClient(login).get(`server/history/job?uid=${uid}`);
|
|
516
540
|
}
|
|
517
541
|
async deleteServerHistoryJob(login, uid) {
|
|
518
|
-
const base =
|
|
542
|
+
const base = `server/history/job`;
|
|
519
543
|
const url = !!uid?.length ? `${base}?uid=${uid}` : `${base}?all=true`;
|
|
520
|
-
return this.
|
|
544
|
+
return this.createClient(login).get(url);
|
|
545
|
+
}
|
|
546
|
+
createClient(login, buildFluentOptions) {
|
|
547
|
+
const baseAddress = login.printerURL;
|
|
548
|
+
return this.createAnonymousClient(baseAddress, (o)=>{
|
|
549
|
+
if (buildFluentOptions) {
|
|
550
|
+
buildFluentOptions(o);
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
createAnonymousClient(baseAddress, buildFluentOptions) {
|
|
555
|
+
const builder = new _defaulthttpclientbuilder.DefaultHttpClientBuilder();
|
|
556
|
+
return this.httpClientFactory.createClientWithBaseUrl(builder, baseAddress, (b)=>{
|
|
557
|
+
if (buildFluentOptions) {
|
|
558
|
+
buildFluentOptions(b);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
521
561
|
}
|
|
522
562
|
}
|
|
523
563
|
|