@routr/common 2.13.4 → 2.13.7

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/errors.d.ts CHANGED
@@ -55,6 +55,18 @@ export declare class ResourceNotFoundError extends Error {
55
55
  */
56
56
  constructor(ref: string);
57
57
  }
58
+ /**
59
+ * Thrown if the resource already exists.
60
+ */
61
+ export declare class ResourceAlreadyExistsError extends Error {
62
+ code: number;
63
+ /**
64
+ * Creates an instance of ResourceAlreadyExistsError.
65
+ *
66
+ * @param {string} message - message with the error to be thrown.
67
+ */
68
+ constructor(message?: string);
69
+ }
58
70
  /**
59
71
  * Thrown if the request is invalid.
60
72
  */
package/dist/errors.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.BadRequestError = exports.ResourceNotFoundError = exports.UnimplementedError = exports.ClientConnectionError = exports.ServiceUnavailableError = exports.ServiceDefinitionNotFoundError = void 0;
26
+ exports.BadRequestError = exports.ResourceAlreadyExistsError = exports.ResourceNotFoundError = exports.UnimplementedError = exports.ClientConnectionError = exports.ServiceUnavailableError = exports.ServiceDefinitionNotFoundError = void 0;
27
27
  /*
28
28
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
29
29
  * http://github.com/fonoster/routr
@@ -54,7 +54,7 @@ class ServiceDefinitionNotFoundError extends Error {
54
54
  * @param {string} version - The version of the service definition.
55
55
  */
56
56
  constructor(name, version) {
57
- super(`service definition for ${name}/${version} not found`);
57
+ super(`Service definition for ${name}/${version} not found`);
58
58
  // Set the prototype explicitly.
59
59
  Object.setPrototypeOf(this, ServiceDefinitionNotFoundError.prototype);
60
60
  }
@@ -70,7 +70,7 @@ class ServiceUnavailableError extends Error {
70
70
  * @param {string} address - The address of the service.
71
71
  */
72
72
  constructor(address) {
73
- super(`service unavailable [service address = ${address}]`);
73
+ super(`Service unavailable [service address = ${address}]`);
74
74
  this.code = grpc.status.UNAVAILABLE;
75
75
  Object.setPrototypeOf(this, ServiceUnavailableError.prototype);
76
76
  }
@@ -86,7 +86,7 @@ class ClientConnectionError extends Error {
86
86
  * @param {boolean} isSecure - Whether the connection is secure.
87
87
  */
88
88
  constructor(address, isSecure) {
89
- super(`cannot connect to service [service address = ${address}, tlsOn = ${isSecure}]`);
89
+ super(`Cannot connect to service [service address = ${address}, tlsOn = ${isSecure}]`);
90
90
  }
91
91
  }
92
92
  exports.ClientConnectionError = ClientConnectionError;
@@ -98,7 +98,7 @@ class UnimplementedError extends Error {
98
98
  * Creates an instance of UnimplementedError.
99
99
  */
100
100
  constructor() {
101
- super("this operation is not supported/enabled in this data api implementation.");
101
+ super("This operation is not supported/enabled in this data api implementation.");
102
102
  this.code = grpc.status.UNIMPLEMENTED;
103
103
  Object.setPrototypeOf(this, UnimplementedError.prototype);
104
104
  }
@@ -114,12 +114,28 @@ class ResourceNotFoundError extends Error {
114
114
  * @param {string} ref - the reference of the resource
115
115
  */
116
116
  constructor(ref) {
117
- super(`resource not found: ${ref}`);
117
+ super(`Resource not found: ${ref}`);
118
118
  this.code = grpc.status.NOT_FOUND;
119
119
  Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
120
120
  }
121
121
  }
122
122
  exports.ResourceNotFoundError = ResourceNotFoundError;
123
+ /**
124
+ * Thrown if the resource already exists.
125
+ */
126
+ class ResourceAlreadyExistsError extends Error {
127
+ /**
128
+ * Creates an instance of ResourceAlreadyExistsError.
129
+ *
130
+ * @param {string} message - message with the error to be thrown.
131
+ */
132
+ constructor(message) {
133
+ super(message !== null && message !== void 0 ? message : "Resource already exists");
134
+ this.code = grpc.status.ALREADY_EXISTS;
135
+ Object.setPrototypeOf(this, ResourceAlreadyExistsError.prototype);
136
+ }
137
+ }
138
+ exports.ResourceAlreadyExistsError = ResourceAlreadyExistsError;
123
139
  /**
124
140
  * Thrown if the request is invalid.
125
141
  */
@@ -130,7 +146,7 @@ class BadRequestError extends Error {
130
146
  * @param {string} message - optional message with the error. Defaults to "bad request."
131
147
  */
132
148
  constructor(message) {
133
- super(message !== null && message !== void 0 ? message : "bad request");
149
+ super(message !== null && message !== void 0 ? message : "Bad request");
134
150
  this.code = grpc.status.INVALID_ARGUMENT;
135
151
  Object.setPrototypeOf(this, BadRequestError.prototype);
136
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/common",
3
- "version": "2.13.4",
3
+ "version": "2.13.7",
4
4
  "description": "Common package",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -55,5 +55,5 @@
55
55
  "devDependencies": {
56
56
  "@types/js-yaml": "^4.0.5"
57
57
  },
58
- "gitHead": "acd1f748311f2e1fe009c6d82d5c13960df83e44"
58
+ "gitHead": "b408f6724aeaf7d42bb10200bc96cbcff0a2390c"
59
59
  }