@tstdl/base 0.92.56 → 0.92.58

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,4 @@
1
- import { getEnumName } from '../../enumeration/enumeration.js';
1
+ import { isDefined } from '../../utils/type-guards.js';
2
2
  import { getDrizzleTableFromType, getPgEnum, registerEnum } from './drizzle/schema-converter.js';
3
3
  export class DatabaseSchema {
4
4
  name;
@@ -8,8 +8,10 @@ export class DatabaseSchema {
8
8
  getTable(type) {
9
9
  return getDrizzleTableFromType(type, this.name);
10
10
  }
11
- getEnum(enumeration, name = getEnumName(enumeration)) {
12
- registerEnum(enumeration, name);
11
+ getEnum(enumeration, name) {
12
+ if (isDefined(name)) {
13
+ registerEnum(enumeration, name);
14
+ }
13
15
  return getPgEnum(this.name, enumeration); // eslint-disable-line @typescript-eslint/no-unsafe-return
14
16
  }
15
17
  }
@@ -1,6 +1,7 @@
1
1
  import { toCamelCase, toSnakeCase } from 'drizzle-orm/casing';
2
2
  import { boolean, date, doublePrecision, index, integer, jsonb, pgSchema, text, timestamp, unique, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
3
3
  import { MultiKeyMap } from '../../../data-structures/multi-key-map.js';
4
+ import { tryGetEnumName } from '../../../enumeration/enumeration.js';
4
5
  import { NotSupportedError } from '../../../errors/not-supported.error.js';
5
6
  import { JsonPath } from '../../../json-path/json-path.js';
6
7
  import { reflectionRegistry } from '../../../reflection/registry.js';
@@ -198,7 +199,7 @@ export function registerEnum(enumeration, name) {
198
199
  }
199
200
  export function getPgEnum(schema, enumeration, context) {
200
201
  const dbSchema = isString(schema) ? getDbSchema(schema) : schema;
201
- const enumName = enumNames.get(enumeration);
202
+ const enumName = enumNames.get(enumeration) ?? tryGetEnumName(enumeration);
202
203
  if (isUndefined(enumName)) {
203
204
  if (isDefined(context)) {
204
205
  throw new Error(`Enum is not registered. (type: ${context.type.name}, property: ${context.property})`);
package/orm/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { boolean, date, doublePrecision, integer, jsonb, PgColumnBuilder, P
3
3
  import { Array, Integer } from '../schema/index.js';
4
4
  import type { AbstractConstructor, EnumerationObject, EnumerationValue, ObjectLiteral, UnionToTuple } from '../types.js';
5
5
  import type { GetTagMetadata, HasTag, Tagged, UnwrapTagged } from '../types/index.js';
6
- import { Column, Embedded, Index, PrimaryKey, References, Unique } from './decorators.js';
6
+ import { Column, Embedded, Encrypted, Index, PrimaryKey, References, Unique } from './decorators.js';
7
7
  import { Json, NumericDate, Timestamp, Uuid } from './schemas/index.js';
8
8
  import type { bytea } from './server/data-types/index.js';
9
9
  export type ColumnTypeTag = 'column';
@@ -27,4 +27,4 @@ export type NumericDate = Tagged<number, ColumnTypeTag, ReturnType<typeof date>>
27
27
  export type Timestamp = Tagged<number, ColumnTypeTag, ReturnType<typeof timestamp>>;
28
28
  export type Bytea = Tagged<Uint8Array, ColumnTypeTag, ReturnType<typeof bytea>>;
29
29
  export type Encrypted<T> = Tagged<T, ColumnTypeTag, ReturnType<typeof bytea>>;
30
- export { Array, Column, Embedded, Index, Integer, Json, NumericDate, PrimaryKey, References, Timestamp, Unique, Uuid };
30
+ export { Array, Column, Embedded, Encrypted, Index, Integer, Json, NumericDate, PrimaryKey, References, Timestamp, Unique, Uuid };
package/orm/types.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Array, Integer } from '../schema/index.js';
2
- import { Column, Embedded, Index, PrimaryKey, References, Unique } from './decorators.js';
2
+ import { Column, Embedded, Encrypted, Index, PrimaryKey, References, Unique } from './decorators.js';
3
3
  import { Json, NumericDate, Timestamp, Uuid } from './schemas/index.js';
4
- export { Array, Column, Embedded, Index, Integer, Json, NumericDate, PrimaryKey, References, Timestamp, Unique, Uuid };
4
+ export { Array, Column, Embedded, Encrypted, Index, Integer, Json, NumericDate, PrimaryKey, References, Timestamp, Unique, Uuid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.56",
3
+ "version": "0.92.58",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"