alepha
Version:
Alepha is a convention-driven TypeScript framework for building robust, end-to-end type-safe applications, from serverless APIs to full-stack React apps.
1,487 lines (1,484 loc) • 56 kB
TypeScript
import * as _alepha_core13 from "alepha";
import * as _alepha_core1 from "alepha";
import * as _alepha_core2 from "alepha";
import * as _alepha_core0 from "alepha";
import { Alepha, AlephaError, Descriptor, KIND, Service, Static, TObject, TSchema as TSchema$1 } from "alepha";
import * as drizzle_orm0 from "drizzle-orm";
import * as drizzle_orm2 from "drizzle-orm";
import * as drizzle_orm9 from "drizzle-orm";
import * as drizzle from "drizzle-orm";
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
import * as pg$1 from "drizzle-orm/pg-core";
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
import * as drizzle_orm_pg_core4 from "drizzle-orm/pg-core";
import * as drizzle_orm_pg_core3 from "drizzle-orm/pg-core";
import { AnyPgColumn, AnyPgTable, LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, PgTransactionConfig, TableConfig as TableConfig$1, UpdateDeleteAction } from "drizzle-orm/pg-core";
import * as _alepha_lock0 from "alepha/lock";
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as _alepha_retry0 from "alepha/retry";
import * as _sinclair_typebox2 from "@sinclair/typebox";
import * as _sinclair_typebox9 from "@sinclair/typebox";
import * as _sinclair_typebox10 from "@sinclair/typebox";
import * as _sinclair_typebox11 from "@sinclair/typebox";
import * as _sinclair_typebox0 from "@sinclair/typebox";
import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TNumber, TObject as TObject$1, TOptional, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2, TString } from "@sinclair/typebox";
import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
import * as DrizzleKit from "drizzle-kit/api";
import { MigrationConfig } from "drizzle-orm/migrator";
import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
export * from "drizzle-orm/pg-core";
//#region src/constants/PG_SCHEMA.d.ts
declare const PG_SCHEMA: unique symbol;
//# sourceMappingURL=PG_SCHEMA.d.ts.map
//#endregion
//#region src/constants/PG_SYMBOLS.d.ts
declare const PG_DEFAULT: unique symbol;
declare const PG_PRIMARY_KEY: unique symbol;
declare const PG_CREATED_AT: unique symbol;
declare const PG_UPDATED_AT: unique symbol;
declare const PG_VERSION: unique symbol;
declare const PG_IDENTITY: unique symbol;
declare const PG_MANY: unique symbol;
declare const PG_ONE: unique symbol;
declare const PG_REF: unique symbol;
/**
* @deprecated Use `PG_IDENTITY` instead.
*/
declare const PG_SERIAL: unique symbol;
type PgDefault = typeof PG_DEFAULT;
type PgMany = typeof PG_MANY;
type PgRef = typeof PG_REF;
type PgPrimaryKey = typeof PG_PRIMARY_KEY;
type PgSymbols = {
[PG_DEFAULT]: {};
[PG_PRIMARY_KEY]: {};
[PG_CREATED_AT]: {};
[PG_UPDATED_AT]: {};
[PG_VERSION]: {};
[PG_IDENTITY]: PgIdentityOptions;
[PG_MANY]: PgManyOptions;
[PG_ONE]: PgManyOptions;
[PG_REF]: PgRefOptions;
/**
* @deprecated Use `PG_IDENTITY` instead.
*/
[PG_SERIAL]: {};
};
type PgSymbolKeys = keyof PgSymbols;
type PgIdentityOptions = {
mode: "always" | "byDefault";
} & PgSequenceOptions & {
name?: string;
};
interface PgManyOptions {
table: AnyPgTable;
schema: TObject$1;
foreignKey: string;
}
interface PgRefOptions {
ref: () => AnyPgColumn;
actions?: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
};
}
//# sourceMappingURL=PG_SYMBOLS.d.ts.map
//#endregion
//#region src/interfaces/TInsertObject.d.ts
/**
* Fork of the original typebox schema "TObject".
*/
interface TInsertObject<T extends TObject$1> extends TSchema$2, ObjectOptions {
[Kind]: "Object";
static: ObjectStatic<{ [K in keyof T["properties"] as T["properties"][K] extends {
[PG_DEFAULT]: any;
} ? never : K]: T["properties"][K] }, this["params"]>;
additionalProperties?: TAdditionalProperties;
type: "object";
required?: string[];
properties: { [K in keyof T["properties"] as T["properties"][K] extends {
[PG_DEFAULT]: any;
} ? never : K]: T["properties"][K] };
}
type ReadonlyOptionalPropertyKeys<T extends TProperties> = { [K in keyof T]: T[K] extends TReadonly<TSchema$2> ? T[K] extends TOptional<T[K]> ? K : never : never }[keyof T];
type ReadonlyPropertyKeys<T extends TProperties> = { [K in keyof T]: T[K] extends TReadonly<TSchema$2> ? T[K] extends TOptional<T[K]> ? never : K : never }[keyof T];
type OptionalPropertyKeys<T extends TProperties> = { [K in keyof T]: T[K] extends TOptional<TSchema$2> ? T[K] extends TReadonly<T[K]> ? never : K : never }[keyof T];
type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>>;
type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, { [K in keyof T]: Static$1<T[K], P> }>;
//#endregion
//#region src/helpers/schemaToPgColumns.d.ts
/**
* Convert a Typebox Schema to Drizzle ORM Postgres columns (yes)
*/
declare const schemaToPgColumns: <T extends TObject>(schema: T) => FromSchema<T>;
/**
* Map a Typebox field to a PG column.
*
* @param name The key of the field.
* @param value The value of the field.
* @returns The PG column.
*/
declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSerialBuilderInitial<string> | pg$1.PgIntegerBuilderInitial<string> | pg$1.PgBigInt53BuilderInitial<string> | pg$1.PgNumericBuilderInitial<string> | pg$1.PgTimestampBuilderInitial<string> | pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
name: string;
dataType: "custom";
columnType: "PgCustomColumn";
data: Buffer<ArrayBufferLike>;
driverParam: unknown;
enumValues: undefined;
}> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]> | pg$1.PgBooleanBuilderInitial<string> | drizzle_orm0.$Type<pg$1.PgCustomColumnBuilder<{
name: string;
dataType: "custom";
columnType: "PgCustomColumn";
data: {
[x: string]: unknown;
[x: number]: unknown;
};
driverParam: string;
enumValues: undefined;
}>, {
[x: string]: unknown;
[x: number]: unknown;
}> | drizzle_orm0.$Type<pg$1.PgCustomColumnBuilder<{
name: string;
dataType: "custom";
columnType: "PgCustomColumn";
data: {};
driverParam: string;
enumValues: undefined;
}>, {}> | drizzle_orm0.$Type<pg$1.PgCustomColumnBuilder<{
name: string;
dataType: "custom";
columnType: "PgCustomColumn";
data: unknown[];
driverParam: string;
enumValues: undefined;
}>, unknown[]> | pg$1.PgArrayBuilder<{
name: string;
dataType: "array";
columnType: "PgArray";
data: string[];
driverParam: string | string[];
enumValues: [string, ...string[]];
size: undefined;
baseBuilder: {
name: string;
dataType: "string";
columnType: "PgText";
data: string;
enumValues: [string, ...string[]];
driverParam: string;
};
}, {
name: string;
dataType: "string";
columnType: "PgText";
data: string;
enumValues: [string, ...string[]];
driverParam: string;
}> | pg$1.PgArrayBuilder<{
name: string;
dataType: "array";
columnType: "PgArray";
data: number[];
driverParam: string | (string | number)[];
enumValues: undefined;
size: undefined;
baseBuilder: {
name: string;
dataType: "number";
columnType: "PgInteger";
data: number;
driverParam: number | string;
enumValues: undefined;
};
}, {
name: string;
dataType: "number";
columnType: "PgInteger";
data: number;
driverParam: number | string;
enumValues: undefined;
}> | pg$1.PgArrayBuilder<{
name: string;
dataType: "array";
columnType: "PgArray";
data: string[];
driverParam: string | string[];
enumValues: undefined;
size: undefined;
baseBuilder: {
name: string;
dataType: "string";
columnType: "PgNumeric";
data: string;
driverParam: string;
enumValues: undefined;
};
}, {
name: string;
dataType: "string";
columnType: "PgNumeric";
data: string;
driverParam: string;
enumValues: undefined;
}> | pg$1.PgArrayBuilder<{
name: string;
dataType: "array";
columnType: "PgArray";
data: boolean[];
driverParam: string | boolean[];
enumValues: undefined;
size: undefined;
baseBuilder: {
name: string;
dataType: "boolean";
columnType: "PgBoolean";
data: boolean;
driverParam: boolean;
enumValues: undefined;
};
}, {
name: string;
dataType: "boolean";
columnType: "PgBoolean";
data: boolean;
driverParam: boolean;
enumValues: undefined;
}>;
/**
* Map a string to a PG column.
*
* @param key The key of the field.
* @param value The value of the field.
*/
declare const mapStringToColumn: (key: string, value: TSchema$1) => pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
name: string;
dataType: "custom";
columnType: "PgCustomColumn";
data: Buffer<ArrayBufferLike>;
driverParam: unknown;
enumValues: undefined;
}> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]>;
declare const camelToSnakeCase: (str: string) => string;
/**
* Convert a schema to columns.
*/
type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
/**
* A table with columns and schema.
*/
type PgTableWithColumnsAndSchema<T extends TableConfig, R extends TObject> = PgTableWithColumns<T> & {
get $table(): PgTableWithColumns<T>;
get $schema(): R;
get $insertSchema(): TInsertObject<R>;
};
interface TableLike<T extends TObject = TObject> {
$schema: T;
}
//# sourceMappingURL=schemaToPgColumns.d.ts.map
//#endregion
//#region src/descriptors/$entity.d.ts
/**
* Declare a new entity in the database.
* This descriptor alone does not create the table, it only describes it.
* It must be used with `$repository` to create the table and perform operations on it.
*
* This is a convenience function to create a table with a json schema.
* For now, it creates a drizzle-orm table under the hood.
* ```ts
* import { $entity } from "alepha/postgres";
*
* const User = $entity({
* name: "user",
* schema: t.object({
* id: pg.primaryKey(t.uuid()),
* name: t.string(),
* email: t.string(),
* }),
* indexes: ["email"],
* });
* ```
*
* @stability 2
*/
declare const $entity: {
<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>): PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
[KIND]: string;
};
interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
/**
* The name of the table. This is the name that will be used in the database.
* @example
* name: "user"
*/
name: TTableName;
/**
* The schema of the table. This is a TypeBox schema that describes the columns and their types.
* @example
* schema: t.object({
* id: t.uuid(),
* name: t.string(),
* email: t.string(),
* phoneNumber: t.string(),
* })
*/
schema: T;
/**
* The indexes to create for the table. This can be a string or an object with the column name and options.
* @example
* indexes: ["name", { column: "email", unique: true }]
*/
indexes?: (Keys | {
column: Keys;
unique?: boolean;
name?: string;
} | {
columns: Keys[];
unique?: boolean;
name?: string;
})[];
foreignKeys?: Array<{
name?: string;
columns: Array<keyof Static$1<T>>;
foreignColumns: Array<AnyPgColumn>;
}>;
constraints?: Array<{
columns: Array<keyof Static$1<T>>;
name?: string;
unique?: boolean | {};
check?: SQL;
}>;
/**
* Extra configuration for the table. See drizzle-orm documentation for more details.
*
* @param self The table descriptor.
* @returns The extra configuration for the table.
*/
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
}
type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
/**
* Create a table with a json schema.
*
* @param name The name of the table.
* @param schema The json schema of the table.
* @param extraConfig Extra configuration for the table.
*/
declare const pgTableSchema: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(name: TTableName, schema: TSchema, extraConfig?: (self: BuildExtraConfigColumns<TTableName, TColumnsMap, "pg">) => PgTableExtraConfigValue[]) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
name: TTableName;
schema: any;
columns: BuildColumns<TTableName, TColumnsMap, "pg">;
dialect: "pg";
};
//# sourceMappingURL=$entity.d.ts.map
//#endregion
//#region src/helpers/nullToUndefined.d.ts
/**
* Replaces all null values in an object with undefined.
* We need this for converting all nulls from Drizzle outputs.
*
* @param value - The object to be processed.
* @return A new object with all null values replaced with undefined.
*/
declare const nullToUndefined: <T extends object>(value: T) => NullToUndefined<T>;
/**
* Replaces all null values in an object with undefined.
*/
type NullToUndefined<T> = T extends null ? undefined : T extends null | undefined | string | number | boolean | symbol | bigint | Function | Date | RegExp ? T : T extends Array<infer U> ? Array<NullToUndefined<U>> : T extends Map<infer K, infer V> ? Map<K, NullToUndefined<V>> : T extends Set<infer U> ? Set<NullToUndefined<U>> : T extends object ? { [K in keyof T]: NullToUndefined<T[K]> } : unknown;
type NullifyIfOptional<T> = { [K in keyof T]: undefined extends T[K] ? T[K] | null : T[K] };
//# sourceMappingURL=nullToUndefined.d.ts.map
//#endregion
//#region src/interfaces/FilterOperators.d.ts
interface FilterOperators<TValue> {
/**
* Test that two values are equal.
*
* Remember that the SQL standard dictates that
* two NULL values are not equal, so if you want to test
* whether a value is null, you may want to use
* `isNull` instead.
*
* ## Examples
*
* ```ts
* // Select cars made by Ford
* db.select().from(cars)
* .where(eq(cars.make, 'Ford'))
* ```
*
* @see isNull for a way to test equality to NULL.
*/
eq?: TValue;
/**
* Test that two values are not equal.
*
* Remember that the SQL standard dictates that
* two NULL values are not equal, so if you want to test
* whether a value is not null, you may want to use
* `isNotNull` instead.
*
* ## Examples
*
* ```ts
* // Select cars not made by Ford
* db.select().from(cars)
* .where(ne(cars.make, 'Ford'))
* ```
*
* @see isNotNull for a way to test whether a value is not null.
*/
ne?: TValue;
/**
* Test that the first expression passed is greater than
* the second expression.
*
* ## Examples
*
* ```ts
* // Select cars made after 2000.
* db.select().from(cars)
* .where(gt(cars.year, 2000))
* ```
*
* @see gte for greater-than-or-equal
*/
gt?: TValue;
/**
* Test that the first expression passed is greater than
* or equal to the second expression. Use `gt` to
* test whether an expression is strictly greater
* than another.
*
* ## Examples
*
* ```ts
* // Select cars made on or after 2000.
* db.select().from(cars)
* .where(gte(cars.year, 2000))
* ```
*
* @see gt for a strictly greater-than condition
*/
gte?: TValue;
/**
* Test that the first expression passed is less than
* the second expression.
*
* ## Examples
*
* ```ts
* // Select cars made before 2000.
* db.select().from(cars)
* .where(lt(cars.year, 2000))
* ```
*
* @see lte for greater-than-or-equal
*/
lt?: TValue;
/**
* Test that the first expression passed is less than
* or equal to the second expression.
*
* ## Examples
*
* ```ts
* // Select cars made before 2000.
* db.select().from(cars)
* .where(lte(cars.year, 2000))
* ```
*
* @see lt for a strictly less-than condition
*/
lte?: TValue;
/**
* Test whether the first parameter, a column or expression,
* has a value from a list passed as the second argument.
*
* ## Throws
*
* The argument passed in the second array can't be empty:
* if an empty is provided, this method will throw.
*
* ## Examples
*
* ```ts
* // Select cars made by Ford or GM.
* db.select().from(cars)
* .where(inArray(cars.make, ['Ford', 'GM']))
* ```
*
* @see notInArray for the inverse of this test
*/
inArray?: TValue[];
/**
* Test whether the first parameter, a column or expression,
* has a value that is not present in a list passed as the
* second argument.
*
* ## Throws
*
* The argument passed in the second array can't be empty:
* if an empty is provided, this method will throw.
*
* ## Examples
*
* ```ts
* // Select cars made by any company except Ford or GM.
* db.select().from(cars)
* .where(notInArray(cars.make, ['Ford', 'GM']))
* ```
*
* @see inArray for the inverse of this test
*/
notInArray?: TValue[];
/**
* Test whether an expression is not NULL. By the SQL standard,
* NULL is neither equal nor not equal to itself, so
* it's recommended to use `isNull` and `notIsNull` for
* comparisons to NULL.
*
* ## Examples
*
* ```ts
* // Select cars that have been discontinued.
* db.select().from(cars)
* .where(isNotNull(cars.discontinuedAt))
* ```
*
* @see isNull for the inverse of this test
*/
isNotNull?: true;
/**
* Test whether an expression is NULL. By the SQL standard,
* NULL is neither equal nor not equal to itself, so
* it's recommended to use `isNull` and `notIsNull` for
* comparisons to NULL.
*
* ## Examples
*
* ```ts
* // Select cars that have no discontinuedAt date.
* db.select().from(cars)
* .where(isNull(cars.discontinuedAt))
* ```
*
* @see isNotNull for the inverse of this test
*/
isNull?: true;
/**
* Test whether an expression is between two values. This
* is an easier way to express range tests, which would be
* expressed mathematically as `x <= a <= y` but in SQL
* would have to be like `a >= x AND a <= y`.
*
* Between is inclusive of the endpoints: if `column`
* is equal to `min` or `max`, it will be TRUE.
*
* ## Examples
*
* ```ts
* // Select cars made between 1990 and 2000
* db.select().from(cars)
* .where(between(cars.year, 1990, 2000))
* ```
*
* @see notBetween for the inverse of this test
*/
between?: [number, number];
/**
* Test whether an expression is not between two values.
*
* This, like `between`, includes its endpoints, so if
* the `column` is equal to `min` or `max`, in this case
* it will evaluate to FALSE.
*
* ## Examples
*
* ```ts
* // Exclude cars made in the 1970s
* db.select().from(cars)
* .where(notBetween(cars.year, 1970, 1979))
* ```
*
* @see between for the inverse of this test
*/
notBetween?: [number, number];
/**
* Compare a column to a pattern, which can include `%` and `_`
* characters to match multiple variations. Including `%`
* in the pattern matches zero or more characters, and including
* `_` will match a single character.
*
* ## Examples
*
* ```ts
* // Select all cars with 'Turbo' in their names.
* db.select().from(cars)
* .where(like(cars.name, '%Turbo%'))
* ```
*
* @see ilike for a case-insensitive version of this condition
*/
like?: string;
/**
* The inverse of like - this tests that a given column
* does not match a pattern, which can include `%` and `_`
* characters to match multiple variations. Including `%`
* in the pattern matches zero or more characters, and including
* `_` will match a single character.
*
* ## Examples
*
* ```ts
* // Select all cars that don't have "ROver" in their name.
* db.select().from(cars)
* .where(notLike(cars.name, '%Rover%'))
* ```
*
* @see like for the inverse condition
* @see notIlike for a case-insensitive version of this condition
*/
notLike?: string;
/**
* Case-insensitively compare a column to a pattern,
* which can include `%` and `_`
* characters to match multiple variations. Including `%`
* in the pattern matches zero or more characters, and including
* `_` will match a single character.
*
* Unlike like, this performs a case-insensitive comparison.
*
* ## Examples
*
* ```ts
* // Select all cars with 'Turbo' in their names.
* db.select().from(cars)
* .where(ilike(cars.name, '%Turbo%'))
* ```
*
* @see like for a case-sensitive version of this condition
*/
ilike?: string;
/**
* The inverse of ilike - this case-insensitively tests that a given column
* does not match a pattern, which can include `%` and `_`
* characters to match multiple variations. Including `%`
* in the pattern matches zero or more characters, and including
* `_` will match a single character.
*
* ## Examples
*
* ```ts
* // Select all cars that don't have "Rover" in their name.
* db.select().from(cars)
* .where(notLike(cars.name, '%Rover%'))
* ```
*
* @see ilike for the inverse condition
* @see notLike for a case-sensitive version of this condition
*/
notIlike?: string;
/**
* Test that a column or expression contains all elements of
* the list passed as the second argument.
*
* ## Throws
*
* The argument passed in the second array can't be empty:
* if an empty is provided, this method will throw.
*
* ## Examples
*
* ```ts
* // Select posts where its tags contain "Typescript" and "ORM".
* db.select().from(posts)
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
* ```
*
* @see arrayContained to find if an array contains all elements of a column or expression
* @see arrayOverlaps to find if a column or expression contains any elements of an array
*/
arrayContains?: TValue;
/**
* Test that the list passed as the second argument contains
* all elements of a column or expression.
*
* ## Throws
*
* The argument passed in the second array can't be empty:
* if an empty is provided, this method will throw.
*
* ## Examples
*
* ```ts
* // Select posts where its tags contain "Typescript", "ORM" or both,
* // but filtering posts that have additional tags.
* db.select().from(posts)
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
* ```
*
* @see arrayContains to find if a column or expression contains all elements of an array
* @see arrayOverlaps to find if a column or expression contains any elements of an array
*/
arrayContained?: TValue;
/**
* Test that a column or expression contains any elements of
* the list passed as the second argument.
*
* ## Throws
*
* The argument passed in the second array can't be empty:
* if an empty is provided, this method will throw.
*
* ## Examples
*
* ```ts
* // Select posts where its tags contain "Typescript", "ORM" or both.
* db.select().from(posts)
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
* ```
*
* @see arrayContains to find if a column or expression contains all elements of an array
* @see arrayContained to find if an array contains all elements of a column or expression
*/
arrayOverlaps?: TValue;
}
//# sourceMappingURL=FilterOperators.d.ts.map
//#endregion
//#region src/interfaces/InferInsert.d.ts
/**
* Enhance Typebox with a support of "Default" (PG_DEFAULT).
*/
type InferInsert<T extends TObject$1> = StaticEntry<T> & StaticDefaultEntry<T>;
type StaticDefaultEntry<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
[PG_DEFAULT]: any;
} | {
[OptionalKind]: "Optional";
} ? K : never]?: Static$1<T["properties"][K]> };
type StaticEntry<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
[PG_DEFAULT]: any;
} | {
[OptionalKind]: "Optional";
} ? never : K]: Static$1<T["properties"][K]> };
//# sourceMappingURL=InferInsert.d.ts.map
//#endregion
//#region src/interfaces/PgQueryWhere.d.ts
type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key]> } & {
/**
* Combine a list of conditions with the `and` operator. Conditions
* that are equal `undefined` are automatically ignored.
*
* ## Examples
*
* ```ts
* db.select().from(cars)
* .where(
* and(
* eq(cars.make, 'Volvo'),
* eq(cars.year, 1950),
* )
* )
* ```
*/
and?: Array<PgQueryWhere<T> | SQL>;
/**
* Combine a list of conditions with the `or` operator. Conditions
* that are equal `undefined` are automatically ignored.
*
* ## Examples
*
* ```ts
* db.select().from(cars)
* .where(
* or(
* eq(cars.make, 'GM'),
* eq(cars.make, 'Ford'),
* )
* )
* ```
*/
or?: Array<PgQueryWhere<T> | SQL>;
/**
* Negate the meaning of an expression using the `not` keyword.
*
* ## Examples
*
* ```ts
* // Select cars _not_ made by GM or Ford.
* db.select().from(cars)
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
* ```
*/
not?: PgQueryWhere<T>;
/**
* Test whether a subquery evaluates to have any rows.
*
* ## Examples
*
* ```ts
* // Users whose `homeCity` column has a match in a cities
* // table.
* db
* .select()
* .from(users)
* .where(
* exists(db.select()
* .from(cities)
* .where(eq(users.homeCity, cities.id))),
* );
* ```
*
* @see notExists for the inverse of this test
*/
exists?: SQLWrapper;
};
//# sourceMappingURL=PgQueryWhere.d.ts.map
//#endregion
//#region src/interfaces/PgQuery.d.ts
interface PgQuery<T extends TObject$1, Select extends (keyof Static$1<T>)[] = []> {
columns?: Select;
distinct?: boolean;
where?: PgQueryWhereWithMany<T> | SQLWrapper;
limit?: number;
offset?: number;
sort?: { [key in keyof Static$1<T>]?: "asc" | "desc" };
groupBy?: (keyof Static$1<T>)[];
relations?: PgQueryWithMap<T>;
}
type PgQueryResult<T extends TObject$1, Select extends (keyof Static$1<T>)[]> = TPick<T, Select>;
type PgQueryWhereWithMany<T extends TObject$1> = PgQueryWhere<Static$1<RemoveManyRelations<T>>> & ExtractManyRelations<T>;
type ExtractManyRelations<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
[PG_MANY]: any;
} ? T["properties"][K] extends TArray ? T["properties"][K]["items"] extends TObject$1 ? K : never : never : never]?: PgQueryWhere<Static$1<T["properties"][K]["items"]>> };
type RemoveManyRelations<T extends TObject$1> = TObject$1<{ [K in keyof T["properties"] as T["properties"][K] extends {
[PG_MANY]: any;
} ? never : K]: T["properties"][K] }>;
type PgQueryWithMap<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
[PG_MANY]: any;
} ? K : never]?: T["properties"][K] extends TObject$1 ? PgQueryWith<T["properties"][K]> : T["properties"][K] extends TArray ? PgQueryWith<T["properties"][K]> : never };
type PgQueryWith<T extends TObject$1 | TArray> = true | {
relations?: {
[key: string]: PgQueryWith<T>;
};
};
//# sourceMappingURL=PgQuery.d.ts.map
//#endregion
//#region src/providers/drivers/PostgresProvider.d.ts
type SQLLike = SQLWrapper | string;
declare abstract class PostgresProvider {
protected readonly alepha: Alepha;
abstract get db(): PgDatabase<any>;
abstract get schema(): string;
abstract get dialect(): string;
abstract execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static$1<T> : any>>;
}
//# sourceMappingURL=PostgresProvider.d.ts.map
//#endregion
//#region src/schemas/pageQuerySchema.d.ts
declare const pageQuerySchema: _sinclair_typebox2.TObject<{
page: _sinclair_typebox2.TOptional<_sinclair_typebox2.TNumber>;
size: _sinclair_typebox2.TOptional<_sinclair_typebox2.TNumber>;
sort: _sinclair_typebox2.TOptional<_sinclair_typebox2.TString>;
}>;
type PageQuery = Static<typeof pageQuerySchema>;
//# sourceMappingURL=pageQuerySchema.d.ts.map
//#endregion
//#region src/schemas/pageSchema.d.ts
/**
* Page Schema
*
* @param objectSchema
* @param options
*/
declare const pageSchema: <T extends TObject$1 | TIntersect | TRecord>(objectSchema: T, options?: ObjectOptions) => TPage<T>;
type TPage<T extends TObject$1 | TIntersect | TRecord> = TObject$1<{
content: TArray<T>;
can: TObject$1<{
next: TBoolean;
previous: TBoolean;
}>;
page: TObject$1<{
number: TInteger;
size: TInteger;
totalElements: TOptionalWithFlag<TInteger, true>;
queryDuration: TOptionalWithFlag<TInteger, true>;
countDuration: TOptionalWithFlag<TInteger, true>;
}>;
}>;
type Page<T> = {
content: T[];
can: {
next: boolean;
previous: boolean;
};
page: {
number: number;
size: number;
totalElements?: number;
queryDuration?: number;
countDuration?: number;
};
};
//# sourceMappingURL=pageSchema.d.ts.map
//#endregion
//#region src/descriptors/$repository.d.ts
/**
* @stability 3
*/
declare const $repository: {
<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1>(optionsOrTable: RepositoryDescriptorOptions<EntityTableConfig, EntitySchema> | PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>): RepositoryDescriptor<EntityTableConfig, EntitySchema>;
[KIND]: typeof RepositoryDescriptor;
};
interface RepositoryDescriptorOptions<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> {
/**
* The table to create the repository for.
*/
table: PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>;
/**
* Override default provider.
*/
provider?: Service<PostgresProvider>;
}
declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> extends Descriptor<RepositoryDescriptorOptions<EntityTableConfig, EntitySchema>> {
readonly provider: PostgresProvider;
protected readonly alepha: Alepha;
readonly schema: EntitySchema;
readonly insertSchema: TInsertObject<EntitySchema>;
protected readonly env: {
POSTGRES_PAGINATION_COUNT_ENABLED: boolean;
};
/**
* Represents the primary key of the table.
* - Key is the name of the primary key column.
* - Type is the type (TypeBox) of the primary key column.
*
* ID is mandatory. If the table does not have a primary key, it will throw an error.
*/
readonly id: {
type: TSchema$2;
key: keyof EntitySchema["properties"];
col: PgColumn;
};
/**
* Get Drizzle table object.
*/
get table(): PgTableWithColumns<EntityTableConfig>;
/**
* Get SQL table name. (from Drizzle table object)
*/
get tableName(): string;
/**
* Getter for the database connection from the database provider.
*/
protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm2.ExtractTablesWithRelations<Record<string, never>>>;
protected organization(): PgColumn;
/**
* Execute a SQL query.
*
* @param query
* @param schema
*/
execute<T extends TObject$1 = EntitySchema>(query: SQLLike | ((table: PgTableWithColumns<EntityTableConfig>, db: PgDatabase<any>) => SQLLike), schema?: T): Promise<Static$1<T>[]>;
/**
* Get a Drizzle column from the table by his name.
*
* @param name - The name of the column to get.
* @returns The column from the table.
*/
protected col(name: keyof PgTableWithColumns<EntityTableConfig>["_"]["columns"]): PgColumn;
/**
* Run a transaction.
*
* @param transaction
* @param config
*/
transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
/**
* Start a SELECT query on the table.
*
* @returns The SELECT query builder.
*/
protected select(opts?: StatementOptions): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, PgColumn<drizzle_orm2.ColumnBaseConfig<drizzle_orm2.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
[x: string]: unknown;
}[], {
[x: string]: PgColumn<drizzle_orm2.ColumnBaseConfig<drizzle_orm2.ColumnDataType, string>, {}, {}>;
}>;
/**
* Start an INSERT query on the table.
*
* @returns The INSERT query builder.
*/
protected insert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<EntityTableConfig>, any, false>;
/**
* Start an UPDATE query on the table.
*
* @returns The UPDATE query builder.
*/
protected update(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<EntityTableConfig>, any>;
/**
* Start a DELETE query on the table.
*
* @returns The DELETE query builder.
*/
protected delete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<EntityTableConfig>, any, undefined, undefined, false, never>;
/**
* Find entities.
*
* @param query The find query.
* @param opts The statement options.
* @returns The found entities.
*/
find<Select extends (keyof Static$1<EntitySchema>)[]>(query?: PgQuery<EntitySchema, Select>, opts?: StatementOptions): Promise<Static$1<PgQueryResult<EntitySchema, Select>>[]>;
/**
* Find a single entity.
*
* @param where The where clause.
* @param opts The statement options.
* @returns The found entity.
*/
findOne<T extends Static$1<EntitySchema> = Static$1<EntitySchema>>(where: PgQueryWhere<T>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
/**
* Find an entity by ID.
*
* @param id
* @param opts
*/
findById(id: string | number, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
/**
* Paginate entities.
*
* @param pageQuery The pagination query.
* @param findQuery The find query.
* @param opts The statement options.
* @returns The paginated entities.
*/
paginate(pageQuery?: PageQuery, findQuery?: PgQuery<EntitySchema>, opts?: StatementOptions): Promise<Page<Static$1<EntitySchema>>>;
createQuery(query?: PgQuery<EntitySchema>): PgQuery<EntitySchema>;
createQueryWhere(where?: PgQueryWhere<Static$1<EntitySchema>>): PgQueryWhere<Static$1<EntitySchema>>;
/**
* Create an entity.
*
* @param data The entity to create.
* @param opts The options for creating the entity.
* @returns The ID of the created entity.
*/
create(data: InferInsert<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
/**
* Create many entities.
*
* @param values The entities to create.
* @param opts The statement options.
* @returns The created entities.
*/
createMany(values: Array<InferInsert<EntitySchema>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>[]>;
/**
* Update an entity.
*
* @param query The where clause.
* @param data The data to update.
* @param opts The statement options.
* @returns The updated entity.
*/
updateOne(query: PgQueryWhere<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>> | {
$append: Partial<NullifyIfOptional<Static$1<EntitySchema>>>;
}, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
save(data: Static$1<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
/**
* Update an entity by ID.
*
* @param id
* @param data
* @param opts
*/
updateById(id: string | number, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
/**
* Update entities.
*
* @param where The where clause.
* @param data The data to update.
* @param opts The statement options.
* @returns The updated entities.
*/
updateMany(where: PgQueryWhere<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>[]>;
/**
* Delete entities.
*
* @param where Query.
* @param opts The statement options.
*/
deleteMany(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<void>;
/**
* Delete all entities.
* @param opts
*/
clear(opts?: StatementOptions): Promise<void>;
/**
* Delete an entity by ID.
*
* @param id
* @param opts
*/
deleteById(id: string | number, opts?: StatementOptions): Promise<void>;
/**
* Count entities.
*
* @param where The where clause.
* @param opts The statement options.
* @returns The count of entities.
*/
count(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<number>;
/**
* Convert a query object to a SQL query.
*
* @param query The query object.
* @param schema The schema to use.
* @param col The column to use.
*/
protected jsonQueryToSql(query: PgQueryWhere<Static$1<EntitySchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
/**
* Map a filter operator to a SQL query.
*
* @param operator
* @param column
* @protected
*/
protected mapOperatorToSql(operator: FilterOperators<any>, column: PgColumn): SQL | undefined;
/**
* Create a pagination object.
*
* @param entities The entities to paginate.
* @param limit The limit of the pagination.
* @param offset The offset of the pagination.
*/
protected createPagination(entities: Static$1<EntitySchema>[], limit?: number, offset?: number): Page<Static$1<EntitySchema>>;
/**
* Convert something to valid Pg Insert Value.
*/
protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<EntityTableConfig>>;
/**
* Clean a row. Remove all null values.
*
* @param row The row to clean.
* @param schema The schema to use.
* @returns The cleaned row.
*/
protected clean<T extends TObject$1 = EntitySchema>(row: any, schema?: T): Static$1<T>;
/**
* Get the where clause for an ID.
*
* @param id The ID to get the where clause for.
* @returns The where clause for the ID.
*/
protected getWhereId(id: string | number): PgQueryWhere<Static$1<EntitySchema>>;
/**
* Find a primary key in the schema.
*
* @param schema
* @protected
*/
protected getPrimaryKey(schema: TObject$1): {
key: string;
col: PgColumn<drizzle_orm2.ColumnBaseConfig<drizzle_orm2.ColumnDataType, string>, {}, {}>;
type: TSchema$2;
};
}
/**
* The options for a statement.
*/
interface StatementOptions {
/**
* Transaction to use.
*/
tx?: PgTransaction<any, Record<string, any>>;
/**
* Lock strength.
*/
for?: LockStrength | {
config: LockConfig;
strength: LockStrength;
};
/**
* Organization ID.
*
* Multi-tenant support.
*
* If set, it will be used to filter the results by organization.
*/
organization?: string;
}
interface PgAttrField {
key: string;
type: TSchema$2;
data: any;
nested?: any[];
}
//# sourceMappingURL=$repository.d.ts.map
//#endregion
//#region src/descriptors/$sequence.d.ts
/**
* @stability 1
*/
declare const $sequence: {
(options?: SequenceDescriptorOptions): SequenceDescriptor;
[KIND]: typeof SequenceDescriptor;
};
interface SequenceDescriptorOptions {
name?: string;
start?: number;
increment?: number;
min?: number;
max?: number;
cycle?: boolean;
}
declare class SequenceDescriptor extends Descriptor<SequenceDescriptorOptions> {
protected readonly provider: PostgresProvider;
protected created: boolean;
get name(): string;
protected create(): Promise<void>;
next(): Promise<number>;
current(): Promise<number>;
}
//# sourceMappingURL=$sequence.d.ts.map
//#endregion
//#region src/descriptors/$transaction.d.ts
/**
* @stability 2
*/
declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry0.RetryDescriptorFn<(...args: T) => Promise<R>>;
interface TransactionDescriptorOptions<T extends any[], R> {
handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
config?: PgTransactionConfig$1;
}
type TransactionContext = PgTransaction<any, any, any>;
//# sourceMappingURL=$transaction.d.ts.map
//#endregion
//#region src/errors/PgEntityNotFoundError.d.ts
declare class PgEntityNotFoundError extends AlephaError {
readonly name = "EntityNotFoundError";
readonly status = 404;
constructor(entityName: string);
}
//# sourceMappingURL=PgEntityNotFoundError.d.ts.map
//#endregion
//#region src/providers/RepositoryDescriptorProvider.d.ts
declare class RepositoryDescriptorProvider {
protected readonly log: _alepha_core13.Logger;
protected readonly alepha: Alepha;
get repositories(): RepositoryDescriptor<TableConfig$1, TObject$1>[];
constructor();
clearRepositories(): Promise<void>;
/**
* Get all repositories.
*
* @param provider - Filter by provider.
*/
getRepositories(provider?: PostgresProvider): RepositoryDescriptor<TableConfig$1, TObject$1>[];
/**
* Get all tables from the repositories.
*
* @param provider
*/
getTables(provider?: PostgresProvider): drizzle_orm_pg_core4.PgTableWithColumns<TableConfig$1>[];
/**
* Get all providers from the repositories.
*/
getProviders(): PostgresProvider[];
}
//# sourceMappingURL=RepositoryDescriptorProvider.d.ts.map
//#endregion
//#region src/providers/DrizzleKitProvider.d.ts
declare class DrizzleKitProvider {
protected readonly log: _alepha_core1.Logger;
protected readonly alepha: Alepha;
protected readonly repositoryProvider: RepositoryDescriptorProvider;
push(provider: PostgresProvider, schema?: string): Promise<void>;
setPgSchema(provider: PostgresProvider): Promise<void>;
/**
* Try to generate migrations from scratch based on the models.
* Then, execute the migrations.
*
* This is useful for testing or development purposes.
*
* Do not use in production.
*
* @param provider - The Postgres provider to use.
* @param schema - The schema to use.
* @returns A promise that resolves once the migrations have been executed.
*/
synchronize(provider: PostgresProvider, schema?: string): Promise<void>;
synchronizeSqlite(provider: PostgresProvider): Promise<void>;
protected getTables(provider: PostgresProvider, schema?: string): Promise<Record<string, any>>;
protected loadMigrationSnapshot(provider: PostgresProvider): Promise<any>;
protected saveMigrationSnapshot(provider: PostgresProvider, curr: Record<string, any>, entry?: {
id: number;
snapshot: string;
}): Promise<void>;
protected executeStatements(statements: string[], provider: PostgresProvider, _schema?: string, catchErrors?: boolean): Promise<void>;
protected prepareSchema(schemaName: string, provider: PostgresProvider, repositories: any[]): Promise<void>;
/**
* Try to load the official Drizzle Kit API.
* If not available, fallback to the local kit import.
*/
protected importDrizzleKit(): Promise<typeof DrizzleKit>;
}
//# sourceMappingURL=DrizzleKitProvider.d.ts.map
//#endregion
//#region src/providers/drivers/NodePostgresProvider.d.ts
declare module "alepha" {
interface Env extends Partial<Static<typeof envSchema>> {}
}
declare const envSchema: TObject$1<{
/**
* Main configuration for database connection.
* Accept a string in the format of a Postgres connection URL.
* Example: postgres://user:password@localhost:5432/database
* or
* Example: postgres://user:password@localhost:5432/database?sslmode=require
*/
DATABASE_URL: _alepha_core2.TOptional<_alepha_core2.TString>;
/**
* In addition to the DATABASE_URL, you can specify the postgres schema name.
*
* It will monkey patch drizzle tables.
*/
POSTGRES_SCHEMA: _alepha_core2.TOptional<_alepha_core2.TString>;
/**
* Synchronize the database schema with the models.
* It uses a custom implementation, it's not related to `drizzle-kit push` command.
* It will generate the migration script and save it to the DB.
*
* This is recommended for development and testing purposes only.
*
* @default false
*/
POSTGRES_SYNCHRONIZE: _alepha_core2.TOptional<_alepha_core2.TBoolean>;
/**
* Push the schema to the database.
* It's like `drizzle-kit push` command.
* It will introspect the models from DB and generate the SQL statements to create or update the tables.
*
* @default false
*/
POSTGRES_PUSH: _alepha_core2.TOptional<_alepha_core2.TBoolean>;
}>;
interface NodePostgresProviderOptions {
migrations: MigrationConfig;
connection: postgres.Options<any>;
}
declare class NodePostgresProvider extends PostgresProvider {
readonly dialect = "postgres";
protected readonly sslModes: readonly ["require", "allow", "prefer", "verify-full"];
protected readonly log: _alepha_core2.Logger;
protected readonly env: {
DATABASE_URL?: string | undefined;
POSTGRES_SCHEMA?: string | undefined;
POSTGRES_SYNCHRONIZE?: boolean | undefined;
POSTGRES_PUSH?: boolean | undefined;
};
protected readonly alepha: Alepha;
protected readonly kit: DrizzleKitProvider;
protected client?: postgres.Sql;
protected pg?: PostgresJsDatabase;
readonly options: NodePostgresProviderOptions;
/**
* In testing mode, the schema name will be generated and deleted after the test.
*/
protected schemaForTesting?: string;
/**
* Get Postgres schema.
*/
get schema(): string;
get db(): PostgresJsDatabase;
protected readonly configure: _alepha_core2.HookDescriptor<"start">;
protected readonly stop: _alepha_core2.HookDescriptor<"stop">;
execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
connect(): Promise<void>;
close(): Promise<void>;
protected migrate: _alepha_lock0.LockDescriptor<() => Promise<void>>;
protected createClient(): {
client: postgres.Sql<{}>;
db: PostgresJsDatabase<Record<string, never>> & {
$client: postgres.Sql<{}>;
};
};
/**
* Generate a minimal migration configuration.
*/
protected getMigrationOptions(): MigrationConfig;
/**
* Map the DATABASE_URL to postgres client options.
*/
protected getClientOptions(): postgres.Options<any>;
protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
/**
* For testing purposes, generate a unique schema name.
* The schema name will be generated based on the current date and time.
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
*
* TODO: investigate for adding the test file name to the schema name if possible.
* TODO: options to skip deletion on failure, in order to inspect the schema?
*/
protected generateTestSchemaName(): string;
protected mapResult<T extends TObject$1 = any>(result: Array<any>, schema?: T): Array<T extends TObject$1 ? Static<T> : any>;
}
//#endregion
//#region src/helpers/pgAttr.d.ts
/**
* Type representation.
*/
type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
//#endregion
//#region src/schemas/createdAtSchema.d.ts
declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox9.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
//# sourceMappingURL=createdAtSchema.d.ts.map
//#endregion
//#region src/schemas/legacyIdSchema.d.ts
/**
* @deprecated Use `pg.primaryKey()` instead.
*/
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox10.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
//# sourceMappingURL=legacyIdSchema.d.ts.map
//#endregion
//#region src/schemas/updatedAtSchema.d.ts
declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox11.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
//# sourceMappingURL=updatedAtSchema.d.ts.map
//#endregion
//#region src/schemas/entitySchema.d.ts
/**
* Entity Schema.
*
* Add some common SQL properties to an object.
*/
declare const entitySchema: TObject$1<{
id: PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
createdAt: PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
updatedAt: PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
}>;
/**
* TypeBox Entity Type.
*/
type TEntity<T extends TProperties> = TObject$1<T & {
id: typeof legacyIdSchema;
createdAt: typeof createdAtSchema;
updatedAt: typeof updatedAtSchema;
}>;
/**
* The base entity.
*/
type BaseEntity = Static<typeof entitySchema>;
/**
* The keys of the base entity.
*/
type BaseEntityKeys = keyof BaseEntity;
/**
* The keys of the base entity.
*/
declare const entityKeys: readonly ["id", "createdAt", "updatedAt"];
//# sourceMappingURL=entitySchema.d.ts.map
//#endregion
//#region src/providers/PostgresTypeProvider.d.ts
declare module "alepha" {
int