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

fix(dataplan-pg): type restrictions #1756

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
46 changes: 3 additions & 43 deletions grafast/dataplan-pg/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,28 +652,11 @@ export type Expand<T> = T extends unknown
: never;

export interface PgRegistry<
TCodecs extends {
[name in string]: PgCodec<
name,
PgCodecAttributes | undefined,
any,
any,
any,
any,
any
>;
} = Record<
TCodecs = Record<
string,
PgCodec<string, PgCodecAttributes | undefined, any, any, any, any, any>
>,
TResourceOptions extends {
[name in string]: PgResourceOptions<
name,
PgCodec, // TCodecs[keyof TCodecs],
ReadonlyArray<PgResourceUnique<PgCodecAttributes>>,
readonly PgResourceParameter[] | undefined
>;
} = Record<
TResourceOptions = Record<
string,
PgResourceOptions<
string,
Expand All @@ -683,22 +666,7 @@ export interface PgRegistry<
readonly PgResourceParameter[] | undefined
>
>,
TRelations extends {
[codecName in keyof TCodecs]?: {
[relationName in string]: PgCodecRelationConfig<
// TCodecs[keyof TCodecs] &
PgCodec<string, PgCodecAttributes, any, any, undefined, any, undefined>,
// TResourceOptions[keyof TResourceOptions] &
PgResourceOptions<
any,
// TCodecs[keyof TCodecs] &
PgCodecWithAttributes,
any,
any
>
>;
};
} = Record<
TRelations = Record<
string,
Record<
string,
Expand Down Expand Up @@ -762,39 +730,31 @@ export interface PgRegistry<

export type GetPgRegistryCodecs<TRegistry extends PgRegistry<any, any, any>> =
TRegistry["pgCodecs"];

export type GetPgRegistrySources<TRegistry extends PgRegistry<any, any, any>> =
TRegistry["pgResources"];

export type GetPgRegistryCodecRelations<
TRegistry extends PgRegistry<any, any, any>,
TCodec extends PgCodec<any, any, any, any, any, any, any>,
> = TRegistry["pgRelations"][TCodec["name"]];

export type GetPgCodecAttributes<
TCodec extends PgCodec<any, any, any, any, any, any, any>,
> = TCodec extends PgCodec<any, infer UAttributes, any, any, any, any, any>
? UAttributes extends undefined
? never
: UAttributes
: PgCodecAttributes;

export type GetPgResourceRegistry<
TResource extends PgResource<any, any, any, any, any>,
> = TResource["registry"];

export type GetPgResourceCodec<
TResource extends PgResource<any, any, any, any, any>,
> = TResource["codec"];

export type GetPgResourceAttributes<
TResource extends PgResource<any, any, any, any, any>,
> = GetPgCodecAttributes<TResource["codec"]>;

export type GetPgResourceRelations<
TResource extends PgResource<any, any, any, any, any>,
> = TResource["registry"]["pgRelations"][TResource["codec"]["name"]];

export type GetPgResourceUniques<
TResource extends PgResource<any, any, any, any, any>,
> = TResource["uniques"];