@powfix/core-js 0.12.3 → 0.12.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/dist/src/constants/CRUD.d.ts +9 -0
- package/dist/src/constants/CRUD.js +22 -0
- package/dist/src/utils/backend/base/SequelizeUtils.d.ts +0 -6
- package/dist/src/utils/backend/base/SequelizeUtils.js +0 -44
- package/dist/src/utils/global/index.d.ts +1 -0
- package/dist/src/utils/global/index.js +1 -0
- package/dist/src/utils/global/pureEnum.d.ts +1 -0
- package/dist/src/utils/global/pureEnum.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CRUD = void 0;
|
|
4
|
+
var CRUD;
|
|
5
|
+
(function (CRUD) {
|
|
6
|
+
CRUD[CRUD["CREATE"] = 1] = "CREATE";
|
|
7
|
+
CRUD[CRUD["READ"] = 2] = "READ";
|
|
8
|
+
CRUD[CRUD["UPDATE"] = 3] = "UPDATE";
|
|
9
|
+
CRUD[CRUD["DELETE"] = 4] = "DELETE";
|
|
10
|
+
})(CRUD || (exports.CRUD = CRUD = {}));
|
|
11
|
+
(function (CRUD) {
|
|
12
|
+
function toString(crud) {
|
|
13
|
+
switch (crud) {
|
|
14
|
+
case CRUD.CREATE: return 'Create';
|
|
15
|
+
case CRUD.READ: return 'Read';
|
|
16
|
+
case CRUD.UPDATE: return 'Update';
|
|
17
|
+
case CRUD.DELETE: return 'Delete';
|
|
18
|
+
default: throw new Error('Unknown crud: ' + crud);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
CRUD.toString = toString;
|
|
22
|
+
})(CRUD || (exports.CRUD = CRUD = {}));
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { ModelAttributeColumnOptions } from "sequelize";
|
|
2
1
|
export declare class SequelizeUtils {
|
|
3
2
|
static decimal2Number(value: any): number | null | undefined;
|
|
4
|
-
static getPrimaryUuidColumn: () => Partial<ModelAttributeColumnOptions>;
|
|
5
|
-
static getForeignUuidColumn: ({ columnName, allowNull }: {
|
|
6
|
-
columnName: string;
|
|
7
|
-
allowNull: boolean;
|
|
8
|
-
}) => Partial<ModelAttributeColumnOptions>;
|
|
9
3
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SequelizeUtils = void 0;
|
|
4
|
-
const UuidUtils_1 = require("../../UuidUtils");
|
|
5
4
|
class SequelizeUtils {
|
|
6
5
|
static decimal2Number(value) {
|
|
7
6
|
if (value === null || value === undefined) {
|
|
@@ -15,46 +14,3 @@ class SequelizeUtils {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
exports.SequelizeUtils = SequelizeUtils;
|
|
18
|
-
SequelizeUtils.getPrimaryUuidColumn = () => ({
|
|
19
|
-
type: "binary(16)",
|
|
20
|
-
allowNull: false,
|
|
21
|
-
primaryKey: true,
|
|
22
|
-
unique: true,
|
|
23
|
-
defaultValue: () => UuidUtils_1.UuidUtils.toBuffer(UuidUtils_1.UuidUtils.v4()),
|
|
24
|
-
get() {
|
|
25
|
-
return UuidUtils_1.UuidUtils.toString(this.getDataValue("uuid"));
|
|
26
|
-
},
|
|
27
|
-
set(uuid) {
|
|
28
|
-
this.setDataValue("uuid", UuidUtils_1.UuidUtils.toBuffer(uuid));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
SequelizeUtils.getForeignUuidColumn = ({ columnName, allowNull }) => {
|
|
32
|
-
if (allowNull) {
|
|
33
|
-
return {
|
|
34
|
-
type: "binary(16)",
|
|
35
|
-
allowNull,
|
|
36
|
-
get() {
|
|
37
|
-
const value = this.getDataValue(columnName);
|
|
38
|
-
if (value === null) {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
return UuidUtils_1.UuidUtils.toString(this.getDataValue(columnName));
|
|
42
|
-
},
|
|
43
|
-
set(uuid) {
|
|
44
|
-
this.setDataValue(columnName, uuid === null ? null : UuidUtils_1.UuidUtils.toBuffer(uuid));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return {
|
|
50
|
-
type: "binary(16)",
|
|
51
|
-
allowNull,
|
|
52
|
-
get() {
|
|
53
|
-
return UuidUtils_1.UuidUtils.toString(this.getDataValue(columnName));
|
|
54
|
-
},
|
|
55
|
-
set(uuid) {
|
|
56
|
-
this.setDataValue(columnName, UuidUtils_1.UuidUtils.toBuffer(uuid));
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pureEnum<E extends object>(e: E): [string, any][];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pureEnum = void 0;
|
|
4
|
+
function pureEnum(e) {
|
|
5
|
+
return Object.entries(e).filter(([key, value]) => !/^\d+$/g.test(key) && typeof value !== 'function');
|
|
6
|
+
}
|
|
7
|
+
exports.pureEnum = pureEnum;
|