77 * file that was distributed with this source code.
88 */
99
10- import { Container , type ContainerResolver } from '@adonisjs/fold'
10+ import { type ContainerResolver } from '@adonisjs/fold'
1111import { RuntimeException } from '@poppinss/exception'
1212
1313import { Item } from './resource/item.ts'
@@ -94,7 +94,7 @@ export abstract class BaseSerializer<
9494 */
9595 serialize < Data extends Record < string , ResourceDataTypes | PaginatorContract < any > > > (
9696 data : Data ,
97- container ? : ContainerResolver < any >
97+ resolver : ContainerResolver < any >
9898 ) : Promise < UnpackTopLevelValues < Data > >
9999
100100 /**
@@ -105,7 +105,7 @@ export abstract class BaseSerializer<
105105 */
106106 serialize < ResourceItem extends ItemContract < any , any , any > > (
107107 resource : ResourceItem ,
108- container ? : ContainerResolver < any >
108+ resolver : ContainerResolver < any >
109109 ) : Promise < UnpackAsTopLevelItem < ResourceItem , Wrappers [ 'Wrap' ] > >
110110
111111 /**
@@ -116,7 +116,7 @@ export abstract class BaseSerializer<
116116 */
117117 serialize < ResourceCollection extends CollectionContract < any , any , any > > (
118118 collection : ResourceCollection ,
119- container ? : ContainerResolver < any >
119+ resolver : ContainerResolver < any >
120120 ) : Promise < UnpackAsTopLevelCollection < ResourceCollection , Wrappers [ 'Wrap' ] > >
121121
122122 /**
@@ -127,7 +127,7 @@ export abstract class BaseSerializer<
127127 */
128128 serialize < ResourcePaginator extends PaginatorContract < any > > (
129129 paginator : ResourcePaginator ,
130- container ? : ContainerResolver < any >
130+ resolver : ContainerResolver < any >
131131 ) : Promise <
132132 UnpackAsTopLevelPaginator <
133133 ResourcePaginator ,
@@ -142,16 +142,15 @@ export abstract class BaseSerializer<
142142 * @param value - The value to serialize
143143 * @param container - Optional container resolver for dependency injection
144144 */
145- serialize < Value > ( value : Value , container ? : ContainerResolver < any > ) : Promise < Value >
145+ serialize < Value > ( value : Value , container : ContainerResolver < any > ) : Promise < Value >
146146 serialize (
147147 data : Record < string , ResourceDataTypes > | Item < any , any , any > | Collection < any , any , any > ,
148- container ? : ContainerResolver < any >
148+ resolver : ContainerResolver < any >
149149 ) : Promise < any > {
150150 if ( data === null ) {
151151 throw new RuntimeException ( 'Cannot serialize an item with null value' )
152152 }
153153
154- const resolver = container ?? new Container ( ) . createResolver ( )
155154 if ( data instanceof Item ) {
156155 return data . resolve ( resolver , 0 , - 1 ) . then ( ( value ) => this . #wrap( value , this . wrap ) )
157156 }
0 commit comments