@shyk/kadak 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/index.cjs +548 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +373 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +373 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +516 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import postgres from "postgres";
|
|
3
|
+
|
|
4
|
+
//#region src/schema.d.ts
|
|
5
|
+
/** Converts camelCase to snake_case for PostgreSQL column naming */
|
|
6
|
+
declare function camelToSnake(str: string): string;
|
|
7
|
+
/** Flattens intersection types so IDE tooltips show clean objects, not A & B */
|
|
8
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
9
|
+
/** @internal Runtime metadata describing a column's PG type, constraints, behavior */
|
|
10
|
+
interface ColumnConfig {
|
|
11
|
+
pgType: string;
|
|
12
|
+
nullable: boolean;
|
|
13
|
+
hasDefault: boolean;
|
|
14
|
+
isPrimaryKey: boolean;
|
|
15
|
+
isUnique: boolean;
|
|
16
|
+
defaultValue?: unknown;
|
|
17
|
+
/** SQL expression for default — 'now()' or 'gen_random_uuid()' */
|
|
18
|
+
defaultSql?: string;
|
|
19
|
+
/** DB auto-generates this value (IDENTITY columns) */
|
|
20
|
+
isGenerated: boolean;
|
|
21
|
+
/** Zod validation hint — 'email', 'uuid' */
|
|
22
|
+
zodCheck?: string;
|
|
23
|
+
/** Stored Zod schema — only for JSONB columns */
|
|
24
|
+
zodSchema?: z.ZodType;
|
|
25
|
+
/** Auto-update on every UPDATE — for updatedAt patterns */
|
|
26
|
+
autoUpdate: boolean;
|
|
27
|
+
/** Soft delete marker — findMany auto-filters, delete sets timestamp */
|
|
28
|
+
softDelete: boolean;
|
|
29
|
+
min?: number;
|
|
30
|
+
max?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A column definition carrying runtime metadata AND compile-time types.
|
|
34
|
+
*
|
|
35
|
+
* Three generics flow through the entire ORM:
|
|
36
|
+
* - TType: JS type (string, number, boolean, Date)
|
|
37
|
+
* - TNullable: whether NULL is allowed (adds `| null`)
|
|
38
|
+
* - THasDefault: whether INSERT can omit this (adds `?`)
|
|
39
|
+
*
|
|
40
|
+
* Every modifier returns a NEW Column — immutable builder.
|
|
41
|
+
*/
|
|
42
|
+
declare class Column<TType, TNullable extends boolean = false, THasDefault extends boolean = false> {
|
|
43
|
+
readonly _config: ColumnConfig;
|
|
44
|
+
readonly _type: TType;
|
|
45
|
+
readonly _nullable: TNullable;
|
|
46
|
+
readonly _hasDefault: THasDefault;
|
|
47
|
+
constructor(config: ColumnConfig);
|
|
48
|
+
/** NOT NULL — already the default. Exists for explicit readability. */
|
|
49
|
+
required(): Column<TType, false, THasDefault>;
|
|
50
|
+
/** Allow NULL — column type becomes TType | null in TypeScript */
|
|
51
|
+
optional(): Column<TType, true, THasDefault>;
|
|
52
|
+
/** Add UNIQUE constraint */
|
|
53
|
+
unique(): Column<TType, TNullable, THasDefault>;
|
|
54
|
+
/** Mark as PRIMARY KEY */
|
|
55
|
+
primaryKey(): Column<TType, TNullable, THasDefault>;
|
|
56
|
+
/**
|
|
57
|
+
* Set default value — makes field optional in INSERT.
|
|
58
|
+
*
|
|
59
|
+
* Named shortcuts are resolved per column type to avoid ambiguity:
|
|
60
|
+
* - 'now' on TIMESTAMPTZ → SQL DEFAULT now()
|
|
61
|
+
* - 'uuid' on UUID → SQL DEFAULT gen_random_uuid()
|
|
62
|
+
* On other types, these strings are treated as literal values.
|
|
63
|
+
*/
|
|
64
|
+
default(value: TType extends Date ? TType | 'now' : TType): Column<TType, TNullable, true>;
|
|
65
|
+
/** Min constraint — string length for text, numeric value for numbers */
|
|
66
|
+
min(n: number): Column<TType, TNullable, THasDefault>;
|
|
67
|
+
/** Max constraint — string length for text, numeric value for numbers */
|
|
68
|
+
max(n: number): Column<TType, TNullable, THasDefault>;
|
|
69
|
+
/** Auto-update on every UPDATE query — designed for updatedAt columns */
|
|
70
|
+
autoUpdate(): Column<TType, TNullable, true>;
|
|
71
|
+
/**
|
|
72
|
+
* Soft delete marker. When set on a column:
|
|
73
|
+
* - findMany() auto-adds WHERE column IS NULL
|
|
74
|
+
* - delete() sets this column to now() instead of DELETE
|
|
75
|
+
* - findMany({ withDeleted: true }) bypasses the filter
|
|
76
|
+
*/
|
|
77
|
+
softDelete(): Column<TType, true, true>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Column factory namespace. Every column definition starts here.
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* const users = table('users', {
|
|
84
|
+
* id: kadak.id(),
|
|
85
|
+
* name: kadak.text().required(),
|
|
86
|
+
* email: kadak.email().unique(),
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare const kadak: {
|
|
91
|
+
/**
|
|
92
|
+
* Modern auto-incrementing integer primary key.
|
|
93
|
+
* Uses IDENTITY (not deprecated SERIAL).
|
|
94
|
+
* DDL: INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY
|
|
95
|
+
*/
|
|
96
|
+
readonly id: () => Column<number, false, true>;
|
|
97
|
+
/**
|
|
98
|
+
* UUID primary key with auto-generation via gen_random_uuid().
|
|
99
|
+
* Built into PostgreSQL 13+ — no extensions needed.
|
|
100
|
+
* Ideal for distributed systems and secure-by-default IDs.
|
|
101
|
+
*/
|
|
102
|
+
readonly uuidId: () => Column<string, false, true>;
|
|
103
|
+
/**
|
|
104
|
+
* Legacy SERIAL primary key — use kadak.id() for new projects.
|
|
105
|
+
* Kept for compatibility with existing schemas.
|
|
106
|
+
*/
|
|
107
|
+
readonly serialId: () => Column<number, false, true>; /** Unlimited-length text. Use .min()/.max() for Zod length validation. */
|
|
108
|
+
readonly text: () => Column<string, false, false>; /** 4-byte integer. For whole numbers — counts, ages, quantities. */
|
|
109
|
+
readonly int: () => Column<number, false, false>;
|
|
110
|
+
/**
|
|
111
|
+
* Alias for kadak.int(). Maps to INTEGER.
|
|
112
|
+
* ⚠️ This is NOT floating point — 9.99 becomes 9 in the database.
|
|
113
|
+
* Use kadak.float() for decimals or kadak.decimal() for money.
|
|
114
|
+
*/
|
|
115
|
+
readonly number: () => Column<number, false, false>;
|
|
116
|
+
/**
|
|
117
|
+
* 8-byte floating point (DOUBLE PRECISION).
|
|
118
|
+
* For scientific data, coordinates, measurements.
|
|
119
|
+
* ⚠️ NEVER use for money — use kadak.decimal() instead.
|
|
120
|
+
*/
|
|
121
|
+
readonly float: () => Column<number, false, false>;
|
|
122
|
+
/**
|
|
123
|
+
* Arbitrary precision decimal (NUMERIC).
|
|
124
|
+
* Returns STRING in TypeScript — intentional to preserve precision.
|
|
125
|
+
* JS floats lose precision: 0.1 + 0.2 !== 0.3
|
|
126
|
+
* ✅ Use for: money, prices, financial math
|
|
127
|
+
*/
|
|
128
|
+
readonly decimal: () => Column<string, false, false>; /** Boolean true/false */
|
|
129
|
+
readonly boolean: () => Column<boolean, false, false>;
|
|
130
|
+
/**
|
|
131
|
+
* Timestamp with timezone — always TIMESTAMPTZ.
|
|
132
|
+
* Prevents the #1 PostgreSQL date/time footgun (timezone-naive timestamps).
|
|
133
|
+
* Supports .default('now') for SQL DEFAULT now().
|
|
134
|
+
*/
|
|
135
|
+
readonly timestamp: () => Column<Date, false, false>;
|
|
136
|
+
/**
|
|
137
|
+
* TEXT with automatic Zod email validation.
|
|
138
|
+
* PostgreSQL has no EMAIL type — this is TEXT underneath.
|
|
139
|
+
* The email check is applied for free in validator().
|
|
140
|
+
*/
|
|
141
|
+
readonly email: () => Column<string, false, false>; /** UUID column (non-primary-key). For foreign keys, tokens, etc. */
|
|
142
|
+
readonly uuid: () => Column<string, false, false>;
|
|
143
|
+
/**
|
|
144
|
+
* JSONB column with required Zod schema for runtime validation.
|
|
145
|
+
* The schema provides BOTH the TS type (via z.infer) AND runtime validation.
|
|
146
|
+
*
|
|
147
|
+
* For unstructured JSON, pass z.unknown():
|
|
148
|
+
* ```ts
|
|
149
|
+
* metadata: kadak.json(z.unknown())
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
readonly json: <T extends z.ZodType>(schema: T) => Column<z.infer<T>, false, false>;
|
|
153
|
+
};
|
|
154
|
+
/** Table-level constraints beyond what individual columns express */
|
|
155
|
+
interface TableOptions {
|
|
156
|
+
/**
|
|
157
|
+
* Compound unique constraints — each array is a group of columns
|
|
158
|
+
* that must be unique together.
|
|
159
|
+
* ```ts
|
|
160
|
+
* { unique: [['userId', 'teamId']] }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
unique?: string[][];
|
|
164
|
+
}
|
|
165
|
+
type ColumnsRecord = Record<string, Column<any, any, any>>;
|
|
166
|
+
/**
|
|
167
|
+
* A table definition. Created via the `table()` function.
|
|
168
|
+
* Holds column metadata and generates typed Zod validators.
|
|
169
|
+
*/
|
|
170
|
+
declare class Table<TName extends string, TColumns extends ColumnsRecord> {
|
|
171
|
+
readonly _name: TName;
|
|
172
|
+
readonly _columns: TColumns;
|
|
173
|
+
readonly _options?: TableOptions;
|
|
174
|
+
/** Maps camelCase TS keys → snake_case PG column names */
|
|
175
|
+
readonly _columnMap: Record<string, string>;
|
|
176
|
+
constructor(name: TName, columns: TColumns, options?: TableOptions);
|
|
177
|
+
/** Alias for insertValidator() — the most common use case (validating user input) */
|
|
178
|
+
validator(): z.ZodObject<{
|
|
179
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
/** Validates data for INSERT — generated/defaulted fields are optional */
|
|
182
|
+
insertValidator(): z.ZodObject<{
|
|
183
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
/** Validates data for SELECT — all columns present, nullability applied */
|
|
186
|
+
selectValidator(): z.ZodObject<{
|
|
187
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
/** Validates data for UPDATE — everything optional (partial update) */
|
|
190
|
+
updateValidator(): z.ZodObject<{
|
|
191
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
/** @internal Builds Zod shape for a given operation mode */
|
|
194
|
+
private _buildShape;
|
|
195
|
+
/** @internal Creates the base Zod type for a column, without nullable/optional */
|
|
196
|
+
private _baseZodType;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Define a table. This is the primary API for declaring your database schema.
|
|
200
|
+
*
|
|
201
|
+
* ```ts
|
|
202
|
+
* export const users = table('users', {
|
|
203
|
+
* id: kadak.id(),
|
|
204
|
+
* name: kadak.text().required(),
|
|
205
|
+
* email: kadak.email().unique(),
|
|
206
|
+
* age: kadak.int().optional(),
|
|
207
|
+
* createdAt: kadak.timestamp().default('now'),
|
|
208
|
+
* })
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
declare function table<TName extends string, TColumns extends ColumnsRecord>(name: TName, columns: TColumns, options?: TableOptions): Table<TName, TColumns>;
|
|
212
|
+
/** Extract the SELECT type for a column — what the database returns */
|
|
213
|
+
type ColumnSelectType<C> = C extends Column<infer T, infer N, any> ? N extends true ? T | null : T : never;
|
|
214
|
+
/** Keys of columns that are REQUIRED in INSERT (no default, not generated) */
|
|
215
|
+
type RequiredInsertKeys<C extends ColumnsRecord> = { [K in keyof C]: C[K] extends Column<any, any, true> ? never : K }[keyof C];
|
|
216
|
+
/** Keys of columns that are OPTIONAL in INSERT (has default or is generated) */
|
|
217
|
+
type OptionalInsertKeys<C extends ColumnsRecord> = { [K in keyof C]: C[K] extends Column<any, any, true> ? K : never }[keyof C];
|
|
218
|
+
/**
|
|
219
|
+
* Infer the SELECT type — what you get back from queries.
|
|
220
|
+
* Every column is present. Nullable columns have `| null`.
|
|
221
|
+
*
|
|
222
|
+
* ```ts
|
|
223
|
+
* type User = Infer<typeof users>
|
|
224
|
+
* // { id: number, name: string, email: string, age: number | null, createdAt: Date }
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
type Infer<T extends Table<any, any>> = Simplify<{ [K in keyof T['_columns']]: ColumnSelectType<T['_columns'][K]> }>;
|
|
228
|
+
/**
|
|
229
|
+
* Infer the INSERT type — what you provide to create a row.
|
|
230
|
+
* Generated/defaulted columns become optional. Nullable columns accept null.
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* type NewUser = InferInsert<typeof users>
|
|
234
|
+
* // { name: string, email: string, age?: number | null, id?: number, createdAt?: Date }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
type InferInsert<T extends Table<any, any>> = Simplify<{ [K in RequiredInsertKeys<T['_columns']>]: ColumnSelectType<T['_columns'][K]> } & { [K in OptionalInsertKeys<T['_columns']>]?: ColumnSelectType<T['_columns'][K]> }>;
|
|
238
|
+
/**
|
|
239
|
+
* Infer the UPDATE type — what you provide for partial updates.
|
|
240
|
+
* Everything is optional. Nullable columns accept null.
|
|
241
|
+
*
|
|
242
|
+
* ```ts
|
|
243
|
+
* type UserUpdate = InferUpdate<typeof users>
|
|
244
|
+
* // { id?: number, name?: string, email?: string, age?: number | null, createdAt?: Date }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
type InferUpdate<T extends Table<any, any>> = Simplify<Partial<Infer<T>>>;
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/query.d.ts
|
|
250
|
+
/** Options for findMany/findFirst — without select (returns full row) */
|
|
251
|
+
interface FindManyOptions<T extends Table<any, any>> {
|
|
252
|
+
where?: Partial<Infer<T>>;
|
|
253
|
+
orderBy?: Partial<Record<keyof Infer<T>, 'asc' | 'desc'>>;
|
|
254
|
+
limit?: number;
|
|
255
|
+
offset?: number;
|
|
256
|
+
/** When true, includes soft-deleted rows */
|
|
257
|
+
withDeleted?: boolean;
|
|
258
|
+
/** Reserved for relations — not yet implemented */
|
|
259
|
+
include?: never;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Query client for a single table. Created by `connect()` — never instantiated directly.
|
|
263
|
+
* Provides findMany, findFirst, insert, update, delete with full type safety.
|
|
264
|
+
*/
|
|
265
|
+
declare class TableClient<T extends Table<any, any>> {
|
|
266
|
+
/** @internal */
|
|
267
|
+
readonly _sql: postgres.Sql;
|
|
268
|
+
/** @internal */
|
|
269
|
+
readonly _table: T;
|
|
270
|
+
/** @internal */
|
|
271
|
+
readonly _reverseMap: Record<string, string>;
|
|
272
|
+
/** @internal */
|
|
273
|
+
_onError?: (err: Error) => void;
|
|
274
|
+
constructor(sql: postgres.Sql, table: T);
|
|
275
|
+
/** Find rows with optional select for precise return types */
|
|
276
|
+
findMany<K extends keyof Infer<T>>(options: FindManyOptions<T> & {
|
|
277
|
+
select: Record<K, true>;
|
|
278
|
+
}): Promise<Pick<Infer<T>, K>[]>;
|
|
279
|
+
/** Find rows — returns full row type */
|
|
280
|
+
findMany(options?: FindManyOptions<T>): Promise<Infer<T>[]>;
|
|
281
|
+
findFirst<K extends keyof Infer<T>>(options: FindManyOptions<T> & {
|
|
282
|
+
select: Record<K, true>;
|
|
283
|
+
}): Promise<Pick<Infer<T>, K> | null>;
|
|
284
|
+
findFirst(options?: FindManyOptions<T>): Promise<Infer<T> | null>;
|
|
285
|
+
/** Insert a single row */
|
|
286
|
+
insert(data: InferInsert<T>): Promise<Infer<T>>;
|
|
287
|
+
/** Insert multiple rows */
|
|
288
|
+
insert(data: InferInsert<T>[]): Promise<Infer<T>[]>;
|
|
289
|
+
update(options: {
|
|
290
|
+
where: Partial<Infer<T>>;
|
|
291
|
+
data: InferUpdate<T>;
|
|
292
|
+
}): Promise<Infer<T>[]>;
|
|
293
|
+
delete(options: {
|
|
294
|
+
where: Partial<Infer<T>>;
|
|
295
|
+
}): Promise<Infer<T>[]>;
|
|
296
|
+
/** Always performs a real DELETE — bypasses soft delete */
|
|
297
|
+
hardDelete(options: {
|
|
298
|
+
where: Partial<Infer<T>>;
|
|
299
|
+
}): Promise<Infer<T>[]>;
|
|
300
|
+
/** Builds a WHERE fragment from a JS object, including soft delete filter */
|
|
301
|
+
private _buildWhere;
|
|
302
|
+
/** Builds an ORDER BY fragment */
|
|
303
|
+
private _buildOrderBy;
|
|
304
|
+
/** Converts a JS object (camelCase) to DB format (snake_case) */
|
|
305
|
+
private _toDb;
|
|
306
|
+
/** Converts a DB row (snake_case) back to JS format (camelCase) */
|
|
307
|
+
private _toJs;
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/connect.d.ts
|
|
311
|
+
/** Connection config for production use */
|
|
312
|
+
interface ConnectionConfig {
|
|
313
|
+
/** PostgreSQL connection URL */
|
|
314
|
+
url: string;
|
|
315
|
+
/** Max connections in pool — default 10 */
|
|
316
|
+
max?: number;
|
|
317
|
+
/**
|
|
318
|
+
* SSL mode — default: auto-detected.
|
|
319
|
+
* Localhost → false. Everything else → 'require'.
|
|
320
|
+
* This means Supabase, Neon, Railway, Vercel Postgres work out of the box.
|
|
321
|
+
*/
|
|
322
|
+
ssl?: boolean | 'require' | 'prefer' | 'allow';
|
|
323
|
+
/** Query timeout in seconds */
|
|
324
|
+
timeout?: number;
|
|
325
|
+
/** Called on connection-level errors */
|
|
326
|
+
onError?: (err: Error) => void;
|
|
327
|
+
}
|
|
328
|
+
/** The database client — each key is a table name mapped to its query client */
|
|
329
|
+
type Database<TTables extends Record<string, Table<any, any>>> = { [K in keyof TTables]: TTables[K] extends Table<any, any> ? TableClient<TTables[K]> : never } & {
|
|
330
|
+
/** Close all connections in the pool */close(): Promise<void>; /** Raw postgres.js client — escape hatch for custom queries */
|
|
331
|
+
sql: postgres.Sql;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Connect to PostgreSQL and create a typed database client.
|
|
335
|
+
*
|
|
336
|
+
* ```ts
|
|
337
|
+
* const db = connect('postgresql://user:pass@localhost/mydb', { users, posts })
|
|
338
|
+
* const allUsers = await db.users.findMany()
|
|
339
|
+
* await db.close()
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
declare function connect<TTables extends Record<string, Table<any, any>>>(config: string | ConnectionConfig, tables: TTables): Database<TTables>;
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/error.d.ts
|
|
345
|
+
/** All error codes KadakORM can produce */
|
|
346
|
+
type KadakErrorCode = 'NOT_NULL_VIOLATION' | 'UNIQUE_VIOLATION' | 'FOREIGN_KEY_VIOLATION' | 'TABLE_NOT_FOUND' | 'COLUMN_NOT_FOUND' | 'CONNECTION_ERROR' | 'AUTH_ERROR' | 'QUERY_TIMEOUT' | 'UNKNOWN';
|
|
347
|
+
/**
|
|
348
|
+
* The one error class users ever see from KadakORM.
|
|
349
|
+
* Always includes: what went wrong, which table/column, and how to fix it.
|
|
350
|
+
*/
|
|
351
|
+
declare class KadakError extends Error {
|
|
352
|
+
readonly code: KadakErrorCode;
|
|
353
|
+
readonly table?: string;
|
|
354
|
+
readonly column?: string;
|
|
355
|
+
readonly constraint?: string;
|
|
356
|
+
readonly hint: string;
|
|
357
|
+
/** Always preserved — the raw pg error for advanced debugging */
|
|
358
|
+
readonly originalError: unknown;
|
|
359
|
+
constructor(opts: {
|
|
360
|
+
code: KadakErrorCode;
|
|
361
|
+
message: string;
|
|
362
|
+
hint: string;
|
|
363
|
+
table?: string;
|
|
364
|
+
column?: string;
|
|
365
|
+
constraint?: string;
|
|
366
|
+
originalError: unknown;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/** Wraps any postgres.js error into a KadakError with context */
|
|
370
|
+
declare function wrapPgError(err: unknown, tableName?: string): KadakError;
|
|
371
|
+
//#endregion
|
|
372
|
+
export { Column, type ColumnConfig, type ConnectionConfig, type Database, type FindManyOptions, type Infer, type InferInsert, type InferUpdate, KadakError, type KadakErrorCode, Table, TableClient, type TableOptions, camelToSnake, connect, kadak, table, wrapPgError };
|
|
373
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/schema.ts","../src/query.ts","../src/connect.ts","../src/error.ts"],"mappings":";;;;;iBAagB,YAAA,CAAa,GAAA;;KAKxB,QAAA,oBAA4B,CAAA,GAAI,CAAA,CAAE,CAAA;;UAOtB,YAAA;EACf,MAAA;EACA,QAAA;EACA,UAAA;EACA,YAAA;EACA,QAAA;EACA,YAAA;EAbsC;EAetC,UAAA;EAfY;EAiBZ,WAAA;EAjB+B;EAmB/B,QAAA;EAnBqC;EAqBrC,SAAA,GAAY,CAAA,CAAE,OAAA;EArBwB;EAuBtC,UAAA;EAhB2B;EAkB3B,UAAA;EACA,GAAA;EACA,GAAA;AAAA;;;;;;;;;;;cAiBW,MAAA;EAAA,SAKF,OAAA,EAAS,YAAA;EAAA,SAID,KAAA,EAAO,KAAA;EAAA,SACP,SAAA,EAAW,SAAA;EAAA,SACX,WAAA,EAAa,WAAA;cAElB,MAAA,EAAQ,YAAA;EAbT;EAmBX,QAAA,CAAA,GAAY,MAAA,CAAO,KAAA,SAAc,WAAA;EAnBhB;EAwBjB,QAAA,CAAA,GAAY,MAAA,CAAO,KAAA,QAAa,WAAA;EAfR;EAoBxB,MAAA,CAAA,GAAU,MAAA,CAAO,KAAA,EAAO,SAAA,EAAW,WAAA;EAlBL;EAuB9B,UAAA,CAAA,GAAc,MAAA,CAAO,KAAA,EAAO,SAAA,EAAW,WAAA;EAfpB;;;;;;;;EA2BnB,OAAA,CAAQ,KAAA,EAAO,KAAA,SAAc,IAAA,GAAO,KAAA,WAAg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