@platecms/delta-plate-resource-notation 0.3.1 → 0.4.1
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/package.json
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvalidPrnError = void 0;
|
|
4
4
|
class InvalidPrnError extends Error {
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
7
|
-
this.name = this.constructor.name;
|
|
5
|
+
constructor(prn) {
|
|
6
|
+
super(`The PRN '${prn}' is invalid or malformed.`);
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
9
|
exports.InvalidPrnError = InvalidPrnError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-prn.error.js","sourceRoot":"","sources":["../../../../../../packages/plate-resource-notation/src/lib/invalid-prn.error.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAmB,
|
|
1
|
+
{"version":3,"file":"invalid-prn.error.js","sourceRoot":"","sources":["../../../../../../packages/plate-resource-notation/src/lib/invalid-prn.error.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAmB,GAAW;QAC5B,KAAK,CAAC,YAAY,GAAG,4BAA4B,CAAC,CAAC;IACrD,CAAC;CACF;AAJD,0CAIC"}
|
|
@@ -8,10 +8,10 @@ class PRN {
|
|
|
8
8
|
constructor(partition, organizationId, service, resourceType, resourceId) {
|
|
9
9
|
const componentArray = [partition, service, organizationId, resourceType, resourceId];
|
|
10
10
|
if (!componentArray.every((comp) => typeof comp === "string" && comp.length > 0)) {
|
|
11
|
-
throw new invalid_prn_error_1.InvalidPrnError("Invalid PRN component(s)
|
|
11
|
+
throw new invalid_prn_error_1.InvalidPrnError("Invalid PRN component(s). All components must be a non-empty string.");
|
|
12
12
|
}
|
|
13
13
|
if (componentArray.some((comp) => comp.includes(":"))) {
|
|
14
|
-
throw new invalid_prn_error_1.InvalidPrnError("Invalid PRN string specification
|
|
14
|
+
throw new invalid_prn_error_1.InvalidPrnError("Invalid PRN string specification. Components cannot contain ':'.");
|
|
15
15
|
}
|
|
16
16
|
this.partition = partition;
|
|
17
17
|
this.organizationId = organizationId;
|
|
@@ -21,11 +21,11 @@ class PRN {
|
|
|
21
21
|
}
|
|
22
22
|
static fromString(prnString) {
|
|
23
23
|
if (!prn_regex_constant_1.PRN_REGEX.test(prnString)) {
|
|
24
|
-
throw new invalid_prn_error_1.InvalidPrnError(`Invalid PRN string '${prnString}'
|
|
24
|
+
throw new invalid_prn_error_1.InvalidPrnError(`Invalid PRN string '${prnString}'. Should match the pattern '${prn_regex_constant_1.PRN_REGEX.source}'`);
|
|
25
25
|
}
|
|
26
26
|
const [_, partition, organizationId, service, resourceType, resourceId] = prnString.split(":");
|
|
27
27
|
if (!Object.values(services_abbreviation_enum_1.ServiceAbbreviation).map(String).includes(service)) {
|
|
28
|
-
throw new invalid_prn_error_1.InvalidPrnError(`Invalid ServiceAbbreviation '${service}'
|
|
28
|
+
throw new invalid_prn_error_1.InvalidPrnError(`Invalid ServiceAbbreviation '${service}'. Use the ServiceAbbreviation enum.`);
|
|
29
29
|
}
|
|
30
30
|
return new PRN(partition, organizationId, service, resourceType, resourceId);
|
|
31
31
|
}
|