rosinterface 1.3.6 → 1.4.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.
@@ -0,0 +1,217 @@
1
+ import { MikrotikClient, IWriteOptions } from "../client/MikrotikClient";
2
+ export declare class PPPWrapper {
3
+ private client;
4
+ constructor(client: MikrotikClient);
5
+ /**
6
+ * **Retrieve: PPP Secrets (PRINT)**
7
+ *
8
+ * Sends a `/ppp/secret/print` command to list user accounts.
9
+ *
10
+ * **Feature: Filtered Search**
11
+ * You can pass a dictionary of parameters to filter the results directly on the router,
12
+ * reducing the amount of data transferred over the network.
13
+ *
14
+ * @param filter Optional dictionary to filter results (e.g., `{"?profile": "Plan_50M"}`).
15
+ * @param options Advanced write options (idempotency, forced protocol).
16
+ * @returns A promise resolving to an array of secret objects.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Get all users
21
+ * const allUsers = await mk.ppp.getSecrets();
22
+ * * // Get users assigned to a specific profile
23
+ * const basicUsers = await mk.ppp.getSecrets({ "?profile": "Plan_20M" });
24
+ * ```
25
+ */
26
+ getSecrets(filter?: Record<string, string>, options?: IWriteOptions): Promise<any[]>;
27
+ /**
28
+ * **Resource Creation: PPP Secret (ADD)**
29
+ *
30
+ * Sends a `/ppp/secret/add` command to create a new PPPoE user account.
31
+ *
32
+ * **Feature: Account Provisioning**
33
+ * Essential for onboarding new clients, allowing you to specify their
34
+ * authentication credentials and link them to a specific bandwidth profile.
35
+ *
36
+ * @param name The username for the PPPoE connection.
37
+ * @param password The password for the connection.
38
+ * @param profile The PPP profile (plan) to assign. Defaults to 'default'.
39
+ * @param service The service type. Defaults to 'pppoe'.
40
+ * @param options Advanced write options.
41
+ * @returns A promise resolving to the API response.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Add a new client with a specific plan
46
+ * await mk.ppp.addSecret('john_doe', 'securePass123', 'Plan_50M');
47
+ * ```
48
+ */
49
+ addSecret(name: string, password: string, profile?: string, service?: string, additionalParams?: Record<string, string | boolean | number>, options?: IWriteOptions): Promise<any[]>;
50
+ /**
51
+ * **Resource Modification: Update Secret (SET)**
52
+ *
53
+ * Sends a `/ppp/secret/set` command to modify an existing user account.
54
+ *
55
+ * **Feature: Dynamic Provisioning**
56
+ * Automatically resolves the internal `.id` based on the username and applies
57
+ * the new parameters. Useful for changing passwords or upgrading plans.
58
+ *
59
+ * @param name The exact username of the secret to modify.
60
+ * @param paramsToUpdate Dictionary containing the fields to update.
61
+ * @param options Advanced write options.
62
+ * @returns A promise resolving to the API response.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * // Upgrade a user's plan and change their password
67
+ * await mk.ppp.setSecret('john_doe', {
68
+ * profile: 'Plan_100M',
69
+ * password: 'newPassword456'
70
+ * });
71
+ * ```
72
+ */
73
+ setSecret(name: string, paramsToUpdate: Record<string, string | boolean | number>, options?: IWriteOptions): Promise<any[]>;
74
+ /**
75
+ * **State Modification: Enable Secret (ENABLE)**
76
+ *
77
+ * Sends a `/ppp/secret/enable` command to activate a previously disabled account.
78
+ *
79
+ * **Feature: Service Reactivation**
80
+ * Restores access for a client, typically used automatically after an invoice is paid.
81
+ *
82
+ * @param name The username to enable.
83
+ * @param options Advanced write options.
84
+ * @returns A promise resolving to the API response.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // Reactivate service for a user who paid their invoice
89
+ * await mk.ppp.enableSecret('john_doe');
90
+ * ```
91
+ */
92
+ enableSecret(name: string, options?: IWriteOptions): Promise<any[]>;
93
+ /**
94
+ * **State Modification: Disable Secret (DISABLE)**
95
+ *
96
+ * Sends a `/ppp/secret/disable` command to suspend a user account.
97
+ *
98
+ * **Feature: Service Suspension**
99
+ * Prevents the user from authenticating. Does not drop active connections
100
+ * automatically (use `killActiveSession` for that).
101
+ *
102
+ * @param name The username to disable.
103
+ * @param options Advanced write options.
104
+ * @returns A promise resolving to the API response.
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Suspend a user for non-payment
109
+ * await mk.ppp.disableSecret('john_doe');
110
+ * * // Note: To immediately drop their connection, call killActiveSession() after this.
111
+ * ```
112
+ */
113
+ disableSecret(name: string, options?: IWriteOptions): Promise<any[]>;
114
+ /**
115
+ * **Execution Terminator: Delete Secret (REMOVE)**
116
+ *
117
+ * Sends a `/ppp/secret/remove` command to permanently delete a user account.
118
+ *
119
+ * **Feature: Safe Deletion**
120
+ * Searches for the exact dynamic ID before attempting removal, preventing errors.
121
+ *
122
+ * @param name The username to delete.
123
+ * @param options Advanced write options.
124
+ * @returns A promise resolving to the API response.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Delete a user who canceled their subscription
129
+ * try {
130
+ * await mk.ppp.removeSecret('john_doe');
131
+ * console.log('User deleted successfully');
132
+ * } catch (error) {
133
+ * console.error(error.message);
134
+ * }
135
+ * ```
136
+ */
137
+ removeSecret(name: string, options?: IWriteOptions): Promise<any[]>;
138
+ /**
139
+ * **Retrieve: Active Sessions (PRINT)**
140
+ *
141
+ * Sends a `/ppp/active/print` command to list currently connected sessions.
142
+ *
143
+ * **Feature: Real-time Monitoring**
144
+ * Allows you to check who is currently authenticated and connected to the router.
145
+ *
146
+ * @param filter Optional dictionary to filter results (e.g., searching by IP).
147
+ * @param options Advanced write options.
148
+ * @returns A promise resolving to an array of active connection objects.
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * // Check if a specific user is currently online
153
+ * const activeSessions = await mk.ppp.getActiveConnections({ "?name": "john_doe" });
154
+ * const isOnline = activeSessions.length > 0;
155
+ * ```
156
+ */
157
+ getActiveConnections(filter?: Record<string, string>, options?: IWriteOptions): Promise<any[]>;
158
+ /**
159
+ * **Execution Terminator: Disconnect Session (REMOVE)**
160
+ *
161
+ * Sends a `/ppp/active/remove` command to force an active session to disconnect.
162
+ *
163
+ * **Feature: Session Management**
164
+ * Ideal for forcing a reconnection after changing a profile, upgrading bandwidth,
165
+ * or suspending service, ensuring the new rules apply immediately.
166
+ *
167
+ * @param name The username of the active session to disconnect.
168
+ * @param options Advanced write options.
169
+ * @returns A promise resolving to the API response, or false if the user wasn't active.
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // Suspend user and immediately drop their current session
174
+ * await mk.ppp.disableSecret('john_doe');
175
+ * await mk.ppp.killActiveSession('john_doe');
176
+ * ```
177
+ */
178
+ killActiveSession(name: string, options?: IWriteOptions): Promise<false | any[]>;
179
+ /**
180
+ * **Retrieve: PPP Profiles (PRINT)**
181
+ *
182
+ * Sends a `/ppp/profile/print` command to list existing service plans.
183
+ *
184
+ * @param filter Optional dictionary to filter results.
185
+ * @param options Advanced write options.
186
+ * @returns A promise resolving to an array of profile objects.
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * // Get all configured plans on the router
191
+ * const profiles = await mk.ppp.getProfiles();
192
+ * ```
193
+ */
194
+ getProfiles(filter?: Record<string, string>, options?: IWriteOptions): Promise<any[]>;
195
+ /**
196
+ * **Resource Creation: PPP Profile (ADD)**
197
+ *
198
+ * Sends a `/ppp/profile/add` command to create a new service plan.
199
+ *
200
+ * **Feature: Bandwidth Allocation**
201
+ * Defines a centralized template for speed limits and routing rules that
202
+ * can be assigned to multiple PPPoE secrets.
203
+ *
204
+ * @param name The name of the new profile.
205
+ * @param rateLimit The bandwidth limit format (Rx/Tx) e.g., '10M/20M'.
206
+ * @param localAddress The local IP address for the tunnel endpoint. Defaults to '192.168.89.1'.
207
+ * @param options Advanced write options.
208
+ * @returns A promise resolving to the API response.
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * // Create a 50 Megabit download / 20 Megabit upload plan
213
+ * await mk.ppp.addProfile('Plan_50M', '20M/50M', '10.0.0.1');
214
+ * ```
215
+ */
216
+ addProfile(name: string, rateLimit: string, localAddress?: string, options?: IWriteOptions): Promise<any[]>;
217
+ }
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PPPWrapper = void 0;
4
+ class PPPWrapper {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ // ==========================================
9
+ // SECRETS (User Management)
10
+ // ==========================================
11
+ /**
12
+ * **Retrieve: PPP Secrets (PRINT)**
13
+ *
14
+ * Sends a `/ppp/secret/print` command to list user accounts.
15
+ *
16
+ * **Feature: Filtered Search**
17
+ * You can pass a dictionary of parameters to filter the results directly on the router,
18
+ * reducing the amount of data transferred over the network.
19
+ *
20
+ * @param filter Optional dictionary to filter results (e.g., `{"?profile": "Plan_50M"}`).
21
+ * @param options Advanced write options (idempotency, forced protocol).
22
+ * @returns A promise resolving to an array of secret objects.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Get all users
27
+ * const allUsers = await mk.ppp.getSecrets();
28
+ * * // Get users assigned to a specific profile
29
+ * const basicUsers = await mk.ppp.getSecrets({ "?profile": "Plan_20M" });
30
+ * ```
31
+ */
32
+ async getSecrets(filter, options) {
33
+ return this.client.write('/ppp/secret/print', filter || {}, options);
34
+ }
35
+ /**
36
+ * **Resource Creation: PPP Secret (ADD)**
37
+ *
38
+ * Sends a `/ppp/secret/add` command to create a new PPPoE user account.
39
+ *
40
+ * **Feature: Account Provisioning**
41
+ * Essential for onboarding new clients, allowing you to specify their
42
+ * authentication credentials and link them to a specific bandwidth profile.
43
+ *
44
+ * @param name The username for the PPPoE connection.
45
+ * @param password The password for the connection.
46
+ * @param profile The PPP profile (plan) to assign. Defaults to 'default'.
47
+ * @param service The service type. Defaults to 'pppoe'.
48
+ * @param options Advanced write options.
49
+ * @returns A promise resolving to the API response.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Add a new client with a specific plan
54
+ * await mk.ppp.addSecret('john_doe', 'securePass123', 'Plan_50M');
55
+ * ```
56
+ */
57
+ async addSecret(name, password, profile = 'default', service = 'pppoe', additionalParams, options) {
58
+ return this.client.write('/ppp/secret/add', {
59
+ name,
60
+ password,
61
+ profile,
62
+ service,
63
+ ...additionalParams
64
+ }, options);
65
+ }
66
+ /**
67
+ * **Resource Modification: Update Secret (SET)**
68
+ *
69
+ * Sends a `/ppp/secret/set` command to modify an existing user account.
70
+ *
71
+ * **Feature: Dynamic Provisioning**
72
+ * Automatically resolves the internal `.id` based on the username and applies
73
+ * the new parameters. Useful for changing passwords or upgrading plans.
74
+ *
75
+ * @param name The exact username of the secret to modify.
76
+ * @param paramsToUpdate Dictionary containing the fields to update.
77
+ * @param options Advanced write options.
78
+ * @returns A promise resolving to the API response.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * // Upgrade a user's plan and change their password
83
+ * await mk.ppp.setSecret('john_doe', {
84
+ * profile: 'Plan_100M',
85
+ * password: 'newPassword456'
86
+ * });
87
+ * ```
88
+ */
89
+ async setSecret(name, paramsToUpdate, options) {
90
+ const result = await this.getSecrets({ "?name": name }, options);
91
+ if (result.length > 0 && result[0]['.id']) {
92
+ return this.client.write('/ppp/secret/set', {
93
+ ".id": result[0]['.id'],
94
+ ...paramsToUpdate // Inject new values
95
+ }, options);
96
+ }
97
+ throw new Error(`PPP Secret '${name}' not found.`);
98
+ }
99
+ /**
100
+ * **State Modification: Enable Secret (ENABLE)**
101
+ *
102
+ * Sends a `/ppp/secret/enable` command to activate a previously disabled account.
103
+ *
104
+ * **Feature: Service Reactivation**
105
+ * Restores access for a client, typically used automatically after an invoice is paid.
106
+ *
107
+ * @param name The username to enable.
108
+ * @param options Advanced write options.
109
+ * @returns A promise resolving to the API response.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * // Reactivate service for a user who paid their invoice
114
+ * await mk.ppp.enableSecret('john_doe');
115
+ * ```
116
+ */
117
+ async enableSecret(name, options) {
118
+ const result = await this.getSecrets({ "?name": name }, options);
119
+ if (result.length > 0 && result[0]['.id']) {
120
+ return this.client.write('/ppp/secret/enable', {
121
+ ".id": result[0]['.id']
122
+ }, options);
123
+ }
124
+ throw new Error(`PPP Secret '${name}' not found.`);
125
+ }
126
+ /**
127
+ * **State Modification: Disable Secret (DISABLE)**
128
+ *
129
+ * Sends a `/ppp/secret/disable` command to suspend a user account.
130
+ *
131
+ * **Feature: Service Suspension**
132
+ * Prevents the user from authenticating. Does not drop active connections
133
+ * automatically (use `killActiveSession` for that).
134
+ *
135
+ * @param name The username to disable.
136
+ * @param options Advanced write options.
137
+ * @returns A promise resolving to the API response.
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * // Suspend a user for non-payment
142
+ * await mk.ppp.disableSecret('john_doe');
143
+ * * // Note: To immediately drop their connection, call killActiveSession() after this.
144
+ * ```
145
+ */
146
+ async disableSecret(name, options) {
147
+ const result = await this.getSecrets({ "?name": name }, options);
148
+ if (result.length > 0 && result[0]['.id']) {
149
+ return this.client.write('/ppp/secret/disable', {
150
+ ".id": result[0]['.id']
151
+ }, options);
152
+ }
153
+ throw new Error(`PPP Secret '${name}' not found.`);
154
+ }
155
+ /**
156
+ * **Execution Terminator: Delete Secret (REMOVE)**
157
+ *
158
+ * Sends a `/ppp/secret/remove` command to permanently delete a user account.
159
+ *
160
+ * **Feature: Safe Deletion**
161
+ * Searches for the exact dynamic ID before attempting removal, preventing errors.
162
+ *
163
+ * @param name The username to delete.
164
+ * @param options Advanced write options.
165
+ * @returns A promise resolving to the API response.
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * // Delete a user who canceled their subscription
170
+ * try {
171
+ * await mk.ppp.removeSecret('john_doe');
172
+ * console.log('User deleted successfully');
173
+ * } catch (error) {
174
+ * console.error(error.message);
175
+ * }
176
+ * ```
177
+ */
178
+ async removeSecret(name, options) {
179
+ const result = await this.getSecrets({ "?name": name }, options);
180
+ if (result.length > 0 && result[0]['.id']) {
181
+ return this.client.write('/ppp/secret/remove', {
182
+ ".id": result[0]['.id']
183
+ }, options);
184
+ }
185
+ throw new Error(`PPP Secret '${name}' not found.`);
186
+ }
187
+ // ==========================================
188
+ // ACTIVE (Active Sessions Management)
189
+ // ==========================================
190
+ /**
191
+ * **Retrieve: Active Sessions (PRINT)**
192
+ *
193
+ * Sends a `/ppp/active/print` command to list currently connected sessions.
194
+ *
195
+ * **Feature: Real-time Monitoring**
196
+ * Allows you to check who is currently authenticated and connected to the router.
197
+ *
198
+ * @param filter Optional dictionary to filter results (e.g., searching by IP).
199
+ * @param options Advanced write options.
200
+ * @returns A promise resolving to an array of active connection objects.
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * // Check if a specific user is currently online
205
+ * const activeSessions = await mk.ppp.getActiveConnections({ "?name": "john_doe" });
206
+ * const isOnline = activeSessions.length > 0;
207
+ * ```
208
+ */
209
+ async getActiveConnections(filter, options) {
210
+ return this.client.write('/ppp/active/print', filter || {}, options);
211
+ }
212
+ /**
213
+ * **Execution Terminator: Disconnect Session (REMOVE)**
214
+ *
215
+ * Sends a `/ppp/active/remove` command to force an active session to disconnect.
216
+ *
217
+ * **Feature: Session Management**
218
+ * Ideal for forcing a reconnection after changing a profile, upgrading bandwidth,
219
+ * or suspending service, ensuring the new rules apply immediately.
220
+ *
221
+ * @param name The username of the active session to disconnect.
222
+ * @param options Advanced write options.
223
+ * @returns A promise resolving to the API response, or false if the user wasn't active.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * // Suspend user and immediately drop their current session
228
+ * await mk.ppp.disableSecret('john_doe');
229
+ * await mk.ppp.killActiveSession('john_doe');
230
+ * ```
231
+ */
232
+ async killActiveSession(name, options) {
233
+ const result = await this.getActiveConnections({ "?name": name }, options);
234
+ if (result.length > 0 && result[0]['.id']) {
235
+ return this.client.write('/ppp/active/remove', {
236
+ ".id": result[0]['.id']
237
+ }, options);
238
+ }
239
+ // If the user is not active, the objective is already met
240
+ return false;
241
+ }
242
+ // ==========================================
243
+ // PROFILES (Plan Management)
244
+ // ==========================================
245
+ /**
246
+ * **Retrieve: PPP Profiles (PRINT)**
247
+ *
248
+ * Sends a `/ppp/profile/print` command to list existing service plans.
249
+ *
250
+ * @param filter Optional dictionary to filter results.
251
+ * @param options Advanced write options.
252
+ * @returns A promise resolving to an array of profile objects.
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * // Get all configured plans on the router
257
+ * const profiles = await mk.ppp.getProfiles();
258
+ * ```
259
+ */
260
+ async getProfiles(filter, options) {
261
+ return this.client.write('/ppp/profile/print', filter || {}, options);
262
+ }
263
+ /**
264
+ * **Resource Creation: PPP Profile (ADD)**
265
+ *
266
+ * Sends a `/ppp/profile/add` command to create a new service plan.
267
+ *
268
+ * **Feature: Bandwidth Allocation**
269
+ * Defines a centralized template for speed limits and routing rules that
270
+ * can be assigned to multiple PPPoE secrets.
271
+ *
272
+ * @param name The name of the new profile.
273
+ * @param rateLimit The bandwidth limit format (Rx/Tx) e.g., '10M/20M'.
274
+ * @param localAddress The local IP address for the tunnel endpoint. Defaults to '192.168.89.1'.
275
+ * @param options Advanced write options.
276
+ * @returns A promise resolving to the API response.
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * // Create a 50 Megabit download / 20 Megabit upload plan
281
+ * await mk.ppp.addProfile('Plan_50M', '20M/50M', '10.0.0.1');
282
+ * ```
283
+ */
284
+ async addProfile(name, rateLimit, localAddress = '192.168.89.1', options) {
285
+ return this.client.write('/ppp/profile/add', {
286
+ name,
287
+ "local-address": localAddress,
288
+ "rate-limit": rateLimit
289
+ }, options);
290
+ }
291
+ }
292
+ exports.PPPWrapper = PPPWrapper;
293
+ //# sourceMappingURL=PPPoEWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PPPoEWrapper.js","sourceRoot":"","sources":["../../src/features/PPPoEWrapper.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAGnB,YAAY,MAAsB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,6CAA6C;IAC7C,4BAA4B;IAC5B,6CAA6C;IAE7C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,UAAU,CAAC,MAA+B,EAAE,OAAuB;QACrE,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC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AE;YACzC,IAAI;YACJ,eAAe,EAAE,YAAY;YAC7B,YAAY,EAAE,SAAS;SAC1B,EAAE,OAAO,CAAC,CAAC;IAChB,CAAC;CACJ;AAnUD,gCAmUC"}
@@ -0,0 +1,118 @@
1
+ import { MikrotikClient, IWriteOptions } from "../client/MikrotikClient";
2
+ export declare class QueueWrapper {
3
+ private client;
4
+ constructor(client: MikrotikClient);
5
+ /**
6
+ * **Retrieve: Simple Queues (PRINT)**
7
+ *
8
+ * Sends a `/queue/simple/print` command to list bandwidth queues.
9
+ *
10
+ * **Feature: Filtered Search**
11
+ * You can pass a dictionary of parameters to filter the results directly on the router,
12
+ * reducing network overhead and processing time.
13
+ *
14
+ * @param filter Optional dictionary to filter results (e.g., `{"?target": "192.168.10.50/32"}`).
15
+ * @param options Advanced write options (idempotency, forced protocol).
16
+ * @returns A promise resolving to an array of queue objects.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Get all configured queues
21
+ * const allQueues = await mk.queue.getQueues();
22
+ * * // Find a specific queue by its target IP
23
+ * const clientQueue = await mk.queue.getQueues({ "?target": "192.168.10.50/32" });
24
+ * ```
25
+ */
26
+ getQueues(filter?: Record<string, string>, options?: IWriteOptions): Promise<any[]>;
27
+ /**
28
+ * **Resource Creation: Simple Queue (ADD)**
29
+ *
30
+ * Sends a `/queue/simple/add` command to limit bandwidth for a specific target.
31
+ *
32
+ * **Feature: Bandwidth Allocation (QoS)**
33
+ * Creates basic rules to limit upload and download speeds. You can also pass
34
+ * additional parameters to build hierarchical QoS trees.
35
+ *
36
+ * @param name The identifier name for the queue (e.g., 'Client_John').
37
+ * @param target The target IP address or subnet (e.g., '192.168.10.50/32').
38
+ * @param maxLimit The maximum bandwidth allowed format (Upload/Download) e.g., '10M/20M'.
39
+ * @param additionalParams Optional dictionary for extra parameters like priority, parent queue, etc.
40
+ * @param options Advanced write options.
41
+ * @returns A promise resolving to the API response.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Create a 20 Megabit download / 10 Megabit upload limit for a single IP
46
+ * await mk.queue.addQueue('Client_John', '192.168.10.50/32', '10M/20M');
47
+ * * // Create a queue with a specific parent for hierarchical QoS
48
+ * await mk.queue.addQueue('Client_Jane', '192.168.10.51/32', '5M/10M', { parent: 'Main_Node' });
49
+ * ```
50
+ */
51
+ addQueue(name: string, target: string, maxLimit: string, additionalParams?: Record<string, string | boolean | number>, options?: IWriteOptions): Promise<any[]>;
52
+ /**
53
+ * **Resource Modification: Update Queue (SET)**
54
+ *
55
+ * Sends a `/queue/simple/set` command to modify an existing Simple Queue.
56
+ *
57
+ * **Feature: Dynamic Speed Adjustment**
58
+ * Automatically resolves the internal `.id` based on the target IP and applies
59
+ * the new parameters, allowing for on-the-fly plan upgrades/downgrades.
60
+ *
61
+ * @param target The exact target IP or subnet of the queue to modify.
62
+ * @param paramsToUpdate Dictionary containing the fields to update (e.g., `{"max-limit": "50M/100M"}`).
63
+ * @param options Advanced write options.
64
+ * @returns A promise resolving to the API response.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * // Upgrade a user's bandwidth on the fly
69
+ * await mk.queue.setQueueLimit('192.168.10.50/32', { "max-limit": "20M/50M" });
70
+ * ```
71
+ */
72
+ setQueueLimit(target: string, paramsToUpdate: Record<string, string | boolean | number>, options?: IWriteOptions): Promise<any[]>;
73
+ /**
74
+ * **Execution Terminator: Delete Queue (REMOVE)**
75
+ *
76
+ * Sends a `/queue/simple/remove` command to permanently delete a Simple Queue.
77
+ *
78
+ * **Feature: Safe Deletion**
79
+ * Searches for the exact dynamic ID before attempting removal, preventing errors
80
+ * if the queue does not exist.
81
+ *
82
+ * @param target The exact target IP or subnet of the queue to delete.
83
+ * @param options Advanced write options.
84
+ * @returns A promise resolving to the API response.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // Remove bandwidth limits for a specific IP
89
+ * try {
90
+ * await mk.queue.removeQueue('192.168.10.50/32');
91
+ * console.log('Queue removed successfully');
92
+ * } catch (error) {
93
+ * console.error(error.message);
94
+ * }
95
+ * ```
96
+ */
97
+ removeQueue(target: string, options?: IWriteOptions): Promise<any[]>;
98
+ /**
99
+ * **Execution: Reset Statistics (RESET-COUNTERS)**
100
+ *
101
+ * Sends a `/queue/simple/reset-counters` command to clear traffic data.
102
+ *
103
+ * **Feature: Traffic Monitoring Reset**
104
+ * Useful for billing cycles or data cap management when you need to reset
105
+ * the bytes/packets counted by the router for a specific target.
106
+ *
107
+ * @param target The exact target IP or subnet of the queue to reset.
108
+ * @param options Advanced write options.
109
+ * @returns A promise resolving to the API response.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * // Reset traffic statistics at the beginning of a billing cycle
114
+ * await mk.queue.resetCounters('192.168.10.50/32');
115
+ * ```
116
+ */
117
+ resetCounters(target: string, options?: IWriteOptions): Promise<any[]>;
118
+ }