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

Rework TypeScript types around registry, codecs, resources and relations #1784

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
268 changes: 163 additions & 105 deletions grafast/dataplan-pg/src/codecs.ts

Large diffs are not rendered by default.

669 changes: 394 additions & 275 deletions grafast/dataplan-pg/src/datasource.ts

Large diffs are not rendered by default.

415 changes: 258 additions & 157 deletions grafast/dataplan-pg/src/examples/exampleSchema.ts

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions grafast/dataplan-pg/src/filters/pgBooleanFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ExecutableStep } from "grafast";
import { ModifierStep } from "grafast";
import type { SQL } from "pg-sql2";

import type { PgCodec, PgConditionLikeStep } from "../interfaces.js";
import type { _AnyPgCodec, PgConditionLikeStep } from "../interfaces.js";

export class PgBooleanFilterStep extends ModifierStep<PgConditionLikeStep> {
static $$export = {
Expand All @@ -22,7 +22,10 @@ export class PgBooleanFilterStep extends ModifierStep<PgConditionLikeStep> {
this.alias = $classFilterPlan.alias;
}

placeholder($step: ExecutableStep, codec: PgCodec): SQL {
placeholder<TCodec extends _AnyPgCodec>(
$step: ExecutableStep,
codec: TCodec,
): SQL {
return this.$parent.placeholder($step, codec);
}

Expand Down
7 changes: 5 additions & 2 deletions grafast/dataplan-pg/src/filters/pgClassFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ExecutableStep } from "grafast";
import { ModifierStep } from "grafast";
import type { SQL } from "pg-sql2";

import type { PgCodec } from "../interfaces.js";
import type { _AnyPgCodec } from "../interfaces.js";
import type {
PgConditionCapableParentStep,
PgConditionStep,
Expand Down Expand Up @@ -30,7 +30,10 @@ export class PgClassFilterStep<
this.conditions.push(condition);
}

placeholder($step: ExecutableStep, codec: PgCodec): SQL {
placeholder<TCodec extends _AnyPgCodec>(
$step: ExecutableStep,
codec: TCodec,
): SQL {
return this.$parent.placeholder($step, codec);
}

Expand Down
7 changes: 5 additions & 2 deletions grafast/dataplan-pg/src/filters/pgOrFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ModifierStep } from "grafast";
import type { SQL } from "pg-sql2";
import { sql } from "pg-sql2";

import type { PgCodec, PgConditionLikeStep } from "../interfaces.js";
import type { _AnyPgCodec, PgConditionLikeStep } from "../interfaces.js";

export class PgOrFilterStep extends ModifierStep<PgConditionLikeStep> {
static $$export = {
Expand All @@ -20,7 +20,10 @@ export class PgOrFilterStep extends ModifierStep<PgConditionLikeStep> {
this.alias = $classFilterPlan.alias;
}

placeholder($step: ExecutableStep, codec: PgCodec): SQL {
placeholder<TCodec extends _AnyPgCodec>(
$step: ExecutableStep,
codec: TCodec,
): SQL {
return this.$parent.placeholder($step, codec);
}

Expand Down
151 changes: 144 additions & 7 deletions grafast/dataplan-pg/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { exportAsMany } from "grafast";

import {
_AnyPgCodecAttribute,
_AnyPgCodecAttributeVia,
_AnyPgCodecAttributeViaAttribute,
_AnyPgCodecAttributeViaRelationName,
domainOfCodec,
enumCodec,
GenericPgCodecAttribute,
GenericPgCodecAttributeVia,
getCodecByPgCatalogTypeName,
getInnerCodec,
isEnumCodec,
listOfCodec,
ObjectFromPgCodecAttributes,
PgCodecAttribute,
PgCodecAttributeExtensions,
PgCodecAttributes,
PgCodecAttributeVia,
PgCodecAttributeViaExplicit,
PgEnumCodecSpec,
Expand All @@ -31,6 +36,20 @@ import {
PgPolygon,
} from "./codecUtils/index.js";
import {
_AnyPgFunctionResourceOptions,
_AnyPgRegistryBuilder,
_AnyPgResource,
_AnyPgResourceOptions,
_AnyPgResourceParameter,
_AnyPgResourceUnique,
_AnyScalarPgResource,
DefaultRegistryBuilder,
EmptyRegistryBuilder,
GenericPgFunctionResourceOptions,
GenericPgResource,
GenericPgResourceOptions,
GenericPgResourceParameter,
GenericPgResourceUnique,
makePgResourceOptions,
makeRegistry,
makeRegistryBuilder,
Expand Down Expand Up @@ -65,7 +84,23 @@ import { PgClassFilterStep } from "./filters/pgClassFilter.js";
import { PgManyFilterStep } from "./filters/pgManyFilter.js";
import { PgOrFilterStep } from "./filters/pgOrFilter.js";
import {
GetPgCodecAttributes,
_AnyPgCodec,
_AnyPgCodecAttributesRecord,
_AnyPgCodecRelationConfig,
_AnyPgRangeItemCodec,
_AnyPgRegistry,
_AnyPgRegistryConfig,
_AnyPgRelation,
_AnyScalarPgCodec,
DefaultScalarPgCodec,
GenericPgCodec,
GenericPgCodecAttributesRecord,
GenericPgCodecRelationConfig,
GenericPgCodecWithAttributes,
GenericPgRangeItemCodec,
GenericPgRegistry,
GenericPgRegistryConfig,
GenericPgRelation,
GetPgRegistryCodecRelations,
GetPgRegistryCodecs,
GetPgRegistrySources,
Expand All @@ -79,17 +114,26 @@ import {
PgClassSingleStep,
PgCodec,
PgCodecAnyScalar,
PgCodecAttributes,
PgCodecAttributesRecord,
PgCodecExtensions,
PgCodecFromJavaScript,
PgCodecFromPg,
PgCodecFromPostgres,
PgCodecList,
PgCodecName,
PgCodecPolymorphism,
PgCodecPolymorphismRelational,
PgCodecPolymorphismRelationalTypeSpec,
PgCodecPolymorphismSingle,
PgCodecPolymorphismSingleTypeAttributeSpec,
PgCodecPolymorphismSingleTypeSpec,
PgCodecPolymorphismUnion,
PgCodecRelation,
PgCodecRelationBase,
PgCodecRelationConfig,
PgCodecRelationConfigLocalCodec,
PgCodecRelationConfigName,
PgCodecRelationConfigRemoteResourceOptions,
PgCodecRelationExtensions,
PgCodecWithAttributes,
PgConditionLikeStep,
Expand All @@ -98,11 +142,23 @@ import {
PgEnumCodec,
PgEnumValue,
PgGroupSpec,
PgOrderAttributeSpec,
PgOrderFragmentSpec,
PgOrderSpec,
PgRefDefinition,
PgRefDefinitionExtensions,
PgRefDefinitions,
PgRegistry,
PgRegistryCodecRelations,
PgRegistryCodecs,
PgRegistryConfig,
PgRegistryConfigCodecs,
PgRegistryConfigRelationConfigs,
PgRegistryConfigResourceOptions,
PgRegistryRelationConfigs,
PgRegistryResourceOptions,
PgRegistryResources,
PgRelation,
PgTypedExecutableStep,
PlanByUniques,
TuplePlanMap,
Expand All @@ -121,7 +177,12 @@ import {
pgWhereConditionSpecListToSQL,
} from "./steps/pgCondition.js";
import { PgCursorStep } from "./steps/pgCursor.js";
import { pgDeleteSingle, PgDeleteSingleStep } from "./steps/pgDeleteSingle.js";
import {
_AnyPgDeleteSingleStep,
GenericPgDeleteSingleStep,
pgDeleteSingle,
PgDeleteSingleStep,
} from "./steps/pgDeleteSingle.js";
import { pgInsertSingle, PgInsertSingleStep } from "./steps/pgInsertSingle.js";
import { pgPageInfo, PgPageInfoStep } from "./steps/pgPageInfo.js";
import {
Expand All @@ -130,7 +191,9 @@ import {
PgPolymorphicTypeMap,
} from "./steps/pgPolymorphic.js";
import {
_AnyPgSelectStep,
digestsFromArgumentSpecs,
GenericPgSelectStep,
pgSelect,
PgSelectArgumentDigest,
PgSelectArgumentSpec,
Expand All @@ -143,6 +206,9 @@ import {
sqlFromArgDigests,
} from "./steps/pgSelect.js";
import {
_AnyPgSelectSinglePlanOptions,
_AnyPgSelectSingleStep,
GenericPgSelectSingleStep,
pgSelectFromRecord,
pgSelectSingleFromRecord,
PgSelectSinglePlanOptions,
Expand All @@ -163,7 +229,12 @@ import {
PgUnionAllStepMember,
PgUnionAllStepOrder,
} from "./steps/pgUnionAll.js";
import { pgUpdateSingle, PgUpdateSingleStep } from "./steps/pgUpdateSingle.js";
import {
_AnyPgUpdateSingleStep,
GenericPgUpdateSingleStep,
pgUpdateSingle,
PgUpdateSingleStep,
} from "./steps/pgUpdateSingle.js";
import {
pgValidateParsedCursor,
PgValidateParsedCursorStep,
Expand All @@ -178,13 +249,57 @@ import {
import { assertPgClassSingleStep } from "./utils.js";

export {
_AnyPgCodec,
_AnyPgCodecAttribute,
_AnyPgCodecAttributesRecord,
_AnyPgCodecAttributeVia,
_AnyPgCodecAttributeViaAttribute,
_AnyPgCodecAttributeViaRelationName,
_AnyPgCodecRelationConfig,
_AnyPgDeleteSingleStep,
_AnyPgFunctionResourceOptions,
_AnyPgRegistry,
_AnyPgRegistryBuilder,
_AnyPgRegistryConfig,
_AnyPgRelation,
_AnyPgResource,
_AnyPgResourceOptions,
_AnyPgResourceParameter,
_AnyPgResourceUnique,
_AnyPgSelectSinglePlanOptions,
_AnyPgSelectSingleStep,
_AnyPgSelectStep,
_AnyPgUpdateSingleStep,
_AnyScalarPgCodec,
_AnyScalarPgResource,
assertPgClassSingleStep,
DefaultRegistryBuilder,
DefaultScalarPgCodec,
digestsFromArgumentSpecs,
domainOfCodec,
EmptyRegistryBuilder,
enumCodec,
GenericPgCodec,
GenericPgCodecAttribute,
GenericPgCodecAttributesRecord,
GenericPgCodecAttributeVia,
GenericPgCodecRelationConfig,
GenericPgCodecWithAttributes,
GenericPgDeleteSingleStep,
GenericPgFunctionResourceOptions,
GenericPgRangeItemCodec,
GenericPgRegistry,
GenericPgRegistryConfig,
GenericPgRelation,
GenericPgResource,
GenericPgResourceOptions,
GenericPgResourceParameter,
GenericPgResourceUnique,
GenericPgSelectSingleStep,
GenericPgSelectStep,
GenericPgUpdateSingleStep,
getCodecByPgCatalogTypeName,
getInnerCodec,
GetPgCodecAttributes,
GetPgRegistryCodecRelations,
GetPgRegistryCodecs,
GetPgRegistrySources,
Expand Down Expand Up @@ -216,10 +331,15 @@ export {
PgCodecAttribute,
PgCodecAttributeExtensions,
PgCodecAttributes,
PgCodecAttributesRecord,
PgCodecAttributeVia,
PgCodecAttributeViaExplicit,
PgCodecExtensions,
PgCodecFromJavaScript,
PgCodecFromPg,
PgCodecFromPostgres,
PgCodecList,
PgCodecName,
PgCodecPolymorphism,
PgCodecPolymorphismRelational,
PgCodecPolymorphismRelationalTypeSpec,
Expand All @@ -232,8 +352,12 @@ export {
PgCodecRefPath,
PgCodecRefPathEntry,
PgCodecRefs,
PgCodecRelation,
PgRelation as PgCodecRelation,
PgCodecRelationBase,
PgCodecRelationConfig,
PgCodecRelationConfigLocalCodec,
PgCodecRelationConfigName,
PgCodecRelationConfigRemoteResourceOptions,
PgCodecRelationExtensions,
PgCodecWithAttributes,
PgConditionCapableParentStep,
Expand Down Expand Up @@ -266,6 +390,8 @@ export {
PgLockCallback,
PgLseg,
PgManyFilterStep,
PgOrderAttributeSpec,
PgOrderFragmentSpec,
PgOrderSpec,
PgOrFilterStep,
pgPageInfo,
Expand All @@ -276,12 +402,23 @@ export {
pgPolymorphic,
PgPolymorphicStep,
PgPolymorphicTypeMap,
_AnyPgRangeItemCodec as PgRangeItemCodec,
PgRecordTypeCodecSpec,
PgRefDefinition,
PgRefDefinitionExtensions,
PgRefDefinitions,
PgRegistry,
PgRegistryBuilder,
PgRegistryCodecRelations,
PgRegistryCodecs,
PgRegistryConfig,
PgRegistryConfigCodecs,
PgRegistryConfigRelationConfigs,
PgRegistryConfigResourceOptions,
PgRegistryRelationConfigs,
PgRegistryResourceOptions,
PgRegistryResources,
PgRelation,
PgResource,
PgResourceExtensions,
PgResourceOptions,
Expand Down
Loading
Loading