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 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.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 { ErrorObject } from 'ajv';
927
+ import { ValidateFunction } from 'ajv';
928
928
 
929
- declare function validateCommand<T extends {
929
+ declare function getValidator<T extends {
930
930
  command: string;
931
- }>(command: T): T | ErrorObject<string, Record<string, any>, unknown>[];
931
+ }>(command: T): ValidateFunction<T>;
932
932
 
933
- export { validateCommand };
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
- validateCommand: () => validateCommand
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 validateCommand(command) {
7109
+ function getValidator(command) {
7110
7110
  if (!initialised) {
7111
7111
  init();
7112
7112
  }
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;
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
- validateCommand
7127
+ getValidator
7137
7128
  });
7138
7129
  /*! Bundled license information:
7139
7130
 
package/dist/meta.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.8",
2
+ "version": "0.1.9",
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.9",
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.9",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src/** --ext ts --exec npm run build",