@forge/manifest 7.7.0-next.5 → 7.7.0-next.6
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/CHANGELOG.md +6 -0
- package/out/interpolator/environment-variable-interpolator.d.ts +15 -0
- package/out/interpolator/environment-variable-interpolator.d.ts.map +1 -0
- package/out/interpolator/environment-variable-interpolator.js +47 -0
- package/out/interpolator/manifest-interpolator-manager.d.ts +9 -0
- package/out/interpolator/manifest-interpolator-manager.d.ts.map +1 -0
- package/out/interpolator/manifest-interpolator-manager.js +21 -0
- package/out/interpolator/manifest-interpolator.d.ts +13 -0
- package/out/interpolator/manifest-interpolator.d.ts.map +1 -0
- package/out/interpolator/manifest-interpolator.js +15 -0
- package/out/interpolator/string-resource-interpolator.d.ts +14 -0
- package/out/interpolator/string-resource-interpolator.d.ts.map +1 -0
- package/out/interpolator/string-resource-interpolator.js +70 -0
- package/out/text/errors.d.ts +4 -0
- package/out/text/errors.d.ts.map +1 -1
- package/out/text/errors.js +5 -1
- package/out/utils/index.d.ts +2 -1
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -1
- package/out/utils/manifest-parser-builder.d.ts +8 -0
- package/out/utils/manifest-parser-builder.d.ts.map +1 -0
- package/out/utils/manifest-parser-builder.js +22 -0
- package/out/utils/manifest-parser.d.ts +4 -6
- package/out/utils/manifest-parser.d.ts.map +1 -1
- package/out/utils/manifest-parser.js +13 -29
- package/out/validators/yaml-validator.d.ts +0 -2
- package/out/validators/yaml-validator.d.ts.map +1 -1
- package/out/validators/yaml-validator.js +2 -6
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InterpolatorType, ManifestInterpolator, ManifestInterpolatorError } from './manifest-interpolator';
|
|
2
|
+
import { ManifestSchema } from '../schema/manifest';
|
|
3
|
+
export declare class EnvironmentVariableInterpolatorError extends ManifestInterpolatorError {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class EnvironmentVariableInterpolator implements ManifestInterpolator {
|
|
7
|
+
private readonly envVarsRecord;
|
|
8
|
+
type: InterpolatorType;
|
|
9
|
+
POSSIBLE_ENVIRONMENT_VARIABLE: RegExp;
|
|
10
|
+
private envVarsToReplace;
|
|
11
|
+
constructor(envVarsRecord?: Record<string, string | undefined>);
|
|
12
|
+
interpolate(manifest: ManifestSchema): ManifestSchema;
|
|
13
|
+
private environmentVariableReviver;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=environment-variable-interpolator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-variable-interpolator.d.ts","sourceRoot":"","sources":["../../src/interpolator/environment-variable-interpolator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC5G,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,qBAAa,oCAAqC,SAAQ,yBAAyB;gBACrE,OAAO,EAAE,MAAM;CAI5B;AAKD,qBAAa,+BAAgC,YAAW,oBAAoB;IAS9D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAR1C,IAAI,EAAE,gBAAgB,CAAyC;IAI/D,6BAA6B,SAAqC;IAElE,OAAO,CAAC,gBAAgB,CAAW;gBAEN,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAM;IAInF,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc;IAKrD,OAAO,CAAC,0BAA0B,CAkBhC;CACH"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvironmentVariableInterpolator = exports.EnvironmentVariableInterpolatorError = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const yaml_1 = require("yaml");
|
|
6
|
+
const manifest_interpolator_1 = require("./manifest-interpolator");
|
|
7
|
+
const text_1 = require("../text");
|
|
8
|
+
const Sentry = tslib_1.__importStar(require("@sentry/node"));
|
|
9
|
+
class EnvironmentVariableInterpolatorError extends manifest_interpolator_1.ManifestInterpolatorError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'EnvironmentVariableInterpolatorError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.EnvironmentVariableInterpolatorError = EnvironmentVariableInterpolatorError;
|
|
16
|
+
class EnvironmentVariableInterpolator {
|
|
17
|
+
envVarsRecord;
|
|
18
|
+
type = manifest_interpolator_1.InterpolatorType.ENVIRONMENT_VARIABLE;
|
|
19
|
+
POSSIBLE_ENVIRONMENT_VARIABLE = /\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;
|
|
20
|
+
envVarsToReplace;
|
|
21
|
+
constructor(envVarsRecord = {}) {
|
|
22
|
+
this.envVarsRecord = envVarsRecord;
|
|
23
|
+
this.envVarsToReplace = [];
|
|
24
|
+
}
|
|
25
|
+
interpolate(manifest) {
|
|
26
|
+
this.envVarsToReplace = manifest.environment?.variables ?? [];
|
|
27
|
+
return (0, yaml_1.parse)(JSON.stringify(manifest), this.environmentVariableReviver);
|
|
28
|
+
}
|
|
29
|
+
environmentVariableReviver = (_, value) => {
|
|
30
|
+
if (!(typeof value == 'string')) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
value = value.replace(this.POSSIBLE_ENVIRONMENT_VARIABLE, (original, envVarName) => {
|
|
34
|
+
if (!this.envVarsToReplace.includes(envVarName)) {
|
|
35
|
+
return original;
|
|
36
|
+
}
|
|
37
|
+
const envVar = this.envVarsRecord[envVarName];
|
|
38
|
+
if (envVar === undefined) {
|
|
39
|
+
throw new EnvironmentVariableInterpolatorError(text_1.errors.schema.missingEnvironmentVariable(envVarName));
|
|
40
|
+
}
|
|
41
|
+
Sentry.captureMessage('replaced environment variable');
|
|
42
|
+
return envVar;
|
|
43
|
+
});
|
|
44
|
+
return value;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.EnvironmentVariableInterpolator = EnvironmentVariableInterpolator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManifestSchema } from '../schema/manifest';
|
|
2
|
+
import { ManifestInterpolator } from './manifest-interpolator';
|
|
3
|
+
export declare class ManifestInterpolatorManager {
|
|
4
|
+
private interpolators;
|
|
5
|
+
constructor();
|
|
6
|
+
addInterpolator(interpolator: ManifestInterpolator): void;
|
|
7
|
+
interpolate(manifest: string): ManifestSchema;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=manifest-interpolator-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-interpolator-manager.d.ts","sourceRoot":"","sources":["../../src/interpolator/manifest-interpolator-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAoB,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAMjF,qBAAa,2BAA2B;IACtC,OAAO,CAAC,aAAa,CAA8C;;IAUnE,eAAe,CAAC,YAAY,EAAE,oBAAoB,GAAG,IAAI;IASzD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc;CAO9C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManifestInterpolatorManager = void 0;
|
|
4
|
+
const yaml_1 = require("yaml");
|
|
5
|
+
class ManifestInterpolatorManager {
|
|
6
|
+
interpolators;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.interpolators = new Map();
|
|
9
|
+
}
|
|
10
|
+
addInterpolator(interpolator) {
|
|
11
|
+
this.interpolators.set(interpolator.type, interpolator);
|
|
12
|
+
}
|
|
13
|
+
interpolate(manifest) {
|
|
14
|
+
let interpolatedManifest = (0, yaml_1.parse)(manifest);
|
|
15
|
+
for (const interpolator of this.interpolators.values()) {
|
|
16
|
+
interpolatedManifest = interpolator.interpolate(interpolatedManifest);
|
|
17
|
+
}
|
|
18
|
+
return interpolatedManifest;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ManifestInterpolatorManager = ManifestInterpolatorManager;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ManifestSchema } from '../schema/manifest';
|
|
2
|
+
export declare class ManifestInterpolatorError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare enum InterpolatorType {
|
|
6
|
+
STRING_RESOURCE = 0,
|
|
7
|
+
ENVIRONMENT_VARIABLE = 1
|
|
8
|
+
}
|
|
9
|
+
export interface ManifestInterpolator {
|
|
10
|
+
type: InterpolatorType;
|
|
11
|
+
interpolate(manifest: ManifestSchema): ManifestSchema;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=manifest-interpolator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-interpolator.d.ts","sourceRoot":"","sources":["../../src/interpolator/manifest-interpolator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED,oBAAY,gBAAgB;IAC1B,eAAe,IAAA;IACf,oBAAoB,IAAA;CACrB;AAKD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,gBAAgB,CAAC;IAMvB,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc,CAAC;CACvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InterpolatorType = exports.ManifestInterpolatorError = void 0;
|
|
4
|
+
class ManifestInterpolatorError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'ManifestInterpolatorError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ManifestInterpolatorError = ManifestInterpolatorError;
|
|
11
|
+
var InterpolatorType;
|
|
12
|
+
(function (InterpolatorType) {
|
|
13
|
+
InterpolatorType[InterpolatorType["STRING_RESOURCE"] = 0] = "STRING_RESOURCE";
|
|
14
|
+
InterpolatorType[InterpolatorType["ENVIRONMENT_VARIABLE"] = 1] = "ENVIRONMENT_VARIABLE";
|
|
15
|
+
})(InterpolatorType = exports.InterpolatorType || (exports.InterpolatorType = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ManifestSchema } from '../schema/manifest';
|
|
2
|
+
import { InterpolatorType, ManifestInterpolator, ManifestInterpolatorError } from './manifest-interpolator';
|
|
3
|
+
export declare class StringResourceInterpolatorError extends ManifestInterpolatorError {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class StringResourceInterpolator implements ManifestInterpolator {
|
|
7
|
+
type: InterpolatorType;
|
|
8
|
+
interpolate(manifest: ManifestSchema): ManifestSchema;
|
|
9
|
+
private fetchContentFromResourceFile;
|
|
10
|
+
private getResourcePath;
|
|
11
|
+
private checkIfResourceIsValid;
|
|
12
|
+
private checkIfResourceTypeIsSupported;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=string-resource-interpolator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-resource-interpolator.d.ts","sourceRoot":"","sources":["../../src/interpolator/string-resource-interpolator.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAY5G,qBAAa,+BAAgC,SAAQ,yBAAyB;gBAChE,OAAO,EAAE,MAAM;CAI5B;AAKD,qBAAa,0BAA2B,YAAW,oBAAoB;IACrE,IAAI,EAAE,gBAAgB,CAAoC;IAE1D,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc;IAiBrD,OAAO,CAAC,4BAA4B;IASpC,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,8BAA8B;CAOvC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringResourceInterpolator = exports.StringResourceInterpolatorError = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const errors_1 = require("../text/errors");
|
|
7
|
+
const manifest_interpolator_1 = require("./manifest-interpolator");
|
|
8
|
+
const mime_types_1 = require("mime-types");
|
|
9
|
+
const MODULE_PROPERTIES_TO_INTERPOLATE = [
|
|
10
|
+
{ moduleType: types_1.AllModuleTypes.RovoAgent, property: 'prompt' }
|
|
11
|
+
];
|
|
12
|
+
class StringResourceInterpolatorError extends manifest_interpolator_1.ManifestInterpolatorError {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'StringResourceInterpolatorError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.StringResourceInterpolatorError = StringResourceInterpolatorError;
|
|
19
|
+
class StringResourceInterpolator {
|
|
20
|
+
type = manifest_interpolator_1.InterpolatorType.STRING_RESOURCE;
|
|
21
|
+
interpolate(manifest) {
|
|
22
|
+
MODULE_PROPERTIES_TO_INTERPOLATE.forEach(({ moduleType, property }) => {
|
|
23
|
+
const modules = manifest.modules?.[moduleType];
|
|
24
|
+
modules?.forEach((module) => {
|
|
25
|
+
if (module.hasOwnProperty(property)) {
|
|
26
|
+
const moduleAny = module;
|
|
27
|
+
const propertyValue = moduleAny[property];
|
|
28
|
+
if (propertyValue.startsWith('resource:')) {
|
|
29
|
+
moduleAny[property] = this.fetchContentFromResourceFile(propertyValue, manifest);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return manifest;
|
|
35
|
+
}
|
|
36
|
+
fetchContentFromResourceFile(modulePropertyWithStringResource, manifest) {
|
|
37
|
+
const resourcePath = this.getResourcePath(manifest, modulePropertyWithStringResource);
|
|
38
|
+
try {
|
|
39
|
+
return (0, fs_1.readFileSync)(resourcePath, 'utf8');
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new StringResourceInterpolatorError(errors_1.errors.schema.errorReadingResourceFile(resourcePath, error?.message));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getResourcePath(manifest, resourceString) {
|
|
46
|
+
const resourceUrl = new URL(resourceString);
|
|
47
|
+
const [resourceKey, relativePath] = resourceUrl.pathname.split(';');
|
|
48
|
+
const resource = this.checkIfResourceIsValid(manifest, resourceKey);
|
|
49
|
+
const resourcePath = `${resource.path}/${relativePath}`;
|
|
50
|
+
this.checkIfResourceTypeIsSupported(resourcePath);
|
|
51
|
+
return resourcePath;
|
|
52
|
+
}
|
|
53
|
+
checkIfResourceIsValid(manifest, resourceKey) {
|
|
54
|
+
const resource = manifest.resources?.find((resource) => resource.key === resourceKey);
|
|
55
|
+
if (!resource) {
|
|
56
|
+
throw new StringResourceInterpolatorError(errors_1.errors.schema.resourceNotFound(resourceKey));
|
|
57
|
+
}
|
|
58
|
+
if (!resource.path) {
|
|
59
|
+
throw new StringResourceInterpolatorError(errors_1.errors.schema.resourcePathNotDefined(resourceKey));
|
|
60
|
+
}
|
|
61
|
+
return resource;
|
|
62
|
+
}
|
|
63
|
+
checkIfResourceTypeIsSupported(resourcePath) {
|
|
64
|
+
const mimeType = (0, mime_types_1.lookup)(resourcePath);
|
|
65
|
+
if (!mimeType || !mimeType.startsWith('text')) {
|
|
66
|
+
throw new StringResourceInterpolatorError(errors_1.errors.schema.resourceFileNotSupported(resourcePath));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.StringResourceInterpolator = StringResourceInterpolator;
|
package/out/text/errors.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export declare const errors: {
|
|
|
10
10
|
additionalProperties: (additionalProperty: string) => string;
|
|
11
11
|
notAllowed: (props: string[] | undefined) => string;
|
|
12
12
|
missingEnvironmentVariable: (variable: string) => string;
|
|
13
|
+
errorReadingResourceFile: (variable: string, errorMessage: string) => string;
|
|
14
|
+
resourceNotFound: (variable: string) => string;
|
|
15
|
+
resourcePathNotDefined: (variable: string) => string;
|
|
16
|
+
resourceFileNotSupported: (variable: string) => string;
|
|
13
17
|
};
|
|
14
18
|
permissions: {
|
|
15
19
|
invalidPermission: (element: string, value: string) => string;
|
package/out/text/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/text/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,eAAO,MAAM,MAAM;8BACS,MAAM,KAAG,MAAM;2BACpB,MAAM;yBAEN,MAAM,GAAG,SAAS,QAAQ,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,KAAG,MAAM;;uBAO3E,MAAM,EAAE,EAAE,GAAG,SAAS,KAAG,MAAM;4BAI1B,MAAM,EAAE,KAAG,MAAM;mCACV,MAAM,SAAS,MAAM,mBAAmB,MAAM,KAAG,MAAM;mDAIvC,MAAM,KAAG,MAAM;4BAEtC,MAAM,EAAE,GAAG,SAAS,KAAG,MAAM;+CAIV,MAAM;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/text/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,eAAO,MAAM,MAAM;8BACS,MAAM,KAAG,MAAM;2BACp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AExB,MAAM,KAAG,MAAM;+BACvB,MAAM,OAAO,MAAM,KAAG,MAAM;;;;;;;;kCASzB,MAAM,UAAU,MAAM,KAAG,MAAM;gCAEjC,MAAM,KAAG,MAAM;2CAEJ,MAAM,eAAe,MAAM,KAAG,MAAM;;;uCAI1C,MAAM;uCAEJ,MAAM,KAAG,MAAM;qCAEnB,MAAM;;6CAGA,MAAM;;;mDAIE,MAAM,KAAG,MAAM;;;;4CAKxB,MAAM,SAAS,MAAM,KAAG,MAAM;4CAE9B,MAAM,KAAG,MAAM;4CACf,MAAM,SAAS,MAAM,KAAG,MAAM;+CAE3B,MAAM,aAAa,MAAM,SAAS,MAAM,KAAG,MAAM;yCAEvD,MAAM,SAAS,MAAM,KAAG,MAAM;4CAE3B,MAAM,SAAS,MAAM,KAAG,MAAM;gDAE1B,MAAM,aAAa,MAAM,KAAG,MAAM;4CAEtC,MAAM,SAAS,MAAM,KAAG,MAAM;;;2CAI7B,MAAM;;;gCAInB,MAAM;;;;;0DAKwB,MAAM,KAAG,MAAM;sDAEnB,MAAM,KAAG,MAAM;kDAEnB,MAAM,QAAQ,MAAM,KAAG,MAAM;mDAE5B,MAAM,KAAG,MAAM;mCAE/B,MAAM,KAAG,MAAM;;oDAEE,MAAM,aAAa,MAAM,KAAG,MAAM;;CAGjF,CAAC;AAEF,oBAAY,UAAU;IACpB,eAAe,2BAA2B;IAC1C,eAAe,wBAAwB;IACvC,WAAW,4BAA4B;IACvC,WAAW,+BAA+B;IAC1C,aAAa,8BAA8B;IAC3C,OAAO,0BAA0B;IACjC,cAAc,kCAAkC;IAChD,SAAS,4BAA4B;IACrC,SAAS,4BAA4B;IACrC,UAAU,wBAAwB;IAClC,GAAG,8BAA8B;IACjC,eAAe,0BAA0B;CAC1C"}
|
package/out/text/errors.js
CHANGED
|
@@ -22,7 +22,11 @@ exports.errors = {
|
|
|
22
22
|
notAllowed: (props) => props
|
|
23
23
|
? `does not support the following Forge properties - ${props.map((v) => "'" + v + "'").join(', ')}`
|
|
24
24
|
: 'provided properties do not match schema. Learn more about modules at https://go.atlassian.com/forge-modules',
|
|
25
|
-
missingEnvironmentVariable: (variable) => `could not find environment variable '${variable}'
|
|
25
|
+
missingEnvironmentVariable: (variable) => `could not find environment variable '${variable}'`,
|
|
26
|
+
errorReadingResourceFile: (variable, errorMessage) => `error while reading resource file: '${variable}'. Error: ${errorMessage}`,
|
|
27
|
+
resourceNotFound: (variable) => `could not find resource: '${variable}'`,
|
|
28
|
+
resourcePathNotDefined: (variable) => `resource path not defined for resource: '${variable}'`,
|
|
29
|
+
resourceFileNotSupported: (variable) => `resource file type not supported: '${variable}'`
|
|
26
30
|
},
|
|
27
31
|
permissions: {
|
|
28
32
|
invalidPermission: (element, value) => `Invalid '${element}' permission in the manifest.yml file - '${value}'. Learn more about permissions at: https://go.atlassian.com/forge-permissions.`,
|
package/out/utils/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export * from './get-all-modules';
|
|
|
2
2
|
export * from './line-finder';
|
|
3
3
|
export * from './module-key-cleaner';
|
|
4
4
|
export * from './module-references';
|
|
5
|
-
export * from './manifest-parser';
|
|
5
|
+
export * from './manifest-parser-builder';
|
|
6
|
+
export type { ManifestParser } from './manifest-parser';
|
|
6
7
|
export * from './module-i18n-helper';
|
|
7
8
|
export * from './translation-value-getter';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/out/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
package/out/utils/index.js
CHANGED
|
@@ -5,6 +5,6 @@ tslib_1.__exportStar(require("./get-all-modules"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("./line-finder"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./module-key-cleaner"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./module-references"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./manifest-parser"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./manifest-parser-builder"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./module-i18n-helper"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./translation-value-getter"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ManifestParser } from './manifest-parser';
|
|
2
|
+
export declare class ManifestParserBuilder {
|
|
3
|
+
private manifestInterpolatorManager;
|
|
4
|
+
constructor();
|
|
5
|
+
withInterpolators(): ManifestParserBuilder;
|
|
6
|
+
build(): ManifestParser;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=manifest-parser-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-parser-builder.d.ts","sourceRoot":"","sources":["../../src/utils/manifest-parser-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMnD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,2BAA2B,CAA8B;;IAcjE,iBAAiB,IAAI,qBAAqB;IAU1C,KAAK,IAAI,cAAc;CAGxB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManifestParserBuilder = void 0;
|
|
4
|
+
const environment_variable_interpolator_1 = require("../interpolator/environment-variable-interpolator");
|
|
5
|
+
const manifest_interpolator_manager_1 = require("../interpolator/manifest-interpolator-manager");
|
|
6
|
+
const string_resource_interpolator_1 = require("../interpolator/string-resource-interpolator");
|
|
7
|
+
const manifest_parser_1 = require("./manifest-parser");
|
|
8
|
+
class ManifestParserBuilder {
|
|
9
|
+
manifestInterpolatorManager;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.manifestInterpolatorManager = new manifest_interpolator_manager_1.ManifestInterpolatorManager();
|
|
12
|
+
}
|
|
13
|
+
withInterpolators() {
|
|
14
|
+
this.manifestInterpolatorManager.addInterpolator(new environment_variable_interpolator_1.EnvironmentVariableInterpolator(process.env));
|
|
15
|
+
this.manifestInterpolatorManager.addInterpolator(new string_resource_interpolator_1.StringResourceInterpolator());
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
build() {
|
|
19
|
+
return new manifest_parser_1.ManifestParser(this.manifestInterpolatorManager);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ManifestParserBuilder = ManifestParserBuilder;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ManifestInterpolatorManager } from '../interpolator/manifest-interpolator-manager';
|
|
2
2
|
export declare class ManifestParserError extends Error {
|
|
3
3
|
constructor(message: string);
|
|
4
4
|
getAttributes(): {
|
|
@@ -6,11 +6,9 @@ export declare class ManifestParserError extends Error {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
export declare class ManifestParser {
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
parseManifest(manifest: string): ManifestSchema;
|
|
9
|
+
private manifestInterpolator;
|
|
10
|
+
constructor(manifestInterpolator: ManifestInterpolatorManager);
|
|
11
|
+
parseManifest(manifest: string): import("../index").ManifestSchema;
|
|
13
12
|
parseManifestAsString: (manifest: string) => string;
|
|
14
|
-
private environmentVariableReviver;
|
|
15
13
|
}
|
|
16
14
|
//# sourceMappingURL=manifest-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-parser.d.ts","sourceRoot":"","sources":["../../src/utils/manifest-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest-parser.d.ts","sourceRoot":"","sources":["../../src/utils/manifest-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAK5F,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;IAMpB,aAAa;;;CAKrB;AAKD,qBAAa,cAAc;IACb,OAAO,CAAC,oBAAoB;gBAApB,oBAAoB,EAAE,2BAA2B;IAQrE,aAAa,CAAC,QAAQ,EAAE,MAAM;IAgB9B,qBAAqB,aAAc,MAAM,YAAgE;CAC1G"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ManifestParser = exports.ManifestParserError = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const yaml_1 = require("yaml");
|
|
6
|
-
const
|
|
7
|
-
const Sentry = tslib_1.__importStar(require("@sentry/node"));
|
|
5
|
+
const manifest_interpolator_1 = require("../interpolator/manifest-interpolator");
|
|
8
6
|
const yamlConfigOptions = { indent: 2, skipInvalid: true };
|
|
9
7
|
class ManifestParserError extends Error {
|
|
10
8
|
constructor(message) {
|
|
@@ -17,36 +15,22 @@ class ManifestParserError extends Error {
|
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
17
|
exports.ManifestParserError = ManifestParserError;
|
|
20
|
-
const POSSIBLE_ENVIRONMENT_VARIABLE = /\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;
|
|
21
18
|
class ManifestParser {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.envVarsRecord = envVarsRecord;
|
|
26
|
-
this.envVarsToReplace = [];
|
|
19
|
+
manifestInterpolator;
|
|
20
|
+
constructor(manifestInterpolator) {
|
|
21
|
+
this.manifestInterpolator = manifestInterpolator;
|
|
27
22
|
}
|
|
28
23
|
parseManifest(manifest) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return (0, yaml_1.parse)(manifest, this.environmentVariableReviver);
|
|
32
|
-
}
|
|
33
|
-
parseManifestAsString = (manifest) => (0, yaml_1.stringify)(this.parseManifest(manifest), yamlConfigOptions);
|
|
34
|
-
environmentVariableReviver = (_, value) => {
|
|
35
|
-
if (!(typeof value == 'string')) {
|
|
36
|
-
return value;
|
|
24
|
+
try {
|
|
25
|
+
return this.manifestInterpolator.interpolate(manifest);
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
const envVar = this.envVarsRecord[envVarName];
|
|
43
|
-
if (envVar === undefined) {
|
|
44
|
-
throw new ManifestParserError(errors_1.errors.schema.missingEnvironmentVariable(envVarName));
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error instanceof manifest_interpolator_1.ManifestInterpolatorError) {
|
|
29
|
+
throw new ManifestParserError(error.message);
|
|
45
30
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
parseManifestAsString = (manifest) => (0, yaml_1.stringify)(this.parseManifest(manifest), yamlConfigOptions);
|
|
51
35
|
}
|
|
52
36
|
exports.ManifestParser = ManifestParser;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ManifestObject, ManifestValidationResult } from '../types';
|
|
2
2
|
import { ValidatorInterface } from './validator-interface';
|
|
3
3
|
export declare class YamlValidator<T> implements ValidatorInterface<ManifestObject<T> | undefined, T> {
|
|
4
|
-
private manifestParser;
|
|
5
|
-
constructor();
|
|
6
4
|
validate(manifest: ManifestObject<T> | undefined): Promise<ManifestValidationResult<T>>;
|
|
7
5
|
}
|
|
8
6
|
//# sourceMappingURL=yaml-validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-validator.d.ts","sourceRoot":"","sources":["../../src/validators/yaml-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAIpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-validator.d.ts","sourceRoot":"","sources":["../../src/validators/yaml-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAIpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC;IACrF,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;CAiD9F"}
|
|
@@ -5,12 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const yaml_1 = require("yaml");
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
7
|
const text_1 = require("../text");
|
|
8
|
-
const
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
9
|
class YamlValidator {
|
|
10
|
-
manifestParser;
|
|
11
|
-
constructor() {
|
|
12
|
-
this.manifestParser = new __1.ManifestParser(process.env);
|
|
13
|
-
}
|
|
14
10
|
async validate(manifest) {
|
|
15
11
|
if (!manifest || !manifest.filePath) {
|
|
16
12
|
return {
|
|
@@ -20,7 +16,7 @@ class YamlValidator {
|
|
|
20
16
|
}
|
|
21
17
|
try {
|
|
22
18
|
const content = fs_1.default.readFileSync(manifest.filePath, 'utf8');
|
|
23
|
-
const manifestContent =
|
|
19
|
+
const manifestContent = new utils_1.ManifestParserBuilder().withInterpolators().build().parseManifest(content);
|
|
24
20
|
return {
|
|
25
21
|
success: true,
|
|
26
22
|
manifestObject: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/manifest",
|
|
3
|
-
"version": "7.7.0-next.
|
|
3
|
+
"version": "7.7.0-next.6",
|
|
4
4
|
"description": "Definitions and validations of the Forge manifest",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"cheerio": "^0.22.0",
|
|
31
31
|
"glob": "^10.3.10",
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
|
+
"mime-types": "^2.1.35",
|
|
33
34
|
"yaml": "^2.3.4"
|
|
34
35
|
}
|
|
35
36
|
}
|