@@ -34,7 +34,7 @@ import * as S from '../types/index.ts'
3434// ------------------------------------------------------------------
3535// Rebase
3636// ------------------------------------------------------------------
37- export function Rebase ( baseUri : string , schema : S . XSchema ) : string {
37+ export function Rebase ( baseUri : string , schema : S . XSchemaObject ) : string {
3838 if ( ! S . IsId ( schema ) ) return baseUri
3939 if ( IsUri ( schema . $id ) ) return schema . $id
4040 if ( ! IsUri ( schema . $id ) && IsUri ( baseUri ) ) {
@@ -51,7 +51,7 @@ function IsHashPointer(value: string): boolean {
5151function IsHash ( value : string ) : boolean {
5252 return value . length > 0 && value [ 0 ] === '#'
5353}
54- function Select ( schema : S . XSchema , baseUri : string , $ref : string ) : S . XSchemaLike | undefined {
54+ function Select ( schema : S . XSchemaObject , baseUri : string , $ref : string ) : S . XSchema | undefined {
5555 if ( IsUri ( baseUri ) ) {
5656 const [ base , ref ] = [ new URL ( baseUri ) , new URL ( $ref , baseUri ) ]
5757 const matched = base . pathname === ref . pathname
@@ -62,14 +62,14 @@ function Select(schema: S.XSchema, baseUri: string, $ref: string): S.XSchemaLike
6262 }
6363 if ( IsHashPointer ( $ref ) ) {
6464 const target = Pointer . Get ( schema , $ref . slice ( 1 ) )
65- if ( S . IsSchemaLike ( target ) ) return target
65+ if ( S . IsSchema ( target ) ) return target
6666 }
6767 return undefined
6868}
6969// ------------------------------------------------------------------
7070// Traversal
7171// ------------------------------------------------------------------
72- function FromObject ( schema : S . XSchema , baseUrl : string , ref : S . XRef ) : S . XSchemaLike | undefined {
72+ function FromObject ( schema : S . XSchemaObject , baseUrl : string , ref : S . XRef ) : S . XSchema | undefined {
7373 // ----------------------------------------------------------------
7474 // TypeBox: Fast TCyclic Deref
7575 // ----------------------------------------------------------------
@@ -81,18 +81,18 @@ function FromObject(schema: S.XSchema, baseUrl: string, ref: S.XRef): S.XSchemaL
8181 // ----------------------------------------------------------------
8282 const rebase = Rebase ( baseUrl , schema )
8383 const target = Select ( schema , rebase , ref . $ref )
84- if ( S . IsSchemaLike ( target ) ) return target
84+ if ( S . IsSchema ( target ) ) return target
8585
8686 // Keep searching ...
87- return Object . values ( schema ) . reduce < S . XSchemaLike | undefined > (
87+ return Object . values ( schema ) . reduce < S . XSchema | undefined > (
8888 ( result , subschema ) => result || FromValue ( subschema , rebase , ref ) ,
8989 undefined
9090 )
9191}
92- function FromArray ( schema : unknown [ ] , baseUri : string , ref : S . XRef ) : S . XSchemaLike | undefined {
93- return schema . reduce ( ( result , value ) => result || FromValue ( value , baseUri , ref ) , undefined ) as S . XSchema | undefined
92+ function FromArray ( schema : unknown [ ] , baseUri : string , ref : S . XRef ) : S . XSchema | undefined {
93+ return schema . reduce ( ( result , value ) => result || FromValue ( value , baseUri , ref ) , undefined ) as S . XSchemaObject | undefined
9494}
95- function FromValue ( schema : unknown , base : string , ref : S . XRef ) : S . XSchemaLike | undefined {
95+ function FromValue ( schema : unknown , base : string , ref : S . XRef ) : S . XSchema | undefined {
9696 return (
9797 ( Guard . IsObject ( schema ) && FromObject ( schema , base , ref ) ) ||
9898 ( Guard . IsArray ( schema ) && FromArray ( schema , base , ref ) ) ||
0 commit comments