@powfix/core-js 0.13.4 → 0.13.6

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.
@@ -6,4 +6,8 @@ export declare class SequelizeUtils {
6
6
  columnName: string;
7
7
  allowNull: boolean;
8
8
  }) => Partial<ModelAttributeColumnOptions>;
9
+ static getUuidColumn: ({ columnName, allowNull }: {
10
+ columnName: string;
11
+ allowNull: boolean;
12
+ }) => Partial<ModelAttributeColumnOptions>;
9
13
  }
@@ -58,3 +58,33 @@ SequelizeUtils.getForeignUuidColumn = ({ columnName, allowNull }) => {
58
58
  };
59
59
  }
60
60
  };
61
+ SequelizeUtils.getUuidColumn = ({ columnName, allowNull }) => {
62
+ if (allowNull) {
63
+ return {
64
+ type: "binary(16)",
65
+ allowNull,
66
+ get() {
67
+ const value = this.getDataValue(columnName);
68
+ if (value === null) {
69
+ return value;
70
+ }
71
+ return UuidUtils_1.UuidUtils.toString(this.getDataValue(columnName));
72
+ },
73
+ set(uuid) {
74
+ this.setDataValue(columnName, uuid === null ? null : UuidUtils_1.UuidUtils.toBuffer(uuid));
75
+ }
76
+ };
77
+ }
78
+ else {
79
+ return {
80
+ type: "binary(16)",
81
+ allowNull,
82
+ get() {
83
+ return UuidUtils_1.UuidUtils.toString(this.getDataValue(columnName));
84
+ },
85
+ set(uuid) {
86
+ this.setDataValue(columnName, UuidUtils_1.UuidUtils.toBuffer(uuid));
87
+ }
88
+ };
89
+ }
90
+ };
@@ -3,4 +3,6 @@ type NonFunction<T, Type extends "keys" | "values"> = {
3
3
  }[keyof T] extends infer R ? (R extends never ? never : R) : never;
4
4
  type PureEnumReturnType<E extends object> = [NonFunction<E, "keys">, NonFunction<E, "values">][];
5
5
  export declare function pureEnum<E extends object>(e: E): PureEnumReturnType<E>;
6
+ export declare function pureEnumKeys<E extends object>(e: E): NonFunction<E, "keys">[];
7
+ export declare function pureEnumValues<E extends object>(e: E): NonFunction<E, "values">[];
6
8
  export {};
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pureEnum = void 0;
3
+ exports.pureEnumValues = exports.pureEnumKeys = exports.pureEnum = void 0;
4
4
  function pureEnum(e) {
5
5
  return Object.entries(e).filter(([key, value]) => !/^\d+$/g.test(key) && typeof value !== 'function');
6
6
  }
7
7
  exports.pureEnum = pureEnum;
8
+ function pureEnumKeys(e) {
9
+ return pureEnum(e).map(([key]) => key);
10
+ }
11
+ exports.pureEnumKeys = pureEnumKeys;
12
+ function pureEnumValues(e) {
13
+ return pureEnum(e).map(([, value]) => value);
14
+ }
15
+ exports.pureEnumValues = pureEnumValues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,