Skip to content

Commit

Permalink
Export data mask types in core (#12076)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller authored Oct 1, 2024
1 parent 585e81b commit d236309
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
25 changes: 16 additions & 9 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
// (undocumented)
abstract performTransaction(transaction: Transaction<TSerialized>, optimisticId?: string | null): void;
// Warning: (ae-forgotten-export) The symbol "Unmasked" needs to be exported by the entry point index.d.ts
//
// (undocumented)
abstract read<TData = any, TVariables = any>(query: Cache_2.ReadOptions<TVariables, TData>): Unmasked<TData> | null;
// (undocumented)
Expand Down Expand Up @@ -126,7 +124,6 @@ export class ApolloClient<TCacheShape> implements DataProxy {
mutate<TData = any, TVariables extends OperationVariables = OperationVariables, TContext extends Record<string, any> = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(options: MutationOptions<TData, TVariables, TContext>): Promise<FetchResult<MaybeMasked<TData>>>;
onClearStore(cb: () => Promise<any>): () => void;
onResetStore(cb: () => Promise<any>): () => void;
// Warning: (ae-forgotten-export) The symbol "MaybeMasked" needs to be exported by the entry point index.d.ts
query<T = any, TVariables extends OperationVariables = OperationVariables>(options: QueryOptions<TVariables, T>): Promise<ApolloQueryResult<MaybeMasked<T>>>;
// (undocumented)
queryDeduplication: boolean;
Expand Down Expand Up @@ -484,7 +481,7 @@ export const createSignalIfSupported: () => {
};

// @public (undocumented)
interface DataMasking {
export interface DataMasking {
}

// @public (undocumented)
Expand Down Expand Up @@ -940,7 +937,7 @@ interface FragmentRegistryAPI {
}

// @public (undocumented)
type FragmentType<TData> = [
export type FragmentType<TData> = [
TData
] extends [{
" $fragmentName"?: infer TKey;
Expand Down Expand Up @@ -1340,6 +1337,18 @@ export function makeReference(id: string): Reference;
// @public (undocumented)
export function makeVar<T>(value: T): ReactiveVar<T>;

// @public
export type Masked<TData> = TData & {
__masked?: true;
};

// @public
export type MaskedDocumentNode<TData = {
[key: string]: any;
}, TVariables = {
[key: string]: any;
}> = TypedDocumentNode<Masked<TData>, TVariables>;

// @public (undocumented)
interface MaskFragmentOptions<TData> {
// (undocumented)
Expand All @@ -1363,10 +1372,9 @@ 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 "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
//
// @public
type MaybeMasked<TData> = TData extends {
export type MaybeMasked<TData> = TData extends {
__masked?: true;
} ? Prettify<RemoveMaskedMarker<TData>> : DataMasking extends {
enabled: true;
Expand Down Expand Up @@ -2324,7 +2332,7 @@ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
type UnionToIntersection_2<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

// @public
type Unmasked<TData> = TData extends object ? UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>> : TData;
export type Unmasked<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
//
Expand Down Expand Up @@ -2364,7 +2372,6 @@ export interface UriFunction {
export interface WatchFragmentOptions<TData, TVars> {
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
fragmentName?: string;
// Warning: (ae-forgotten-export) The symbol "FragmentType" needs to be exported by the entry point index.d.ts
from: StoreObject | Reference | FragmentType<NoInfer_2<TData>> | string;
optimistic?: boolean;
variables?: TVars;
Expand Down
3 changes: 1 addition & 2 deletions .api-reports/api-report-masking.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type CombineFragmentRefs<FragmentRefs extends Record<string, any>> = UnionToInte
}[keyof FragmentRefs]>;

// @public (undocumented)
interface DataMasking {
export interface DataMasking {
}

// @public (undocumented)
Expand Down Expand Up @@ -44,7 +44,6 @@ export type MaskedDocumentNode<TData = {

// Warning: (ae-forgotten-export) The symbol "Prettify" 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
//
// @public
export type MaybeMasked<TData> = TData extends {
Expand Down
26 changes: 16 additions & 10 deletions .api-reports/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache_2.ModifyOptions<Entity>): boolean;
// (undocumented)
abstract performTransaction(transaction: Transaction<TSerialized>, optimisticId?: string | null): void;
// Warning: (ae-forgotten-export) The symbol "Unmasked" needs to be exported by the entry point index.d.ts
//
// (undocumented)
abstract read<TData = any, TVariables = any>(query: Cache_2.ReadOptions<TVariables, TData>): Unmasked<TData> | null;
// (undocumented)
Expand Down Expand Up @@ -128,7 +126,6 @@ export class ApolloClient<TCacheShape> implements DataProxy {
mutate<TData = any, TVariables extends OperationVariables = OperationVariables, TContext extends Record<string, any> = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(options: MutationOptions<TData, TVariables, TContext>): Promise<FetchResult<MaybeMasked<TData>>>;
onClearStore(cb: () => Promise<any>): () => void;
onResetStore(cb: () => Promise<any>): () => void;
// Warning: (ae-forgotten-export) The symbol "MaybeMasked" needs to be exported by the entry point index.d.ts
query<T = any, TVariables extends OperationVariables = OperationVariables>(options: QueryOptions<TVariables, T>): Promise<ApolloQueryResult<MaybeMasked<T>>>;
// (undocumented)
queryDeduplication: boolean;
Expand Down Expand Up @@ -584,7 +581,7 @@ export const createSignalIfSupported: () => {
};

// @public (undocumented)
interface DataMasking {
export interface DataMasking {
}

// @public (undocumented)
Expand Down Expand Up @@ -1061,7 +1058,7 @@ interface FragmentRegistryAPI {
}

// @public (undocumented)
type FragmentType<TData> = [
export type FragmentType<TData> = [
TData
] extends [{
" $fragmentName"?: infer TKey;
Expand Down Expand Up @@ -1521,6 +1518,18 @@ export function makeReference(id: string): Reference;
// @public (undocumented)
export function makeVar<T>(value: T): ReactiveVar<T>;

// @public
export type Masked<TData> = TData & {
__masked?: true;
};

// @public
export type MaskedDocumentNode<TData = {
[key: string]: any;
}, TVariables = {
[key: string]: any;
}> = TypedDocumentNode<Masked<TData>, TVariables>;

// @public (undocumented)
interface MaskFragmentOptions<TData> {
// (undocumented)
Expand All @@ -1544,10 +1553,9 @@ 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 "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
//
// @public
type MaybeMasked<TData> = TData extends {
export type MaybeMasked<TData> = TData extends {
__masked?: true;
} ? Prettify<RemoveMaskedMarker<TData>> : DataMasking extends {
enabled: true;
Expand Down Expand Up @@ -2789,7 +2797,7 @@ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
type UnionToIntersection_2<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

// @public
type Unmasked<TData> = TData extends object ? UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>> : TData;
export type Unmasked<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
//
Expand Down Expand Up @@ -2911,8 +2919,6 @@ export function useFragment<TData = any, TVars = OperationVariables>(options: Us
// @public (undocumented)
export interface UseFragmentOptions<TData, TVars> extends Omit<Cache_2.DiffOptions<NoInfer_2<TData>, NoInfer_2<TVars>>, "id" | "query" | "optimistic" | "previousResult" | "returnPartialData">, Omit<Cache_2.ReadFragmentOptions<TData, TVars>, "id" | "variables" | "returnPartialData"> {
client?: ApolloClient<any>;
// Warning: (ae-forgotten-export) The symbol "FragmentType" needs to be exported by the entry point index.d.ts
//
// (undocumented)
from: StoreObject | Reference | FragmentType<NoInfer_2<TData>> | string;
// (undocumented)
Expand Down
10 changes: 10 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ export {
throwServerError,
} from "../link/utils/index.js";

/* Masking */
export type {
DataMasking,
FragmentType,
Masked,
MaskedDocumentNode,
MaybeMasked,
Unmasked,
} from "../masking/index.js";

/* Utilities */

export type {
Expand Down
1 change: 1 addition & 0 deletions src/masking/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type {
DataMasking,
FragmentType,
Masked,
MaskedDocumentNode,
Expand Down

0 comments on commit d236309

Please sign in to comment.