@spinajs/templates 2.0.45 → 2.0.50
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/README.md +11 -11
- package/lib/cli/render.d.ts +1 -0
- package/lib/cli/render.d.ts.map +1 -0
- package/lib/cli/render.js +15 -41
- package/lib/cli/render.js.map +1 -1
- package/lib/config/templates.d.ts +1 -0
- package/lib/config/templates.d.ts.map +1 -0
- package/lib/config/templates.js +3 -5
- package/lib/config/templates.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -35
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +4 -1
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +14 -14
- package/lib/interfaces.js.map +1 -1
- package/package.json +60 -60
- package/lib/di/src/array.d.ts +0 -10
- package/lib/di/src/array.js +0 -14
- package/lib/di/src/array.js.map +0 -1
- package/lib/di/src/container-cache.d.ts +0 -17
- package/lib/di/src/container-cache.js +0 -64
- package/lib/di/src/container-cache.js.map +0 -1
- package/lib/di/src/enums.d.ts +0 -31
- package/lib/di/src/enums.js +0 -36
- package/lib/di/src/enums.js.map +0 -1
- package/lib/di/src/helpers.d.ts +0 -25
- package/lib/di/src/helpers.js +0 -69
- package/lib/di/src/helpers.js.map +0 -1
- package/lib/di/src/interfaces.d.ts +0 -150
- package/lib/di/src/interfaces.js +0 -48
- package/lib/di/src/interfaces.js.map +0 -1
- package/lib/di/src/registry.d.ts +0 -14
- package/lib/di/src/registry.js +0 -81
- package/lib/di/src/registry.js.map +0 -1
- package/lib/di/src/types.d.ts +0 -13
- package/lib/di/src/types.js +0 -3
- package/lib/di/src/types.js.map +0 -1
- package/lib/templates/src/cli/render.d.ts +0 -12
- package/lib/templates/src/cli/render.js +0 -86
- package/lib/templates/src/cli/render.js.map +0 -1
- package/lib/templates/src/config/templates.d.ts +0 -9
- package/lib/templates/src/config/templates.js +0 -16
- package/lib/templates/src/config/templates.js.map +0 -1
- package/lib/templates/src/index.d.ts +0 -13
- package/lib/templates/src/index.js +0 -67
- package/lib/templates/src/index.js.map +0 -1
- package/lib/templates/src/interfaces.d.ts +0 -21
- package/lib/templates/src/interfaces.js +0 -71
- package/lib/templates/src/interfaces.js.map +0 -1
- package/lib/templates.js +0 -7
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# `email`
|
|
2
|
-
|
|
3
|
-
> TODO: description
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
const email = require('email');
|
|
9
|
-
|
|
10
|
-
// TODO: DEMONSTRATE API
|
|
11
|
-
```
|
|
1
|
+
# `email`
|
|
2
|
+
|
|
3
|
+
> TODO: description
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
const email = require('email');
|
|
9
|
+
|
|
10
|
+
// TODO: DEMONSTRATE API
|
|
11
|
+
```
|
package/lib/cli/render.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/cli/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,UAAU,EAAmB,MAAM,cAAc,CAAC;AAIrE,OAAO,EAAU,IAAI,EAAE,MAAM,cAAc,CAAC;AAE5C,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAKa,qBAAsB,SAAQ,UAAU;IAEnD,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;IAEP,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAwC9E"}
|
package/lib/cli/render.js
CHANGED
|
@@ -1,49 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const log_1 = require("@spinajs/log");
|
|
42
|
-
let RenderTemplateCommand = class RenderTemplateCommand extends cli_1.CliCommand {
|
|
10
|
+
import { Templates } from './../index.js';
|
|
11
|
+
import { Argument, CliCommand, Command, Option } from '@spinajs/cli';
|
|
12
|
+
import { DI } from '@spinajs/di';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import * as fs from 'fs';
|
|
15
|
+
import { Logger } from '@spinajs/log';
|
|
16
|
+
let RenderTemplateCommand = class RenderTemplateCommand extends CliCommand {
|
|
43
17
|
async execute(template, options) {
|
|
44
18
|
this.Log.trace(`Rendering ${template}, options: ${JSON.stringify(options)}`);
|
|
45
19
|
try {
|
|
46
|
-
const templates = await
|
|
20
|
+
const templates = await DI.resolve(Templates);
|
|
47
21
|
let model = {};
|
|
48
22
|
if (options.model && fs.existsSync(options.model)) {
|
|
49
23
|
this.Log.trace(`Found model file at ${options.model}, trying to load model data ... `);
|
|
@@ -72,15 +46,15 @@ let RenderTemplateCommand = class RenderTemplateCommand extends cli_1.CliCommand
|
|
|
72
46
|
}
|
|
73
47
|
};
|
|
74
48
|
__decorate([
|
|
75
|
-
|
|
49
|
+
Logger('templates'),
|
|
76
50
|
__metadata("design:type", Object)
|
|
77
51
|
], RenderTemplateCommand.prototype, "Log", void 0);
|
|
78
52
|
RenderTemplateCommand = __decorate([
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
53
|
+
Command('template-render', 'Renders template, usefull for template testing'),
|
|
54
|
+
Argument('template', 'template path, must be in one of directory provided in configs'),
|
|
55
|
+
Option('-f, --file [file]', false, 'path for file, where parsing result will be saved'),
|
|
56
|
+
Option('-m, --model [model]', false, 'path to optional model data, passed to template, in json format'),
|
|
57
|
+
Option('-l, --lang [lang]', false, 'optional language. Language data must be in directories configured in intl module. If none provided, default language is used')
|
|
84
58
|
], RenderTemplateCommand);
|
|
85
|
-
|
|
59
|
+
export { RenderTemplateCommand };
|
|
86
60
|
//# sourceMappingURL=render.js.map
|
package/lib/cli/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/cli/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/cli/render.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,MAAM,EAAQ,MAAM,cAAc,CAAC;AAarC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAI5C,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,OAAsB;QAC3D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,QAAQ,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE7E,IAAI;YACF,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC9C,IAAI,KAAK,GAAG,EAAE,CAAC;YAEf,IAAI,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,OAAO,CAAC,KAAK,kCAAkC,CAAC,CAAC;gBAEvF,MAAM,KAAK,GAA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AAE,CAAC,CAAC;SACnG;IACH,CAAC;CACF,CAAA;AA3CC;IAAC,MAAM,CAAC,WAAW,CAAC;;kDACA;AAFT,qBAAqB;IALjC,OAAO,CAAC,iBAAiB,EAAE,gDAAgD,CAAC;IAC5E,QAAQ,CAAC,UAAU,EAAE,gEAAgE,CAAC;IACtF,MAAM,CAAC,mBAAmB,EAAE,KAAK,EAAE,mDAAmD,CAAC;IACvF,MAAM,CAAC,qBAAqB,EAAE,KAAK,EAAE,iEAAiE,CAAC;IACvG,MAAM,CAAC,mBAAmB,EAAE,KAAK,EAAE,+HAA+H,CAAC;GACvJ,qBAAqB,CA4CjC;SA5CY,qBAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/config/templates.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,SAAS;;;;;;;CAOd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/lib/config/templates.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path_1 = require("path");
|
|
1
|
+
import { join, normalize, resolve } from 'path';
|
|
4
2
|
function dir(path) {
|
|
5
|
-
return
|
|
3
|
+
return resolve(normalize(join(__dirname, path)));
|
|
6
4
|
}
|
|
7
5
|
const templates = {
|
|
8
6
|
system: {
|
|
@@ -12,5 +10,5 @@ const templates = {
|
|
|
12
10
|
},
|
|
13
11
|
},
|
|
14
12
|
};
|
|
15
|
-
|
|
13
|
+
export default templates;
|
|
16
14
|
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/config/templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/config/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEhD,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,SAAS,GAAG;IAChB,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,SAAS,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;YAClC,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SACvB;KACF;CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncService } from '@spinajs/di';
|
|
2
2
|
import { Log } from '@spinajs/log';
|
|
3
|
-
import { TemplateRenderer } from './interfaces';
|
|
4
|
-
export * from './interfaces';
|
|
3
|
+
import { TemplateRenderer } from './interfaces.js';
|
|
4
|
+
export * from './interfaces.js';
|
|
5
5
|
/**
|
|
6
6
|
* Inject INTL module for language support. We does nothing but to initialize module for use in templates.
|
|
7
7
|
*/
|
|
@@ -11,3 +11,4 @@ export declare class Templates extends AsyncService {
|
|
|
11
11
|
render(template: string, model: unknown, language?: string): Promise<string>;
|
|
12
12
|
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
13
13
|
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,cAAc,iBAAiB,CAAC;AAEhC;;GAEG;AACH,qBACa,SAAU,SAAQ,YAAY;IAEzC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAKnB,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAEtC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAS5E,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQhH"}
|
package/lib/index.js
CHANGED
|
@@ -1,67 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
6
|
};
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
23
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
9
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const intl_1 = require("@spinajs/intl");
|
|
33
|
-
__exportStar(require("./interfaces"), exports);
|
|
10
|
+
import { InvalidOperation } from '../../exceptions/lib/index.js';
|
|
11
|
+
import { AsyncService, Inject, Autoinject } from '@spinajs/di';
|
|
12
|
+
import { Log, Logger } from '@spinajs/log';
|
|
13
|
+
import { TemplateRenderer } from './interfaces.js';
|
|
14
|
+
import { extname } from 'path';
|
|
15
|
+
import { Intl } from '@spinajs/intl';
|
|
16
|
+
export * from './interfaces.js';
|
|
34
17
|
/**
|
|
35
18
|
* Inject INTL module for language support. We does nothing but to initialize module for use in templates.
|
|
36
19
|
*/
|
|
37
|
-
let Templates = class Templates extends
|
|
20
|
+
let Templates = class Templates extends AsyncService {
|
|
38
21
|
async render(template, model, language) {
|
|
39
|
-
const extension =
|
|
22
|
+
const extension = extname(template);
|
|
40
23
|
if (!this.Renderers.has(extension)) {
|
|
41
|
-
throw new
|
|
24
|
+
throw new InvalidOperation(`No renderer for file ${template} with extension ${extension}`);
|
|
42
25
|
}
|
|
43
26
|
return await this.Renderers.get(extension).render(template, model, language);
|
|
44
27
|
}
|
|
45
28
|
async renderToFile(template, model, filePath, language) {
|
|
46
|
-
const extension =
|
|
29
|
+
const extension = extname(template);
|
|
47
30
|
if (!this.Renderers.has(extension)) {
|
|
48
|
-
throw new
|
|
31
|
+
throw new InvalidOperation(`No renderer for file ${template} with extension ${extension}`);
|
|
49
32
|
}
|
|
50
33
|
return await this.Renderers.get(extension).renderToFile(template, model, filePath, language);
|
|
51
34
|
}
|
|
52
35
|
};
|
|
53
36
|
__decorate([
|
|
54
|
-
|
|
55
|
-
__metadata("design:type",
|
|
37
|
+
Logger('templates'),
|
|
38
|
+
__metadata("design:type", Log)
|
|
56
39
|
], Templates.prototype, "Log", void 0);
|
|
57
40
|
__decorate([
|
|
58
|
-
|
|
59
|
-
mapFunc: (x) => x.
|
|
41
|
+
Autoinject(TemplateRenderer, {
|
|
42
|
+
mapFunc: (x) => x.ServiceName,
|
|
60
43
|
}),
|
|
61
44
|
__metadata("design:type", Map)
|
|
62
45
|
], Templates.prototype, "Renderers", void 0);
|
|
63
46
|
Templates = __decorate([
|
|
64
|
-
|
|
47
|
+
Inject(Intl)
|
|
65
48
|
], Templates);
|
|
66
|
-
|
|
49
|
+
export { Templates };
|
|
67
50
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAEhC;;GAEG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,YAAY;IASlC,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,KAAc,EAAE,QAAiB;QACrE,MAAM,SA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
3
|
-
export declare abstract class TemplateRenderer extends AsyncService {
|
|
4
|
+
export declare abstract class TemplateRenderer extends AsyncService implements IMappableService {
|
|
4
5
|
protected Log: Log;
|
|
5
6
|
protected TemplatePaths: string[];
|
|
6
7
|
protected TemplateFiles: Map<string, string[]>;
|
|
7
8
|
abstract get Type(): string;
|
|
8
9
|
abstract get Extension(): string;
|
|
10
|
+
get ServiceName(): string;
|
|
9
11
|
abstract render(templatePath: string, model: unknown, language?: string): Promise<string>;
|
|
10
12
|
abstract renderToFile(templatePath: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
11
13
|
/**
|
|
@@ -17,3 +19,4 @@ export declare abstract class TemplateRenderer extends AsyncService {
|
|
|
17
19
|
protected abstract compile(templateName: string, path: string): Promise<void>;
|
|
18
20
|
resolve(): Promise<void>;
|
|
19
21
|
}
|
|
22
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAU,GAAG,EAAE,MAAM,cAAc,CAAC;AAK3C,8BAAsB,gBAAiB,SAAQ,YAAa,YAAW,gBAAgB;IAErF,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAGnB,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IAElC,SAAS,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAA+B;IAE7E,aAAoB,IAAI,IAAI,MAAM,CAAC;IAEnC,aAAoB,SAAS,IAAI,MAAM,CAAC;IAExC,IAAW,WAAW,WAGrB;aAEe,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;aAChF,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEtH;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAsCtC"}
|
package/lib/interfaces.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,21 +7,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const glob_1 = require("glob");
|
|
18
|
-
class TemplateRenderer extends di_1.AsyncService {
|
|
10
|
+
import { Config } from '@spinajs/configuration';
|
|
11
|
+
import { AsyncService } from '@spinajs/di';
|
|
12
|
+
import { Logger, Log } from '@spinajs/log';
|
|
13
|
+
import { join } from 'path';
|
|
14
|
+
import glob from 'glob';
|
|
15
|
+
export class TemplateRenderer extends AsyncService {
|
|
19
16
|
constructor() {
|
|
20
17
|
super(...arguments);
|
|
21
18
|
this.TemplateFiles = new Map();
|
|
22
19
|
}
|
|
20
|
+
get ServiceName() {
|
|
21
|
+
// we map this service by extension
|
|
22
|
+
return this.Extension;
|
|
23
|
+
}
|
|
23
24
|
async resolve() {
|
|
24
25
|
for (const path of this.TemplatePaths) {
|
|
25
|
-
const files =
|
|
26
|
+
const files = glob.sync(join(path, `/**/*${this.Extension}`).replace(/\\/g, '/'));
|
|
26
27
|
for (const file of files) {
|
|
27
28
|
const templateName = file.substring(path.length + 1, file.length);
|
|
28
29
|
if (this.TemplateFiles.has(templateName)) {
|
|
@@ -56,12 +57,11 @@ class TemplateRenderer extends di_1.AsyncService {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
__decorate([
|
|
59
|
-
|
|
60
|
-
__metadata("design:type",
|
|
60
|
+
Logger('renderer'),
|
|
61
|
+
__metadata("design:type", Log)
|
|
61
62
|
], TemplateRenderer.prototype, "Log", void 0);
|
|
62
63
|
__decorate([
|
|
63
|
-
|
|
64
|
+
Config('system.dirs.templates', { defaultValue: [] }),
|
|
64
65
|
__metadata("design:type", Array)
|
|
65
66
|
], TemplateRenderer.prototype, "TemplatePaths", void 0);
|
|
66
|
-
exports.TemplateRenderer = TemplateRenderer;
|
|
67
67
|
//# sourceMappingURL=interfaces.js.map
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,OAAgB,gBA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AAS;aACV;YAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,YAAY,aAAa,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;YAEvF,wCAAwC;YACxC,qDAAqD;YACrD,SAAS;YACT,IAAI;gBACF,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;aACzD;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,2BAA2B,YAAY,cAAc,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAE7H,SAAS;aACV;YAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,YAAY,aAAa,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;SACjG;IACH,CAAC;CACF;AAlEC;IAAC,MAAM,CAAC,UAAU,CAAC;8BACJ,GAAG;6CAAC;AAEnB;IAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;;uDACpB"}
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@spinajs/templates",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "templates support eg. html file generation",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"spinajs"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"@spinajs/
|
|
52
|
-
"@spinajs/
|
|
53
|
-
"@spinajs/
|
|
54
|
-
"@spinajs/
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"tempfile": "
|
|
58
|
-
},
|
|
59
|
-
"gitHead": "
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinajs/templates",
|
|
3
|
+
"version": "2.0.50",
|
|
4
|
+
"description": "templates support eg. html file generation",
|
|
5
|
+
"exports": "./lib/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16.11"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "npm run clean && npm run compile",
|
|
13
|
+
"compile": "tsc -b tsconfig.json",
|
|
14
|
+
"rimraf": "./node_modules/rimraf/bin.js",
|
|
15
|
+
"clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo",
|
|
16
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
17
|
+
"coverage": "nyc npm run test",
|
|
18
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
19
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
20
|
+
"lint": "eslint -c .eslintrc.cjs --ext .ts src --fix",
|
|
21
|
+
"preversion": "npm run lint",
|
|
22
|
+
"version": "npm run format && git add -A src",
|
|
23
|
+
"postinstall": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/**/*"
|
|
27
|
+
],
|
|
28
|
+
"types": "lib",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"spinajs",
|
|
35
|
+
"http"
|
|
36
|
+
],
|
|
37
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/luxon": "^3.2.0",
|
|
45
|
+
"@types/mocha": "10.0.1",
|
|
46
|
+
"@types/node": "^18.11.18",
|
|
47
|
+
"@types/pug": "^2.0.6",
|
|
48
|
+
"rimraf": "^4.1.2"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@spinajs/cli": "^2.0.46",
|
|
52
|
+
"@spinajs/configuration": "^2.0.46",
|
|
53
|
+
"@spinajs/di": "^2.0.46",
|
|
54
|
+
"@spinajs/exceptions": "^2.0.39",
|
|
55
|
+
"@spinajs/intl": "^2.0.46",
|
|
56
|
+
"@spinajs/log": "^2.0.46",
|
|
57
|
+
"tempfile": "4.0.0"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "002dc553b0ffffd72193d0121ac425a4083bc9ee"
|
|
60
|
+
}
|
package/lib/di/src/array.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Class } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
interface ArrayConstructor {
|
|
4
|
-
ofType<T>(type: Class<T> | string): TypedArray<T>;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export declare class TypedArray<R> extends Array<R> {
|
|
8
|
-
Type: Class<R> | string;
|
|
9
|
-
constructor(Type: Class<R> | string);
|
|
10
|
-
}
|
package/lib/di/src/array.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypedArray = void 0;
|
|
4
|
-
class TypedArray extends Array {
|
|
5
|
-
constructor(Type) {
|
|
6
|
-
super();
|
|
7
|
-
this.Type = Type;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.TypedArray = TypedArray;
|
|
11
|
-
Array.ofType = function (type) {
|
|
12
|
-
return new TypedArray(type);
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=array.js.map
|
package/lib/di/src/array.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../di/src/array.ts"],"names":[],"mappings":";;;AAOA,MAAa,UAAc,SAAQ,KAAQ;IACzC,YAAmB,IAAuB;QACxC,KAAK,EAAE,CAAC;QADS,SAAI,GAAJ,IAAI,CAAmB;IAE1C,CAAC;CACF;AAJD,gCAIC;AAED,KAAK,CAAC,MAAM,GAAG,UAAa,IAAuB;IACjD,OAAO,IAAI,UAAU,CAAI,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { TypedArray } from './array';
|
|
2
|
-
import { IContainer } from './interfaces';
|
|
3
|
-
import { Class } from './types';
|
|
4
|
-
export declare class ContainerCache {
|
|
5
|
-
private container;
|
|
6
|
-
private cache;
|
|
7
|
-
constructor(container: IContainer);
|
|
8
|
-
[Symbol.iterator](): Generator<{
|
|
9
|
-
key: string;
|
|
10
|
-
value: any;
|
|
11
|
-
}, void, unknown>;
|
|
12
|
-
remove(key: string | Class<any> | TypedArray<any>, parent?: boolean): void;
|
|
13
|
-
add(key: string | Class<any> | object, instance: any): void;
|
|
14
|
-
has(key: string | Class<any> | object | TypedArray<any>, parent?: boolean): boolean;
|
|
15
|
-
get(key: string | Class<any> | TypedArray<any>, parent?: boolean): any;
|
|
16
|
-
clear(): void;
|
|
17
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContainerCache = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
|
-
class ContainerCache {
|
|
6
|
-
constructor(container) {
|
|
7
|
-
this.container = container;
|
|
8
|
-
this.cache = new Map();
|
|
9
|
-
// add to cache container
|
|
10
|
-
// so we can inject container if needed
|
|
11
|
-
this.add(container, container);
|
|
12
|
-
}
|
|
13
|
-
*[Symbol.iterator]() {
|
|
14
|
-
for (const [key, value] of this.cache) {
|
|
15
|
-
for (const v of value) {
|
|
16
|
-
yield { key, value: v };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
remove(key, parent) {
|
|
21
|
-
if (this.has(key)) {
|
|
22
|
-
this.cache.delete((0, helpers_1.getTypeName)(key));
|
|
23
|
-
}
|
|
24
|
-
else if (parent && this.container.Parent) {
|
|
25
|
-
this.container.Parent.uncache(key);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
add(key, instance) {
|
|
29
|
-
const tName = (0, helpers_1.getTypeName)(key);
|
|
30
|
-
if (this.has(key)) {
|
|
31
|
-
if (this.cache.get(tName).indexOf(instance) === -1) {
|
|
32
|
-
this.cache.get(tName).push(instance);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.cache.set(tName, [instance]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
has(key, parent) {
|
|
40
|
-
if (this.cache.has((0, helpers_1.getTypeName)(key))) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
if (parent && this.container.Parent) {
|
|
44
|
-
return this.container.Parent.Cache.has(key, parent);
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
get(key, parent) {
|
|
49
|
-
const tName = (0, helpers_1.getTypeName)(key);
|
|
50
|
-
if (this.cache.has(tName)) {
|
|
51
|
-
return this.cache.get(tName);
|
|
52
|
-
}
|
|
53
|
-
if (parent && this.container.Parent) {
|
|
54
|
-
return this.container.Parent.Cache.get(key, parent);
|
|
55
|
-
}
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
clear() {
|
|
59
|
-
this.cache.clear();
|
|
60
|
-
this.add(this.container, this.container);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.ContainerCache = ContainerCache;
|
|
64
|
-
//# sourceMappingURL=container-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container-cache.js","sourceRoot":"","sources":["../../../../di/src/container-cache.ts"],"names":[],"mappings":";;;AAEA,uCAAwC;AAIxC,MAAa,cAAc;IAGzB,YAAoB,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAiB,CAAC;QAEtC,yBAAyB;QACzB,uCAAuC;QACvC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;YACrC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;gBACrB,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;aACzB;SACF;IACH,CAAC;IAEM,MAAM,CAAC,GAA0C,EAAE,MAAgB;QACxE,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAA,qBAAW,EAAC,GAAG,CAAC,CAAC,CAAC;SACrC;aAAM,IAAI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