@powfix/core-js 0.13.5 → 0.13.7
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.
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ModelAttributeColumnOptions } from "sequelize";
|
|
2
|
+
interface UuidColumnOptions extends Omit<ModelAttributeColumnOptions, 'type'> {
|
|
3
|
+
columnName: string;
|
|
4
|
+
}
|
|
2
5
|
export declare class SequelizeUtils {
|
|
3
6
|
static decimal2Number(value: any): number | null | undefined;
|
|
4
7
|
static getPrimaryUuidColumn: () => Partial<ModelAttributeColumnOptions>;
|
|
@@ -6,4 +9,6 @@ export declare class SequelizeUtils {
|
|
|
6
9
|
columnName: string;
|
|
7
10
|
allowNull: boolean;
|
|
8
11
|
}) => Partial<ModelAttributeColumnOptions>;
|
|
12
|
+
static getUuidColumn: ({ columnName, ...overrideOptions }: UuidColumnOptions) => Partial<ModelAttributeColumnOptions>;
|
|
9
13
|
}
|
|
14
|
+
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.SequelizeUtils = void 0;
|
|
4
15
|
const UuidUtils_1 = require("../../UuidUtils");
|
|
@@ -58,3 +69,26 @@ SequelizeUtils.getForeignUuidColumn = ({ columnName, allowNull }) => {
|
|
|
58
69
|
};
|
|
59
70
|
}
|
|
60
71
|
};
|
|
72
|
+
SequelizeUtils.getUuidColumn = (_a) => {
|
|
73
|
+
var { columnName } = _a, overrideOptions = __rest(_a, ["columnName"]);
|
|
74
|
+
if (overrideOptions.allowNull) {
|
|
75
|
+
return Object.assign({ type: "binary(16)", get() {
|
|
76
|
+
const value = this.getDataValue(columnName);
|
|
77
|
+
if (value === null) {
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
return UuidUtils_1.UuidUtils.toString(this.getDataValue(columnName));
|
|
81
|
+
},
|
|
82
|
+
set(uuid) {
|
|
83
|
+
this.setDataValue(columnName, uuid === null ? null : UuidUtils_1.UuidUtils.toBuffer(uuid));
|
|
84
|
+
} }, overrideOptions);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return Object.assign({ type: "binary(16)", get() {
|
|
88
|
+
return UuidUtils_1.UuidUtils.toString(this.getDataValue(columnName));
|
|
89
|
+
},
|
|
90
|
+
set(uuid) {
|
|
91
|
+
this.setDataValue(columnName, UuidUtils_1.UuidUtils.toBuffer(uuid));
|
|
92
|
+
} }, overrideOptions);
|
|
93
|
+
}
|
|
94
|
+
};
|