1
1
import type { OT } from "@contentlayer/utils/effect" ;
2
2
import { pipe , T } from "@contentlayer/utils/effect" ;
3
3
4
- import { getFieldFunctions } from "../mapping" ;
5
- import type { DatabaseProperties , FieldDef } from "../types" ;
6
- import type { ProvideDatabaseSchemaArgs } from "./provideDatabaseSchema" ;
7
- import type { DatabaseTypeDef } from "./types" ;
8
- import { findDatabaseFieldDef } from "./utils/findDatabaseFieldDef" ;
9
- import { normalizeKey } from "./utils/normalizeKey" ;
4
+ import { getFieldFunctions } from "../mapping/index.js " ;
5
+ import type { DatabaseProperties , FieldDef } from "../types.js " ;
6
+ import type { ProvideDatabaseSchemaArgs } from "./provideDatabaseSchema.js " ;
7
+ import type { DatabaseTypeDef } from "./types.js " ;
8
+ import { findDatabaseFieldDef } from "./utils/findDatabaseFieldDef.js " ;
9
+ import { normalizeKey } from "./utils/normalizeKey.js " ;
10
10
11
11
export type ProvideDatabaseFieldSchemaArgs = {
12
12
property : DatabaseProperties
@@ -15,11 +15,13 @@ export type ProvideDatabaseFieldSchemaArgs = {
15
15
16
16
export const provideDatabaseFieldSchema =
17
17
( { property, databaseTypeDef, ...rest } : ProvideDatabaseFieldSchemaArgs ) :
18
- T . Effect < OT . HasTracer , unknown , FieldDef > => pipe (
18
+ T . Effect < OT . HasTracer , unknown , FieldDef | undefined > => pipe (
19
19
T . succeed ( findDatabaseFieldDef ( { databaseTypeDef, property } ) ) ,
20
20
T . chain ( ( databaseFieldTypeDef ) => pipe (
21
21
T . succeed ( getFieldFunctions ( property . type ) ?. getFieldDef ( { property, databaseFieldTypeDef, databaseTypeDef, ...rest } ) ) ,
22
22
T . map ( ( def ) => {
23
+ if ( ! def ) return ; // TODO : Find a more beautiful way using ts-effects
24
+
23
25
const name = normalizeKey ( databaseFieldTypeDef ?. key ?? property . name ) ;
24
26
25
27
return {
0 commit comments