ocpp-ws-io 2.1.8 → 2.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.mts CHANGED
@@ -324,10 +324,6 @@ declare class LRUMap<K, V> extends Map<K, V> {
324
324
 
325
325
  declare function getStandardValidators(): Validator[];
326
326
 
327
- /**
328
- * Instantiate a typed RPCError from a string error code.
329
- * Returns an RPCGenericError if the code is not recognized.
330
- */
331
327
  declare function createRPCError(code: string, message?: string, details?: Record<string, unknown>): RPCError;
332
328
  /**
333
329
  * Convert an Error (or subclass) into a plain, JSON-safe object.
package/dist/index.d.ts CHANGED
@@ -324,10 +324,6 @@ declare class LRUMap<K, V> extends Map<K, V> {
324
324
 
325
325
  declare function getStandardValidators(): Validator[];
326
326
 
327
- /**
328
- * Instantiate a typed RPCError from a string error code.
329
- * Returns an RPCGenericError if the code is not recognized.
330
- */
331
327
  declare function createRPCError(code: string, message?: string, details?: Record<string, unknown>): RPCError;
332
328
  /**
333
329
  * Convert an Error (or subclass) into a plain, JSON-safe object.
package/dist/index.js CHANGED
@@ -37096,31 +37096,37 @@ var import_ajv = __toESM(require("ajv"));
37096
37096
  var import_ajv_formats = __toESM(require("ajv-formats"));
37097
37097
 
37098
37098
  // src/util.ts
37099
- var RPC_ERROR_REGISTRY = /* @__PURE__ */ new Map([
37100
- // Generic / framework errors
37101
- ["GenericError", RPCGenericError],
37102
- ["RpcFrameworkError", RPCFrameworkError],
37103
- ["MessageTypeNotSupported", RPCMessageTypeNotSupportedError],
37104
- // Action-level errors
37105
- ["NotImplemented", RPCNotImplementedError],
37106
- ["NotSupported", RPCNotSupportedError],
37107
- ["InternalError", RPCInternalError],
37108
- // Protocol / security errors
37109
- ["ProtocolError", RPCProtocolError],
37110
- ["SecurityError", RPCSecurityError],
37111
- // Payload validation errors
37112
- ["FormatViolation", RPCFormatViolationError],
37113
- ["FormationViolation", RPCFormationViolationError],
37114
- ["PropertyConstraintViolation", RPCPropertyConstraintViolationError],
37115
- [
37116
- "OccurrenceConstraintViolation",
37117
- RPCOccurrenceConstraintViolationError
37118
- ],
37119
- ["TypeConstraintViolation", RPCTypeConstraintViolationError]
37120
- ]);
37121
37099
  function createRPCError(code, message, details = {}) {
37122
- const Ctor = RPC_ERROR_REGISTRY.get(code) ?? RPCGenericError;
37123
- return new Ctor(message, details);
37100
+ switch (code) {
37101
+ case "GenericError":
37102
+ return new RPCGenericError(message, details);
37103
+ case "RpcFrameworkError":
37104
+ return new RPCFrameworkError(message, details);
37105
+ case "MessageTypeNotSupported":
37106
+ return new RPCMessageTypeNotSupportedError(message, details);
37107
+ case "NotImplemented":
37108
+ return new RPCNotImplementedError(message, details);
37109
+ case "NotSupported":
37110
+ return new RPCNotSupportedError(message, details);
37111
+ case "InternalError":
37112
+ return new RPCInternalError(message, details);
37113
+ case "ProtocolError":
37114
+ return new RPCProtocolError(message, details);
37115
+ case "SecurityError":
37116
+ return new RPCSecurityError(message, details);
37117
+ case "FormatViolation":
37118
+ return new RPCFormatViolationError(message, details);
37119
+ case "FormationViolation":
37120
+ return new RPCFormationViolationError(message, details);
37121
+ case "PropertyConstraintViolation":
37122
+ return new RPCPropertyConstraintViolationError(message, details);
37123
+ case "OccurrenceConstraintViolation":
37124
+ return new RPCOccurrenceConstraintViolationError(message, details);
37125
+ case "TypeConstraintViolation":
37126
+ return new RPCTypeConstraintViolationError(message, details);
37127
+ default:
37128
+ return new RPCGenericError(message, details);
37129
+ }
37124
37130
  }
37125
37131
  var ERROR_PROPERTIES = [
37126
37132
  "name",