orchid-orm 1.13.1 → 1.13.3
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 +41 -66
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -209,14 +209,16 @@ type Table = {
|
|
|
209
209
|
columnTypes: ColumnTypesBase;
|
|
210
210
|
noPrimaryKey?: boolean;
|
|
211
211
|
filePath: string;
|
|
212
|
+
language?: string;
|
|
212
213
|
};
|
|
213
214
|
type TableType<T extends Pick<Table, 'columns'>> = T['columns']['type'];
|
|
214
|
-
declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ columnTypes, snakeCase, filePath, nowSQL, exportAs, }?: {
|
|
215
|
+
declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ columnTypes, snakeCase, filePath, nowSQL, exportAs, language, }?: {
|
|
215
216
|
columnTypes?: CT | ((t: DefaultColumnTypes) => CT) | undefined;
|
|
216
217
|
snakeCase?: boolean | undefined;
|
|
217
218
|
filePath?: string | undefined;
|
|
218
219
|
nowSQL?: string | undefined;
|
|
219
220
|
exportAs?: string | undefined;
|
|
221
|
+
language?: string | undefined;
|
|
220
222
|
}) => {
|
|
221
223
|
new (): {
|
|
222
224
|
table: string;
|
|
@@ -318,39 +320,24 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
|
|
|
318
320
|
tsquery(): pqb.TsQueryColumn;
|
|
319
321
|
uuid(): pqb.UUIDColumn;
|
|
320
322
|
xml(): pqb.XMLColumn;
|
|
321
|
-
json<Type extends orchid_core.
|
|
322
|
-
|
|
323
|
-
tuple: <T_5 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_5, rest?: Rest) => orchid_core.JSONTuple<T_5, Rest>;
|
|
324
|
-
union: <T_6 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_6) => orchid_core.JSONUnion<T_6>;
|
|
325
|
-
any: () => orchid_core.JSONAny;
|
|
326
|
-
bigint: () => orchid_core.JSONBigInt;
|
|
323
|
+
json<Type extends orchid_core.JSONType<unknown, {}> = orchid_core.JSONUnknown>(schemaOrFn?: Type | ((j: {
|
|
324
|
+
unknown: () => orchid_core.JSONUnknown;
|
|
327
325
|
boolean: () => orchid_core.JSONBoolean;
|
|
328
|
-
date: () => orchid_core.JSONDate;
|
|
329
|
-
nan: () => orchid_core.JSONNaN;
|
|
330
|
-
never: () => orchid_core.JSONNever;
|
|
331
326
|
null: () => orchid_core.JSONNull;
|
|
332
327
|
number: () => orchid_core.JSONNumber;
|
|
333
328
|
string: () => orchid_core.JSONString;
|
|
334
|
-
unknown:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
intersection: <Left extends orchid_core.
|
|
340
|
-
lazy: <
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
object: <T_14 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_14) => orchid_core.JSONObject<T_14, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_15 extends object ? { [k in keyof T_15]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_18 extends object ? { [k in keyof T_18]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
|
|
347
|
-
[k: string]: Catchall["type"];
|
|
348
|
-
} extends infer T_16 extends object ? { [k_2 in keyof T_16]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_17 extends object ? { [k in keyof T_17]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
|
|
349
|
-
[k: string]: Catchall["type"];
|
|
350
|
-
})[k_2]; } : never>;
|
|
351
|
-
optional: <T_19 extends orchid_core.JSONTypeAny>(type: T_19) => orchid_core.JSONOptional<T_19>;
|
|
352
|
-
record: typeof orchid_core.record;
|
|
353
|
-
}) => Type)): pqb.JSONColumn<Type>;
|
|
329
|
+
array: <T_5 extends orchid_core.JSONType<unknown, {}>>(item: T_5) => orchid_core.JSONArray<T_5, "many">;
|
|
330
|
+
object: <Shape extends orchid_core.JSONObjectShape>(shape: Shape) => orchid_core.JSONObject<Shape, "strip", orchid_core.JSONType<unknown, {}>>;
|
|
331
|
+
literal: <T_6 extends orchid_core.JSONPrimitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
|
|
332
|
+
discriminatedUnion: <Discriminator extends string, Types extends orchid_core.JSONDiscriminatedUnionArg<Discriminator>>(discriminator: Discriminator, types: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, Types>;
|
|
333
|
+
enum: <U_1 extends string, T_7 extends [U_1, ...U_1[]]>(options: T_7) => orchid_core.JSONEnum<string, T_7>;
|
|
334
|
+
intersection: <Left extends orchid_core.JSONType<unknown, {}>, Right extends orchid_core.JSONType<unknown, {}>>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
|
|
335
|
+
lazy: <T_8 extends orchid_core.JSONType<unknown, {}>>(fn: () => T_8) => orchid_core.JSONLazy<T_8>;
|
|
336
|
+
nativeEnum: <T_9 extends orchid_core.EnumLike>(type: T_9) => orchid_core.JSONNativeEnum<T_9>;
|
|
337
|
+
record: <Key extends orchid_core.JSONNumber | orchid_core.JSONString, Value extends orchid_core.JSONType<unknown, {}>>(...args: [value: Value] | [key: Key, value: Value]) => orchid_core.JSONRecord<Key, Value>;
|
|
338
|
+
tuple: <T_10 extends orchid_core.JSONTupleItems, Rest extends orchid_core.JSONType<unknown, {}> | undefined = undefined>(items: T_10, rest?: Rest | undefined) => orchid_core.JSONTuple<T_10, Rest>;
|
|
339
|
+
union: <T_11 extends orchid_core.JSONUnionArgs>(...types: T_11) => orchid_core.JSONUnion<T_11>;
|
|
340
|
+
}) => Type) | undefined): pqb.JSONColumn<Type>;
|
|
354
341
|
jsonText(): pqb.JSONTextColumn;
|
|
355
342
|
array<Item extends pqb.ColumnType<unknown, pqb.BaseOperators, unknown>>(item: Item): pqb.ArrayColumn<Item>;
|
|
356
343
|
type(dataType: string): pqb.CustomTypeColumn;
|
|
@@ -359,7 +346,8 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
|
|
|
359
346
|
name?: string | undefined;
|
|
360
347
|
} | undefined): {};
|
|
361
348
|
index(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
362
|
-
unique(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
349
|
+
unique(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions | undefined): {};
|
|
350
|
+
searchIndex(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions | undefined): {};
|
|
363
351
|
constraint<Table_1 extends string | (() => orchid_core.ForeignKeyTable), Columns extends Table_1 extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<Table_1>>, ...orchid_core.ColumnNameOfTable<ReturnType<Table_1>>[]] : [string, ...string[]]>({ name, references, check, dropMode, }: {
|
|
364
352
|
name?: string | undefined;
|
|
365
353
|
references?: [columns: string[], fnOrTable: Table_1, foreignColumns: Columns, options?: pqb.ForeignKeyOptions | undefined] | undefined;
|
|
@@ -373,11 +361,12 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
|
|
|
373
361
|
check(check: orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>): {};
|
|
374
362
|
} : CT;
|
|
375
363
|
q: QueryData;
|
|
364
|
+
language: string | undefined;
|
|
376
365
|
filePath: string;
|
|
377
366
|
result: ColumnsShapeBase;
|
|
378
|
-
clone<
|
|
367
|
+
clone<T_12 extends QueryBase>(this: T_12): T_12;
|
|
379
368
|
getFilePath(): string;
|
|
380
|
-
setColumns<
|
|
369
|
+
setColumns<T_13 extends ColumnsShape>(fn: (t: Record<string, orchid_core.AnyColumnTypeCreator> extends CT ? {
|
|
381
370
|
timestamps<T extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
|
|
382
371
|
name(name: string): {
|
|
383
372
|
timestamp(): T;
|
|
@@ -471,39 +460,24 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
|
|
|
471
460
|
tsquery(): pqb.TsQueryColumn;
|
|
472
461
|
uuid(): pqb.UUIDColumn;
|
|
473
462
|
xml(): pqb.XMLColumn;
|
|
474
|
-
json<Type extends orchid_core.
|
|
475
|
-
|
|
476
|
-
tuple: <T_5 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_5, rest?: Rest) => orchid_core.JSONTuple<T_5, Rest>;
|
|
477
|
-
union: <T_6 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_6) => orchid_core.JSONUnion<T_6>;
|
|
478
|
-
any: () => orchid_core.JSONAny;
|
|
479
|
-
bigint: () => orchid_core.JSONBigInt;
|
|
463
|
+
json<Type extends orchid_core.JSONType<unknown, {}> = orchid_core.JSONUnknown>(schemaOrFn?: Type | ((j: {
|
|
464
|
+
unknown: () => orchid_core.JSONUnknown;
|
|
480
465
|
boolean: () => orchid_core.JSONBoolean;
|
|
481
|
-
date: () => orchid_core.JSONDate;
|
|
482
|
-
nan: () => orchid_core.JSONNaN;
|
|
483
|
-
never: () => orchid_core.JSONNever;
|
|
484
466
|
null: () => orchid_core.JSONNull;
|
|
485
467
|
number: () => orchid_core.JSONNumber;
|
|
486
468
|
string: () => orchid_core.JSONString;
|
|
487
|
-
unknown:
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
intersection: <Left extends orchid_core.
|
|
493
|
-
lazy: <
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
object: <T_14 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_14) => orchid_core.JSONObject<T_14, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_22 extends object ? { [k in keyof T_22]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_25 extends object ? { [k in keyof T_25]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
|
|
500
|
-
[k: string]: Catchall["type"];
|
|
501
|
-
} extends infer T_23 extends object ? { [k_2 in keyof T_23]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }> extends infer T_24 extends object ? { [k in keyof T_24]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_14]: T_14[k_1]["type"]; }>[k]; } : never) & {
|
|
502
|
-
[k: string]: Catchall["type"];
|
|
503
|
-
})[k_2]; } : never>;
|
|
504
|
-
optional: <T_19 extends orchid_core.JSONTypeAny>(type: T_19) => orchid_core.JSONOptional<T_19>;
|
|
505
|
-
record: typeof orchid_core.record;
|
|
506
|
-
}) => Type)): pqb.JSONColumn<Type>;
|
|
469
|
+
array: <T_5 extends orchid_core.JSONType<unknown, {}>>(item: T_5) => orchid_core.JSONArray<T_5, "many">;
|
|
470
|
+
object: <Shape extends orchid_core.JSONObjectShape>(shape: Shape) => orchid_core.JSONObject<Shape, "strip", orchid_core.JSONType<unknown, {}>>;
|
|
471
|
+
literal: <T_6 extends orchid_core.JSONPrimitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
|
|
472
|
+
discriminatedUnion: <Discriminator extends string, Types extends orchid_core.JSONDiscriminatedUnionArg<Discriminator>>(discriminator: Discriminator, types: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, Types>;
|
|
473
|
+
enum: <U_1 extends string, T_7 extends [U_1, ...U_1[]]>(options: T_7) => orchid_core.JSONEnum<string, T_7>;
|
|
474
|
+
intersection: <Left extends orchid_core.JSONType<unknown, {}>, Right extends orchid_core.JSONType<unknown, {}>>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
|
|
475
|
+
lazy: <T_8 extends orchid_core.JSONType<unknown, {}>>(fn: () => T_8) => orchid_core.JSONLazy<T_8>;
|
|
476
|
+
nativeEnum: <T_9 extends orchid_core.EnumLike>(type: T_9) => orchid_core.JSONNativeEnum<T_9>;
|
|
477
|
+
record: <Key extends orchid_core.JSONNumber | orchid_core.JSONString, Value extends orchid_core.JSONType<unknown, {}>>(...args: [value: Value] | [key: Key, value: Value]) => orchid_core.JSONRecord<Key, Value>;
|
|
478
|
+
tuple: <T_10 extends orchid_core.JSONTupleItems, Rest extends orchid_core.JSONType<unknown, {}> | undefined = undefined>(items: T_10, rest?: Rest | undefined) => orchid_core.JSONTuple<T_10, Rest>;
|
|
479
|
+
union: <T_11 extends orchid_core.JSONUnionArgs>(...types: T_11) => orchid_core.JSONUnion<T_11>;
|
|
480
|
+
}) => Type) | undefined): pqb.JSONColumn<Type>;
|
|
507
481
|
jsonText(): pqb.JSONTextColumn;
|
|
508
482
|
array<Item extends pqb.ColumnType<unknown, pqb.BaseOperators, unknown>>(item: Item): pqb.ArrayColumn<Item>;
|
|
509
483
|
type(dataType: string): pqb.CustomTypeColumn;
|
|
@@ -512,7 +486,8 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
|
|
|
512
486
|
name?: string | undefined;
|
|
513
487
|
} | undefined): {};
|
|
514
488
|
index(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
515
|
-
unique(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions): {};
|
|
489
|
+
unique(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions | undefined): {};
|
|
490
|
+
searchIndex(columns: orchid_core.MaybeArray<string | pqb.IndexColumnOptions>, options?: pqb.IndexOptions | undefined): {};
|
|
516
491
|
constraint<Table_1 extends string | (() => orchid_core.ForeignKeyTable), Columns extends Table_1 extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<Table_1>>, ...orchid_core.ColumnNameOfTable<ReturnType<Table_1>>[]] : [string, ...string[]]>({ name, references, check, dropMode, }: {
|
|
517
492
|
name?: string | undefined;
|
|
518
493
|
references?: [columns: string[], fnOrTable: Table_1, foreignColumns: Columns, options?: pqb.ForeignKeyOptions | undefined] | undefined;
|
|
@@ -524,9 +499,9 @@ declare const createBaseTable: <CT extends Record<string, orchid_core.AnyColumnT
|
|
|
524
499
|
dropMode?: pqb.DropMode | undefined;
|
|
525
500
|
}) | undefined): {};
|
|
526
501
|
check(check: orchid_core.RawSQLBase<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>, {}>): {};
|
|
527
|
-
} : CT) =>
|
|
528
|
-
shape:
|
|
529
|
-
type: ColumnShapeOutput<
|
|
502
|
+
} : CT) => T_13): {
|
|
503
|
+
shape: T_13;
|
|
504
|
+
type: ColumnShapeOutput<T_13>;
|
|
530
505
|
};
|
|
531
506
|
belongsTo<Self extends any, Related extends TableClass<Table>, Scope extends Query, Options extends {
|
|
532
507
|
primaryKey: keyof InstanceType<Related>["columns"]["shape"];
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,8 @@ const createBaseTable = ({
|
|
|
9
9
|
snakeCase,
|
|
10
10
|
filePath,
|
|
11
11
|
nowSQL,
|
|
12
|
-
exportAs
|
|
12
|
+
exportAs,
|
|
13
|
+
language
|
|
13
14
|
} = { columnTypes: pqb.columnTypes }) => {
|
|
14
15
|
const ct = typeof columnTypes === "function" ? columnTypes(pqb.columnTypes) : columnTypes || pqb.columnTypes;
|
|
15
16
|
return create(
|
|
@@ -18,10 +19,11 @@ const createBaseTable = ({
|
|
|
18
19
|
filePath || orchidCore.getStackTrace(),
|
|
19
20
|
snakeCase,
|
|
20
21
|
nowSQL,
|
|
21
|
-
exportAs
|
|
22
|
+
exportAs,
|
|
23
|
+
language
|
|
22
24
|
);
|
|
23
25
|
};
|
|
24
|
-
const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "BaseTable") => {
|
|
26
|
+
const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "BaseTable", language) => {
|
|
25
27
|
var _a;
|
|
26
28
|
let filePath;
|
|
27
29
|
const base = (_a = class {
|
|
@@ -29,6 +31,7 @@ const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "Bas
|
|
|
29
31
|
this.snakeCase = snakeCase;
|
|
30
32
|
this.columnTypes = columnTypes;
|
|
31
33
|
this.q = {};
|
|
34
|
+
this.language = language;
|
|
32
35
|
}
|
|
33
36
|
static getFilePath() {
|
|
34
37
|
if (filePath)
|
|
@@ -59,7 +62,7 @@ const create = (columnTypes, filePathOrStack, snakeCase, nowSQL, exportAs = "Bas
|
|
|
59
62
|
}
|
|
60
63
|
setColumns(fn) {
|
|
61
64
|
columnTypes[orchidCore.snakeCaseKey] = this.snakeCase;
|
|
62
|
-
const shape = pqb.getColumnTypes(columnTypes, fn, nowSQL);
|
|
65
|
+
const shape = pqb.getColumnTypes(columnTypes, fn, nowSQL, this.language);
|
|
63
66
|
if (this.snakeCase) {
|
|
64
67
|
for (const key in shape) {
|
|
65
68
|
const column = shape[key];
|
|
@@ -1428,7 +1431,8 @@ const orchidORM = (_a, tables) => {
|
|
|
1428
1431
|
const table = new tables[key]();
|
|
1429
1432
|
tableInstances[key] = table;
|
|
1430
1433
|
const options2 = __spreadProps(__spreadValues$1({}, commonOptions), {
|
|
1431
|
-
schema: table.schema
|
|
1434
|
+
schema: table.schema,
|
|
1435
|
+
language: table.language
|
|
1432
1436
|
});
|
|
1433
1437
|
if (table.noPrimaryKey)
|
|
1434
1438
|
options2.noPrimaryKey = "ignore";
|