@powfix/core-js 0.13.38 → 0.13.39

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,2 +1,2 @@
1
1
  export * from './HookUtils';
2
- export * from './SequelizeUtils';
2
+ export { SequelizeUtils } from './sequelize-utils';
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SequelizeUtils = void 0;
17
18
  __exportStar(require("./HookUtils"), exports);
18
- __exportStar(require("./SequelizeUtils"), exports);
19
+ var sequelize_utils_1 = require("./sequelize-utils");
20
+ Object.defineProperty(exports, "SequelizeUtils", { enumerable: true, get: function () { return sequelize_utils_1.SequelizeUtils; } });
@@ -0,0 +1,9 @@
1
+ import { ModelAttributeColumnOptions, WhereOptions } from "sequelize";
2
+ import { Model, NonKnownUuidStringKeys, UuidColumnOptionsBase, UuidColumnOptionsForModel } from "./types";
3
+ export declare class SequelizeUtils {
4
+ static decimal2Number(value: any): number | null | undefined;
5
+ static buildPrimaryUuidColumn: () => Partial<ModelAttributeColumnOptions>;
6
+ static buildUuidColumn<T extends Model, AdditionalKeys extends NonKnownUuidStringKeys<T> = never>(options: UuidColumnOptionsForModel<T, AdditionalKeys>): Partial<ModelAttributeColumnOptions>;
7
+ static buildUuidColumn(options: UuidColumnOptionsBase): Partial<ModelAttributeColumnOptions>;
8
+ static getNullableArrayFilter<T = undefined>(arr: (null | any)[]): WhereOptions<T>;
9
+ }
@@ -13,8 +13,8 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.SequelizeUtils = void 0;
15
15
  const sequelize_1 = require("sequelize");
16
- const UuidUtils_1 = require("../UuidUtils");
17
- const constants_1 = require("../../constants");
16
+ const UuidUtils_1 = require("../../UuidUtils");
17
+ const constants_1 = require("../../../constants");
18
18
  class SequelizeUtils {
19
19
  static decimal2Number(value) {
20
20
  if (value === null || value === undefined) {
@@ -26,7 +26,7 @@ class SequelizeUtils {
26
26
  }
27
27
  return parsed;
28
28
  }
29
- static getUuidColumn(options) {
29
+ static buildUuidColumn(options) {
30
30
  const { columnName } = options, overrideOptions = __rest(options, ["columnName"]);
31
31
  if (overrideOptions.allowNull) {
32
32
  return Object.assign({ type: "binary(16)", get() {
@@ -66,16 +66,10 @@ class SequelizeUtils {
66
66
  }
67
67
  }
68
68
  exports.SequelizeUtils = SequelizeUtils;
69
- SequelizeUtils.getPrimaryUuidColumn = () => ({
70
- type: "binary(16)",
69
+ SequelizeUtils.buildPrimaryUuidColumn = () => (Object.assign({}, SequelizeUtils.buildUuidColumn({
70
+ columnName: "uuid",
71
71
  allowNull: false,
72
72
  primaryKey: true,
73
73
  unique: true,
74
74
  defaultValue: () => UuidUtils_1.UuidUtils.toBuffer(UuidUtils_1.UuidUtils.v4()),
75
- get() {
76
- return UuidUtils_1.UuidUtils.toString(this.getDataValue("uuid"));
77
- },
78
- set(uuid) {
79
- this.setDataValue("uuid", UuidUtils_1.UuidUtils.toBuffer(uuid));
80
- }
81
- });
75
+ })));
@@ -0,0 +1 @@
1
+ export { SequelizeUtils } from './SequelizeUtils';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SequelizeUtils = void 0;
4
+ var SequelizeUtils_1 = require("./SequelizeUtils");
5
+ Object.defineProperty(exports, "SequelizeUtils", { enumerable: true, get: function () { return SequelizeUtils_1.SequelizeUtils; } });
@@ -0,0 +1,16 @@
1
+ import { ModelAttributeColumnOptions } from "sequelize";
2
+ export type Model = Record<string, any> | undefined;
3
+ export type ExtractUuidKeys<T extends Model> = {
4
+ [Property in keyof T]: Property extends `${string}Uuid` | 'uuid' ? Property : never;
5
+ }[keyof T];
6
+ export type ExtractStringKeys<T extends Model> = {
7
+ [Property in keyof T]: string extends T[Property] ? Property : never;
8
+ }[keyof T];
9
+ export type ConcreteUuidKeys<T extends Model> = ExtractUuidKeys<T>;
10
+ export type NonKnownUuidStringKeys<T extends Model> = Exclude<ExtractStringKeys<T>, ConcreteUuidKeys<T>> & string;
11
+ export interface UuidColumnOptionsBase extends Omit<ModelAttributeColumnOptions, 'type'> {
12
+ columnName: string;
13
+ }
14
+ export interface UuidColumnOptionsForModel<T extends Model, AdditionalKeys extends string> extends Omit<ModelAttributeColumnOptions, 'type'> {
15
+ columnName: ConcreteUuidKeys<T> | AdditionalKeys;
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.13.38",
3
+ "version": "0.13.39",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,
@@ -1,23 +0,0 @@
1
- import { ModelAttributeColumnOptions, WhereOptions } from "sequelize";
2
- type Model = Record<string, any> | undefined;
3
- type GetIncludeKeyPatterns<T extends Model> = T extends {
4
- _id: string;
5
- } ? `${string}Uuid` | 'uuid' : `${string}Uuid`;
6
- type ExtractUuidKeys<T extends Model> = {
7
- [Property in keyof T]: Property extends GetIncludeKeyPatterns<T> ? Property : never;
8
- }[keyof T];
9
- type ConcreteUuidKeys<T extends Record<string, any>> = ExtractUuidKeys<T>;
10
- interface UuidColumnOptionsBase extends Omit<ModelAttributeColumnOptions, 'type'> {
11
- columnName: string;
12
- }
13
- interface UuidColumnOptionsForModel<T extends Record<string, any>> extends Omit<ModelAttributeColumnOptions, 'type'> {
14
- columnName: ConcreteUuidKeys<T>;
15
- }
16
- export declare class SequelizeUtils {
17
- static decimal2Number(value: any): number | null | undefined;
18
- static getPrimaryUuidColumn: () => Partial<ModelAttributeColumnOptions>;
19
- static getUuidColumn<T extends Record<string, any>>(options: UuidColumnOptionsForModel<T>): Partial<ModelAttributeColumnOptions>;
20
- static getUuidColumn(options: UuidColumnOptionsBase): Partial<ModelAttributeColumnOptions>;
21
- static getNullableArrayFilter<T = undefined>(arr: (null | any)[]): WhereOptions<T>;
22
- }
23
- export {};