orchid-orm 1.5.39 → 1.6.1
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/dist/index.d.ts +167 -163
- package/dist/index.js +27 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as pqb from 'pqb';
|
|
2
|
-
import { BelongsToRelation, HasManyRelation, HasOneRelation, Db, Adapter, FromArgs, Query, FromResult, AdapterOptions, QueryLogOptions, NoPrimaryKeyOption, HasAndBelongsToManyRelation, defaultsKey,
|
|
2
|
+
import { BelongsToRelation, HasManyRelation, HasOneRelation, Db, Adapter, FromArgs, Query, FromResult, AdapterOptions, QueryLogOptions, NoPrimaryKeyOption, HasAndBelongsToManyRelation, defaultsKey, BaseRelation, RelationQuery, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsAll, DefaultColumnTypes, ColumnsShape, WhereResult, MergeQuery, SetQueryReturns, QueryReturnType } from 'pqb';
|
|
3
3
|
export { columnTypes } from 'pqb';
|
|
4
|
+
import * as orchid_core from 'orchid-core';
|
|
5
|
+
import { EmptyObject, ColumnTypesBase, ColumnShapeOutput, SetOptional } from 'orchid-core';
|
|
4
6
|
import { AppCodeUpdater } from 'rake-db';
|
|
5
7
|
|
|
6
8
|
interface BelongsTo extends RelationThunkBase {
|
|
@@ -150,96 +152,97 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
|
|
|
150
152
|
columns: TableConfig;
|
|
151
153
|
schema?: string | undefined;
|
|
152
154
|
columnTypes: ColumnTypesBase extends CT ? {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
155
|
+
name: typeof orchid_core.name;
|
|
156
|
+
raw: (sql: string, values?: false | Record<string, unknown> | undefined) => orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>;
|
|
157
|
+
smallint(this: ColumnTypesBase): pqb.SmallIntColumn;
|
|
158
|
+
integer(this: ColumnTypesBase): pqb.IntegerColumn;
|
|
159
|
+
bigint(this: ColumnTypesBase): pqb.BigIntColumn;
|
|
160
|
+
numeric<Precision extends number | undefined = undefined, Scale extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision | undefined, scale?: Scale | undefined): pqb.DecimalColumn<Precision, Scale>;
|
|
161
|
+
decimal<Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_1 | undefined, scale?: Scale_1 | undefined): pqb.DecimalColumn<Precision_1, Scale_1>;
|
|
162
|
+
real(this: ColumnTypesBase): pqb.RealColumn;
|
|
163
|
+
doublePrecision(this: ColumnTypesBase): pqb.DoublePrecisionColumn;
|
|
164
|
+
smallSerial(this: ColumnTypesBase): pqb.SmallSerialColumn;
|
|
165
|
+
serial(this: ColumnTypesBase): pqb.SerialColumn;
|
|
166
|
+
bigSerial(this: ColumnTypesBase): pqb.BigSerialColumn;
|
|
167
|
+
money(this: ColumnTypesBase): pqb.MoneyColumn;
|
|
168
|
+
varchar<Limit extends number | undefined = undefined>(this: ColumnTypesBase, limit?: Limit | undefined): pqb.VarCharColumn<Limit>;
|
|
169
|
+
char<Limit_1 extends number | undefined = undefined>(this: ColumnTypesBase, limit?: Limit_1 | undefined): pqb.CharColumn<Limit_1>;
|
|
170
|
+
text: (this: ColumnTypesBase, min: number, max: number) => pqb.TextColumn;
|
|
171
|
+
string: (this: ColumnTypesBase, min: number, max: number) => pqb.TextColumn;
|
|
172
|
+
bytea(this: ColumnTypesBase): pqb.ByteaColumn;
|
|
173
|
+
date(this: ColumnTypesBase): pqb.DateColumn;
|
|
174
|
+
timestamp<Precision_2 extends number>(this: ColumnTypesBase, precision?: Precision_2 | undefined): pqb.TimestampColumn<Precision_2>;
|
|
175
|
+
timestampWithTimeZone<Precision_3 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_3 | undefined): pqb.TimestampWithTimeZoneColumn<number>;
|
|
176
|
+
time<Precision_4 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_4 | undefined): pqb.TimeColumn<Precision_4>;
|
|
177
|
+
timeWithTimeZone<Precision_5 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_5 | undefined): pqb.TimeWithTimeZoneColumn<Precision_5>;
|
|
178
|
+
interval<Fields extends string | undefined = undefined, Precision_6 extends number | undefined = undefined>(this: ColumnTypesBase, fields?: Fields | undefined, precision?: Precision_6 | undefined): pqb.IntervalColumn<Fields, Precision_6>;
|
|
179
|
+
boolean(this: ColumnTypesBase): pqb.BooleanColumn;
|
|
180
|
+
enum<U extends string, T extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T): pqb.EnumColumn<U, T>;
|
|
181
|
+
point(this: ColumnTypesBase): pqb.PointColumn;
|
|
182
|
+
line(this: ColumnTypesBase): pqb.LineColumn;
|
|
183
|
+
lseg(this: ColumnTypesBase): pqb.LsegColumn;
|
|
184
|
+
box(this: ColumnTypesBase): pqb.BoxColumn;
|
|
185
|
+
path(this: ColumnTypesBase): pqb.PathColumn;
|
|
186
|
+
polygon(this: ColumnTypesBase): pqb.PolygonColumn;
|
|
187
|
+
circle(this: ColumnTypesBase): pqb.CircleColumn;
|
|
188
|
+
cidr(this: ColumnTypesBase): pqb.CidrColumn;
|
|
189
|
+
inet(this: ColumnTypesBase): pqb.InetColumn;
|
|
190
|
+
macaddr(this: ColumnTypesBase): pqb.MacAddrColumn;
|
|
191
|
+
macaddr8(this: ColumnTypesBase): pqb.MacAddr8Column;
|
|
192
|
+
bit<Length extends number>(this: ColumnTypesBase, length: Length): pqb.BitColumn<Length>;
|
|
193
|
+
bitVarying<Length_1 extends number | undefined = undefined>(this: ColumnTypesBase, length?: Length_1 | undefined): pqb.BitVaryingColumn<Length_1>;
|
|
194
|
+
tsvector(this: ColumnTypesBase): pqb.TsVectorColumn;
|
|
195
|
+
tsquery(this: ColumnTypesBase): pqb.TsQueryColumn;
|
|
196
|
+
uuid(this: ColumnTypesBase): pqb.UUIDColumn;
|
|
197
|
+
xml(this: ColumnTypesBase): pqb.XMLColumn;
|
|
198
|
+
json<Type extends orchid_core.JSONTypeAny>(this: ColumnTypesBase, schemaOrFn: Type | ((j: {
|
|
199
|
+
set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
|
|
200
|
+
tuple: <T_1 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => orchid_core.JSONTuple<T_1, Rest>;
|
|
201
|
+
union: <T_2 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_2) => orchid_core.JSONUnion<T_2>;
|
|
202
|
+
any: () => orchid_core.JSONAny;
|
|
203
|
+
bigint: () => orchid_core.JSONBigInt;
|
|
204
|
+
boolean: () => orchid_core.JSONBoolean;
|
|
205
|
+
date: () => orchid_core.JSONDate;
|
|
206
|
+
nan: () => orchid_core.JSONNaN;
|
|
207
|
+
never: () => orchid_core.JSONNever;
|
|
208
|
+
null: () => orchid_core.JSONNull;
|
|
209
|
+
number: () => orchid_core.JSONNumber;
|
|
210
|
+
string: () => orchid_core.JSONString;
|
|
211
|
+
undefined: () => orchid_core.JSONUndefined;
|
|
212
|
+
unknown: () => orchid_core.JSONUnknown;
|
|
213
|
+
void: () => orchid_core.JSONVoid;
|
|
214
|
+
array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
|
|
215
|
+
discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
|
|
216
|
+
enum: <U_1 extends string, T_3 extends [U_1, ...U_1[]]>(options: T_3) => orchid_core.JSONEnum<U_1, T_3>;
|
|
217
|
+
instanceOf: <T_4 extends new (...args: any[]) => any>(cls: T_4) => orchid_core.JSONInstanceOf<T_4>;
|
|
218
|
+
intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
|
|
219
|
+
lazy: <T_5 extends orchid_core.JSONTypeAny>(fn: () => T_5) => orchid_core.JSONLazy<T_5>;
|
|
220
|
+
literal: <T_6 extends orchid_core.Primitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
|
|
221
|
+
map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
|
|
222
|
+
nativeEnum: <T_7 extends orchid_core.EnumLike>(givenEnum: T_7) => orchid_core.JSONNativeEnum<T_7>;
|
|
223
|
+
nullable: <T_8 extends orchid_core.JSONTypeAny>(type: T_8) => orchid_core.JSONNullable<T_8>;
|
|
224
|
+
nullish: <T_9 extends orchid_core.JSONTypeAny>(type: T_9) => orchid_core.JSONNullish<T_9>;
|
|
225
|
+
object: <T_10 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_10) => orchid_core.JSONObject<T_10, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
223
226
|
[k: string]: Catchall["type"];
|
|
224
|
-
} extends infer T_12 extends object ? { [k_2 in keyof T_12]: ((
|
|
227
|
+
} extends infer T_12 extends object ? { [k_2 in keyof T_12]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
225
228
|
[k: string]: Catchall["type"];
|
|
226
229
|
})[k_2]; } : never>;
|
|
227
|
-
optional: <T_13 extends
|
|
228
|
-
record: typeof
|
|
229
|
-
}) => Type))
|
|
230
|
-
jsonText:
|
|
231
|
-
array
|
|
232
|
-
timestamps: <T_14 extends pqb.ColumnType<unknown,
|
|
230
|
+
optional: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONOptional<T_13>;
|
|
231
|
+
record: typeof orchid_core.record;
|
|
232
|
+
}) => Type)): pqb.JSONColumn<Type>;
|
|
233
|
+
jsonText(this: ColumnTypesBase): pqb.JSONTextColumn;
|
|
234
|
+
array<Item extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: ColumnTypesBase, item: Item): pqb.ArrayColumn<Item>;
|
|
235
|
+
timestamps: <T_14 extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: {
|
|
233
236
|
timestamp(): T_14;
|
|
234
237
|
}) => {
|
|
235
|
-
createdAt:
|
|
236
|
-
updatedAt:
|
|
238
|
+
createdAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
|
|
239
|
+
updatedAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
|
|
237
240
|
};
|
|
238
241
|
primaryKey(columns: string[], options?: {
|
|
239
242
|
name?: string | undefined;
|
|
240
243
|
} | undefined): {};
|
|
241
|
-
index(columns:
|
|
242
|
-
unique(columns:
|
|
244
|
+
index(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
245
|
+
unique(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
243
246
|
foreignKey: {
|
|
244
247
|
<Table_1 extends pqb.ForeignKeyTableWithColumns, Columns extends [Exclude<keyof InstanceType<Table_1>["columns"]["shape"], number | symbol>, ...Exclude<keyof InstanceType<Table_1>["columns"]["shape"], number | symbol>[]]>(columns: string[], fn: () => Table_1, foreignColumns: Columns, options?: pqb.ForeignKeyOptions | undefined): {};
|
|
245
248
|
<Table_2 extends string, Columns_1 extends [string, ...string[]]>(columns: string[], table: Table_2, foreignColumns: Columns_1, options?: pqb.ForeignKeyOptions | undefined): {};
|
|
@@ -247,96 +250,97 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
|
|
|
247
250
|
} : CT;
|
|
248
251
|
noPrimaryKey?: boolean | undefined;
|
|
249
252
|
setColumns: <T_15 extends ColumnsShape>(fn: (t: ColumnTypesBase extends CT ? {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
253
|
+
name: typeof orchid_core.name;
|
|
254
|
+
raw: (sql: string, values?: false | Record<string, unknown> | undefined) => orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>;
|
|
255
|
+
smallint(this: ColumnTypesBase): pqb.SmallIntColumn;
|
|
256
|
+
integer(this: ColumnTypesBase): pqb.IntegerColumn;
|
|
257
|
+
bigint(this: ColumnTypesBase): pqb.BigIntColumn;
|
|
258
|
+
numeric<Precision extends number | undefined = undefined, Scale extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision | undefined, scale?: Scale | undefined): pqb.DecimalColumn<Precision, Scale>;
|
|
259
|
+
decimal<Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_1 | undefined, scale?: Scale_1 | undefined): pqb.DecimalColumn<Precision_1, Scale_1>;
|
|
260
|
+
real(this: ColumnTypesBase): pqb.RealColumn;
|
|
261
|
+
doublePrecision(this: ColumnTypesBase): pqb.DoublePrecisionColumn;
|
|
262
|
+
smallSerial(this: ColumnTypesBase): pqb.SmallSerialColumn;
|
|
263
|
+
serial(this: ColumnTypesBase): pqb.SerialColumn;
|
|
264
|
+
bigSerial(this: ColumnTypesBase): pqb.BigSerialColumn;
|
|
265
|
+
money(this: ColumnTypesBase): pqb.MoneyColumn;
|
|
266
|
+
varchar<Limit extends number | undefined = undefined>(this: ColumnTypesBase, limit?: Limit | undefined): pqb.VarCharColumn<Limit>;
|
|
267
|
+
char<Limit_1 extends number | undefined = undefined>(this: ColumnTypesBase, limit?: Limit_1 | undefined): pqb.CharColumn<Limit_1>;
|
|
268
|
+
text: (this: ColumnTypesBase, min: number, max: number) => pqb.TextColumn;
|
|
269
|
+
string: (this: ColumnTypesBase, min: number, max: number) => pqb.TextColumn;
|
|
270
|
+
bytea(this: ColumnTypesBase): pqb.ByteaColumn;
|
|
271
|
+
date(this: ColumnTypesBase): pqb.DateColumn;
|
|
272
|
+
timestamp<Precision_2 extends number>(this: ColumnTypesBase, precision?: Precision_2 | undefined): pqb.TimestampColumn<Precision_2>;
|
|
273
|
+
timestampWithTimeZone<Precision_3 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_3 | undefined): pqb.TimestampWithTimeZoneColumn<number>;
|
|
274
|
+
time<Precision_4 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_4 | undefined): pqb.TimeColumn<Precision_4>;
|
|
275
|
+
timeWithTimeZone<Precision_5 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_5 | undefined): pqb.TimeWithTimeZoneColumn<Precision_5>;
|
|
276
|
+
interval<Fields extends string | undefined = undefined, Precision_6 extends number | undefined = undefined>(this: ColumnTypesBase, fields?: Fields | undefined, precision?: Precision_6 | undefined): pqb.IntervalColumn<Fields, Precision_6>;
|
|
277
|
+
boolean(this: ColumnTypesBase): pqb.BooleanColumn;
|
|
278
|
+
enum<U extends string, T extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T): pqb.EnumColumn<U, T>;
|
|
279
|
+
point(this: ColumnTypesBase): pqb.PointColumn;
|
|
280
|
+
line(this: ColumnTypesBase): pqb.LineColumn;
|
|
281
|
+
lseg(this: ColumnTypesBase): pqb.LsegColumn;
|
|
282
|
+
box(this: ColumnTypesBase): pqb.BoxColumn;
|
|
283
|
+
path(this: ColumnTypesBase): pqb.PathColumn;
|
|
284
|
+
polygon(this: ColumnTypesBase): pqb.PolygonColumn;
|
|
285
|
+
circle(this: ColumnTypesBase): pqb.CircleColumn;
|
|
286
|
+
cidr(this: ColumnTypesBase): pqb.CidrColumn;
|
|
287
|
+
inet(this: ColumnTypesBase): pqb.InetColumn;
|
|
288
|
+
macaddr(this: ColumnTypesBase): pqb.MacAddrColumn;
|
|
289
|
+
macaddr8(this: ColumnTypesBase): pqb.MacAddr8Column;
|
|
290
|
+
bit<Length extends number>(this: ColumnTypesBase, length: Length): pqb.BitColumn<Length>;
|
|
291
|
+
bitVarying<Length_1 extends number | undefined = undefined>(this: ColumnTypesBase, length?: Length_1 | undefined): pqb.BitVaryingColumn<Length_1>;
|
|
292
|
+
tsvector(this: ColumnTypesBase): pqb.TsVectorColumn;
|
|
293
|
+
tsquery(this: ColumnTypesBase): pqb.TsQueryColumn;
|
|
294
|
+
uuid(this: ColumnTypesBase): pqb.UUIDColumn;
|
|
295
|
+
xml(this: ColumnTypesBase): pqb.XMLColumn;
|
|
296
|
+
json<Type extends orchid_core.JSONTypeAny>(this: ColumnTypesBase, schemaOrFn: Type | ((j: {
|
|
297
|
+
set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
|
|
298
|
+
tuple: <T_1 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => orchid_core.JSONTuple<T_1, Rest>;
|
|
299
|
+
union: <T_2 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_2) => orchid_core.JSONUnion<T_2>;
|
|
300
|
+
any: () => orchid_core.JSONAny;
|
|
301
|
+
bigint: () => orchid_core.JSONBigInt;
|
|
302
|
+
boolean: () => orchid_core.JSONBoolean;
|
|
303
|
+
date: () => orchid_core.JSONDate;
|
|
304
|
+
nan: () => orchid_core.JSONNaN;
|
|
305
|
+
never: () => orchid_core.JSONNever;
|
|
306
|
+
null: () => orchid_core.JSONNull;
|
|
307
|
+
number: () => orchid_core.JSONNumber;
|
|
308
|
+
string: () => orchid_core.JSONString;
|
|
309
|
+
undefined: () => orchid_core.JSONUndefined;
|
|
310
|
+
unknown: () => orchid_core.JSONUnknown;
|
|
311
|
+
void: () => orchid_core.JSONVoid;
|
|
312
|
+
array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
|
|
313
|
+
discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
|
|
314
|
+
enum: <U_1 extends string, T_3 extends [U_1, ...U_1[]]>(options: T_3) => orchid_core.JSONEnum<U_1, T_3>;
|
|
315
|
+
instanceOf: <T_4 extends new (...args: any[]) => any>(cls: T_4) => orchid_core.JSONInstanceOf<T_4>;
|
|
316
|
+
intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
|
|
317
|
+
lazy: <T_5 extends orchid_core.JSONTypeAny>(fn: () => T_5) => orchid_core.JSONLazy<T_5>;
|
|
318
|
+
literal: <T_6 extends orchid_core.Primitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
|
|
319
|
+
map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
|
|
320
|
+
nativeEnum: <T_7 extends orchid_core.EnumLike>(givenEnum: T_7) => orchid_core.JSONNativeEnum<T_7>;
|
|
321
|
+
nullable: <T_8 extends orchid_core.JSONTypeAny>(type: T_8) => orchid_core.JSONNullable<T_8>;
|
|
322
|
+
nullish: <T_9 extends orchid_core.JSONTypeAny>(type: T_9) => orchid_core.JSONNullish<T_9>;
|
|
323
|
+
object: <T_10 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_10) => orchid_core.JSONObject<T_10, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
320
324
|
[k: string]: Catchall["type"];
|
|
321
|
-
} extends infer T_12 extends object ? { [k_2 in keyof T_12]: ((
|
|
325
|
+
} extends infer T_12 extends object ? { [k_2 in keyof T_12]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
322
326
|
[k: string]: Catchall["type"];
|
|
323
327
|
})[k_2]; } : never>;
|
|
324
|
-
optional: <T_13 extends
|
|
325
|
-
record: typeof
|
|
326
|
-
}) => Type))
|
|
327
|
-
jsonText:
|
|
328
|
-
array
|
|
329
|
-
timestamps: <T_14 extends pqb.ColumnType<unknown,
|
|
328
|
+
optional: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONOptional<T_13>;
|
|
329
|
+
record: typeof orchid_core.record;
|
|
330
|
+
}) => Type)): pqb.JSONColumn<Type>;
|
|
331
|
+
jsonText(this: ColumnTypesBase): pqb.JSONTextColumn;
|
|
332
|
+
array<Item extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: ColumnTypesBase, item: Item): pqb.ArrayColumn<Item>;
|
|
333
|
+
timestamps: <T_14 extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: {
|
|
330
334
|
timestamp(): T_14;
|
|
331
335
|
}) => {
|
|
332
|
-
createdAt:
|
|
333
|
-
updatedAt:
|
|
336
|
+
createdAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
|
|
337
|
+
updatedAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
|
|
334
338
|
};
|
|
335
339
|
primaryKey(columns: string[], options?: {
|
|
336
340
|
name?: string | undefined;
|
|
337
341
|
} | undefined): {};
|
|
338
|
-
index(columns:
|
|
339
|
-
unique(columns:
|
|
342
|
+
index(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
343
|
+
unique(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
340
344
|
foreignKey: {
|
|
341
345
|
<Table_1 extends pqb.ForeignKeyTableWithColumns, Columns extends [Exclude<keyof InstanceType<Table_1>["columns"]["shape"], number | symbol>, ...Exclude<keyof InstanceType<Table_1>["columns"]["shape"], number | symbol>[]]>(columns: string[], fn: () => Table_1, foreignColumns: Columns, options?: pqb.ForeignKeyOptions | undefined): {};
|
|
342
346
|
<Table_2 extends string, Columns_1 extends [string, ...string[]]>(columns: string[], table: Table_2, foreignColumns: Columns_1, options?: pqb.ForeignKeyOptions | undefined): {};
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var pqb = require('pqb');
|
|
6
|
+
var orchidCore = require('orchid-core');
|
|
6
7
|
var path = require('path');
|
|
7
8
|
var fs = require('fs/promises');
|
|
8
9
|
var typescript = require('typescript');
|
|
@@ -84,8 +85,8 @@ const create = (columnTypes2) => {
|
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
class BelongsToVirtualColumn extends pqb.VirtualColumn {
|
|
87
|
-
constructor(key, state) {
|
|
88
|
-
super();
|
|
88
|
+
constructor(types, key, state) {
|
|
89
|
+
super(types);
|
|
89
90
|
this.key = key;
|
|
90
91
|
this.state = state;
|
|
91
92
|
this.nestedInsert = nestedInsert$3(this.state);
|
|
@@ -138,7 +139,7 @@ const makeBelongsToMethod = (relation, relationName, query) => {
|
|
|
138
139
|
method: (params) => {
|
|
139
140
|
return query.findBy({ [primaryKey]: params[foreignKey] });
|
|
140
141
|
},
|
|
141
|
-
virtualColumn: new BelongsToVirtualColumn(relationName, state),
|
|
142
|
+
virtualColumn: new BelongsToVirtualColumn(orchidCore.emptyObject, relationName, state),
|
|
142
143
|
joinQuery(fromQuery, toQuery) {
|
|
143
144
|
return pqb.addQueryOn(toQuery, fromQuery, toQuery, primaryKey, foreignKey);
|
|
144
145
|
},
|
|
@@ -348,8 +349,8 @@ var __spreadValues$6 = (a, b) => {
|
|
|
348
349
|
};
|
|
349
350
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
350
351
|
class HasOneVirtualColumn extends pqb.VirtualColumn {
|
|
351
|
-
constructor(key, state) {
|
|
352
|
-
super();
|
|
352
|
+
constructor(types, key, state) {
|
|
353
|
+
super(types);
|
|
353
354
|
this.key = key;
|
|
354
355
|
this.state = state;
|
|
355
356
|
this.nestedInsert = nestedInsert$2(state);
|
|
@@ -429,7 +430,7 @@ const makeHasOneMethod = (table, relation, relationName, query) => {
|
|
|
429
430
|
const values = { [foreignKey]: params[primaryKey] };
|
|
430
431
|
return query.where(values)._defaults(values);
|
|
431
432
|
},
|
|
432
|
-
virtualColumn: new HasOneVirtualColumn(relationName, state),
|
|
433
|
+
virtualColumn: new HasOneVirtualColumn(orchidCore.emptyObject, relationName, state),
|
|
433
434
|
joinQuery(fromQuery, toQuery) {
|
|
434
435
|
return pqb.addQueryOn(toQuery, fromQuery, toQuery, foreignKey, primaryKey);
|
|
435
436
|
},
|
|
@@ -540,8 +541,8 @@ var __spreadValues$5 = (a, b) => {
|
|
|
540
541
|
};
|
|
541
542
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
542
543
|
class HasManyVirtualColumn extends pqb.VirtualColumn {
|
|
543
|
-
constructor(key, state) {
|
|
544
|
-
super();
|
|
544
|
+
constructor(types, key, state) {
|
|
545
|
+
super(types);
|
|
545
546
|
this.key = key;
|
|
546
547
|
this.state = state;
|
|
547
548
|
this.nestedInsert = nestedInsert$1(state);
|
|
@@ -620,7 +621,7 @@ const makeHasManyMethod = (table, relation, relationName, query) => {
|
|
|
620
621
|
const values = { [foreignKey]: params[primaryKey] };
|
|
621
622
|
return query.where(values)._defaults(values);
|
|
622
623
|
},
|
|
623
|
-
virtualColumn: new HasManyVirtualColumn(relationName, state),
|
|
624
|
+
virtualColumn: new HasManyVirtualColumn(orchidCore.emptyObject, relationName, state),
|
|
624
625
|
joinQuery(fromQuery, toQuery) {
|
|
625
626
|
return pqb.addQueryOn(toQuery, fromQuery, toQuery, foreignKey, primaryKey);
|
|
626
627
|
},
|
|
@@ -784,8 +785,8 @@ var __spreadValues$4 = (a, b) => {
|
|
|
784
785
|
};
|
|
785
786
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
786
787
|
class HasAndBelongsToManyVirtualColumn extends pqb.VirtualColumn {
|
|
787
|
-
constructor(key, state) {
|
|
788
|
-
super();
|
|
788
|
+
constructor(types, key, state) {
|
|
789
|
+
super(types);
|
|
789
790
|
this.key = key;
|
|
790
791
|
this.state = state;
|
|
791
792
|
this.nestedInsert = nestedInsert(state);
|
|
@@ -856,7 +857,11 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
856
857
|
})
|
|
857
858
|
);
|
|
858
859
|
},
|
|
859
|
-
virtualColumn: new HasAndBelongsToManyVirtualColumn(
|
|
860
|
+
virtualColumn: new HasAndBelongsToManyVirtualColumn(
|
|
861
|
+
orchidCore.emptyObject,
|
|
862
|
+
relationName,
|
|
863
|
+
state
|
|
864
|
+
),
|
|
860
865
|
joinQuery(fromQuery, toQuery) {
|
|
861
866
|
return toQuery.whereExists(
|
|
862
867
|
subQuery,
|
|
@@ -1613,7 +1618,7 @@ const optionsToString = (options) => {
|
|
|
1613
1618
|
const value = options[key];
|
|
1614
1619
|
if (typeof value !== "object" && typeof value !== "function") {
|
|
1615
1620
|
lines.push(
|
|
1616
|
-
`${key}: ${typeof value === "string" ?
|
|
1621
|
+
`${key}: ${typeof value === "string" ? orchidCore.singleQuote(value) : value},`
|
|
1617
1622
|
);
|
|
1618
1623
|
}
|
|
1619
1624
|
}
|
|
@@ -1769,9 +1774,9 @@ const createTable = async (_a) => {
|
|
|
1769
1774
|
const baseTablePath = getImportPath(tablePath, params.baseTablePath);
|
|
1770
1775
|
const props = [];
|
|
1771
1776
|
if (ast.schema) {
|
|
1772
|
-
props.push(`schema = ${
|
|
1777
|
+
props.push(`schema = ${orchidCore.singleQuote(ast.schema)};`);
|
|
1773
1778
|
}
|
|
1774
|
-
props.push(`table = ${
|
|
1779
|
+
props.push(`table = ${orchidCore.singleQuote(ast.name)};`);
|
|
1775
1780
|
if (ast.noPrimaryKey === "ignore") {
|
|
1776
1781
|
props.push("noPrimaryKey = true;");
|
|
1777
1782
|
}
|
|
@@ -2051,7 +2056,7 @@ const addColumns = ({
|
|
|
2051
2056
|
const end = object.end - 1;
|
|
2052
2057
|
for (const key in add) {
|
|
2053
2058
|
const code = pqb.codeToString(add[key].toCode(t), spaces + " ", " ");
|
|
2054
|
-
changes.add(end, ` ${
|
|
2059
|
+
changes.add(end, ` ${orchidCore.quoteObjectKey(key)}: ${code.trim()},
|
|
2055
2060
|
${spaces}`);
|
|
2056
2061
|
}
|
|
2057
2062
|
};
|
|
@@ -2089,13 +2094,13 @@ const getColumnMethodArgs = (to, key) => {
|
|
|
2089
2094
|
}
|
|
2090
2095
|
const code = [`.${key}(`];
|
|
2091
2096
|
if (key === "collate" || key === "compression") {
|
|
2092
|
-
|
|
2097
|
+
orchidCore.addCode(code, orchidCore.singleQuote(value));
|
|
2093
2098
|
} else if (key === "default") {
|
|
2094
|
-
|
|
2099
|
+
orchidCore.addCode(code, pqb.columnDefaultArgumentToCode(value));
|
|
2095
2100
|
} else if (key !== "nullable" && key !== "primaryKey") {
|
|
2096
2101
|
return;
|
|
2097
2102
|
}
|
|
2098
|
-
|
|
2103
|
+
orchidCore.addCode(code, ")");
|
|
2099
2104
|
return code;
|
|
2100
2105
|
};
|
|
2101
2106
|
const dropMatchingIndexes = (context, prop, i, call, items) => {
|
|
@@ -2245,7 +2250,7 @@ const renameTable = async (_a) => {
|
|
|
2245
2250
|
changes.add(
|
|
2246
2251
|
node.members.pos,
|
|
2247
2252
|
`
|
|
2248
|
-
schema = ${
|
|
2253
|
+
schema = ${orchidCore.singleQuote(ast.toSchema)};`
|
|
2249
2254
|
);
|
|
2250
2255
|
}
|
|
2251
2256
|
for (const member of node.members) {
|
|
@@ -2260,13 +2265,13 @@ const renameTable = async (_a) => {
|
|
|
2260
2265
|
changes.replace(
|
|
2261
2266
|
value.pos,
|
|
2262
2267
|
value.end,
|
|
2263
|
-
` ${
|
|
2268
|
+
` ${orchidCore.singleQuote(ast.toSchema)}`
|
|
2264
2269
|
);
|
|
2265
2270
|
} else {
|
|
2266
2271
|
changes.remove(member.pos, member.end);
|
|
2267
2272
|
}
|
|
2268
2273
|
} else {
|
|
2269
|
-
changes.replace(value.pos, value.end, ` ${
|
|
2274
|
+
changes.replace(value.pos, value.end, ` ${orchidCore.singleQuote(ast.to)}`);
|
|
2270
2275
|
}
|
|
2271
2276
|
}
|
|
2272
2277
|
}
|