tachyon-protocol 0.1.8 → 0.1.9
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/index.d.ts +5 -5
- package/dist/index.js +13 -22
- package/dist/meta.json +1 -1
- package/dist/system/version/response.json +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -458,7 +458,7 @@ export type SystemVersionResponse =
|
|
|
458
458
|
command: "system/version/response";
|
|
459
459
|
status: "success";
|
|
460
460
|
data: {
|
|
461
|
-
tachyonVersion: "0.1.
|
|
461
|
+
tachyonVersion: "0.1.9";
|
|
462
462
|
versionParity: "major_mismatch" | "minor_mismatch" | "patch_mismatch" | "match" | "unknown";
|
|
463
463
|
};
|
|
464
464
|
}
|
|
@@ -924,10 +924,10 @@ export type ResponseData<S extends ServiceId, E extends ResponseEndpointId<S>> =
|
|
|
924
924
|
export type RemoveField<T, K extends string> = T extends { [P in K]: any } ? Omit<T, K> : never;
|
|
925
925
|
|
|
926
926
|
export type GetCommands<S extends ServiceId, E extends keyof Tachyon[S]> = Tachyon[S][E];
|
|
927
|
-
import {
|
|
927
|
+
import { ValidateFunction } from 'ajv';
|
|
928
928
|
|
|
929
|
-
declare function
|
|
929
|
+
declare function getValidator<T extends {
|
|
930
930
|
command: string;
|
|
931
|
-
}>(command: T): T
|
|
931
|
+
}>(command: T): ValidateFunction<T>;
|
|
932
932
|
|
|
933
|
-
export {
|
|
933
|
+
export { getValidator };
|
package/dist/index.js
CHANGED
|
@@ -7068,7 +7068,7 @@ var require_dist = __commonJS({
|
|
|
7068
7068
|
// src/validator.ts
|
|
7069
7069
|
var validator_exports = {};
|
|
7070
7070
|
__export(validator_exports, {
|
|
7071
|
-
|
|
7071
|
+
getValidator: () => getValidator
|
|
7072
7072
|
});
|
|
7073
7073
|
module.exports = __toCommonJS(validator_exports);
|
|
7074
7074
|
var import_ajv = __toESM(require_ajv());
|
|
@@ -7106,34 +7106,25 @@ function init() {
|
|
|
7106
7106
|
}
|
|
7107
7107
|
}
|
|
7108
7108
|
}
|
|
7109
|
-
function
|
|
7109
|
+
function getValidator(command) {
|
|
7110
7110
|
if (!initialised) {
|
|
7111
7111
|
init();
|
|
7112
7112
|
}
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
throw new Error(`Validator not found for: ${command.command}`);
|
|
7123
|
-
}
|
|
7124
|
-
const isValid = validator(command);
|
|
7125
|
-
if (isValid) {
|
|
7126
|
-
return command;
|
|
7127
|
-
}
|
|
7128
|
-
return validator.errors;
|
|
7129
|
-
} catch (err) {
|
|
7130
|
-
console.error(`Error validating command:`, err, command);
|
|
7131
|
-
throw err;
|
|
7113
|
+
if (typeof command !== "object") {
|
|
7114
|
+
throw new Error("Command not object type");
|
|
7115
|
+
}
|
|
7116
|
+
if (!command.command || typeof command.command !== "string") {
|
|
7117
|
+
throw new Error("Command Id missing");
|
|
7118
|
+
}
|
|
7119
|
+
const validator = validators.get(command.command);
|
|
7120
|
+
if (!validator) {
|
|
7121
|
+
throw new Error(`Validator not found for: ${command.command}`);
|
|
7132
7122
|
}
|
|
7123
|
+
return validator;
|
|
7133
7124
|
}
|
|
7134
7125
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7135
7126
|
0 && (module.exports = {
|
|
7136
|
-
|
|
7127
|
+
getValidator
|
|
7137
7128
|
});
|
|
7138
7129
|
/*! Bundled license information:
|
|
7139
7130
|
|
package/dist/meta.json
CHANGED