Skip to content

Commit

Permalink
feat: implement basics of moonraker API
Browse files Browse the repository at this point in the history
  • Loading branch information
David Zwart committed Mar 26, 2024
1 parent b947d87 commit 0312919
Show file tree
Hide file tree
Showing 28 changed files with 659 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface MachineDevicePowerDeviceStateDto {
[k: string]: "off" | "on";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface MachineDevicePowerDevicesDto {
devices: Device[];
}

export interface Device {
device: string;
status: string;
locked_while_printing: boolean;
type: string;
}
115 changes: 115 additions & 0 deletions src/services/moonraker/dto/machine/machine-update-status.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
export interface MachineUpdateStatusDto {
busy: boolean;
github_rate_limit: number;
github_requests_remaining: number;
github_limit_reset_time: number;
version_info: VersionInfo;
}

export interface VersionInfo {
system: System;
moonraker: Moonraker;
mainsail: Mainsail;
fluidd: Fluidd;
klipper: Klipper;
}

export interface System {
package_count: number;
package_list: string[];
}

export interface Moonraker {
channel: string;
debug_enabled: boolean;
is_valid: boolean;
configured_type: string;
corrupt: boolean;
info_tags: any[];
detected_type: string;
remote_alias: string;
branch: string;
owner: string;
repo_name: string;
version: string;
remote_version: string;
rollback_version: string;
current_hash: string;
remote_hash: string;
is_dirty: boolean;
detached: boolean;
commits_behind: any[];
git_messages: any[];
full_version_string: string;
pristine: boolean;
recovery_url: string;
remote_url: string;
warnings: any[];
anomalies: string[];
}

export interface Mainsail {
name: string;
owner: string;
version: string;
remote_version: string;
rollback_version: string;
configured_type: string;
channel: string;
info_tags: string[];
warnings: any[];
anomalies: any[];
is_valid: boolean;
}

export interface Fluidd {
name: string;
owner: string;
version: string;
remote_version: string;
rollback_version: string;
configured_type: string;
channel: string;
info_tags: any[];
warnings: any[];
anomalies: any[];
is_valid: boolean;
}

export interface Klipper {
channel: string;
debug_enabled: boolean;
is_valid: boolean;
configured_type: string;
corrupt: boolean;
info_tags: any[];
detected_type: string;
remote_alias: string;
branch: string;
owner: string;
repo_name: string;
version: string;
remote_version: string;
rollback_version: string;
current_hash: string;
remote_hash: string;
is_dirty: boolean;
detached: boolean;
commits_behind: CommitsBehind[];
git_messages: any[];
full_version_string: string;
pristine: boolean;
recovery_url: string;
remote_url: string;
warnings: any[];
anomalies: any[];
}

export interface CommitsBehind {
sha: string;
author: string;
date: string;
subject: string;
message: string;
tag: any;
}
20 changes: 20 additions & 0 deletions src/services/moonraker/dto/machine/machine-wled-strips.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface MachineWledStripsDto {
strips: Strips;
}

export interface Strips {
lights: StripStatus;
desk: StripStatus;
[k: string]: StripStatus;
}

export interface StripStatus {
strip: string;
status: string;
chain_count: number;
preset: number;
brightness: number;
intensity: number;
speed: number;
error: any;
}
File renamed without changes.
28 changes: 28 additions & 0 deletions src/services/moonraker/dto/octoprint-compat/api-job.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface ApiJobDto {
job: Job;
progress: Progress;
state: string;
}

export interface Job {
file: File;
estimatedPrintTime: any;
filament: Filament;
user: any;
}

export interface File {
name: any;
}

export interface Filament {
length: any;
}

export interface Progress {
completion: any;
filepos: any;
printTime: any;
printTimeLeft: any;
printTimeOrigin: any;
}
11 changes: 11 additions & 0 deletions src/services/moonraker/dto/octoprint-compat/api-login.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface ApiLoginDto {
_is_external_client: boolean;
_login_mechanism: string;
name: string;
active: boolean;
user: boolean;
admin: boolean;
apikey: any;
permissions: any[];
groups: string[];
}
40 changes: 40 additions & 0 deletions src/services/moonraker/dto/octoprint-compat/api-printer.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface ApiPrinterDto {
temperature: Temperature;
state: State;
}

export interface Temperature {
tool0: Tool0;
bed: Bed;
"...additionalHeaters": AdditionalHeaters;
}

export interface Tool0 {
actual: number;
offset: number;
target: number;
}

export interface Bed {
actual: number;
offset: number;
target: number;
}

export interface AdditionalHeaters {}

export interface State {
text: string;
flags: Flags;
}

export interface Flags {
operational: boolean;
paused: boolean;
printing: boolean;
cancelling: boolean;
pausing: boolean;
error: boolean;
ready: boolean;
closedOrError: boolean;
}
18 changes: 18 additions & 0 deletions src/services/moonraker/dto/octoprint-compat/api-profiles.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface ApiProfilesDto {
profiles: Profiles;
}

export interface Profiles {
_default: Default;
}

export interface Default {
id: string;
name: string;
color: string;
model: string;
default: boolean;
current: boolean;
heatedBed: boolean;
heatedChamber: boolean;
}
33 changes: 33 additions & 0 deletions src/services/moonraker/dto/octoprint-compat/api-settings.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export interface ApiSettingsDto {
plugins: Plugins;
feature: Feature;
webcam: Webcam;
}

export interface Plugins {
UltimakerFormatPackage: UltimakerFormatPackage;
}

export interface UltimakerFormatPackage {
align_inline_thumbnail: boolean;
inline_thumbnail: boolean;
inline_thumbnail_align_value: string;
inline_thumbnail_scale_value: string;
installed: boolean;
installed_version: string;
scale_inline_thumbnail: boolean;
state_panel_thumbnail: boolean;
}

export interface Feature {
sdSupport: boolean;
temperatureGraph: boolean;
}

export interface Webcam {
flipH: boolean;
flipV: boolean;
rotate90: boolean;
streamUrl: string;
webcamEnabled: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ApiVersionDto {
server: string;
api: string;
text: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ServerVersionDto {
server: string;
safemode: string;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export interface RpcErrorDto {
export interface JsonRpcErrorDto {
jsonrpc: string;
error: Error;
id: number;
}

export interface Error {
code: number
message: string
code: number;
message: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export interface JsonRpcRequestDto {
jsonrpc: string;
export interface JsonRpcRequestDto<I = Record<string, any>> {
jsonrpc: "2.0" | string;
method: string;
id: number;
// MQTT may provide mqtt_timestamp param
// "To avoid potential collisions from time drift it is recommended to specify the timestamp in microseconds since the Unix Epoch"
// QoS 0 or 2
params: Record<string, any>;
id: number;
params?: I;
}
5 changes: 5 additions & 0 deletions src/services/moonraker/dto/rpc/json-rpc-response.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface JsonRpcResponseDto<T> {
jsonrpc: "2.0" | string;
id: number;
result: T;
}
5 changes: 0 additions & 5 deletions src/services/moonraker/dto/rpc/rpc-response.dto.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/services/moonraker/dto/server-history/history-job.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { JobDto } from "@/services/moonraker/dto/server-history/history-list.dto";

export interface HistoryJobDto {
job: JobDto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { JobTotals } from "@/services/moonraker/dto/server-history/history-totals.dto";

export interface HistoryLastTotalsDto {
last_totals: JobTotals;
}
19 changes: 19 additions & 0 deletions src/services/moonraker/dto/server-history/history-list.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface HistoryListDto {
count: number;
jobs: JobDto[];
}

export interface JobDto {
job_id: string;
exists: boolean;
end_time: number;
filament_used: number;
filename: string;
metadata: Metadata;
print_duration: number;
status: string;
start_time: number;
total_duration: number;
}

export interface Metadata {}
12 changes: 12 additions & 0 deletions src/services/moonraker/dto/server-history/history-totals.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface HistoryTotalsDto {
job_totals: JobTotals;
}

export interface JobTotals {
total_jobs: number;
total_time: number;
total_print_time: number;
total_filament_used: number;
longest_job: number;
longest_print: number;
}
12 changes: 12 additions & 0 deletions src/services/moonraker/dto/server-sensors/sensor-info.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface SensorDto {
id: string;
friendly_name: string;
type: string;
values: SensorValues;
}

export interface SensorValues {
value1: number;
value2: number;
[k: string]: number;
}
Loading

0 comments on commit 0312919

Please sign in to comment.