@rocketmakers/orbit-template-service 2.0.0-beta.2 → 2.0.0-beta.5
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 +13 -13
- package/lib/src/core/index.d.ts +0 -2
- package/lib/src/core/index.d.ts.map +0 -1
- package/lib/src/core/index.js +0 -5
- package/lib/src/core/index.js.map +0 -1
- package/lib/src/core/validation.d.ts +0 -8
- package/lib/src/core/validation.d.ts.map +0 -1
- package/lib/src/core/validation.js +0 -20
- package/lib/src/core/validation.js.map +0 -1
- package/lib/src/index.d.ts +0 -4
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/index.js +0 -7
- package/lib/src/index.js.map +0 -1
- package/lib/src/ioc/container.d.ts +0 -13
- package/lib/src/ioc/container.d.ts.map +0 -1
- package/lib/src/ioc/container.js +0 -7
- package/lib/src/ioc/container.js.map +0 -1
- package/lib/src/ioc/index.d.ts +0 -3
- package/lib/src/ioc/index.d.ts.map +0 -1
- package/lib/src/ioc/index.js +0 -6
- package/lib/src/ioc/index.js.map +0 -1
- package/lib/src/ioc/register.d.ts +0 -2
- package/lib/src/ioc/register.d.ts.map +0 -1
- package/lib/src/ioc/register.js +0 -13
- package/lib/src/ioc/register.js.map +0 -1
- package/lib/src/ioc/types.d.ts +0 -5
- package/lib/src/ioc/types.d.ts.map +0 -1
- package/lib/src/ioc/types.js +0 -3
- package/lib/src/ioc/types.js.map +0 -1
- package/lib/src/services/index.d.ts +0 -2
- package/lib/src/services/index.d.ts.map +0 -1
- package/lib/src/services/index.js +0 -5
- package/lib/src/services/index.js.map +0 -1
- package/lib/src/services/templateService.d.ts +0 -11
- package/lib/src/services/templateService.d.ts.map +0 -1
- package/lib/src/services/templateService.js +0 -102
- package/lib/src/services/templateService.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -2341
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocketmakers/orbit-template-service",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Product team <product-team@rocketmakers.com>",
|
|
6
6
|
"homepage": "https://gitlab.com/rocketmakers/microservices/orbit-packages#readme",
|
|
7
7
|
"license": "ISC",
|
|
8
|
-
"main": "lib/
|
|
9
|
-
"types": "lib/
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"types": "lib/index.d.ts",
|
|
10
10
|
"directories": {
|
|
11
|
-
"lib": "lib"
|
|
12
|
-
"test": "__tests__"
|
|
11
|
+
"lib": "lib"
|
|
13
12
|
},
|
|
14
13
|
"files": [
|
|
15
14
|
"lib/**/*"
|
|
@@ -22,8 +21,8 @@
|
|
|
22
21
|
"access": "public"
|
|
23
22
|
},
|
|
24
23
|
"scripts": {
|
|
25
|
-
"build": "tsc",
|
|
26
|
-
"build-watch": "
|
|
24
|
+
"build": "tsc -p src",
|
|
25
|
+
"build-watch": "npm run build -- --watch",
|
|
27
26
|
"local-publish": "npm publish --registry=http://127.0.0.1:4873 --force",
|
|
28
27
|
"local-unpublish": "npm unpublish @rocketmakers/orbit-template-service --registry=http://127.0.0.1:4873 --force",
|
|
29
28
|
"local-update": "npm run local-unpublish && npm run local-publish",
|
|
@@ -33,16 +32,17 @@
|
|
|
33
32
|
"url": "https://gitlab.com/rocketmakers/microservices/orbit-packages/issues"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
|
-
"@rocketmakers/ioc": "
|
|
37
|
-
"@rocketmakers/
|
|
38
|
-
"@rocketmakers/orbit-
|
|
39
|
-
"@rocketmakers/orbit-template-
|
|
35
|
+
"@rocketmakers/ioc": "0.3.3",
|
|
36
|
+
"@rocketmakers/log": "^0.1.0",
|
|
37
|
+
"@rocketmakers/orbit-core": "^2.0.0-beta.5",
|
|
38
|
+
"@rocketmakers/orbit-template-core": "^2.0.0-beta.5",
|
|
39
|
+
"@rocketmakers/orbit-template-http-repository": "^2.0.0-beta.5",
|
|
40
40
|
"ajv": "6.10.2",
|
|
41
41
|
"axios": "0.24.0",
|
|
42
42
|
"handlebars": "^4.7.7"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@rocketmakers/orbit-testing-core": "^2.0.0-beta.
|
|
45
|
+
"@rocketmakers/orbit-testing-core": "^2.0.0-beta.5"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "02a5cafdc1e285697ea35093f51303802c34eda7"
|
|
48
48
|
}
|
package/lib/src/core/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/lib/src/core/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LayoutId } from '@rocketmakers/orbit-template-core';
|
|
2
|
-
export declare namespace Validation {
|
|
3
|
-
function renderLayoutTemplates<TPayload>(layoutId: LayoutId, payload: TPayload): Promise<{
|
|
4
|
-
validatedLayoutId: string;
|
|
5
|
-
providedPayload: unknown;
|
|
6
|
-
}>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/core/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAM7D,yBAAiB,UAAU,CAAC;IAC1B,SAAsB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;;;OAK1F;CACF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Validation = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const orbit_core_1 = require("@rocketmakers/orbit-core");
|
|
6
|
-
const validateLayoutId = orbit_core_1.CommonValidators.opaque(true).minLength(1).build();
|
|
7
|
-
const validatePayloadExists = orbit_core_1.CommonValidators.objectMandatory({}, { ignoreExtraKeys: true }).build();
|
|
8
|
-
var Validation;
|
|
9
|
-
(function (Validation) {
|
|
10
|
-
function renderLayoutTemplates(layoutId, payload) {
|
|
11
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
return {
|
|
13
|
-
validatedLayoutId: yield orbit_core_1.validate(validateLayoutId, layoutId),
|
|
14
|
-
providedPayload: yield orbit_core_1.validate(validatePayloadExists, payload),
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
Validation.renderLayoutTemplates = renderLayoutTemplates;
|
|
19
|
-
})(Validation = exports.Validation || (exports.Validation = {}));
|
|
20
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/core/validation.ts"],"names":[],"mappings":";;;;AACA,yDAAsE;AAEtE,MAAM,gBAAgB,GAAG,6BAAgB,CAAC,MAAM,CAAW,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;AACtF,MAAM,qBAAqB,GAAG,6BAAgB,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AAEtG,IAAiB,UAAU,CAO1B;AAPD,WAAiB,UAAU;IACzB,SAAsB,qBAAqB,CAAW,QAAkB,EAAE,OAAiB;;YACzF,OAAO;gBACL,iBAAiB,EAAE,MAAM,qBAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC;gBAC7D,eAAe,EAAE,MAAM,qBAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;aAChE,CAAC;QACJ,CAAC;KAAA;IALqB,gCAAqB,wBAK1C,CAAA;AACH,CAAC,EAPgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAO1B"}
|
package/lib/src/index.d.ts
DELETED
package/lib/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
|
package/lib/src/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./core"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ioc"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./services"), exports);
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/lib/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAIA,iDAAuB;AACvB,gDAAsB;AACtB,qDAA2B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IRepositoryContainerTypes } from '@rocketmakers/orbit-template-core';
|
|
2
|
-
import { ITemplateServicesContainerTypes } from './types';
|
|
3
|
-
export declare const register: {
|
|
4
|
-
function<K extends never>(key: K, item: ITemplateServicesContainerTypes[K] | import("@rocketmakers/ioc").IFunctionResolver<ITemplateServicesContainerTypes[K]>): void;
|
|
5
|
-
constant<K_1 extends "templateService">(key: K_1, item: ITemplateServicesContainerTypes[K_1]): void;
|
|
6
|
-
class<K_2 extends "templateService", C extends new (...args: any) => ITemplateServicesContainerTypes[K_2]>(key: K_2, cls: C): {
|
|
7
|
-
construct<TK = ITemplateServicesContainerTypes>(keys: { [K_3 in keyof ConstructorParameters<C>]: ConstructorParameters<C>[K_3] extends ConstructorParameters<C>[number] ? import("@rocketmakers/ioc").PropsOfType<TK, ConstructorParameters<C>[K_3]> : never; }): import("@rocketmakers/ioc").BindingInWhenOnSyntax<InstanceType<C>>;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare const container: {
|
|
11
|
-
get<K extends "templateService" | "rootUrl" | "serviceName" | "logger" | "templateRepository">(key: K): (ITemplateServicesContainerTypes & IRepositoryContainerTypes)[K];
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=container.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/ioc/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,QAAQ;;;;;;CAAuD,CAAC;AAE7E,eAAO,MAAM,SAAS;;CAAkF,CAAC"}
|
package/lib/src/ioc/container.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.container = exports.register = void 0;
|
|
4
|
-
const ioc_1 = require("@rocketmakers/ioc");
|
|
5
|
-
exports.register = ioc_1.containerRegister();
|
|
6
|
-
exports.container = ioc_1.containerFactory();
|
|
7
|
-
//# sourceMappingURL=container.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/ioc/container.ts"],"names":[],"mappings":";;;AACA,2CAAwE;AAG3D,QAAA,QAAQ,GAAG,uBAAiB,EAAmC,CAAC;AAEhE,QAAA,SAAS,GAAG,sBAAgB,EAA+D,CAAC"}
|
package/lib/src/ioc/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ioc/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/lib/src/ioc/index.js
DELETED
package/lib/src/ioc/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ioc/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,kDAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/ioc/register.ts"],"names":[],"mappings":"AAIA,wBAAgB,0BAA0B,SAKzC"}
|
package/lib/src/ioc/register.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerTemplateServiceIoC = void 0;
|
|
4
|
-
const services_1 = require("../services");
|
|
5
|
-
const container_1 = require("./container");
|
|
6
|
-
function registerTemplateServiceIoC() {
|
|
7
|
-
container_1.register
|
|
8
|
-
.class('templateService', services_1.TemplateService)
|
|
9
|
-
.construct(['templateRepository'])
|
|
10
|
-
.inSingletonScope();
|
|
11
|
-
}
|
|
12
|
-
exports.registerTemplateServiceIoC = registerTemplateServiceIoC;
|
|
13
|
-
//# sourceMappingURL=register.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/ioc/register.ts"],"names":[],"mappings":";;;AACA,0CAA8C;AAC9C,2CAAuC;AAEvC,SAAgB,0BAA0B;IACxC,oBAAQ;SACL,KAAK,CAAC,iBAAiB,EAAE,0BAAe,CAAC;SACzC,SAAS,CAA4B,CAAC,oBAAoB,CAAC,CAAC;SAC5D,gBAAgB,EAAE,CAAC;AACxB,CAAC;AALD,gEAKC"}
|
package/lib/src/ioc/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ioc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,+BAA+B;IAE9C,eAAe,EAAE,eAAe,CAAC;CAClC"}
|
package/lib/src/ioc/types.js
DELETED
package/lib/src/ioc/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ioc/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CompiledTemplate, ICache, ITemplateRepository, LayoutId } from '@rocketmakers/orbit-template-core';
|
|
2
|
-
export declare class TemplateService {
|
|
3
|
-
private templateRepository;
|
|
4
|
-
constructor(templateRepository: ITemplateRepository);
|
|
5
|
-
private cache;
|
|
6
|
-
getCache(): Promise<ICache | undefined>;
|
|
7
|
-
initCache(): Promise<ICache>;
|
|
8
|
-
updateCache(): Promise<ICache>;
|
|
9
|
-
renderLayoutTemplates<TPayload>(layoutId: LayoutId, payload: TPayload): Promise<CompiledTemplate[]>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=templateService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templateService.d.ts","sourceRoot":"","sources":["../../../src/services/templateService.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,mBAAmB,EACnB,QAAQ,EAET,MAAM,mCAAmC,CAAC;AAS3C,qBAAa,eAAe;IAEd,OAAO,CAAC,kBAAkB;gBAAlB,kBAAkB,EAAE,mBAAmB;IAE3D,OAAO,CAAC,KAAK,CAAmB;IAMnB,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAcvC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAkC5B,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAkC9B,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAyCjH"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TemplateService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const handlebars = require("handlebars");
|
|
6
|
-
const Ajv = require("ajv");
|
|
7
|
-
const orbit_core_1 = require("@rocketmakers/orbit-core");
|
|
8
|
-
const core_1 = require("../core");
|
|
9
|
-
class TemplateService {
|
|
10
|
-
constructor(templateRepository) {
|
|
11
|
-
this.templateRepository = templateRepository;
|
|
12
|
-
}
|
|
13
|
-
getCache() {
|
|
14
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const currentCache = yield this.cache;
|
|
16
|
-
if (currentCache) {
|
|
17
|
-
return currentCache;
|
|
18
|
-
}
|
|
19
|
-
return undefined;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
initCache() {
|
|
23
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (this.cache) {
|
|
25
|
-
return this.cache;
|
|
26
|
-
}
|
|
27
|
-
const updateFunctions = [];
|
|
28
|
-
const { partials, layouts } = yield this.templateRepository.getInitialCache();
|
|
29
|
-
this.cache = new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
for (const partial in partials) {
|
|
31
|
-
updateFunctions.push(() => handlebars.registerPartial(partial, partials[partial]));
|
|
32
|
-
}
|
|
33
|
-
for (const layout in layouts) {
|
|
34
|
-
layouts[layout].forEach(template => {
|
|
35
|
-
updateFunctions.push(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
handlebars.precompile(template.content, { strict: true });
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
yield updateFunctions.forEach(fn => fn());
|
|
41
|
-
resolve({ partials, layouts });
|
|
42
|
-
}));
|
|
43
|
-
return this.cache;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
updateCache() {
|
|
47
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const updateFunctions = [];
|
|
49
|
-
const currentCache = yield this.cache;
|
|
50
|
-
this.cache = new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const { partials, layouts } = yield this.templateRepository.getUpdatedCache(currentCache);
|
|
52
|
-
for (const partial in partials) {
|
|
53
|
-
updateFunctions.push(() => handlebars.registerPartial(partial, partials[partial]));
|
|
54
|
-
}
|
|
55
|
-
for (const layout in layouts) {
|
|
56
|
-
layouts[layout].forEach(template => {
|
|
57
|
-
updateFunctions.push(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
handlebars.precompile(template.content, { strict: true });
|
|
59
|
-
}));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
yield updateFunctions.forEach(fn => fn());
|
|
63
|
-
resolve({ partials, layouts });
|
|
64
|
-
}));
|
|
65
|
-
return this.cache;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
renderLayoutTemplates(layoutId, payload) {
|
|
69
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const { validatedLayoutId } = yield core_1.Validation.renderLayoutTemplates(layoutId, payload);
|
|
71
|
-
const schema = yield this.templateRepository.getPayloadSchema(validatedLayoutId);
|
|
72
|
-
if (schema) {
|
|
73
|
-
const ajv = new Ajv({ allErrors: true, verbose: true });
|
|
74
|
-
const valid = ajv.validate(schema, payload);
|
|
75
|
-
if (!valid && ajv.errors) {
|
|
76
|
-
const { errors } = ajv;
|
|
77
|
-
const validationErrors = errors === null || errors === void 0 ? void 0 : errors.map(e => {
|
|
78
|
-
return { path: e.dataPath, value: e.params, messages: { developer: e.message ? e.message : '' } };
|
|
79
|
-
});
|
|
80
|
-
throw new orbit_core_1.ValidationError(validationErrors, 'Payload does not match schema retrieved from template repository');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const currentCache = yield this.cache;
|
|
84
|
-
if (!currentCache.layouts[validatedLayoutId]) {
|
|
85
|
-
throw new orbit_core_1.NotFoundError(`No layout found matching id: ${validatedLayoutId}`);
|
|
86
|
-
}
|
|
87
|
-
const res = currentCache.layouts[validatedLayoutId].map(template => {
|
|
88
|
-
const compile = handlebars.compile(template.content, { strict: true });
|
|
89
|
-
try {
|
|
90
|
-
return { name: template.type, compiled: compile(payload) };
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
console.error(error);
|
|
94
|
-
throw new orbit_core_1.BadRequestError('Provided payload did not successfully compile using target template', error.message);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
return res;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.TemplateService = TemplateService;
|
|
102
|
-
//# sourceMappingURL=templateService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templateService.js","sourceRoot":"","sources":["../../../src/services/templateService.ts"],"names":[],"mappings":";;;;AAQA,yCAAyC;AACzC,2BAA2B;AAC3B,yDAA2F;AAC3F,kCAAqC;AAKrC,MAAa,eAAe;IAE1B,YAAoB,kBAAuC;QAAvC,uBAAkB,GAAlB,kBA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