@tstdl/base 0.92.57 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.57",
3
+ "version": "0.92.58",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"