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 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.8";
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 { ErrorObject } from 'ajv';
927
+ import { ValidateFunction } from 'ajv';
928
928
 
929
- declare function validateCommand<T extends {
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 | ErrorObject<string, Record<string, any>, unknown>[];
935
+ }>(command: T): ValidateFunction<T>;
932
936
 
933
- export { validateCommand };
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
- validateCommand: () => validateCommand
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
- version: "N/A",
7080
- ids: {}
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 validateCommand(command) {
7107
+ function getValidator(command) {
7110
7108
  if (!initialised) {
7111
7109
  init();
7112
7110
  }
7113
- try {
7114
- if (typeof command !== "object") {
7115
- throw new Error("Command not object type");
7116
- }
7117
- if (!command.command || typeof command.command !== "string") {
7118
- throw new Error("Command Id missing");
7119
- }
7120
- const validator = validators.get(command.command);
7121
- if (!validator) {
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
- validateCommand
7125
+ getValidator,
7126
+ tachyonMeta
7137
7127
  });
7138
7128
  /*! Bundled license information:
7139
7129
 
package/dist/meta.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.8",
2
+ "version": "0.1.10",
3
3
  "ids": {
4
4
  "account": {
5
5
  "getToken": [
@@ -18,7 +18,7 @@
18
18
  "type": "object",
19
19
  "properties": {
20
20
  "tachyonVersion": {
21
- "const": "0.1.8",
21
+ "const": "0.1.10",
22
22
  "type": "string"
23
23
  },
24
24
  "versionParity": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tachyon-protocol",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src/** --ext ts --exec npm run build",