@nathapp/nestjs-data 1.0.0-rc.1

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/.eslintrc.js ADDED
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ project: 'tsconfig.json',
5
+ sourceType: 'module',
6
+ },
7
+ plugins: ['@typescript-eslint/eslint-plugin'],
8
+ extends: [
9
+ 'plugin:@typescript-eslint/recommended',
10
+ 'plugin:prettier/recommended',
11
+ ],
12
+ root: true,
13
+ env: {
14
+ node: true,
15
+ jest: true,
16
+ },
17
+ ignorePatterns: ['.eslintrc.js'],
18
+ rules: {
19
+ '@typescript-eslint/interface-name-prefix': 'off',
20
+ '@typescript-eslint/explicit-function-return-type': 'off',
21
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
22
+ '@typescript-eslint/no-explicit-any': 'off',
23
+ },
24
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 KnowYourself
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # nestjs-data Library
2
+
3
+
4
+ chatbot: 0
@@ -0,0 +1,3 @@
1
+ export declare const CreateDate: (format?: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
2
+ export declare const UpdateDate: (format?: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
3
+ export declare const DateColumn: (format?: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateColumn = exports.UpdateDate = exports.CreateDate = void 0;
4
+ const moment = require("moment");
5
+ const typeorm_1 = require("typeorm");
6
+ const common_1 = require("@nestjs/common");
7
+ const class_transformer_1 = require("class-transformer");
8
+ const DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
9
+ const toDateString = (value, format) => {
10
+ return value ? moment(value).format(format || DEFAULT_DATE_FORMAT) : value;
11
+ };
12
+ const applyDateDecorators = (decorator) => {
13
+ return (0, common_1.applyDecorators)((0, class_transformer_1.Transform)(({ value, type }) => toDateString(value)), decorator);
14
+ };
15
+ const CreateDate = (format) => {
16
+ return applyDateDecorators((0, typeorm_1.CreateDateColumn)({
17
+ transformer: {
18
+ to: (value) => toDateString(value, format),
19
+ from: (value) => new Date(value),
20
+ },
21
+ }));
22
+ };
23
+ exports.CreateDate = CreateDate;
24
+ const UpdateDate = (format) => {
25
+ return applyDateDecorators((0, typeorm_1.UpdateDateColumn)({
26
+ transformer: {
27
+ to: (value) => toDateString(value, format),
28
+ from: (value) => new Date(value),
29
+ },
30
+ }));
31
+ };
32
+ exports.UpdateDate = UpdateDate;
33
+ const DateColumn = (format) => {
34
+ return applyDateDecorators((0, typeorm_1.Column)({
35
+ type: "datetime",
36
+ transformer: {
37
+ to: (value) => toDateString(value, format),
38
+ from: (value) => new Date(value),
39
+ },
40
+ }));
41
+ };
42
+ exports.DateColumn = DateColumn;
@@ -0,0 +1,3 @@
1
+ import { CreateDate, DateColumn, UpdateDate } from "./date-column.decorator";
2
+ import { ReadOnlyColumn } from "./readonly-column.decorator";
3
+ export { DateColumn, CreateDate, UpdateDate, ReadOnlyColumn, };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReadOnlyColumn = exports.UpdateDate = exports.CreateDate = exports.DateColumn = void 0;
4
+ const date_column_decorator_1 = require("./date-column.decorator");
5
+ Object.defineProperty(exports, "CreateDate", { enumerable: true, get: function () { return date_column_decorator_1.CreateDate; } });
6
+ Object.defineProperty(exports, "DateColumn", { enumerable: true, get: function () { return date_column_decorator_1.DateColumn; } });
7
+ Object.defineProperty(exports, "UpdateDate", { enumerable: true, get: function () { return date_column_decorator_1.UpdateDate; } });
8
+ const readonly_column_decorator_1 = require("./readonly-column.decorator");
9
+ Object.defineProperty(exports, "ReadOnlyColumn", { enumerable: true, get: function () { return readonly_column_decorator_1.ReadOnlyColumn; } });
@@ -0,0 +1 @@
1
+ export declare const ReadOnlyColumn: () => PropertyDecorator;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReadOnlyColumn = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const ReadOnlyColumn = () => {
6
+ return (0, typeorm_1.Column)({
7
+ select: false,
8
+ insert: false,
9
+ readonly: true,
10
+ nullable: true,
11
+ });
12
+ };
13
+ exports.ReadOnlyColumn = ReadOnlyColumn;
@@ -0,0 +1 @@
1
+ export * from "./decorator";
package/dist/index.js ADDED
@@ -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("./decorator"), exports);
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist";
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ exports.__esModule = true;
6
+ __export(require("./dist"));
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@nathapp/nestjs-data",
3
+ "version": "1.0.0-rc.1",
4
+ "description": "@nathapp/nestjs-data",
5
+ "scripts": {
6
+ "build": "rimraf dist && tsc -p tsconfig.json",
7
+ "precommit": "lint-staged",
8
+ "test": "jest",
9
+ "test:watch": "jest --watch",
10
+ "test:cov": "jest --coverage",
11
+ "test:e2e": "jest --config ./test/jest-e2e.json",
12
+ "lint": "eslint -c .eslintrc.js"
13
+ },
14
+ "author": "",
15
+ "license": "ISC",
16
+ "devDependencies": {
17
+ "@nestjs/platform-express": "^9.0.0",
18
+ "@nestjs/platform-fastify": "^9.0.0",
19
+ "@types/js-yaml": "^4.0.5",
20
+ "@types/node": "^17.0.22",
21
+ "@typescript-eslint/eslint-plugin": "^4",
22
+ "@typescript-eslint/parser": "^4",
23
+ "eslint": "*",
24
+ "eslint-config-prettier": "^6",
25
+ "eslint-plugin-prettier": "^3",
26
+ "prettier": "^2",
27
+ "typescript": "^4"
28
+ },
29
+ "types": "./index.d.ts",
30
+ "main": "index.js",
31
+ "directories": {
32
+ "lib": "lib"
33
+ },
34
+ "dependencies": {
35
+ "@nestjs/typeorm": "^9.0.1",
36
+ "moment": "^2.29.4",
37
+ "typeorm": "^0.3.12",
38
+ "typeorm-naming-strategies": "^4.1.0"
39
+ },
40
+ "peerDependencies": {
41
+ "@nestjs/common": "*",
42
+ "@nestjs/core": "*",
43
+ "class-transformer": "*",
44
+ "class-validator": "*",
45
+ "rxjs": "*"
46
+ }
47
+ }