@fatehan/tsrp 1.3.45 → 1.3.47
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/dist/fatehan/apis/client.d.ts +45 -0
- package/dist/fatehan/apis/client.d.ts.map +1 -1
- package/dist/fatehan/apis/client.js +655 -1
- package/dist/fatehan/devices/maintenance.d.ts +68 -0
- package/dist/fatehan/devices/maintenance.d.ts.map +1 -0
- package/dist/fatehan/devices/maintenance.js +683 -0
- package/dist/fatehan/identities/identities.d.ts +34 -2
- package/dist/fatehan/identities/identities.d.ts.map +1 -1
- package/dist/fatehan/identities/identities.js +69 -2
- package/dist/fatehan/notifies/notify.d.ts +146 -4
- package/dist/fatehan/notifies/notify.d.ts.map +1 -1
- package/dist/fatehan/notifies/notify.js +1869 -80
- package/dist/fatehan/packets/dataModel.d.ts +5 -0
- package/dist/fatehan/packets/dataModel.d.ts.map +1 -1
- package/dist/fatehan/packets/dataModel.js +30 -0
- package/dist/fatehan/packets/messages.d.ts +2 -2
- package/dist/fatehan/packets/messages.d.ts.map +1 -1
- package/dist/fatehan/packets/messages.js +14 -14
- package/dist/fatehan/reports/report.d.ts +0 -130
- package/dist/fatehan/reports/report.d.ts.map +1 -1
- package/dist/fatehan/reports/report.js +297 -2126
- package/dist/fatehan/services/api.d.ts +62 -2
- package/dist/fatehan/services/api.d.ts.map +1 -1
- package/dist/fatehan/services/api.js +850 -4
- package/dist/system.io.d.ts +1 -0
- package/dist/system.io.d.ts.map +1 -1
- package/dist/system.io.js +22 -35
- package/package.json +1 -1
package/dist/system.io.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShownIo, SystemIo } from "./fatehan/devices/devices";
|
|
2
2
|
import { Data } from "./fatehan/packets/dataModel";
|
|
3
3
|
declare const SystemIoCast: (systemIo: SystemIo[], deviceIo: SystemIo[], data: Data) => ShownIo[];
|
|
4
|
+
export declare function evalExpressionSafe(template: string, context: any): number | boolean | string | null;
|
|
4
5
|
export default SystemIoCast;
|
|
5
6
|
//# sourceMappingURL=system.io.d.ts.map
|
package/dist/system.io.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.io.d.ts","sourceRoot":"","sources":["../src/system.io.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,EAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,QAAA,MAAM,YAAY,GAChB,UAAU,QAAQ,EAAE,EACpB,UAAU,QAAQ,EAAE,EACpB,MAAM,IAAI,KACT,OAAO,EA4FT,CAAC;
|
|
1
|
+
{"version":3,"file":"system.io.d.ts","sourceRoot":"","sources":["../src/system.io.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,EAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,QAAA,MAAM,YAAY,GAChB,UAAU,QAAQ,EAAE,EACpB,UAAU,QAAQ,EAAE,EACpB,MAAM,IAAI,KACT,OAAO,EA4FT,CAAC;AAkGF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CA4BnG;AACD,eAAe,YAAY,CAAC"}
|
package/dist/system.io.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evalExpressionSafe = evalExpressionSafe;
|
|
3
4
|
const devices_1 = require("./fatehan/devices/devices");
|
|
4
5
|
const SystemIoCast = (systemIo, deviceIo, data) => {
|
|
5
6
|
let list = [];
|
|
@@ -139,16 +140,20 @@ function getValueByPathCaseInsensitive(obj, path) {
|
|
|
139
140
|
for (const rawPart of parts) {
|
|
140
141
|
if (cur == null)
|
|
141
142
|
return undefined;
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
const isIndex = /^\d+$/.test(rawPart);
|
|
144
|
+
if (isIndex) {
|
|
145
|
+
const idx = rawPart;
|
|
144
146
|
if (Array.isArray(cur) || cur instanceof Uint8Array) {
|
|
145
|
-
cur = cur[idx];
|
|
147
|
+
cur = cur[Number(idx)];
|
|
146
148
|
continue;
|
|
147
149
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
if (typeof cur === "object" && cur !== null && idx in cur) {
|
|
151
|
+
cur = cur[idx];
|
|
152
|
+
continue;
|
|
150
153
|
}
|
|
154
|
+
return undefined;
|
|
151
155
|
}
|
|
156
|
+
// حالت 3: object معمولی (case-insensitive)
|
|
152
157
|
if (isPlainObject(cur)) {
|
|
153
158
|
const lower = rawPart.toLowerCase();
|
|
154
159
|
const foundKey = Object.keys(cur).find(k => k.toLowerCase() === lower);
|
|
@@ -168,7 +173,7 @@ function evalExpressionSafe(template, context) {
|
|
|
168
173
|
try {
|
|
169
174
|
if (typeof template !== 'string')
|
|
170
175
|
return null;
|
|
171
|
-
const replaced = template.replace(/\$([A-Za-z0-9_.\[\]]+)/gi, (
|
|
176
|
+
const replaced = template.replace(/\$([A-Za-z0-9_.\[\]]+)/gi, (_, expr) => {
|
|
172
177
|
const value = getValueByPathCaseInsensitive(context, expr);
|
|
173
178
|
if (value === undefined || value === null)
|
|
174
179
|
return "null";
|
|
@@ -180,38 +185,20 @@ function evalExpressionSafe(template, context) {
|
|
|
180
185
|
return JSON.stringify(value);
|
|
181
186
|
if (value instanceof Uint8Array)
|
|
182
187
|
return `[${Array.from(value).join(',')}]`;
|
|
183
|
-
if (Array.isArray(value))
|
|
184
|
-
return `[${value.map(v => (typeof v ===
|
|
185
|
-
}
|
|
188
|
+
if (Array.isArray(value))
|
|
189
|
+
return `[${value.map(v => (typeof v === "string" ? JSON.stringify(v) : v)).join(',')}]`;
|
|
186
190
|
return "null";
|
|
187
191
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
const cleaned = replaced
|
|
192
|
-
.replace(/;/g, ' ')
|
|
193
|
-
.replace(/`/g, ' ')
|
|
194
|
-
.replace(/\\/g, ' ')
|
|
195
|
-
.trim();
|
|
196
|
-
const allowedPattern = /^[0-9+\-*/ %().,<>=!&|"\[\]truefalsenull,':\s]*$/i;
|
|
197
|
-
if (!allowedPattern.test(cleaned))
|
|
198
|
-
return null;
|
|
199
|
-
const forbidden = [/constructor\b/i, /process\b/i, /require\b/i, /global\b/i, /__proto__\b/i];
|
|
200
|
-
if (forbidden.some(rx => rx.test(cleaned)))
|
|
192
|
+
const cleaned = replaced.replace(/;/g, ' ').replace(/`/g, ' ').replace(/\\/g, ' ').trim();
|
|
193
|
+
if (!/^[0-9+\-*/ ().><=!&|,"'\[\]truefalsenull]*$/i.test(cleaned))
|
|
201
194
|
return null;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
result
|
|
208
|
-
|
|
209
|
-
catch {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
if (result === undefined || result === null)
|
|
213
|
-
return null;
|
|
214
|
-
if (typeof result === "number" || typeof result === "boolean" || typeof result === "string")
|
|
195
|
+
const fn = new Function(`return (${cleaned});`);
|
|
196
|
+
const result = fn();
|
|
197
|
+
if (typeof result === "number" && !isNaN(result))
|
|
198
|
+
return result;
|
|
199
|
+
if (typeof result === "boolean")
|
|
200
|
+
return result;
|
|
201
|
+
if (typeof result === "string")
|
|
215
202
|
return result;
|
|
216
203
|
return null;
|
|
217
204
|
}
|