@open-norantec/herbal 1.0.0-alpha.0

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.
Files changed (58) hide show
  1. package/LICENSE +22 -0
  2. package/dist/abstracts/auth-adapter.abstract.class.d.ts +19 -0
  3. package/dist/abstracts/auth-adapter.abstract.class.js +11 -0
  4. package/dist/abstracts/index.d.ts +1 -0
  5. package/dist/abstracts/index.js +17 -0
  6. package/dist/builder/index.d.ts +47 -0
  7. package/dist/builder/index.js +606 -0
  8. package/dist/cli/herbal.d.ts +1 -0
  9. package/dist/cli/herbal.js +34 -0
  10. package/dist/common.d.ts +1 -0
  11. package/dist/common.js +17 -0
  12. package/dist/constants/headers.constant.d.ts +4 -0
  13. package/dist/constants/headers.constant.js +7 -0
  14. package/dist/constants/index.d.ts +1 -0
  15. package/dist/constants/index.js +17 -0
  16. package/dist/core.d.ts +18 -0
  17. package/dist/core.js +135 -0
  18. package/dist/create.d.ts +27 -0
  19. package/dist/create.js +132 -0
  20. package/dist/decorators/auth-adapter.decorator.d.ts +7 -0
  21. package/dist/decorators/auth-adapter.decorator.js +18 -0
  22. package/dist/decorators/hide-in-client.decorator.d.ts +6 -0
  23. package/dist/decorators/hide-in-client.decorator.js +15 -0
  24. package/dist/decorators/index.d.ts +2 -0
  25. package/dist/decorators/index.js +18 -0
  26. package/dist/index.d.ts +12 -0
  27. package/dist/index.js +28 -0
  28. package/dist/modules/index.d.ts +1 -0
  29. package/dist/modules/index.js +17 -0
  30. package/dist/modules/logger/index.d.ts +2 -0
  31. package/dist/modules/logger/index.js +18 -0
  32. package/dist/modules/logger/logger.module.d.ts +2 -0
  33. package/dist/modules/logger/logger.module.js +25 -0
  34. package/dist/modules/logger/logger.service.d.ts +13 -0
  35. package/dist/modules/logger/logger.service.js +57 -0
  36. package/dist/sequelize-di.d.ts +11 -0
  37. package/dist/sequelize-di.js +93 -0
  38. package/dist/sequelize.d.ts +1 -0
  39. package/dist/sequelize.js +17 -0
  40. package/dist/transformers/reflect-declaration.d.ts +3 -0
  41. package/dist/transformers/reflect-declaration.js +63 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/dist/types/http-response-body.type.d.ts +4 -0
  44. package/dist/types/http-response-body.type.js +2 -0
  45. package/dist/types/index.d.ts +2 -0
  46. package/dist/types/index.js +18 -0
  47. package/dist/types/request.type.d.ts +9 -0
  48. package/dist/types/request.type.js +2 -0
  49. package/dist/utilities/controller-util.class.d.ts +18 -0
  50. package/dist/utilities/controller-util.class.js +214 -0
  51. package/dist/utilities/index.d.ts +3 -0
  52. package/dist/utilities/index.js +19 -0
  53. package/dist/utilities/model-util.class.d.ts +6 -0
  54. package/dist/utilities/model-util.class.js +31 -0
  55. package/dist/utilities/nest-util.class.d.ts +5 -0
  56. package/dist/utilities/nest-util.class.js +27 -0
  57. package/package.json +80 -0
  58. package/preserved/@@notfound.js +0 -0
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
40
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
41
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
42
+ 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;
43
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
44
+ };
45
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
46
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
47
+ };
48
+ var __metadata = (this && this.__metadata) || function (k, v) {
49
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.HerbalModel = exports.BelongsTo = exports.Table = void 0;
53
+ var sequelize_typescript_1 = require("sequelize-typescript");
54
+ var uuid_1 = require("uuid");
55
+ __exportStar(require("sequelize-typescript"), exports);
56
+ function Table(options) {
57
+ return function (target) {
58
+ var newOptions = !options ? {} : options;
59
+ if (!Array.isArray(newOptions === null || newOptions === void 0 ? void 0 : newOptions.indexes))
60
+ newOptions.indexes = [];
61
+ newOptions.indexes = Array.from(newOptions.indexes).concat({
62
+ name: 'pagination',
63
+ fields: ['id', 'created_at'],
64
+ });
65
+ (0, sequelize_typescript_1.Table)(__assign(__assign({}, newOptions), { tableName: newOptions === null || newOptions === void 0 ? void 0 : newOptions.modelName, modelName: target.name }))(target);
66
+ };
67
+ }
68
+ exports.Table = Table;
69
+ function BelongsTo(associatedClassGetter, options) {
70
+ return (0, sequelize_typescript_1.BelongsTo)(associatedClassGetter, __assign({ onUpdate: 'CASCADE', onDelete: 'CASCADE' }, options));
71
+ }
72
+ exports.BelongsTo = BelongsTo;
73
+ var HerbalModel = exports.HerbalModel = (function (_super) {
74
+ __extends(HerbalModel, _super);
75
+ function HerbalModel() {
76
+ return _super !== null && _super.apply(this, arguments) || this;
77
+ }
78
+ __decorate([
79
+ (0, sequelize_typescript_1.Column)({ primaryKey: true, type: sequelize_typescript_1.DataType.UUID, defaultValue: uuid_1.v4 }),
80
+ __metadata("design:type", String)
81
+ ], HerbalModel.prototype, "id", void 0);
82
+ __decorate([
83
+ sequelize_typescript_1.CreatedAt,
84
+ (0, sequelize_typescript_1.Column)({ field: 'created_at' }),
85
+ __metadata("design:type", Date)
86
+ ], HerbalModel.prototype, "createdAt", void 0);
87
+ __decorate([
88
+ sequelize_typescript_1.UpdatedAt,
89
+ (0, sequelize_typescript_1.Column)({ field: 'updated_at' }),
90
+ __metadata("design:type", Date)
91
+ ], HerbalModel.prototype, "updatedAt", void 0);
92
+ return HerbalModel;
93
+ }(sequelize_typescript_1.Model));
@@ -0,0 +1 @@
1
+ export * from 'sequelize';
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("sequelize"), exports);
@@ -0,0 +1,3 @@
1
+ import * as ts from 'typescript';
2
+ export declare const DECORATOR_NAME_PREFIX = "\u03A6nt:method:";
3
+ export default function transformer(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DECORATOR_NAME_PREFIX = void 0;
13
+ var ts = require("typescript");
14
+ var ts_morph_1 = require("ts-morph");
15
+ var string_util_class_1 = require("@open-norantec/utilities/dist/string-util.class");
16
+ exports.DECORATOR_NAME_PREFIX = 'Φnt:method:';
17
+ function transformer(program) {
18
+ var project = new ts_morph_1.Project({
19
+ compilerOptions: program.getCompilerOptions(),
20
+ });
21
+ return function () {
22
+ return function (sourceFile) {
23
+ var _a, _b;
24
+ var filePath = sourceFile.fileName;
25
+ var patchSourceFile = project.addSourceFileAtPathIfExists(filePath);
26
+ if (!(patchSourceFile instanceof ts_morph_1.SourceFile))
27
+ return sourceFile;
28
+ var statements = [];
29
+ for (var _i = 0, _c = patchSourceFile.getClasses(); _i < _c.length; _i++) {
30
+ var cls = _c[_i];
31
+ var className = cls.getName();
32
+ if (string_util_class_1.StringUtil.isFalsyString(className))
33
+ continue;
34
+ for (var _d = 0, _e = cls.getProperties(); _d < _e.length; _d++) {
35
+ var prop = _e[_d];
36
+ var name_1 = prop.getName();
37
+ var type = prop.getType();
38
+ var callSignature = type.getCallSignatures()[0];
39
+ if (!(callSignature instanceof ts_morph_1.Signature))
40
+ continue;
41
+ var returnType = callSignature.getReturnType();
42
+ var actualReturn = returnType;
43
+ if (((_b = (_a = returnType.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName) === null || _b === void 0 ? void 0 : _b.call(_a)) === 'Promise') {
44
+ var args = returnType.getTypeArguments();
45
+ if (args.length > 0) {
46
+ actualReturn = args[0];
47
+ }
48
+ }
49
+ var typeStr = actualReturn.getText();
50
+ if (string_util_class_1.StringUtil.isFalsyString(typeStr))
51
+ continue;
52
+ statements.push(ts.factory.createExpressionStatement(ts.factory.createCallExpression(ts.factory.createIdentifier('Reflect.defineMetadata'), undefined, [
53
+ ts.factory.createStringLiteral("".concat(exports.DECORATOR_NAME_PREFIX).concat(name_1)),
54
+ ts.factory.createStringLiteral(typeStr),
55
+ ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(className), ts.factory.createIdentifier('prototype')),
56
+ ])));
57
+ }
58
+ }
59
+ return ts.factory.updateSourceFile(sourceFile, __spreadArray(__spreadArray([], sourceFile.statements, true), statements, true));
60
+ };
61
+ };
62
+ }
63
+ exports.default = transformer;