@@ -10,7 +10,7 @@ import {
1010import type { FieldDef , ModelDef , SchemaDef } from '@zenstackhq/orm/schema' ;
1111import { Decimal } from 'decimal.js' ;
1212import SuperJSON from 'superjson' ;
13- import { Linker , Paginator , Relator , Serializer , type SerializerOptions } from 'ts-japi' ;
13+ import tsjapi , { type Linker , type Paginator , type Relator , type Serializer , type SerializerOptions } from 'ts-japi' ;
1414import UrlPattern from 'url-pattern' ;
1515import z from 'zod' ;
1616import type { ApiHandler , LogConfig , RequestContext , Response } from '../../types' ;
@@ -610,7 +610,9 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
610610 status : 200 ,
611611 body : await this . serializeItems ( relationInfo . type , entity [ relationship ] , {
612612 linkers : {
613- document : new Linker ( ( ) => this . makeLinkUrl ( `/${ mappedType } /${ resourceId } /${ relationship } ` ) ) ,
613+ document : new tsjapi . Linker ( ( ) =>
614+ this . makeLinkUrl ( `/${ mappedType } /${ resourceId } /${ relationship } ` ) ,
615+ ) ,
614616 paginator,
615617 } ,
616618 include,
@@ -670,7 +672,7 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
670672 if ( entity ?. [ relationship ] ) {
671673 const serialized : any = await this . serializeItems ( relationInfo . type , entity [ relationship ] , {
672674 linkers : {
673- document : new Linker ( ( ) =>
675+ document : new tsjapi . Linker ( ( ) =>
674676 this . makeLinkUrl ( `/${ mappedType } /${ resourceId } /relationships/${ relationship } ` ) ,
675677 ) ,
676678 paginator,
@@ -827,7 +829,7 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
827829
828830 const totalPages = Math . ceil ( total / limit ) ;
829831
830- return new Paginator ( ( ) => ( {
832+ return new tsjapi . Paginator ( ( ) => ( {
831833 first : this . replaceURLSearchParams ( baseUrl , { 'page[limit]' : limit } ) ,
832834 last : this . replaceURLSearchParams ( baseUrl , {
833835 'page[offset]' : ( totalPages - 1 ) * limit ,
@@ -1110,7 +1112,7 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
11101112
11111113 const serialized : any = await this . serializeItems ( relationInfo . type , entity [ relationship ] , {
11121114 linkers : {
1113- document : new Linker ( ( ) =>
1115+ document : new tsjapi . Linker ( ( ) =>
11141116 this . makeLinkUrl ( `/${ mappedType } /${ resourceId } /relationships/${ relationship } ` ) ,
11151117 ) ,
11161118 } ,
@@ -1308,7 +1310,7 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
13081310 continue ;
13091311 }
13101312
1311- const linker = new Linker ( ( items ) =>
1313+ const linker = new tsjapi . Linker ( ( items ) =>
13121314 Array . isArray ( items )
13131315 ? this . makeLinkUrl ( `/${ mappedModel } ` )
13141316 : this . makeLinkUrl ( `/${ mappedModel } /${ this . getId ( model , items ) } ` ) ,
@@ -1326,7 +1328,7 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
13261328 projection = null ;
13271329 }
13281330
1329- const serializer = new Serializer ( model , {
1331+ const serializer = new tsjapi . Serializer ( model , {
13301332 version : '1.1' ,
13311333 idKey : this . makeIdKey ( ids ) ,
13321334 linkers : {
@@ -1360,18 +1362,18 @@ export class RestApiHandler<Schema extends SchemaDef> implements ApiHandler<Sche
13601362 if ( fieldIds . length > 0 ) {
13611363 const mappedModel = this . mapModelName ( modelLower ) ;
13621364
1363- const relator = new Relator (
1365+ const relator = new tsjapi . Relator (
13641366 async ( data ) => {
13651367 return ( data as any ) [ field ] ;
13661368 } ,
13671369 fieldSerializer ,
13681370 {
13691371 relatedName : field ,
13701372 linkers : {
1371- related : new Linker ( ( primary ) =>
1373+ related : new tsjapi . Linker ( ( primary ) =>
13721374 this . makeLinkUrl ( `/${ mappedModel } /${ this . getId ( model , primary ) } /${ field } ` ) ,
13731375 ) ,
1374- relationship : new Linker ( ( primary ) =>
1376+ relationship : new tsjapi . Linker ( ( primary ) =>
13751377 this . makeLinkUrl (
13761378 `/${ mappedModel } /${ this . getId ( model , primary ) } /relationships/${ field } ` ,
13771379 ) ,
0 commit comments