Skip to content

Commit

Permalink
docs: cleanup outdated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aniravi24 committed Sep 28, 2024
1 parent 0ff177f commit 851bf13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/typefusion/src/db/mysql/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO
import { MysqlClient } from "@effect/sql-mysql2";
import { Config, Effect, Layer, Redacted } from "effect";
import { MySqlDatabaseHelperContext } from "../common/layer.js";
Expand Down
18 changes: 6 additions & 12 deletions packages/typefusion/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { MySqlType } from "./db/mysql/types.js";
import { DbType } from "./db/common/types.js";
import { DatabaseHelper } from "./db/common/service.js";

// TODO this file needs to be generalized so we can support other databases

// For some reason when we dynamically import the PgType when executing scripts, somePgType instanceof PgType is false
const PgTypeSchema = Schema.declare(<T>(input: unknown): input is PgType<T> => {
if (typeof input === "object" && input !== null) {
Expand All @@ -28,10 +26,7 @@ const MySqlTypeSchema = Schema.declare(

const ScriptExportSchema = Schema.Struct({
name: Schema.String,
resultDatabase: Schema.Union(
Schema.Literal("postgresql"),
Schema.Literal("mysql"),
),
resultDatabase: Schema.Literal("postgresql", "mysql"),
schema: Schema.Union(
Schema.Record({
key: Schema.String,
Expand All @@ -57,7 +52,7 @@ const ScriptResultSchema = Schema.Array(
);

/**
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains only the 'data' field.
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains the data without any schema.
*/
export interface TypefusionResultDataOnly<
DataElement extends Record<string, unknown>,
Expand All @@ -69,7 +64,7 @@ export interface TypefusionResultDataOnly<
}

/**
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains both the 'types' and 'data' fields
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains both the 'schema' and return data
* you want to use your existing {@link PgType} or {@link MySqlType} schema.
*/
export interface TypefusionDbResult<T extends Record<string, DbType<unknown>>>
Expand All @@ -83,7 +78,7 @@ export interface TypefusionDbResult<T extends Record<string, DbType<unknown>>>
}

/**
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains both the 'types' and 'data' fields
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains both the 'schema' and return data
* you want to use your existing {@link PgType} or {@link MySqlType} schema.
* However, the data is unknown, so you can pass in any data array and it will type check.
*/
Expand All @@ -94,7 +89,7 @@ export interface TypefusionDbResultDataUnknown<
run: () => PromiseLike<Record<any, any>[]>;
}
/**
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains both the 'types' and 'data' fields.
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains both the 'schema' and return data.
* This will check that your `pgType` schema matches the data you are returning, but it's more verbose than using {@link TypefusionDbResult}.
*/

Expand All @@ -107,7 +102,7 @@ export interface TypefusionResult<DataElement extends Record<string, unknown>>
}

/**
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains potentially only the 'data' field.
* The return type of a Typefusion script ({@link TypefusionScriptExport}) when the result contains potentially only the return data.
* However, the data is unknown, so you can pass in any data array and it will type check.
*/
export interface TypefusionResultUnknown
Expand All @@ -120,7 +115,6 @@ export class ConvertDataToSQLDDLError extends Data.TaggedError(
message: string;
}> {}

// TODO support multiple casings? (camelCase, snake_case)
const convertTypefusionScriptResultToSQLDDL = (
module: TypefusionScriptExport,
result: Schema.Schema.Type<typeof ScriptResultSchema>,
Expand Down

0 comments on commit 851bf13

Please sign in to comment.