Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle additional cases in unmasked types #12154

Merged
merged 24 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 70 additions & 19 deletions .api-reports/api-report-cache.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,26 @@ export const canonicalStringify: ((value: any) => string) & {
// @public (undocumented)
type CanReadFunction = (value: StoreValue) => boolean;

// Warning: (ae-forgotten-export) The symbol "UnionToIntersection" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UnwrapFragmentRefs" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RemoveFragmentName" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Prettify" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "MergeUnions" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type CombineFragmentRefs<FragmentRefs extends Record<string, any>> = UnionToIntersection<{
[K in keyof FragmentRefs]-?: UnwrapFragmentRefs<RemoveFragmentName<FragmentRefs[K]>>;
}[keyof FragmentRefs]>;
// @public
type CombineByTypeName<T extends {
__typename?: string;
}> = {
[TypeName in NonNullable<T["__typename"]>]: Extract<T, {
__typename?: TypeName;
}> extends infer SubSelection ? Prettify<MergeUnions<SubSelection>> : never;
}[NonNullable<T["__typename"]>];

// Warning: (ae-forgotten-export) The symbol "CombineByTypeName" needs to be exported by the entry point index.d.ts
//
// @public
type CombineIntersection<T> = Exclude<T, {
__typename?: string;
}> | CombineByTypeName<Extract<T, {
__typename?: string;
}>>;

// @public (undocumented)
type ContainsFragmentsRefs<TData> = TData extends object ? " $fragmentRefs" extends keyof TData ? true : ContainsFragmentsRefs<TData[keyof TData]> : false;
Expand Down Expand Up @@ -352,6 +364,9 @@ export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
returnPartialData?: boolean;
};

// @public (undocumented)
type DistributedRequiredExclude<T, U> = T extends any ? Required<T> extends Required<U> ? Required<U> extends Required<T> ? never : T : T : T;

// @public (undocumented)
export abstract class EntityStore implements NormalizedCache {
constructor(policies: Policies, group: CacheGroup);
Expand Down Expand Up @@ -677,6 +692,9 @@ interface InvalidateModifier {
// @public (undocumented)
const _invalidateModifier: unique symbol;

// @public (undocumented)
type IsAny<T> = 0 extends 1 & T ? true : false;

// @public (undocumented)
export function isReference(obj: any): obj is Reference;

Expand Down Expand Up @@ -733,17 +751,17 @@ export function makeReference(id: string): Reference;
// @public (undocumented)
export function makeVar<T>(value: T): ReactiveVar<T>;

// Warning: (ae-forgotten-export) The symbol "Prettify" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "IsAny" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RemoveMaskedMarker" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "DataMasking" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ContainsFragmentsRefs" needs to be exported by the entry point index.d.ts
//
// @public
type MaybeMasked<TData> = TData extends {
type MaybeMasked<TData> = TData extends any ? true extends IsAny<TData> ? TData : TData extends {
__masked?: true;
} ? Prettify<RemoveMaskedMarker<TData>> : DataMasking extends {
enabled: true;
} ? TData : true extends ContainsFragmentsRefs<TData> ? Unmasked<TData> : TData;
} ? TData : true extends ContainsFragmentsRefs<TData> ? Unmasked<TData> : TData : never;

// @public (undocumented)
export interface MergeInfo {
Expand All @@ -755,6 +773,19 @@ export interface MergeInfo {
typename: string | undefined;
}

// Warning: (ae-forgotten-export) The symbol "CombineIntersection" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type MergeObjects<T, U> = Prettify<{
[k in keyof T]: k extends keyof U ? [
NonNullable<T[k]>,
NonNullable<U[k]>
] extends ([
infer TK extends object,
infer UK extends object
]) ? TK extends unknown[] ? UK extends unknown[] ? CombineIntersection<TK[number] | UK[number]>[] | Extract<T[k] | U[k], undefined | null> : T[k] : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null> : T[k] : T[k];
} & Pick<U, Exclude<keyof U, keyof T>>>;

// @public (undocumented)
type MergeObjectsFunction = <T extends StoreObject | Reference>(existing: T, incoming: T) => T;

Expand All @@ -766,6 +797,22 @@ export interface MergeTree {
map: Map<string | number, MergeTree>;
}

// Warning: (ae-forgotten-export) The symbol "MergeUnionsAcc" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "takeOneFromUnion" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type MergeUnions<TUnion> = MergeUnionsAcc<TUnion, takeOneFromUnion<TUnion>, never>;

// Warning: (ae-forgotten-export) The symbol "DistributedRequiredExclude" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "MergeObjects" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type MergeUnionsAcc<TUnion, Curr, Merged> = [
Curr
] extends [never] ? Merged : MergeUnionsAcc<DistributedRequiredExclude<TUnion, Curr>, takeOneFromUnion<DistributedRequiredExclude<TUnion, Curr>>, [
Merged
] extends [never] ? Curr : MergeObjects<Curr, Merged>>;

// @public (undocumented)
export class MissingFieldError extends Error {
constructor(message: string, path: MissingTree | Array<string | number>, query: DocumentNode, variables?: Record<string, any> | undefined);
Expand Down Expand Up @@ -1016,6 +1063,11 @@ class Stump extends Layer {
removeLayer(): this;
}

// Warning: (ae-forgotten-export) The symbol "unionToIntersection" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type takeOneFromUnion<T> = unionToIntersection<T extends T ? (x: T) => 0 : never> extends ((x: infer U) => 0) ? U : never;

// @public (undocumented)
type ToReferenceFunction = (objOrIdOrRef: StoreObject | string | Reference, mergeIntoStore?: boolean) => Reference | undefined;

Expand All @@ -1040,19 +1092,18 @@ export type TypePolicy = {
};

// @public (undocumented)
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
type unionToIntersection<T> = (T extends unknown ? (x: T) => unknown : never) extends ((x: infer U) => unknown) ? U : never;

// Warning: (ae-forgotten-export) The symbol "UnwrapFragmentRefs" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RemoveFragmentName" needs to be exported by the entry point index.d.ts
//
// @public
type Unmasked<TData> = TData extends object ? UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>> : TData;
type Unmasked<TData> = true extends IsAny<TData> ? TData : TData extends object ? UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>> : TData;

// Warning: (ae-forgotten-export) The symbol "CombineFragmentRefs" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNullable<TData> ? TData : " $fragmentRefs" extends keyof NonNullable<TData> ? TData extends {
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
type UnwrapFragmentRefs<TData> = true extends IsAny<TData> ? TData : TData extends any ? string extends keyof TData ? TData : keyof TData extends never ? TData : TData extends {
" $fragmentRefs"?: infer FragmentRefs;
} ? UnwrapFragmentRefs<CombineIntersection<Omit<TData, " $fragmentRefs"> | RemoveFragmentName<NonNullable<NonNullable<FragmentRefs>[keyof NonNullable<FragmentRefs>]>>>> : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
95 changes: 73 additions & 22 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,26 @@ export type ClientParseError = InvariantError & {
parseError: Error;
};

// Warning: (ae-forgotten-export) The symbol "UnionToIntersection" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UnwrapFragmentRefs" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RemoveFragmentName" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Prettify" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "MergeUnions" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type CombineFragmentRefs<FragmentRefs extends Record<string, any>> = UnionToIntersection<{
[K in keyof FragmentRefs]-?: UnwrapFragmentRefs<RemoveFragmentName<FragmentRefs[K]>>;
}[keyof FragmentRefs]>;
// @public
type CombineByTypeName<T extends {
__typename?: string;
}> = {
[TypeName in NonNullable<T["__typename"]>]: Extract<T, {
__typename?: TypeName;
}> extends infer SubSelection ? Prettify<MergeUnions<SubSelection>> : never;
}[NonNullable<T["__typename"]>];

// Warning: (ae-forgotten-export) The symbol "CombineByTypeName" needs to be exported by the entry point index.d.ts
//
// @public
type CombineIntersection<T> = Exclude<T, {
__typename?: string;
}> | CombineByTypeName<Extract<T, {
__typename?: string;
}>>;

// @public (undocumented)
class Concast<T> extends Observable<T> {
Expand Down Expand Up @@ -633,6 +645,9 @@ export { disableExperimentalFragmentVariables }

export { disableFragmentWarnings }

// @public (undocumented)
type DistributedRequiredExclude<T, U> = T extends any ? Required<T> extends Required<U> ? Required<U> extends Required<T> ? never : T : T : T;

export { DocumentNode }

// @public (undocumented)
Expand Down Expand Up @@ -1227,6 +1242,9 @@ interface InvalidateModifier {
// @public (undocumented)
const _invalidateModifier: unique symbol;

// @public (undocumented)
type IsAny<T> = 0 extends 1 & T ? true : false;

// @public (undocumented)
export function isApolloError(err: Error): err is ApolloError;

Expand All @@ -1236,11 +1254,11 @@ export function isNetworkRequestSettled(networkStatus?: NetworkStatus): boolean;
// @public (undocumented)
export function isReference(obj: any): obj is Reference;

// Warning: (ae-forgotten-export) The symbol "UnionToIntersection_2" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UnionToIntersection" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UnionForAny" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type IsStrictlyAny<T> = UnionToIntersection_2<UnionForAny<T>> extends never ? true : false;
type IsStrictlyAny<T> = UnionToIntersection<UnionForAny<T>> extends never ? true : false;

// @public (undocumented)
type KeyArgsFunction = (args: Record<string, any> | null, context: {
Expand Down Expand Up @@ -1377,16 +1395,16 @@ interface MaskOperationOptions<TData> {
// @public (undocumented)
type MaybeAsync<T> = T | PromiseLike<T>;

// Warning: (ae-forgotten-export) The symbol "Prettify" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "IsAny" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RemoveMaskedMarker" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ContainsFragmentsRefs" needs to be exported by the entry point index.d.ts
//
// @public
export type MaybeMasked<TData> = TData extends {
export type MaybeMasked<TData> = TData extends any ? true extends IsAny<TData> ? TData : TData extends {
__masked?: true;
} ? Prettify<RemoveMaskedMarker<TData>> : DataMasking extends {
enabled: true;
} ? TData : true extends ContainsFragmentsRefs<TData> ? Unmasked<TData> : TData;
} ? TData : true extends ContainsFragmentsRefs<TData> ? Unmasked<TData> : TData : never;

// @public (undocumented)
export interface MergeInfo {
Expand All @@ -1398,6 +1416,19 @@ export interface MergeInfo {
typename: string | undefined;
}

// Warning: (ae-forgotten-export) The symbol "CombineIntersection" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type MergeObjects<T, U> = Prettify<{
[k in keyof T]: k extends keyof U ? [
NonNullable<T[k]>,
NonNullable<U[k]>
] extends ([
infer TK extends object,
infer UK extends object
]) ? TK extends unknown[] ? UK extends unknown[] ? CombineIntersection<TK[number] | UK[number]>[] | Extract<T[k] | U[k], undefined | null> : T[k] : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null> : T[k] : T[k];
} & Pick<U, Exclude<keyof U, keyof T>>>;

// @public (undocumented)
type MergeObjectsFunction = <T extends StoreObject | Reference>(existing: T, incoming: T) => T;

Expand All @@ -1414,6 +1445,22 @@ export interface MergeTree {
map: Map<string | number, MergeTree>;
}

// Warning: (ae-forgotten-export) The symbol "MergeUnionsAcc" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "takeOneFromUnion" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type MergeUnions<TUnion> = MergeUnionsAcc<TUnion, takeOneFromUnion<TUnion>, never>;

// Warning: (ae-forgotten-export) The symbol "DistributedRequiredExclude" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "MergeObjects" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type MergeUnionsAcc<TUnion, Curr, Merged> = [
Curr
] extends [never] ? Merged : MergeUnionsAcc<DistributedRequiredExclude<TUnion, Curr>, takeOneFromUnion<DistributedRequiredExclude<TUnion, Curr>>, [
Merged
] extends [never] ? Curr : MergeObjects<Curr, Merged>>;

// @public (undocumented)
export type MethodKeys<T> = {
[P in keyof T]: T[P] extends Function ? P : never;
Expand Down Expand Up @@ -2276,6 +2323,11 @@ export interface SubscriptionOptions<TVariables = OperationVariables, TData = an
variables?: TVariables;
}

// Warning: (ae-forgotten-export) The symbol "unionToIntersection" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type takeOneFromUnion<T> = unionToIntersection<T extends T ? (x: T) => 0 : never> extends ((x: infer U) => 0) ? U : never;

// @public (undocumented)
export const throwServerError: (response: Response, result: any, message: string) => never;

Expand Down Expand Up @@ -2334,22 +2386,21 @@ export type TypePolicy = {
type UnionForAny<T> = T extends never ? "a" : 1;

// @public (undocumented)
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

// @public (undocumented)
type UnionToIntersection_2<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
type unionToIntersection<T> = (T extends unknown ? (x: T) => unknown : never) extends ((x: infer U) => unknown) ? U : never;

// Warning: (ae-forgotten-export) The symbol "UnwrapFragmentRefs" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RemoveFragmentName" needs to be exported by the entry point index.d.ts
//
// @public
export type Unmasked<TData> = TData extends object ? UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>> : TData;
export type Unmasked<TData> = true extends IsAny<TData> ? TData : TData extends object ? UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>> : TData;

// Warning: (ae-forgotten-export) The symbol "CombineFragmentRefs" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNullable<TData> ? TData : " $fragmentRefs" extends keyof NonNullable<TData> ? TData extends {
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
type UnwrapFragmentRefs<TData> = true extends IsAny<TData> ? TData : TData extends any ? string extends keyof TData ? TData : keyof TData extends never ? TData : TData extends {
" $fragmentRefs"?: infer FragmentRefs;
} ? UnwrapFragmentRefs<CombineIntersection<Omit<TData, " $fragmentRefs"> | RemoveFragmentName<NonNullable<NonNullable<FragmentRefs>[keyof NonNullable<FragmentRefs>]>>>> : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
Loading
Loading