@contrail/util 1.0.39 → 1.0.40
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/lib/app-util/app-util.d.ts +14 -4
- package/lib/app-util/app-util.js +40 -9
- package/package.json +1 -1
|
@@ -3,13 +3,23 @@ export interface ActionDefinitionIdentifierParts {
|
|
|
3
3
|
versionId: string;
|
|
4
4
|
actionNameIdentifier: string;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export interface ExtensionIdentifierParts {
|
|
7
|
+
appIdentifier: string;
|
|
8
|
+
extensionIdentifier: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = "Action definition has no identifier. An identifier is required.";
|
|
11
|
+
export declare const ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = "Invalid action identifier. Action definition identifier must conform with '@appIdentifier@versionId:actionIdentifier'";
|
|
12
|
+
export declare const ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = "Invalid action definition identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+";
|
|
13
|
+
export declare const ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = "Invalid action definitions identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. 'appIdentifier', 'versionId', and 'actionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+.";
|
|
14
|
+
export declare const EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = "Extension definition has no identifier. An identifier is required.";
|
|
15
|
+
export declare const EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = "Invalid extension identifier. Action definition identifier must conform with '@appIdentifier:extensionIdentifier'";
|
|
16
|
+
export declare const EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = "Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+";
|
|
17
|
+
export declare const EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = "Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. 'appIdentifier' and 'extensionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' '.' and conform to the regex ^@([_.-/A-Za-z0-9]+)@([_.-/A-Za-z0-9])+:([_.-/A-Za-z0-9])+.";
|
|
10
18
|
export declare class BadIdentifierException extends Error {
|
|
11
19
|
}
|
|
12
20
|
export declare class AppUtil {
|
|
13
21
|
static parseActionIdentifier(actionIdentifier: string): ActionDefinitionIdentifierParts;
|
|
14
22
|
static createActionIdentifier(actionDefinitionParts: ActionDefinitionIdentifierParts): string;
|
|
23
|
+
static parseExtensionIdentifier(extensionIdentifier: string): ExtensionIdentifierParts;
|
|
24
|
+
static createExtensionIdentifier(extensionDefinitionParts: ExtensionIdentifierParts): string;
|
|
15
25
|
}
|
package/lib/app-util/app-util.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppUtil = exports.BadIdentifierException = exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
3
|
+
exports.AppUtil = exports.BadIdentifierException = exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = void 0;
|
|
4
|
+
exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = 'Action definition has no identifier. An identifier is required.';
|
|
5
|
+
exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = `Invalid action identifier. Action definition identifier must conform with '@appIdentifier@versionId:actionIdentifier'`;
|
|
6
|
+
exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = `Invalid action definition identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+`;
|
|
7
|
+
exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = `Invalid action definitions identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. 'appIdentifier', 'versionId', and 'actionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+.`;
|
|
8
|
+
exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = 'Extension definition has no identifier. An identifier is required.';
|
|
9
|
+
exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = `Invalid extension identifier. Action definition identifier must conform with '@appIdentifier:extensionIdentifier'`;
|
|
10
|
+
exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = `Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+`;
|
|
11
|
+
exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = `Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. 'appIdentifier' and 'extensionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' '.' and conform to the regex ^@([_\.\-\/A-Za-z0-9]+)@([_\.\-\/A-Za-z0-9])+:([_\.\-\/A-Za-z0-9])+.`;
|
|
8
12
|
class BadIdentifierException extends Error {
|
|
9
13
|
}
|
|
10
14
|
exports.BadIdentifierException = BadIdentifierException;
|
|
@@ -13,19 +17,19 @@ class AppUtil {
|
|
|
13
17
|
static parseActionIdentifier(actionIdentifier) {
|
|
14
18
|
{
|
|
15
19
|
if (!actionIdentifier) {
|
|
16
|
-
throw new BadIdentifierException(exports.
|
|
20
|
+
throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER);
|
|
17
21
|
}
|
|
18
22
|
if (!actionIdentifier.startsWith('@')) {
|
|
19
|
-
throw new BadIdentifierException(exports.
|
|
23
|
+
throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT);
|
|
20
24
|
}
|
|
21
25
|
const identifierParts = actionIdentifier.split(/[@:]/);
|
|
22
26
|
if (identifierParts.length !== 4) {
|
|
23
|
-
throw new BadIdentifierException(exports.
|
|
27
|
+
throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN);
|
|
24
28
|
}
|
|
25
29
|
for (const appVersionPart of identifierParts.slice(1)) {
|
|
26
30
|
const badCharacters = appVersionPart.match(/[^@_.\-\/A-Za-z0-9]/g);
|
|
27
31
|
if (badCharacters === null || badCharacters === void 0 ? void 0 : badCharacters.length) {
|
|
28
|
-
throw new BadIdentifierException(exports.
|
|
32
|
+
throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
return {
|
|
@@ -38,5 +42,32 @@ class AppUtil {
|
|
|
38
42
|
static createActionIdentifier(actionDefinitionParts) {
|
|
39
43
|
return `${actionDefinitionParts.appIdentifier}@${actionDefinitionParts.versionId}:${actionDefinitionParts.actionNameIdentifier}`;
|
|
40
44
|
}
|
|
45
|
+
static parseExtensionIdentifier(extensionIdentifier) {
|
|
46
|
+
{
|
|
47
|
+
if (!extensionIdentifier) {
|
|
48
|
+
throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER);
|
|
49
|
+
}
|
|
50
|
+
if (!extensionIdentifier.startsWith('@')) {
|
|
51
|
+
throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT);
|
|
52
|
+
}
|
|
53
|
+
const identifierParts = extensionIdentifier.split(/[@:]/);
|
|
54
|
+
if (identifierParts.length !== 3) {
|
|
55
|
+
throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN);
|
|
56
|
+
}
|
|
57
|
+
for (const appVersionPart of identifierParts.slice(1)) {
|
|
58
|
+
const badCharacters = appVersionPart.match(/[^@_.\-\/A-Za-z0-9]/g);
|
|
59
|
+
if (badCharacters === null || badCharacters === void 0 ? void 0 : badCharacters.length) {
|
|
60
|
+
throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
appIdentifier: `@${identifierParts[1]}`,
|
|
65
|
+
extensionIdentifier: identifierParts[2]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static createExtensionIdentifier(extensionDefinitionParts) {
|
|
70
|
+
return `${extensionDefinitionParts.appIdentifier}:${extensionDefinitionParts.extensionIdentifier}`;
|
|
71
|
+
}
|
|
41
72
|
}
|
|
42
73
|
exports.AppUtil = AppUtil;
|