@smartsoft001/crud-shell-dtos 2.76.0 → 2.81.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.
- package/index.js +191 -0
- package/package.json +1 -1
- package/src/lib/interfaces.d.ts +21 -0
- package/src/lib/user.dto.d.ts +4 -0
- package/.eslintrc +0 -13
- package/jest.config.ts +0 -27
- package/project.json +0 -44
- package/src/lib/interfaces.ts +0 -28
- package/src/lib/user.dto.ts +0 -7
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -11
- package/tsconfig.spec.json +0 -20
- /package/src/{index.ts → index.d.ts} +0 -0
- /package/{test-setup.ts → test-setup.d.ts} +0 -0
package/index.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// packages/shared/models/src/lib/symbols.ts
|
|
14
|
+
var SYMBOL_MODEL = Symbol.for("smartsoft:model");
|
|
15
|
+
var SYMBOL_FIELD = Symbol.for("smartsoft:field");
|
|
16
|
+
|
|
17
|
+
// packages/shared/models/src/lib/interfaces.ts
|
|
18
|
+
var FieldTypeDef = /* @__PURE__ */ ((FieldTypeDef2) => {
|
|
19
|
+
FieldTypeDef2["address"] = "address";
|
|
20
|
+
FieldTypeDef2["currency"] = "currency";
|
|
21
|
+
FieldTypeDef2["date"] = "date";
|
|
22
|
+
FieldTypeDef2["dateTime"] = "dateTime";
|
|
23
|
+
FieldTypeDef2["dateWithEdit"] = "dateWithEdit";
|
|
24
|
+
FieldTypeDef2["email"] = "email";
|
|
25
|
+
FieldTypeDef2["enum"] = "enum";
|
|
26
|
+
FieldTypeDef2["file"] = "file";
|
|
27
|
+
FieldTypeDef2["flag"] = "flag";
|
|
28
|
+
FieldTypeDef2["int"] = "int";
|
|
29
|
+
FieldTypeDef2["nip"] = "nip";
|
|
30
|
+
FieldTypeDef2["object"] = "object";
|
|
31
|
+
FieldTypeDef2["array"] = "array";
|
|
32
|
+
FieldTypeDef2["password"] = "password";
|
|
33
|
+
FieldTypeDef2["radio"] = "radio";
|
|
34
|
+
FieldTypeDef2["text"] = "text";
|
|
35
|
+
FieldTypeDef2["strings"] = "strings";
|
|
36
|
+
FieldTypeDef2["ints"] = "ints";
|
|
37
|
+
FieldTypeDef2["longText"] = "longText";
|
|
38
|
+
FieldTypeDef2["color"] = "color";
|
|
39
|
+
FieldTypeDef2["logo"] = "logo";
|
|
40
|
+
FieldTypeDef2["check"] = "check";
|
|
41
|
+
FieldTypeDef2["phoneNumber"] = "phoneNumber";
|
|
42
|
+
FieldTypeDef2["phoneNumberPl"] = "phoneNumberPl";
|
|
43
|
+
FieldTypeDef2["pesel"] = "pesel";
|
|
44
|
+
FieldTypeDef2["pdf"] = "pdf";
|
|
45
|
+
FieldTypeDef2["video"] = "video";
|
|
46
|
+
FieldTypeDef2["attachment"] = "attachment";
|
|
47
|
+
FieldTypeDef2["dateRange"] = "dateRange";
|
|
48
|
+
FieldTypeDef2["image"] = "image";
|
|
49
|
+
FieldTypeDef2["float"] = "float";
|
|
50
|
+
return FieldTypeDef2;
|
|
51
|
+
})(FieldTypeDef || {});
|
|
52
|
+
var FieldType = FieldTypeDef;
|
|
53
|
+
|
|
54
|
+
// packages/shared/models/src/lib/decorators/model/model.decorator.ts
|
|
55
|
+
import "reflect-metadata";
|
|
56
|
+
var Model = ModelDecorator;
|
|
57
|
+
function ModelDecorator(options) {
|
|
58
|
+
return function(target) {
|
|
59
|
+
options = options ? { ...options } : {};
|
|
60
|
+
Reflect.defineMetadata(SYMBOL_MODEL, options, target);
|
|
61
|
+
target.prototype.toJSON = function() {
|
|
62
|
+
const result = { ...this };
|
|
63
|
+
if (this.constructor["__properties"]) {
|
|
64
|
+
Object.keys(this.constructor["__properties"]).forEach((protoKey) => {
|
|
65
|
+
result[protoKey] = this["_" + protoKey];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// packages/shared/models/src/lib/decorators/field/field.decorator.ts
|
|
74
|
+
import "reflect-metadata";
|
|
75
|
+
|
|
76
|
+
// packages/shared/utils/src/lib/services/password/password.service.ts
|
|
77
|
+
import * as md5_ from "md5";
|
|
78
|
+
|
|
79
|
+
// packages/shared/utils/src/lib/services/object/object.service.ts
|
|
80
|
+
import { stringify } from "flatted";
|
|
81
|
+
var ObjectService = class {
|
|
82
|
+
/***
|
|
83
|
+
* Create object with data
|
|
84
|
+
* @param data {object} - data to set
|
|
85
|
+
* @param type {type} - new type
|
|
86
|
+
* @return - new type object
|
|
87
|
+
*/
|
|
88
|
+
static createByType(data, type) {
|
|
89
|
+
if (!data)
|
|
90
|
+
return data;
|
|
91
|
+
try {
|
|
92
|
+
if (data instanceof type)
|
|
93
|
+
return data;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.warn(e);
|
|
96
|
+
}
|
|
97
|
+
const result = new type();
|
|
98
|
+
Object.keys(data).forEach((key) => {
|
|
99
|
+
result[key] = data[key];
|
|
100
|
+
});
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/***
|
|
104
|
+
* Remove object type from data
|
|
105
|
+
* @param obj {object} - object
|
|
106
|
+
* @return - object without type
|
|
107
|
+
*/
|
|
108
|
+
static removeTypes(obj) {
|
|
109
|
+
if (!obj)
|
|
110
|
+
return obj;
|
|
111
|
+
const result = {};
|
|
112
|
+
Object.keys(obj).forEach((key) => {
|
|
113
|
+
if (obj[key] && obj[key].constructor && !(obj[key] instanceof Date)) {
|
|
114
|
+
let stringValue = "";
|
|
115
|
+
try {
|
|
116
|
+
stringValue = JSON.stringify(obj[key]);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
console.warn("can't stringify without circular package");
|
|
119
|
+
stringValue = stringify(obj[key]);
|
|
120
|
+
}
|
|
121
|
+
result[key] = JSON.parse(stringValue);
|
|
122
|
+
} else {
|
|
123
|
+
result[key] = obj[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// packages/shared/utils/src/lib/services/guid/guid.service.ts
|
|
131
|
+
import { Guid } from "guid-typescript";
|
|
132
|
+
|
|
133
|
+
// packages/shared/utils/src/lib/services/array/array.service.ts
|
|
134
|
+
import * as _ from "lodash";
|
|
135
|
+
|
|
136
|
+
// packages/shared/models/src/lib/decorators/field/field.decorator.ts
|
|
137
|
+
var Field = FieldDecorator;
|
|
138
|
+
function FieldDecorator(options) {
|
|
139
|
+
return (target, key) => {
|
|
140
|
+
options = options ? { ...options } : {};
|
|
141
|
+
if (!target.constructor["__fields"]) {
|
|
142
|
+
target.constructor["__fields"] = {};
|
|
143
|
+
}
|
|
144
|
+
target.constructor["__fields"][key] = true;
|
|
145
|
+
if (!options.type && key === "password") {
|
|
146
|
+
options.type = FieldType.password;
|
|
147
|
+
} else if (!options.type) {
|
|
148
|
+
options.type = FieldType.text;
|
|
149
|
+
}
|
|
150
|
+
if (options.classType) {
|
|
151
|
+
target["_" + key] = target[key];
|
|
152
|
+
delete target[key];
|
|
153
|
+
Object.defineProperty(target, key, {
|
|
154
|
+
get: function() {
|
|
155
|
+
if (!this["_" + key] && options?.type === FieldType.array) {
|
|
156
|
+
this["_" + key] = [];
|
|
157
|
+
}
|
|
158
|
+
return this["_" + key];
|
|
159
|
+
},
|
|
160
|
+
set: function(v) {
|
|
161
|
+
this["_" + key] = options?.type === FieldType.array && v ? v.map(
|
|
162
|
+
(i) => ObjectService.createByType(i, options?.classType)
|
|
163
|
+
) : ObjectService.createByType(v, options?.classType);
|
|
164
|
+
},
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true
|
|
167
|
+
});
|
|
168
|
+
if (!target.constructor["__properties"]) {
|
|
169
|
+
target.constructor["__properties"] = {};
|
|
170
|
+
}
|
|
171
|
+
target.constructor["__properties"][key] = true;
|
|
172
|
+
}
|
|
173
|
+
Reflect.defineMetadata(SYMBOL_FIELD, options, target, key);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// packages/crud/shell/dtos/src/lib/user.dto.ts
|
|
178
|
+
var UserDto = class {
|
|
179
|
+
};
|
|
180
|
+
__decorateClass([
|
|
181
|
+
Field({ required: true, focused: true })
|
|
182
|
+
], UserDto.prototype, "username", 2);
|
|
183
|
+
__decorateClass([
|
|
184
|
+
Field({ required: true })
|
|
185
|
+
], UserDto.prototype, "password", 2);
|
|
186
|
+
UserDto = __decorateClass([
|
|
187
|
+
Model({})
|
|
188
|
+
], UserDto);
|
|
189
|
+
export {
|
|
190
|
+
UserDto
|
|
191
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface IItemCreateData {
|
|
2
|
+
id: string;
|
|
3
|
+
type: 'create';
|
|
4
|
+
data: any;
|
|
5
|
+
}
|
|
6
|
+
export interface IItemUpdateData {
|
|
7
|
+
id: string;
|
|
8
|
+
type: 'update';
|
|
9
|
+
data: {
|
|
10
|
+
removedFields: Array<string>;
|
|
11
|
+
updatedFields: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface IItemDeleteData {
|
|
17
|
+
id: string;
|
|
18
|
+
type: 'delete';
|
|
19
|
+
}
|
|
20
|
+
export type ItemChangedData = IItemCreateData | IItemUpdateData | IItemDeleteData;
|
|
21
|
+
export type ItemChangedDataType = 'create' | 'update' | 'delete';
|
package/.eslintrc
DELETED
package/jest.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
export default {
|
|
3
|
-
globals: {},
|
|
4
|
-
transform: {
|
|
5
|
-
'^.+\\.[tj]sx?$': [
|
|
6
|
-
'ts-jest',
|
|
7
|
-
{
|
|
8
|
-
tsConfig: '<rootDir>/tsconfig.spec.json',
|
|
9
|
-
},
|
|
10
|
-
],
|
|
11
|
-
},
|
|
12
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
13
|
-
coverageDirectory: '../../../../coverage/packages/crud/shell/dtos',
|
|
14
|
-
displayName: 'crud-shell-dtos',
|
|
15
|
-
testEnvironment: 'node',
|
|
16
|
-
preset: '../../../../jest.preset.js',
|
|
17
|
-
/* TODO: Update to latest Jest snapshotFormat
|
|
18
|
-
* By default Nx has kept the older style of Jest Snapshot formats
|
|
19
|
-
* to prevent breaking of any existing tests with snapshots.
|
|
20
|
-
* It's recommend you update to the latest format.
|
|
21
|
-
* You can do this by removing snapshotFormat property
|
|
22
|
-
* and running tests with --update-snapshot flag.
|
|
23
|
-
* Example: From within the project directory, run "nx test --update-snapshot"
|
|
24
|
-
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
|
|
25
|
-
*/
|
|
26
|
-
snapshotFormat: { escapeString: true, printBasicPrototype: true },
|
|
27
|
-
};
|
package/project.json
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "crud-shell-dtos",
|
|
3
|
-
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "packages/crud/shell/dtos/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"tags": ["scope:crud", "type:shell"],
|
|
7
|
-
"generators": {},
|
|
8
|
-
"targets": {
|
|
9
|
-
"lint": {
|
|
10
|
-
"executor": "@nx/eslint:lint",
|
|
11
|
-
"outputs": ["{options.outputFile}"],
|
|
12
|
-
"options": {
|
|
13
|
-
"lintFilePatterns": [
|
|
14
|
-
"packages/crud/shell/dtos/**/*.{ts,tsx,js,jsx}",
|
|
15
|
-
"packages/crud/shell/dtos/package.json"
|
|
16
|
-
],
|
|
17
|
-
"tsConfig": [
|
|
18
|
-
"packages/crud/shell/dtos/tsconfig.lib.json",
|
|
19
|
-
"packages/crud/shell/dtos/tsconfig.spec.json"
|
|
20
|
-
],
|
|
21
|
-
"exclude": ["**/node_modules/**", "!packages/crud/shell/dtos/**/*"]
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"test": {
|
|
25
|
-
"executor": "@nx/jest:jest",
|
|
26
|
-
"options": {
|
|
27
|
-
"jestConfig": "packages/crud/shell/dtos/jest.config.ts",
|
|
28
|
-
"passWithNoTests": true
|
|
29
|
-
},
|
|
30
|
-
"outputs": ["{workspaceRoot}/coverage/packages/crud/shell/dtos"]
|
|
31
|
-
},
|
|
32
|
-
"build": {
|
|
33
|
-
"executor": "@nx/esbuild:esbuild",
|
|
34
|
-
"options": {
|
|
35
|
-
"outputPath": "dist/packages/crud/shell/dtos",
|
|
36
|
-
"tsConfig": "packages/crud/shell/dtos/tsconfig.lib.json",
|
|
37
|
-
"packageJson": "packages/crud/shell/dtos/package.json",
|
|
38
|
-
"main": "packages/crud/shell/dtos/src/index.ts",
|
|
39
|
-
"assets": ["packages/crud/shell/dtos/*.md"]
|
|
40
|
-
},
|
|
41
|
-
"outputs": ["{options.outputPath}"]
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/lib/interfaces.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export interface IItemCreateData {
|
|
2
|
-
id: string;
|
|
3
|
-
type: 'create';
|
|
4
|
-
data: any;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface IItemUpdateData {
|
|
8
|
-
id: string;
|
|
9
|
-
type: 'update';
|
|
10
|
-
data: {
|
|
11
|
-
removedFields: Array<string>;
|
|
12
|
-
updatedFields: {
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface IItemDeleteData {
|
|
19
|
-
id: string;
|
|
20
|
-
type: 'delete';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type ItemChangedData =
|
|
24
|
-
| IItemCreateData
|
|
25
|
-
| IItemUpdateData
|
|
26
|
-
| IItemDeleteData;
|
|
27
|
-
|
|
28
|
-
export type ItemChangedDataType = 'create' | 'update' | 'delete';
|
package/src/lib/user.dto.ts
DELETED
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"outDir": "../../../../dist/out-tsc",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"types": ["node"]
|
|
8
|
-
},
|
|
9
|
-
"exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
|
|
10
|
-
"include": ["**/*.ts"]
|
|
11
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["jest", "node"]
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"**/*.spec.ts",
|
|
10
|
-
"**/*.test.ts",
|
|
11
|
-
"**/*.spec.tsx",
|
|
12
|
-
"**/*.test.tsx",
|
|
13
|
-
"**/*.spec.js",
|
|
14
|
-
"**/*.test.js",
|
|
15
|
-
"**/*.spec.jsx",
|
|
16
|
-
"**/*.test.jsx",
|
|
17
|
-
"**/*.d.ts",
|
|
18
|
-
"jest.config.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
File without changes
|
|
File without changes
|