@supabase/postgrest-js
Advanced tools
Comparing version 1.17.3 to 1.17.4
@@ -7,2 +7,6 @@ import { Ast } from './parser'; | ||
} & Message; | ||
export declare type DeduplicateRelationships<T extends readonly unknown[]> = T extends readonly [ | ||
infer First, | ||
...infer Rest | ||
] ? First extends Rest[number] ? DeduplicateRelationships<Rest extends readonly unknown[] ? Rest : []> : [First, ...DeduplicateRelationships<Rest extends readonly unknown[] ? Rest : []>] : T; | ||
export declare type GetFieldNodeResultName<Field extends Ast.FieldNode> = Field['alias'] extends string ? Field['alias'] : Field['aggregateFunction'] extends AggregateFunctions ? Field['aggregateFunction'] : Field['name']; | ||
@@ -47,3 +51,4 @@ declare type FilterRelationNodes<Nodes extends Ast.Node[]> = UnionToArray<{ | ||
*/ | ||
declare type FindDuplicates<Arr extends any[]> = Arr extends [infer Head, ...infer Tail] ? CheckDuplicates<Tail, Head> | FindDuplicates<Tail> : never; | ||
declare type FindDuplicatesWithinDeduplicated<Arr extends any[]> = Arr extends [infer Head, ...infer Tail] ? CheckDuplicates<Tail, Head> | FindDuplicatesWithinDeduplicated<Tail> : never; | ||
declare type FindDuplicates<Arr extends any[]> = FindDuplicatesWithinDeduplicated<DeduplicateRelationships<Arr>>; | ||
export declare type CheckDuplicateEmbededReference<Schema extends GenericSchema, RelationName extends string, Relationships extends GenericRelationship[], Nodes extends Ast.Node[]> = FilterRelationNodes<Nodes> extends infer RelationsNodes ? RelationsNodes extends Ast.FieldNode[] ? ResolveRelationships<Schema, RelationName, Relationships, RelationsNodes> extends infer ResolvedRels ? ResolvedRels extends unknown[] ? FindDuplicates<ResolvedRels> extends infer Duplicates ? Duplicates extends never ? false : Duplicates extends { | ||
@@ -64,3 +69,3 @@ fieldName: infer FieldName; | ||
*/ | ||
declare type HasMultipleFKeysToFRel<FRelName, Relationships> = Relationships extends [ | ||
declare type HasMultipleFKeysToFRelDeduplicated<FRelName, Relationships> = Relationships extends [ | ||
infer R, | ||
@@ -70,3 +75,4 @@ ...infer Rest | ||
referencedRelation: FRelName; | ||
} ? HasFKeyToFRel<FRelName, Rest> extends true ? true : HasMultipleFKeysToFRel<FRelName, Rest> : HasMultipleFKeysToFRel<FRelName, Rest> : false; | ||
} ? HasFKeyToFRel<FRelName, Rest> extends true ? true : HasMultipleFKeysToFRelDeduplicated<FRelName, Rest> : HasMultipleFKeysToFRelDeduplicated<FRelName, Rest> : false; | ||
declare type HasMultipleFKeysToFRel<FRelName, Relationships extends unknown[]> = HasMultipleFKeysToFRelDeduplicated<FRelName, DeduplicateRelationships<Relationships>>; | ||
declare type CheckRelationshipError<Schema extends GenericSchema, Relationships extends GenericRelationship[], CurrentTableOrView extends keyof TablesAndViews<Schema> & string, FoundRelation> = FoundRelation extends SelectQueryError<string> ? FoundRelation : FoundRelation extends { | ||
@@ -224,5 +230,5 @@ relation: { | ||
declare type ResolveJoinTableRelationship<Schema extends GenericSchema, CurrentTableOrView extends keyof TablesAndViews<Schema> & string, FieldName extends string> = { | ||
[TableName in keyof TablesAndViews<Schema>]: TablesAndViews<Schema>[TableName]['Relationships'] extends readonly (infer Rel)[] ? Rel extends { | ||
[TableName in keyof TablesAndViews<Schema>]: DeduplicateRelationships<TablesAndViews<Schema>[TableName]['Relationships']> extends readonly (infer Rel)[] ? Rel extends { | ||
referencedRelation: CurrentTableOrView; | ||
} ? TablesAndViews<Schema>[TableName]['Relationships'] extends readonly (infer OtherRel)[] ? OtherRel extends { | ||
} ? DeduplicateRelationships<TablesAndViews<Schema>[TableName]['Relationships']> extends readonly (infer OtherRel)[] ? OtherRel extends { | ||
referencedRelation: FieldName; | ||
@@ -229,0 +235,0 @@ } ? OtherRel : never : never : never : never; |
{ | ||
"name": "@supabase/postgrest-js", | ||
"version": "1.17.3", | ||
"version": "1.17.4", | ||
"description": "Isomorphic PostgREST client", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -17,2 +17,19 @@ import { Ast } from './parser' | ||
/* | ||
** Because of pg-meta types generation there is some cases where a same relationship can be duplicated | ||
** if the relation is across schemas and views this ensure that we dedup those relations and treat them | ||
** as postgrest would. | ||
** This is no longer the case and has been patched here: https://github.com/supabase/postgres-meta/pull/809 | ||
** But we still need this for retro-compatibilty with older generated types | ||
** TODO: Remove this in next major version | ||
*/ | ||
export type DeduplicateRelationships<T extends readonly unknown[]> = T extends readonly [ | ||
infer First, | ||
...infer Rest | ||
] | ||
? First extends Rest[number] | ||
? DeduplicateRelationships<Rest extends readonly unknown[] ? Rest : []> | ||
: [First, ...DeduplicateRelationships<Rest extends readonly unknown[] ? Rest : []>] | ||
: T | ||
export type GetFieldNodeResultName<Field extends Ast.FieldNode> = Field['alias'] extends string | ||
@@ -91,6 +108,10 @@ ? Field['alias'] | ||
*/ | ||
type FindDuplicates<Arr extends any[]> = Arr extends [infer Head, ...infer Tail] | ||
? CheckDuplicates<Tail, Head> | FindDuplicates<Tail> | ||
type FindDuplicatesWithinDeduplicated<Arr extends any[]> = Arr extends [infer Head, ...infer Tail] | ||
? CheckDuplicates<Tail, Head> | FindDuplicatesWithinDeduplicated<Tail> | ||
: never | ||
type FindDuplicates<Arr extends any[]> = FindDuplicatesWithinDeduplicated< | ||
DeduplicateRelationships<Arr> | ||
> | ||
export type CheckDuplicateEmbededReference< | ||
@@ -142,3 +163,3 @@ Schema extends GenericSchema, | ||
*/ | ||
type HasMultipleFKeysToFRel<FRelName, Relationships> = Relationships extends [ | ||
type HasMultipleFKeysToFRelDeduplicated<FRelName, Relationships> = Relationships extends [ | ||
infer R, | ||
@@ -150,6 +171,11 @@ ...infer Rest | ||
? true | ||
: HasMultipleFKeysToFRel<FRelName, Rest> | ||
: HasMultipleFKeysToFRel<FRelName, Rest> | ||
: HasMultipleFKeysToFRelDeduplicated<FRelName, Rest> | ||
: HasMultipleFKeysToFRelDeduplicated<FRelName, Rest> | ||
: false | ||
type HasMultipleFKeysToFRel< | ||
FRelName, | ||
Relationships extends unknown[] | ||
> = HasMultipleFKeysToFRelDeduplicated<FRelName, DeduplicateRelationships<Relationships>> | ||
type CheckRelationshipError< | ||
@@ -461,5 +487,9 @@ Schema extends GenericSchema, | ||
> = { | ||
[TableName in keyof TablesAndViews<Schema>]: TablesAndViews<Schema>[TableName]['Relationships'] extends readonly (infer Rel)[] | ||
[TableName in keyof TablesAndViews<Schema>]: DeduplicateRelationships< | ||
TablesAndViews<Schema>[TableName]['Relationships'] | ||
> extends readonly (infer Rel)[] | ||
? Rel extends { referencedRelation: CurrentTableOrView } | ||
? TablesAndViews<Schema>[TableName]['Relationships'] extends readonly (infer OtherRel)[] | ||
? DeduplicateRelationships< | ||
TablesAndViews<Schema>[TableName]['Relationships'] | ||
> extends readonly (infer OtherRel)[] | ||
? OtherRel extends { referencedRelation: FieldName } | ||
@@ -466,0 +496,0 @@ ? OtherRel |
@@ -1,1 +0,1 @@ | ||
export const version = '1.17.3' | ||
export const version = '1.17.4' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
325003
5630