@tstdl/base 0.93.39 → 0.93.40

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.
@@ -11,5 +11,6 @@ export declare function getColumnDefinitions(table: PgTableWithColumns<any>): Co
11
11
  export declare function getColumnDefinitionsMap(table: PgTableWithColumns<any>): ColumnDefinitionsMap;
12
12
  export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, fallbackSchemaName?: S): PgTableFromType<T, S>;
13
13
  export declare function registerEnum(enumeration: Enumeration, name: string): void;
14
+ export declare function getEnumName(enumeration: Enumeration): string | undefined;
14
15
  export declare function getPgEnum(schema: string | PgSchema, enumeration: Enumeration, context?: ConverterContext): PgEnum<[string, ...string[]]>;
15
16
  export {};
@@ -328,9 +328,16 @@ const enums = new MultiKeyMap();
328
328
  export function registerEnum(enumeration, name) {
329
329
  enumNames.set(enumeration, toSnakeCase(name));
330
330
  }
331
+ export function getEnumName(enumeration) {
332
+ const baseName = enumNames.get(enumeration) ?? tryGetEnumName(enumeration);
333
+ if (isUndefined(baseName)) {
334
+ return undefined;
335
+ }
336
+ return toSnakeCase(baseName);
337
+ }
331
338
  export function getPgEnum(schema, enumeration, context) {
332
339
  const dbSchema = isString(schema) ? getDbSchema(schema) : schema;
333
- const enumName = enumNames.get(enumeration) ?? tryGetEnumName(enumeration);
340
+ const enumName = getEnumName(enumeration);
334
341
  if (isUndefined(enumName)) {
335
342
  const errorMessage = 'Enum is not registered. Please register it using `databaseSchema.getEnum(MyEnum)` before use.';
336
343
  if (isDefined(context)) {
@@ -340,7 +347,7 @@ export function getPgEnum(schema, enumeration, context) {
340
347
  }
341
348
  const values = (isArray(enumeration) ? enumeration : enumValues(enumeration))
342
349
  .map((value) => value.toString());
343
- const dbEnum = dbSchema.enum(toSnakeCase(enumName), values);
350
+ const dbEnum = dbSchema.enum(enumName, values);
344
351
  if (enums.has([dbSchema.schemaName, enumeration])) {
345
352
  enums.set([dbSchema.schemaName, enumeration], dbEnum);
346
353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.39",
3
+ "version": "0.93.40",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"