Skip to main content
Sign in
Snippets Groups Projects
Commit 20e882ab authored by Marin Karamihalev's avatar Marin Karamihalev
Browse files

simplified version files

parent f5b147cd
No related branches found
No related tags found
No related merge requests found
Showing
with 24 additions and 450 deletions
......@@ -508,4 +508,4 @@ Run the following command after making any changes to the base code:
```
yarn run qjs
```
This script needs to be run as compilation for quickjs requires several direct changes to the code.
\ No newline at end of file
This script needs to be run because compilation for quickjs requires several direct changes to the code.
\ No newline at end of file
import get from "./get";
import set from "./set";
import add from "./add";
import del from "./del";
import operate from "./operate";
import supported from "./supported";
import proto from "./proto";
import instances from "./instances";
import notify from "./notify";
export default {
GET: get,
ADD: add,
DELETE: del,
GET_INSTANCES: instances,
GET_SUPPORTED_DM: supported,
GET_SUPPORTED_PROTO: proto,
NOTIFY: notify,
OPERATE: operate,
SET: set,
};
export default {};
export { default } from "../common/operate";
\ No newline at end of file
import { DecodeFn, EncodeFn } from "../../types";
import * as util from "../util";
const decode: DecodeFn = (msg) => {
const results = util.search(msg, "agentSupportedProtocolVersions");
return [results.split(",")];
};
const encode: EncodeFn = ({ proto }) => ({
lookup: "Msg",
header: {
msgId: util.uniq("GET_SUPPORTED_PROTO@"),
msgType: "GET_SUPPORTED_PROTO",
lookup: "Header",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
getSupportedProtocol: {
controllerSupportedProtocolVersions: proto || "",
},
},
},
});
export default {
decode,
encode,
};
import {
DecodeFn,
EncodeFn,
SetLookupUpdateObject,
SetLookupUpdateParamSetting,
} from "../../types";
import * as util from "../util";
import { decode as commonDecode } from "../common/set";
const decode = commonDecode;
const isObject = (v) =>
typeof v === "object" && v.required !== undefined && v.value !== undefined;
const makePairs = (path: string, value): [string, any, boolean][] =>
path.endsWith(".") && typeof value === "object" && value !== null
? Object.entries(value as any[]).map(([k, v]) =>
isObject(v)
? [k, v.value.toString(), "required" in v && Boolean(v.required)]
: [k, v.toString(), true]
)
: [[path.split(".").pop() || "", (value || "").toString(), true]];
const encode: EncodeFn = ({ value, path: initialPath }) => {
const paths = Array.isArray(initialPath) ? initialPath : [initialPath];
const values = value ? (Array.isArray(value) ? value : [value]) : [];
const allowPartial =
(values && values.some((it) => it.allowPartial)) || false;
const updateObjs = paths.map((path, i) => ({
lookup: "Set.UpdateObject" as SetLookupUpdateObject,
objPath: path.endsWith(".")
? path
: path.slice(0, path.lastIndexOf(".") + 1),
paramSettings: makePairs(path, values[i])
.filter(([k]) => k !== "allowPartial")
.map(([param, value, required]) => ({
lookup: "Set.UpdateParamSetting" as SetLookupUpdateParamSetting,
param,
value,
required,
})),
}));
return {
lookup: "Msg",
header: {
lookup: "Header",
msgId: util.uniq("SET@"),
msgType: "SET",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
set: {
allowPartial,
updateObjs,
},
},
},
};
};
export default {
decode,
encode,
};
import { DecodeFn, EncodeFn } from "../../types";
import * as util from "../util";
import { AddLookupCreateObject, AddLookupCreateParamSetting } from "../../types";
const decode: DecodeFn = (msg) => {
const paths: string[] | undefined = util.searchAll(msg, "instantiatedPath");
if (paths && paths.length === 1) return [paths[0]];
return [paths];
};
const isObj = (v) =>
typeof v === "object" && v.required !== undefined && v.value !== undefined;
const makePair = (value): [string, any, boolean][] =>
value
? Object.entries(value as any[]).map(([k, v]) =>
isObj(v)
? [k, v.value.toString(), "required" in v && Boolean(v.required)]
: [k, v.toString(), true]
)
: [];
const encode: EncodeFn = ({ value, path }) => {
const paths = Array.isArray(path) ? path : [path];
const values = value ? (Array.isArray(value) ? value : [value]) : [];
const allowPartial = values && values.some((it) => it.allowPartial) || false;
const createObjs = paths.map((path, i) => ({
lookup: "Add.CreateObject" as AddLookupCreateObject,
objPath: path,
paramSettings: makePair(values[i])
.filter(([k]) => k !== "allowPartial")
.map(([param, value, required]) => ({
lookup: "Add.CreateParamSetting" as AddLookupCreateParamSetting,
param,
value,
required,
})),
}));
return {
lookup: "Msg",
header: {
lookup: "Header",
msgId: util.uniq("ADD@"),
msgType: "ADD",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
add: {
allowPartial,
createObjs,
},
},
},
};
};
export default {
decode,
encode,
};
import { DecodeFn, EncodeFn } from "../../types";
import { uniq, searchAll } from "../util";
const decode: DecodeFn = (msg) => {
const affectedPaths = searchAll(msg, "affectedPaths") || [];
return [affectedPaths];
};
const encode: EncodeFn = ({ paths, allowPartial }) => ({
lookup: "Msg",
header: {
msgId: uniq("DELETE@"),
msgType: "DELETE",
lookup: "Header",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
delete: {
objPaths: Array.isArray(paths) ? paths : [paths],
allowPartial: allowPartial || false
},
},
},
});
export default {
decode,
encode
};
import { DecodeFn, EncodeFn } from "../../types";
import * as util from "../util";
const decode: DecodeFn = (msg, decodeOptions) => {
const reqPathResults = util.search(msg, "reqPathResults");
if (decodeOptions?.raw) return [reqPathResults];
if (reqPathResults) {
return [
util.processGetResult(reqPathResults as util.PathResult[], decodeOptions),
];
}
return [null];
};
const encode: EncodeFn = ({ paths, options }) => ({
lookup: "Msg",
header: {
msgId: util.uniq("GET@"),
msgType: "GET",
lookup: "Header",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
get: {
paramPaths: Array.isArray(paths) ? paths : [paths],
maxDepth: options?.max_depth || 2,
},
},
},
});
export default {
decode,
encode,
};
import get from "./get";
import set from "./set";
import add from "./add";
import del from "./del";
import operate from "./operate";
import supported from "./supported";
import proto from "./proto";
import instances from "./instances";
import notify from "./notify";
export default {
GET: get,
ADD: add,
DELETE: del,
GET_INSTANCES: instances,
GET_SUPPORTED_DM: supported,
GET_SUPPORTED_PROTO: proto,
NOTIFY: notify,
OPERATE: operate,
SET: set,
};
export default {};
import { DecodeFn, EncodeFn } from "../../types";
import * as util from "../util";
const decode: DecodeFn = (msg) => {
const results = util.search(msg, "reqPathResults");
return [results];
};
const encode: EncodeFn = ({ paths, opts = {} }) => ({
lookup: "Msg",
header: {
msgId: util.uniq("GET_INSTANCES@"),
msgType: "GET_INSTANCES",
lookup: "Header",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
getInstances: {
objPaths: Array.isArray(paths) ? paths : [paths],
firstLevelOnly: opts.firstLevelOnly || false
},
},
},
});
export default {
decode,
encode
};
import { DecodeFn, EncodeFn } from "../../types";
import * as util from "../util";
const parseInfo = (key: string, data: Record<string, any>) =>
util.unflatten(
util.search(data, key === "operComplete" ? "outputArgs" : key) || {}
);
const decode: DecodeFn = (msg) => {
const parent = util.searchParent(msg, "subscriptionId");
if (parent) {
const id = parent.subscriptionId;
const relField = Object.keys(parent).find((k) => k !== "subscriptionId");
return id && relField
? [parseInfo(relField, msg), id, null]
: [null, id, null];
}
return [null];
};
const encode: EncodeFn = ({ paths }) => ({
lookup: "Msg",
header: {
msgId: util.uniq("NOTIFY@"),
msgType: "GET",
lookup: "Header",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
get: {
paramPaths: Array.isArray(paths) ? paths : [paths],
},
},
},
});
export default {
decode,
encode,
};
export { default } from "../common/operate";
\ No newline at end of file
import {
DecodeFn,
EncodeFn,
SetLookupUpdateObject,
SetLookupUpdateParamSetting,
} from "../../types";
import * as util from "../util";
import { decode as commonDecode } from "../common/set";
const decode = commonDecode;
const isObject = (v) =>
typeof v === "object" && v.required !== undefined && v.value !== undefined;
const makePairs = (path: string, value): [string, any, boolean][] =>
path.endsWith(".") && typeof value === "object" && value !== null
? Object.entries(value as any[]).map(([k, v]) =>
isObject(v)
? [k, v.value.toString(), "required" in v && Boolean(v.required)]
: [k, v.toString(), true]
)
: [[path.split(".").pop() || "", (value || "").toString(), true]];
const encode: EncodeFn = ({ value, path: initialPath }) => {
const paths = Array.isArray(initialPath) ? initialPath : [initialPath];
const values = value ? (Array.isArray(value) ? value : [value]) : [];
const allowPartial =
(values && values.some((it) => it.allowPartial)) || false;
const updateObjs = paths.map((path, i) => ({
lookup: "Set.UpdateObject" as SetLookupUpdateObject,
objPath: path.endsWith(".")
? path
: path.slice(0, path.lastIndexOf(".") + 1),
paramSettings: makePairs(path, values[i])
.filter(([k]) => k !== "allowPartial")
.map(([param, value, required]) => ({
lookup: "Set.UpdateParamSetting" as SetLookupUpdateParamSetting,
param,
value,
required,
})),
}));
return {
lookup: "Msg",
header: {
lookup: "Header",
msgId: util.uniq("SET@"),
msgType: "SET",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
set: {
allowPartial,
updateObjs,
},
},
},
};
};
export default {
decode,
encode,
};
import { DecodeFn, EncodeFn } from "../../types";
import * as util from "../util";
const decode: DecodeFn = (msg) => {
const results = util.search(msg, "reqObjResults");
return [results];
};
const encode: EncodeFn = ({ paths, opts = {} }) => ({
lookup: "Msg",
header: {
msgId: util.uniq("GET_SUPPORTED_DM@"),
msgType: "GET_SUPPORTED_DM",
lookup: "Header",
},
body: {
lookup: "Body",
request: {
lookup: "Request",
getSupportedDm: {
objPaths: Array.isArray(paths) ? paths : [paths],
firstLevelOnly: opts.firstLevelOnly || false,
returnCommands: opts.returnCommands || false,
returnEvents: opts.returnEvents || false,
returnParams: opts.returnParams || false,
},
},
},
});
export default {
decode,
encode
};
File moved
File moved
File moved
import get from "./get";
import set from "./set";
import add from "./add";
import del from "./del";
import operate from "./operate";
import supported from "./supported";
import proto from "./proto";
import instances from "./instances";
import notify from "./notify";
export default {
GET: get,
GET_INSTANCES: instances,
GET_SUPPORTED_DM: supported,
GET_SUPPORTED_PROTO: proto,
NOTIFY: notify,
ADD: add,
DELETE: del,
OPERATE: operate,
SET: set,
};
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment