elysia-auth-drizzle
Advanced tools
Comparing version 1.2.11 to 1.2.12
@@ -87,38 +87,100 @@ 'use strict'; | ||
// node_modules/drizzle-orm/subquery.js | ||
var SubqueryConfig = Symbol.for("drizzle:SubqueryConfig"); | ||
var _a2, _b; | ||
var Subquery = class { | ||
constructor(sql2, selection, alias, isWith = false) { | ||
/** @internal */ | ||
__publicField(this, _b); | ||
this[SubqueryConfig] = { | ||
sql: sql2, | ||
selection, | ||
alias, | ||
isWith | ||
// node_modules/drizzle-orm/column-builder.js | ||
var _a2; | ||
var ColumnBuilder = class { | ||
constructor(name, dataType, columnType) { | ||
__publicField(this, "config"); | ||
/** | ||
* Alias for {@link $defaultFn}. | ||
*/ | ||
__publicField(this, "$default", this.$defaultFn); | ||
/** | ||
* Alias for {@link $onUpdateFn}. | ||
*/ | ||
__publicField(this, "$onUpdate", this.$onUpdateFn); | ||
this.config = { | ||
name, | ||
notNull: false, | ||
default: void 0, | ||
hasDefault: false, | ||
primaryKey: false, | ||
isUnique: false, | ||
uniqueName: void 0, | ||
uniqueType: void 0, | ||
dataType, | ||
columnType | ||
}; | ||
} | ||
// getSQL(): SQL<unknown> { | ||
// return new SQL([this]); | ||
// } | ||
}; | ||
_a2 = entityKind, _b = SubqueryConfig; | ||
__publicField(Subquery, _a2, "Subquery"); | ||
var _a3; | ||
var WithSubquery = class extends Subquery { | ||
}; | ||
_a3 = entityKind; | ||
__publicField(WithSubquery, _a3, "WithSubquery"); | ||
var tracer = { | ||
startActiveSpan(name, fn) { | ||
{ | ||
return fn(); | ||
} | ||
/** | ||
* Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types. | ||
* | ||
* @example | ||
* ```ts | ||
* const users = pgTable('users', { | ||
* id: integer('id').$type<UserId>().primaryKey(), | ||
* details: json('details').$type<UserDetails>().notNull(), | ||
* }); | ||
* ``` | ||
*/ | ||
$type() { | ||
return this; | ||
} | ||
/** | ||
* Adds a `not null` clause to the column definition. | ||
* | ||
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select. | ||
*/ | ||
notNull() { | ||
this.config.notNull = true; | ||
return this; | ||
} | ||
/** | ||
* Adds a `default <value>` clause to the column definition. | ||
* | ||
* Affects the `insert` model of the table - columns *with* `default` are optional on insert. | ||
* | ||
* If you need to set a dynamic default value, use {@link $defaultFn} instead. | ||
*/ | ||
default(value) { | ||
this.config.default = value; | ||
this.config.hasDefault = true; | ||
return this; | ||
} | ||
/** | ||
* Adds a dynamic default value to the column. | ||
* The function will be called when the row is inserted, and the returned value will be used as the column value. | ||
* | ||
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`. | ||
*/ | ||
$defaultFn(fn) { | ||
this.config.defaultFn = fn; | ||
this.config.hasDefault = true; | ||
return this; | ||
} | ||
/** | ||
* Adds a dynamic update value to the column. | ||
* The function will be called when the row is updated, and the returned value will be used as the column value if none is provided. | ||
* If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value. | ||
* | ||
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`. | ||
*/ | ||
$onUpdateFn(fn) { | ||
this.config.onUpdateFn = fn; | ||
this.config.hasDefault = true; | ||
return this; | ||
} | ||
/** | ||
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`. | ||
* | ||
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing. | ||
*/ | ||
primaryKey() { | ||
this.config.primaryKey = true; | ||
this.config.notNull = true; | ||
return this; | ||
} | ||
}; | ||
_a2 = entityKind; | ||
__publicField(ColumnBuilder, _a2, "ColumnBuilder"); | ||
// node_modules/drizzle-orm/view-common.js | ||
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig"); | ||
// node_modules/drizzle-orm/table.js | ||
@@ -128,2 +190,3 @@ var TableName = Symbol.for("drizzle:Name"); | ||
var Columns = Symbol.for("drizzle:Columns"); | ||
var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns"); | ||
var OriginalName = Symbol.for("drizzle:OriginalName"); | ||
@@ -134,3 +197,3 @@ var BaseName = Symbol.for("drizzle:BaseName"); | ||
var IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable"); | ||
var _a4, _b2, _c, _d, _e, _f, _g, _h, _i; | ||
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j; | ||
var Table = class { | ||
@@ -142,3 +205,3 @@ constructor(name, schema, baseName) { | ||
*/ | ||
__publicField(this, _b2); | ||
__publicField(this, _b); | ||
/** | ||
@@ -153,2 +216,4 @@ * @internal | ||
__publicField(this, _e); | ||
/** @internal */ | ||
__publicField(this, _f); | ||
/** | ||
@@ -158,8 +223,8 @@ * @internal | ||
*/ | ||
__publicField(this, _f); | ||
__publicField(this, _g); | ||
/** @internal */ | ||
__publicField(this, _g, false); | ||
__publicField(this, _h, false); | ||
/** @internal */ | ||
__publicField(this, _h); | ||
__publicField(this, _i, true); | ||
__publicField(this, _i); | ||
__publicField(this, _j, true); | ||
this[TableName] = this[OriginalName] = name; | ||
@@ -170,4 +235,4 @@ this[Schema] = schema; | ||
}; | ||
_a4 = entityKind, _b2 = TableName, _c = OriginalName, _d = Schema, _e = Columns, _f = BaseName, _g = IsAlias, _h = ExtraConfigBuilder, _i = IsDrizzleTable; | ||
__publicField(Table, _a4, "Table"); | ||
_a3 = entityKind, _b = TableName, _c = OriginalName, _d = Schema, _e = Columns, _f = ExtraConfigColumns, _g = BaseName, _h = IsAlias, _i = ExtraConfigBuilder, _j = IsDrizzleTable; | ||
__publicField(Table, _a3, "Table"); | ||
/** @internal */ | ||
@@ -179,2 +244,3 @@ __publicField(Table, "Symbol", { | ||
Columns, | ||
ExtraConfigColumns, | ||
BaseName, | ||
@@ -185,10 +251,491 @@ IsAlias, | ||
// node_modules/drizzle-orm/pg-core/table.js | ||
var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys"); | ||
var _a4, _b2, _c2; | ||
var PgTable = class extends Table { | ||
constructor() { | ||
super(...arguments); | ||
/**@internal */ | ||
__publicField(this, _b2, []); | ||
/** @internal */ | ||
__publicField(this, _c2); | ||
} | ||
}; | ||
_a4 = entityKind, _b2 = InlineForeignKeys, _c2 = Table.Symbol.ExtraConfigBuilder; | ||
__publicField(PgTable, _a4, "PgTable"); | ||
/** @internal */ | ||
__publicField(PgTable, "Symbol", Object.assign({}, Table.Symbol, { | ||
InlineForeignKeys | ||
})); | ||
// node_modules/drizzle-orm/pg-core/foreign-keys.js | ||
var _a5; | ||
var ForeignKeyBuilder = class { | ||
constructor(config, actions) { | ||
/** @internal */ | ||
__publicField(this, "reference"); | ||
/** @internal */ | ||
__publicField(this, "_onUpdate", "no action"); | ||
/** @internal */ | ||
__publicField(this, "_onDelete", "no action"); | ||
this.reference = () => { | ||
const { name, columns, foreignColumns } = config(); | ||
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns }; | ||
}; | ||
if (actions) { | ||
this._onUpdate = actions.onUpdate; | ||
this._onDelete = actions.onDelete; | ||
} | ||
} | ||
onUpdate(action) { | ||
this._onUpdate = action === void 0 ? "no action" : action; | ||
return this; | ||
} | ||
onDelete(action) { | ||
this._onDelete = action === void 0 ? "no action" : action; | ||
return this; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
return new ForeignKey(table, this); | ||
} | ||
}; | ||
_a5 = entityKind; | ||
__publicField(ForeignKeyBuilder, _a5, "PgForeignKeyBuilder"); | ||
var _a6; | ||
var ForeignKey = class { | ||
constructor(table, builder) { | ||
__publicField(this, "reference"); | ||
__publicField(this, "onUpdate"); | ||
__publicField(this, "onDelete"); | ||
this.table = table; | ||
this.reference = builder.reference; | ||
this.onUpdate = builder._onUpdate; | ||
this.onDelete = builder._onDelete; | ||
} | ||
getName() { | ||
const { name, columns, foreignColumns } = this.reference(); | ||
const columnNames = columns.map((column) => column.name); | ||
const foreignColumnNames = foreignColumns.map((column) => column.name); | ||
const chunks = [ | ||
this.table[PgTable.Symbol.Name], | ||
...columnNames, | ||
foreignColumns[0].table[PgTable.Symbol.Name], | ||
...foreignColumnNames | ||
]; | ||
return name ?? `${chunks.join("_")}_fk`; | ||
} | ||
}; | ||
_a6 = entityKind; | ||
__publicField(ForeignKey, _a6, "PgForeignKey"); | ||
// node_modules/drizzle-orm/tracing-utils.js | ||
function iife(fn, ...args) { | ||
return fn(...args); | ||
} | ||
// node_modules/drizzle-orm/pg-core/unique-constraint.js | ||
function uniqueKeyName(table, columns) { | ||
return `${table[PgTable.Symbol.Name]}_${columns.join("_")}_unique`; | ||
} | ||
var _a7; | ||
var UniqueConstraintBuilder = class { | ||
constructor(columns, name) { | ||
/** @internal */ | ||
__publicField(this, "columns"); | ||
/** @internal */ | ||
__publicField(this, "nullsNotDistinctConfig", false); | ||
this.name = name; | ||
this.columns = columns; | ||
} | ||
nullsNotDistinct() { | ||
this.nullsNotDistinctConfig = true; | ||
return this; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name); | ||
} | ||
}; | ||
_a7 = entityKind; | ||
__publicField(UniqueConstraintBuilder, _a7, "PgUniqueConstraintBuilder"); | ||
var _a8; | ||
var UniqueOnConstraintBuilder = class { | ||
constructor(name) { | ||
/** @internal */ | ||
__publicField(this, "name"); | ||
this.name = name; | ||
} | ||
on(...columns) { | ||
return new UniqueConstraintBuilder(columns, this.name); | ||
} | ||
}; | ||
_a8 = entityKind; | ||
__publicField(UniqueOnConstraintBuilder, _a8, "PgUniqueOnConstraintBuilder"); | ||
var _a9; | ||
var UniqueConstraint = class { | ||
constructor(table, columns, nullsNotDistinct, name) { | ||
__publicField(this, "columns"); | ||
__publicField(this, "name"); | ||
__publicField(this, "nullsNotDistinct", false); | ||
this.table = table; | ||
this.columns = columns; | ||
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name)); | ||
this.nullsNotDistinct = nullsNotDistinct; | ||
} | ||
getName() { | ||
return this.name; | ||
} | ||
}; | ||
_a9 = entityKind; | ||
__publicField(UniqueConstraint, _a9, "PgUniqueConstraint"); | ||
// node_modules/drizzle-orm/pg-core/utils/array.js | ||
function parsePgArrayValue(arrayString, startFrom, inQuotes) { | ||
for (let i = startFrom; i < arrayString.length; i++) { | ||
const char = arrayString[i]; | ||
if (char === "\\") { | ||
i++; | ||
continue; | ||
} | ||
if (char === '"') { | ||
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1]; | ||
} | ||
if (inQuotes) { | ||
continue; | ||
} | ||
if (char === "," || char === "}") { | ||
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i]; | ||
} | ||
} | ||
return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length]; | ||
} | ||
function parsePgNestedArray(arrayString, startFrom = 0) { | ||
const result = []; | ||
let i = startFrom; | ||
let lastCharIsComma = false; | ||
while (i < arrayString.length) { | ||
const char = arrayString[i]; | ||
if (char === ",") { | ||
if (lastCharIsComma || i === startFrom) { | ||
result.push(""); | ||
} | ||
lastCharIsComma = true; | ||
i++; | ||
continue; | ||
} | ||
lastCharIsComma = false; | ||
if (char === "\\") { | ||
i += 2; | ||
continue; | ||
} | ||
if (char === '"') { | ||
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true); | ||
result.push(value2); | ||
i = startFrom2; | ||
continue; | ||
} | ||
if (char === "}") { | ||
return [result, i + 1]; | ||
} | ||
if (char === "{") { | ||
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1); | ||
result.push(value2); | ||
i = startFrom2; | ||
continue; | ||
} | ||
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false); | ||
result.push(value); | ||
i = newStartFrom; | ||
} | ||
return [result, i]; | ||
} | ||
function parsePgArray(arrayString) { | ||
const [result] = parsePgNestedArray(arrayString, 1); | ||
return result; | ||
} | ||
function makePgArray(array) { | ||
return `{${array.map((item) => { | ||
if (Array.isArray(item)) { | ||
return makePgArray(item); | ||
} | ||
if (typeof item === "string") { | ||
return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`; | ||
} | ||
return `${item}`; | ||
}).join(",")}}`; | ||
} | ||
// node_modules/drizzle-orm/pg-core/columns/common.js | ||
var _a10; | ||
var PgColumnBuilder = class extends ColumnBuilder { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "foreignKeyConfigs", []); | ||
} | ||
array(size) { | ||
return new PgArrayBuilder(this.config.name, this, size); | ||
} | ||
references(ref, actions = {}) { | ||
this.foreignKeyConfigs.push({ ref, actions }); | ||
return this; | ||
} | ||
unique(name, config) { | ||
this.config.isUnique = true; | ||
this.config.uniqueName = name; | ||
this.config.uniqueType = config?.nulls; | ||
return this; | ||
} | ||
/** @internal */ | ||
buildForeignKeys(column, table) { | ||
return this.foreignKeyConfigs.map(({ ref, actions }) => { | ||
return iife( | ||
(ref2, actions2) => { | ||
const builder = new ForeignKeyBuilder(() => { | ||
const foreignColumn = ref2(); | ||
return { columns: [column], foreignColumns: [foreignColumn] }; | ||
}); | ||
if (actions2.onUpdate) { | ||
builder.onUpdate(actions2.onUpdate); | ||
} | ||
if (actions2.onDelete) { | ||
builder.onDelete(actions2.onDelete); | ||
} | ||
return builder.build(table); | ||
}, | ||
ref, | ||
actions | ||
); | ||
}); | ||
} | ||
/** @internal */ | ||
buildExtraConfigColumn(table) { | ||
return new ExtraConfigColumn(table, this.config); | ||
} | ||
}; | ||
_a10 = entityKind; | ||
__publicField(PgColumnBuilder, _a10, "PgColumnBuilder"); | ||
var _a11; | ||
var PgColumn = class extends Column { | ||
constructor(table, config) { | ||
if (!config.uniqueName) { | ||
config.uniqueName = uniqueKeyName(table, [config.name]); | ||
} | ||
super(table, config); | ||
this.table = table; | ||
} | ||
}; | ||
_a11 = entityKind; | ||
__publicField(PgColumn, _a11, "PgColumn"); | ||
var _a12; | ||
var ExtraConfigColumn = class extends PgColumn { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "indexConfig", { | ||
order: this.config.order ?? "asc", | ||
nulls: this.config.nulls ?? "last", | ||
opClass: this.config.opClass | ||
}); | ||
__publicField(this, "defaultConfig", { | ||
order: "asc", | ||
nulls: "last", | ||
opClass: void 0 | ||
}); | ||
} | ||
getSQLType() { | ||
return this.getSQLType(); | ||
} | ||
asc() { | ||
this.indexConfig.order = "asc"; | ||
return this; | ||
} | ||
desc() { | ||
this.indexConfig.order = "desc"; | ||
return this; | ||
} | ||
nullsFirst() { | ||
this.indexConfig.nulls = "first"; | ||
return this; | ||
} | ||
nullsLast() { | ||
this.indexConfig.nulls = "last"; | ||
return this; | ||
} | ||
/** | ||
* ### PostgreSQL documentation quote | ||
* | ||
* > An operator class with optional parameters can be specified for each column of an index. | ||
* The operator class identifies the operators to be used by the index for that column. | ||
* For example, a B-tree index on four-byte integers would use the int4_ops class; | ||
* this operator class includes comparison functions for four-byte integers. | ||
* In practice the default operator class for the column's data type is usually sufficient. | ||
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering. | ||
* For example, we might want to sort a complex-number data type either by absolute value or by real part. | ||
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index. | ||
* More information about operator classes check: | ||
* | ||
* ### Useful links | ||
* https://www.postgresql.org/docs/current/sql-createindex.html | ||
* | ||
* https://www.postgresql.org/docs/current/indexes-opclass.html | ||
* | ||
* https://www.postgresql.org/docs/current/xindex.html | ||
* | ||
* ### Additional types | ||
* If you have the `pg_vector` extension installed in your database, you can use the | ||
* `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types. | ||
* | ||
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types** | ||
* | ||
* @param opClass | ||
* @returns | ||
*/ | ||
op(opClass) { | ||
this.indexConfig.opClass = opClass; | ||
return this; | ||
} | ||
}; | ||
_a12 = entityKind; | ||
__publicField(ExtraConfigColumn, _a12, "ExtraConfigColumn"); | ||
var _a13; | ||
var IndexedColumn = class { | ||
constructor(name, type, indexConfig) { | ||
__publicField(this, "name"); | ||
__publicField(this, "type"); | ||
__publicField(this, "indexConfig"); | ||
this.name = name; | ||
this.type = type; | ||
this.indexConfig = indexConfig; | ||
} | ||
}; | ||
_a13 = entityKind; | ||
__publicField(IndexedColumn, _a13, "IndexedColumn"); | ||
var _a14; | ||
var PgArrayBuilder = class extends PgColumnBuilder { | ||
constructor(name, baseBuilder, size) { | ||
super(name, "array", "PgArray"); | ||
this.config.baseBuilder = baseBuilder; | ||
this.config.size = size; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
const baseColumn = this.config.baseBuilder.build(table); | ||
return new PgArray( | ||
table, | ||
this.config, | ||
baseColumn | ||
); | ||
} | ||
}; | ||
_a14 = entityKind; | ||
__publicField(PgArrayBuilder, _a14, "PgArrayBuilder"); | ||
var _a15; | ||
var _PgArray = class _PgArray extends PgColumn { | ||
constructor(table, config, baseColumn, range) { | ||
super(table, config); | ||
__publicField(this, "size"); | ||
this.baseColumn = baseColumn; | ||
this.range = range; | ||
this.size = config.size; | ||
} | ||
getSQLType() { | ||
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`; | ||
} | ||
mapFromDriverValue(value) { | ||
if (typeof value === "string") { | ||
value = parsePgArray(value); | ||
} | ||
return value.map((v) => this.baseColumn.mapFromDriverValue(v)); | ||
} | ||
mapToDriverValue(value, isNestedArray = false) { | ||
const a = value.map( | ||
(v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v) | ||
); | ||
if (isNestedArray) | ||
return a; | ||
return makePgArray(a); | ||
} | ||
}; | ||
_a15 = entityKind; | ||
__publicField(_PgArray, _a15, "PgArray"); | ||
var PgArray = _PgArray; | ||
// node_modules/drizzle-orm/pg-core/columns/enum.js | ||
var isPgEnumSym = Symbol.for("drizzle:isPgEnum"); | ||
function isPgEnum(obj) { | ||
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true; | ||
} | ||
var _a16; | ||
var PgEnumColumnBuilder = class extends PgColumnBuilder { | ||
constructor(name, enumInstance) { | ||
super(name, "string", "PgEnumColumn"); | ||
this.config.enum = enumInstance; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
return new PgEnumColumn( | ||
table, | ||
this.config | ||
); | ||
} | ||
}; | ||
_a16 = entityKind; | ||
__publicField(PgEnumColumnBuilder, _a16, "PgEnumColumnBuilder"); | ||
var _a17; | ||
var PgEnumColumn = class extends PgColumn { | ||
constructor(table, config) { | ||
super(table, config); | ||
__publicField(this, "enum", this.config.enum); | ||
__publicField(this, "enumValues", this.config.enum.enumValues); | ||
this.enum = config.enum; | ||
} | ||
getSQLType() { | ||
return this.enum.enumName; | ||
} | ||
}; | ||
_a17 = entityKind; | ||
__publicField(PgEnumColumn, _a17, "PgEnumColumn"); | ||
// node_modules/drizzle-orm/subquery.js | ||
var _a18; | ||
var Subquery = class { | ||
constructor(sql2, selection, alias, isWith = false) { | ||
this._ = { | ||
brand: "Subquery", | ||
sql: sql2, | ||
selectedFields: selection, | ||
alias, | ||
isWith | ||
}; | ||
} | ||
// getSQL(): SQL<unknown> { | ||
// return new SQL([this]); | ||
// } | ||
}; | ||
_a18 = entityKind; | ||
__publicField(Subquery, _a18, "Subquery"); | ||
var _a19; | ||
var WithSubquery = class extends Subquery { | ||
}; | ||
_a19 = entityKind; | ||
__publicField(WithSubquery, _a19, "WithSubquery"); | ||
var tracer = { | ||
startActiveSpan(name, fn) { | ||
{ | ||
return fn(); | ||
} | ||
} | ||
}; | ||
// node_modules/drizzle-orm/view-common.js | ||
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig"); | ||
// node_modules/drizzle-orm/sql/sql.js | ||
var _a5; | ||
var _a20; | ||
var FakePrimitiveParam = class { | ||
}; | ||
_a5 = entityKind; | ||
__publicField(FakePrimitiveParam, _a5, "FakePrimitiveParam"); | ||
_a20 = entityKind; | ||
__publicField(FakePrimitiveParam, _a20, "FakePrimitiveParam"); | ||
function isSQLWrapper(value) { | ||
return typeof value === "object" && value !== null && "getSQL" in value && typeof value.getSQL === "function"; | ||
return value !== null && value !== void 0 && typeof value.getSQL === "function"; | ||
} | ||
@@ -209,3 +756,3 @@ function mergeQueries(queries) { | ||
} | ||
var _a6; | ||
var _a21; | ||
var StringChunk = class { | ||
@@ -220,5 +767,5 @@ constructor(value) { | ||
}; | ||
_a6 = entityKind; | ||
__publicField(StringChunk, _a6, "StringChunk"); | ||
var _a7; | ||
_a21 = entityKind; | ||
__publicField(StringChunk, _a21, "StringChunk"); | ||
var _a22; | ||
var _SQL = class _SQL { | ||
@@ -293,2 +840,5 @@ constructor(queryChunks) { | ||
if (is(chunk, Column)) { | ||
if (_config.invokeSource === "indexes") { | ||
return { sql: escapeName(chunk.name), params: [] }; | ||
} | ||
return { sql: escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(chunk.name), params: [] }; | ||
@@ -325,12 +875,18 @@ } | ||
if (is(chunk, Subquery)) { | ||
if (chunk[SubqueryConfig].isWith) { | ||
return { sql: escapeName(chunk[SubqueryConfig].alias), params: [] }; | ||
if (chunk._.isWith) { | ||
return { sql: escapeName(chunk._.alias), params: [] }; | ||
} | ||
return this.buildQueryFromSourceParams([ | ||
new StringChunk("("), | ||
chunk[SubqueryConfig].sql, | ||
chunk._.sql, | ||
new StringChunk(") "), | ||
new Name(chunk[SubqueryConfig].alias) | ||
new Name(chunk._.alias) | ||
], config); | ||
} | ||
if (isPgEnum(chunk)) { | ||
if (chunk.schema) { | ||
return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] }; | ||
} | ||
return { sql: escapeName(chunk.enumName), params: [] }; | ||
} | ||
if (isSQLWrapper(chunk)) { | ||
@@ -385,7 +941,16 @@ return this.buildQueryFromSourceParams([ | ||
} | ||
/** | ||
* This method is used to conditionally include a part of the query. | ||
* | ||
* @param condition - Condition to check | ||
* @returns itself if the condition is `true`, otherwise `undefined` | ||
*/ | ||
if(condition) { | ||
return condition ? this : void 0; | ||
} | ||
}; | ||
_a7 = entityKind; | ||
__publicField(_SQL, _a7, "SQL"); | ||
_a22 = entityKind; | ||
__publicField(_SQL, _a22, "SQL"); | ||
var SQL = _SQL; | ||
var _a8; | ||
var _a23; | ||
var Name = class { | ||
@@ -400,4 +965,4 @@ constructor(value) { | ||
}; | ||
_a8 = entityKind; | ||
__publicField(Name, _a8, "Name"); | ||
_a23 = entityKind; | ||
__publicField(Name, _a23, "Name"); | ||
function isDriverValueEncoder(value) { | ||
@@ -416,3 +981,3 @@ return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function"; | ||
}); | ||
var _a9; | ||
var _a24; | ||
var Param = class { | ||
@@ -432,4 +997,4 @@ /** | ||
}; | ||
_a9 = entityKind; | ||
__publicField(Param, _a9, "Param"); | ||
_a24 = entityKind; | ||
__publicField(Param, _a24, "Param"); | ||
function sql(strings, ...params) { | ||
@@ -483,3 +1048,3 @@ const queryChunks = []; | ||
((SQL2) => { | ||
var _a12; | ||
var _a27; | ||
const _Aliased = class _Aliased { | ||
@@ -500,8 +1065,8 @@ constructor(sql2, fieldAlias) { | ||
}; | ||
_a12 = entityKind; | ||
__publicField(_Aliased, _a12, "SQL.Aliased"); | ||
_a27 = entityKind; | ||
__publicField(_Aliased, _a27, "SQL.Aliased"); | ||
let Aliased = _Aliased; | ||
SQL2.Aliased = Aliased; | ||
})(SQL || (SQL = {})); | ||
var _a10; | ||
var _a25; | ||
var Placeholder = class { | ||
@@ -515,5 +1080,5 @@ constructor(name2) { | ||
}; | ||
_a10 = entityKind; | ||
__publicField(Placeholder, _a10, "Placeholder"); | ||
var _a11, _b3; | ||
_a25 = entityKind; | ||
__publicField(Placeholder, _a25, "Placeholder"); | ||
var _a26, _b3; | ||
var View = class { | ||
@@ -537,4 +1102,4 @@ constructor({ name: name2, schema, selectedFields, query }) { | ||
}; | ||
_a11 = entityKind, _b3 = ViewBaseConfig; | ||
__publicField(View, _a11, "View"); | ||
_a26 = entityKind, _b3 = ViewBaseConfig; | ||
__publicField(View, _a26, "View"); | ||
Column.prototype.getSQL = function() { | ||
@@ -541,0 +1106,0 @@ return new SQL([this]); |
{ | ||
"name": "elysia-auth-drizzle", | ||
"version": "1.2.11", | ||
"version": "1.2.12", | ||
"main": "./dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"scripts": { | ||
"test": "bun test --coverage", | ||
"test:watch": "bun test --watch", | ||
"lint": "eslint src test", | ||
"build": "tsup src/index.ts", | ||
"migration:make": "drizzle-kit generate:pg", | ||
"migration:up": "bun test/utils/migrate.ts", | ||
"migration:studio": "drizzle-kit studio" | ||
}, | ||
"files": [ | ||
@@ -33,3 +42,3 @@ "dist", | ||
"postgres": "^3.4.4", | ||
"prettier": "3.3.0", | ||
"prettier": "3.3.1", | ||
"tsup": "^8.0.2", | ||
@@ -39,11 +48,3 @@ "unify-elysia": "^1.0.5" | ||
"module": "dist/index.mjs", | ||
"scripts": { | ||
"test": "bun test --coverage", | ||
"test:watch": "bun test --watch", | ||
"lint": "eslint src test", | ||
"build": "tsup src/index.ts", | ||
"migration:make": "drizzle-kit generate:pg", | ||
"migration:up": "bun test/utils/migrate.ts", | ||
"migration:studio": "drizzle-kit studio" | ||
} | ||
} | ||
"packageManager": "pnpm@9.1.4" | ||
} |
Sorry, the diff of this file is not supported yet
106036
3435