@tikoci/centrs 0.1.6 → 0.1.7
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/CHANGELOG.md +108 -1
- package/README.md +8 -4
- package/commands/api/README.md +21 -10
- package/commands/api/examples.md +70 -2
- package/commands/devices/README.md +10 -1
- package/commands/devices/examples.md +33 -2
- package/commands/execute/README.md +29 -15
- package/commands/execute/examples.md +89 -0
- package/commands/explain/README.md +12 -1
- package/commands/mcp/README.md +2 -1
- package/commands/retrieve/examples.md +20 -0
- package/docs/CLI.md +1 -1
- package/docs/CONSTITUTION.md +11 -6
- package/docs/errors/cdb/create-failed.md +20 -0
- package/docs/errors/cdb/file-exists.md +23 -0
- package/docs/errors/input/invalid-target.md +25 -3
- package/docs/errors/routeros/invalid-value.md +3 -2
- package/docs/errors/transport/cancel-unacknowledged.md +24 -0
- package/package.json +1 -1
- package/src/api.ts +109 -25
- package/src/cli/devices.ts +16 -3
- package/src/core/error-catalog.ts +14 -0
- package/src/core/execute-command.ts +313 -6
- package/src/core/inspect.ts +22 -22
- package/src/core/routeros-errors.ts +66 -0
- package/src/data/winbox-cdb-write.ts +22 -8
- package/src/devices.ts +142 -28
- package/src/execute-fanout.ts +1 -1
- package/src/execute.ts +22 -51
- package/src/explain/catalog.ts +8 -8
- package/src/explain/menus.ts +4 -4
- package/src/index.ts +2 -0
- package/src/mcp/tools.ts +1 -1
- package/src/protocols/adapter.ts +12 -1
- package/src/protocols/mac-telnet-console.ts +6 -4
- package/src/protocols/native-api.ts +29 -3
- package/src/resolver/target.ts +32 -12
- package/src/retrieve.ts +17 -4
package/src/retrieve.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
} from "./core/envelope.ts";
|
|
9
9
|
import {
|
|
10
10
|
extractCompletionNames,
|
|
11
|
+
inspectArgumentNames,
|
|
11
12
|
inspectChildren,
|
|
12
13
|
inspectChildrenOrEmpty,
|
|
13
14
|
inspectCompletions,
|
|
@@ -124,6 +125,7 @@ export type RetrieveErrorEnvelope = CentrsErrorEnvelope<RetrieveOperationMeta>;
|
|
|
124
125
|
|
|
125
126
|
interface RetrieveInspection {
|
|
126
127
|
command: "get" | "print";
|
|
128
|
+
singleton: boolean;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
export interface ResolvedRetrieveRequest {
|
|
@@ -240,7 +242,7 @@ export async function runResolvedRetrieve(
|
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
244
|
|
|
243
|
-
const data = await executeRetrieve(resolved, backend);
|
|
245
|
+
const data = await executeRetrieve(resolved, backend, inspection);
|
|
244
246
|
const envelope = buildSuccessEnvelope(
|
|
245
247
|
resolved,
|
|
246
248
|
{
|
|
@@ -999,9 +1001,18 @@ async function inspectRetrievePath(
|
|
|
999
1001
|
});
|
|
1000
1002
|
}
|
|
1001
1003
|
|
|
1002
|
-
|
|
1004
|
+
// A singleton's `get` takes only `value-name`; a list menu's also takes
|
|
1005
|
+
// `number` (CHR 7.23.7: /tool/romon, /ip/dns, /system/identity vs
|
|
1006
|
+
// /ip/address). A hardcoded path list missed every other singleton and
|
|
1007
|
+
// validated its properties against `print`'s flags (issue #377).
|
|
1008
|
+
const singleton =
|
|
1009
|
+
supportsGet &&
|
|
1010
|
+
!(await inspectArgumentNames(backend, [...tokens, "get"])).includes(
|
|
1011
|
+
"number",
|
|
1012
|
+
);
|
|
1003
1013
|
return {
|
|
1004
|
-
command: singleton
|
|
1014
|
+
command: singleton ? "get" : "print",
|
|
1015
|
+
singleton,
|
|
1005
1016
|
};
|
|
1006
1017
|
}
|
|
1007
1018
|
|
|
@@ -1040,8 +1051,9 @@ async function inspectAttributes(
|
|
|
1040
1051
|
async function executeRetrieve(
|
|
1041
1052
|
resolved: ResolvedRetrieveRequest,
|
|
1042
1053
|
backend: ProtocolAdapter,
|
|
1054
|
+
inspection: RetrieveInspection | undefined,
|
|
1043
1055
|
): Promise<unknown> {
|
|
1044
|
-
if (isKnownSingletonPath(resolved.path)) {
|
|
1056
|
+
if (inspection?.singleton ?? isKnownSingletonPath(resolved.path)) {
|
|
1045
1057
|
const data = await backend.getSingleton(resolved.path);
|
|
1046
1058
|
if (resolved.attributes.length > 0) {
|
|
1047
1059
|
return projectSingletonAttributes(data, resolved.attributes);
|
|
@@ -1055,6 +1067,7 @@ async function executeRetrieve(
|
|
|
1055
1067
|
});
|
|
1056
1068
|
}
|
|
1057
1069
|
|
|
1070
|
+
/** Fallback for `--validate=false`, which skips the inspect that detects singletons. */
|
|
1058
1071
|
function isKnownSingletonPath(path: string): boolean {
|
|
1059
1072
|
return ["/system/resource", "/system/identity"].includes(
|
|
1060
1073
|
path.replace(/\/$/, ""),
|