tachyon-protocol 0.1.8 → 0.1.10
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 +9 -5
- package/dist/index.js +20 -30
- 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.10";
|
|
462
462
|
versionParity: "major_mismatch" | "minor_mismatch" | "patch_mismatch" | "match" | "unknown";
|
|
463
463
|
};
|
|
464
464
|
}
|
|
@@ -924,10 +924,14 @@ 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
|
|
929
|
+
declare const tachyonMeta: {
|
|
930
|
+
version: string;
|
|
931
|
+
ids: Record<string, Record<string, string[]>>;
|
|
932
|
+
};
|
|
933
|
+
declare function getValidator<T extends {
|
|
930
934
|
command: string;
|
|
931
|
-
}>(command: T): T
|
|
935
|
+
}>(command: T): ValidateFunction<T>;
|
|
932
936
|
|
|
933
|
-
export {
|
|
937
|
+
export { getValidator, tachyonMeta };
|
package/dist/index.js
CHANGED
|
@@ -7068,17 +7068,19 @@ var require_dist = __commonJS({
|
|
|
7068
7068
|
// src/validator.ts
|
|
7069
7069
|
var validator_exports = {};
|
|
7070
7070
|
__export(validator_exports, {
|
|
7071
|
-
|
|
7071
|
+
getValidator: () => getValidator,
|
|
7072
|
+
tachyonMeta: () => tachyonMeta
|
|
7072
7073
|
});
|
|
7073
7074
|
module.exports = __toCommonJS(validator_exports);
|
|
7074
7075
|
var import_ajv = __toESM(require_ajv());
|
|
7075
7076
|
var import_ajv_formats = __toESM(require_dist());
|
|
7076
7077
|
var import_fs = __toESM(require("fs"));
|
|
7077
7078
|
var import_path = __toESM(require("path"));
|
|
7078
|
-
var tachyonMeta =
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
}
|
|
7079
|
+
var tachyonMeta = JSON.parse(
|
|
7080
|
+
import_fs.default.readFileSync(import_path.default.join(__dirname, `./meta.json`), {
|
|
7081
|
+
encoding: "utf-8"
|
|
7082
|
+
})
|
|
7083
|
+
);
|
|
7082
7084
|
var validators = /* @__PURE__ */ new Map();
|
|
7083
7085
|
var ajv = new import_ajv.default({ coerceTypes: true });
|
|
7084
7086
|
var initialised = false;
|
|
@@ -7087,10 +7089,6 @@ function init() {
|
|
|
7087
7089
|
import_ajv_formats.default.default(ajv);
|
|
7088
7090
|
ajv.addKeyword("requiresLogin");
|
|
7089
7091
|
ajv.addKeyword("requiresRole");
|
|
7090
|
-
const tachyonMetaStr = import_fs.default.readFileSync(import_path.default.join(__dirname, `./meta.json`), {
|
|
7091
|
-
encoding: "utf-8"
|
|
7092
|
-
});
|
|
7093
|
-
tachyonMeta = JSON.parse(tachyonMetaStr);
|
|
7094
7092
|
for (const serviceId in tachyonMeta.ids) {
|
|
7095
7093
|
for (const endpointId in tachyonMeta.ids[serviceId]) {
|
|
7096
7094
|
for (const commandType of tachyonMeta.ids[serviceId][endpointId]) {
|
|
@@ -7106,34 +7104,26 @@ function init() {
|
|
|
7106
7104
|
}
|
|
7107
7105
|
}
|
|
7108
7106
|
}
|
|
7109
|
-
function
|
|
7107
|
+
function getValidator(command) {
|
|
7110
7108
|
if (!initialised) {
|
|
7111
7109
|
init();
|
|
7112
7110
|
}
|
|
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;
|
|
7111
|
+
if (typeof command !== "object") {
|
|
7112
|
+
throw new Error("Command not object type");
|
|
7113
|
+
}
|
|
7114
|
+
if (!command.command || typeof command.command !== "string") {
|
|
7115
|
+
throw new Error("Command Id missing");
|
|
7116
|
+
}
|
|
7117
|
+
const validator = validators.get(command.command);
|
|
7118
|
+
if (!validator) {
|
|
7119
|
+
throw new Error(`Validator not found for: ${command.command}`);
|
|
7132
7120
|
}
|
|
7121
|
+
return validator;
|
|
7133
7122
|
}
|
|
7134
7123
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7135
7124
|
0 && (module.exports = {
|
|
7136
|
-
|
|
7125
|
+
getValidator,
|
|
7126
|
+
tachyonMeta
|
|
7137
7127
|
});
|
|
7138
7128
|
/*! Bundled license information:
|
|
7139
7129
|
|
package/dist/meta.json
CHANGED