orchid-orm 1.71.1 → 1.72.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/bun.d.ts +17 -0
- package/dist/bun.js +31 -0
- package/dist/bun.js.map +1 -0
- package/dist/bun.mjs +21 -0
- package/dist/bun.mjs.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +23 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -20
- package/dist/index.mjs.map +1 -1
- package/dist/migrations/bun.d.ts +14 -0
- package/dist/migrations/bun.js +12 -0
- package/dist/migrations/bun.js.map +1 -0
- package/dist/migrations/bun.mjs +5 -0
- package/dist/migrations/bun.mjs.map +1 -0
- package/dist/migrations/index.js +4 -4
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +5 -5
- package/dist/migrations/index.mjs.map +1 -1
- package/dist/node-postgres.d.ts +2 -2
- package/dist/node-postgres.js +6 -0
- package/dist/node-postgres.js.map +1 -1
- package/dist/node-postgres.mjs +2 -2
- package/dist/node-postgres.mjs.map +1 -1
- package/package.json +28 -17
package/dist/bun.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as _$pqb_internal0 from "pqb/internal";
|
|
2
|
+
import { DbSharedOptions } from "pqb/internal";
|
|
3
|
+
import * as _$pqb_bun0 from "pqb/bun";
|
|
4
|
+
import { BunAdapterOptions, bunSchemaConfig } from "pqb/bun";
|
|
5
|
+
import { OrchidORM, OrchidORMTables, OrchidOrmParam, TableClasses } from "orchid-orm";
|
|
6
|
+
interface BunOrchidORMOptions extends BunAdapterOptions, DbSharedOptions {}
|
|
7
|
+
declare const Adapter: _$pqb_internal0.DriverAdapter;
|
|
8
|
+
declare const createDb: <SchemaConfig extends _$pqb_internal0.ColumnSchemaConfig = _$pqb_internal0.DefaultSchemaConfig, ColumnTypes = _$pqb_internal0.DefaultColumnTypes<SchemaConfig>>({
|
|
9
|
+
log,
|
|
10
|
+
...options
|
|
11
|
+
}: _$pqb_bun0.CreateBunDbOptions<SchemaConfig, ColumnTypes>) => _$pqb_internal0.DbResult<ColumnTypes>;
|
|
12
|
+
declare const makeOrchidOrmDb: <T extends TableClasses>(orm: OrchidORMTables<T>, {
|
|
13
|
+
log,
|
|
14
|
+
...options
|
|
15
|
+
}: OrchidOrmParam<BunOrchidORMOptions>) => OrchidORM<T>;
|
|
16
|
+
declare const orchidORM: <T extends TableClasses>(options: OrchidOrmParam<BunOrchidORMOptions>, tables: T) => OrchidORM<T>;
|
|
17
|
+
export { Adapter, BunOrchidORMOptions, bunSchemaConfig, createDb, makeOrchidOrmDb, orchidORM };
|
package/dist/bun.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let orchid_orm = require("orchid-orm");
|
|
3
|
+
let pqb_bun = require("pqb/bun");
|
|
4
|
+
let pqb_internal = require("pqb/internal");
|
|
5
|
+
const Adapter = pqb_bun.BunAdapter;
|
|
6
|
+
const createDb = pqb_bun.createDb;
|
|
7
|
+
const makeOrchidOrmDb = (orm, { log, ...options }) => {
|
|
8
|
+
return (0, orchid_orm.makeOrchidOrmDbWithAdapter)(orm, {
|
|
9
|
+
...options,
|
|
10
|
+
log,
|
|
11
|
+
adapter: new pqb_internal.AdapterClass({
|
|
12
|
+
driverAdapter: pqb_bun.BunAdapter,
|
|
13
|
+
config: options
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const orchidORM = (options, tables) => {
|
|
18
|
+
return makeOrchidOrmDb((0, orchid_orm.bundleOrchidORMTables)(tables), options);
|
|
19
|
+
};
|
|
20
|
+
exports.Adapter = Adapter;
|
|
21
|
+
Object.defineProperty(exports, "bunSchemaConfig", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return pqb_bun.bunSchemaConfig;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.createDb = createDb;
|
|
28
|
+
exports.makeOrchidOrmDb = makeOrchidOrmDb;
|
|
29
|
+
exports.orchidORM = orchidORM;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=bun.js.map
|
package/dist/bun.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.js","names":["BunAdapter","cdb","AdapterClass"],"sources":["../src/adapters/bun.ts"],"sourcesContent":["import {\n TableClasses,\n OrchidORM,\n OrchidORMTables,\n OrchidOrmParam,\n bundleOrchidORMTables,\n makeOrchidOrmDbWithAdapter,\n} from 'orchid-orm';\nimport { BunAdapter, BunAdapterOptions, createDb as cdb } from 'pqb/bun';\nimport { DbSharedOptions, AdapterClass } from 'pqb/internal';\nexport { bunSchemaConfig } from 'pqb/bun';\n\nexport interface BunOrchidORMOptions\n extends BunAdapterOptions, DbSharedOptions {}\n\nexport const Adapter = BunAdapter;\n\nexport const createDb = cdb;\n\nexport const makeOrchidOrmDb = <T extends TableClasses>(\n orm: OrchidORMTables<T>,\n { log, ...options }: OrchidOrmParam<BunOrchidORMOptions>,\n): OrchidORM<T> => {\n return makeOrchidOrmDbWithAdapter(orm, {\n ...options,\n log,\n adapter: new AdapterClass({\n driverAdapter: BunAdapter,\n config: options,\n }),\n });\n};\n\nexport const orchidORM = <T extends TableClasses>(\n options: OrchidOrmParam<BunOrchidORMOptions>,\n tables: T,\n): OrchidORM<T> => {\n const orm = bundleOrchidORMTables(tables);\n return makeOrchidOrmDb(orm, options);\n};\n"],"mappings":";;;;AAeA,MAAa,UAAUA,QAAAA;AAEvB,MAAa,WAAWC,QAAAA;AAExB,MAAa,mBACX,KACA,EAAE,KAAK,GAAG,cACO;AACjB,SAAA,GAAA,WAAA,4BAAkC,KAAK;EACrC,GAAG;EACH;EACA,SAAS,IAAIC,aAAAA,aAAa;GACxB,eAAeF,QAAAA;GACf,QAAQ;GACT,CAAC;EACH,CAAC;;AAGJ,MAAa,aACX,SACA,WACiB;AAEjB,QAAO,iBAAA,GAAA,WAAA,uBAD2B,OAAO,EACb,QAAQ"}
|
package/dist/bun.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { bundleOrchidORMTables, makeOrchidOrmDbWithAdapter } from "orchid-orm";
|
|
2
|
+
import { BunAdapter, bunSchemaConfig, createDb as createDb$1 } from "pqb/bun";
|
|
3
|
+
import { AdapterClass } from "pqb/internal";
|
|
4
|
+
const Adapter = BunAdapter;
|
|
5
|
+
const createDb = createDb$1;
|
|
6
|
+
const makeOrchidOrmDb = (orm, { log, ...options }) => {
|
|
7
|
+
return makeOrchidOrmDbWithAdapter(orm, {
|
|
8
|
+
...options,
|
|
9
|
+
log,
|
|
10
|
+
adapter: new AdapterClass({
|
|
11
|
+
driverAdapter: BunAdapter,
|
|
12
|
+
config: options
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const orchidORM = (options, tables) => {
|
|
17
|
+
return makeOrchidOrmDb(bundleOrchidORMTables(tables), options);
|
|
18
|
+
};
|
|
19
|
+
export { Adapter, bunSchemaConfig, createDb, makeOrchidOrmDb, orchidORM };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=bun.mjs.map
|
package/dist/bun.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.mjs","names":["cdb"],"sources":["../src/adapters/bun.ts"],"sourcesContent":["import {\n TableClasses,\n OrchidORM,\n OrchidORMTables,\n OrchidOrmParam,\n bundleOrchidORMTables,\n makeOrchidOrmDbWithAdapter,\n} from 'orchid-orm';\nimport { BunAdapter, BunAdapterOptions, createDb as cdb } from 'pqb/bun';\nimport { DbSharedOptions, AdapterClass } from 'pqb/internal';\nexport { bunSchemaConfig } from 'pqb/bun';\n\nexport interface BunOrchidORMOptions\n extends BunAdapterOptions, DbSharedOptions {}\n\nexport const Adapter = BunAdapter;\n\nexport const createDb = cdb;\n\nexport const makeOrchidOrmDb = <T extends TableClasses>(\n orm: OrchidORMTables<T>,\n { log, ...options }: OrchidOrmParam<BunOrchidORMOptions>,\n): OrchidORM<T> => {\n return makeOrchidOrmDbWithAdapter(orm, {\n ...options,\n log,\n adapter: new AdapterClass({\n driverAdapter: BunAdapter,\n config: options,\n }),\n });\n};\n\nexport const orchidORM = <T extends TableClasses>(\n options: OrchidOrmParam<BunOrchidORMOptions>,\n tables: T,\n): OrchidORM<T> => {\n const orm = bundleOrchidORMTables(tables);\n return makeOrchidOrmDb(orm, options);\n};\n"],"mappings":";;;AAeA,MAAa,UAAU;AAEvB,MAAa,WAAWA;AAExB,MAAa,mBACX,KACA,EAAE,KAAK,GAAG,cACO;AACjB,QAAO,2BAA2B,KAAK;EACrC,GAAG;EACH;EACA,SAAS,IAAI,aAAa;GACxB,eAAe;GACf,QAAQ;GACT,CAAC;EACH,CAAC;;AAGJ,MAAa,aACX,SACA,WACiB;AAEjB,QAAO,gBADK,sBAAsB,OAAO,EACb,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,13 @@ interface OrchidORMQueryHelper<Q extends Query, Args extends unknown[], Result>
|
|
|
184
184
|
__result: Result;
|
|
185
185
|
}
|
|
186
186
|
interface OrchidORMTableHelper<T extends Query> {
|
|
187
|
+
/**
|
|
188
|
+
* Static table name from the table class.
|
|
189
|
+
*/
|
|
190
|
+
table: T['table'];
|
|
191
|
+
/**
|
|
192
|
+
* Create a helper that binds to the DB-aware table query when used.
|
|
193
|
+
*/
|
|
187
194
|
makeHelper<Args extends unknown[], Result>(fn: (q: T, ...args: Args) => Result): OrchidORMQueryHelper<T, Args, Result>;
|
|
188
195
|
}
|
|
189
196
|
type OrchidORMTables<T extends TableClasses = TableClasses> = { [K in keyof T]: T[K] extends {
|
|
@@ -758,7 +765,7 @@ declare function createBaseTable<SchemaConfig extends ColumnSchemaConfig = Defau
|
|
|
758
765
|
language,
|
|
759
766
|
autoForeignKeys
|
|
760
767
|
}?: {
|
|
761
|
-
schemaConfig?: SchemaConfig;
|
|
768
|
+
schemaConfig?: () => SchemaConfig;
|
|
762
769
|
columnTypes?: ColumnTypes | ((t: DefaultColumnTypes<SchemaConfig>) => ColumnTypes);
|
|
763
770
|
snakeCase?: boolean;
|
|
764
771
|
filePath?: string;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ let pqb_internal = require("pqb/internal");
|
|
|
3
3
|
let pqb = require("pqb");
|
|
4
4
|
let node_async_hooks = require("node:async_hooks");
|
|
5
5
|
function createBaseTable({ schemaConfig = pqb_internal.defaultSchemaConfig, columnTypes: columnTypesArg, snakeCase, filePath: filePathArg, nowSQL, exportAs = "BaseTable", language, autoForeignKeys } = {}) {
|
|
6
|
-
const
|
|
6
|
+
const schema = schemaConfig();
|
|
7
|
+
const columnTypes = typeof columnTypesArg === "function" ? columnTypesArg((0, pqb_internal.makeColumnTypes)(schema)) : columnTypesArg || (0, pqb_internal.makeColumnTypes)(schema);
|
|
7
8
|
const filePathOrStack = filePathArg || (0, pqb_internal.getStackTrace)();
|
|
8
9
|
let filePath;
|
|
9
10
|
const defaultColumns = {
|
|
@@ -33,27 +34,27 @@ function createBaseTable({ schemaConfig = pqb_internal.defaultSchemaConfig, colu
|
|
|
33
34
|
}
|
|
34
35
|
static inputSchema() {
|
|
35
36
|
this.instance();
|
|
36
|
-
return this._inputSchema === void 0 ? this._inputSchema =
|
|
37
|
+
return this._inputSchema === void 0 ? this._inputSchema = schema.inputSchema.call(this) : this._inputSchema;
|
|
37
38
|
}
|
|
38
39
|
static outputSchema() {
|
|
39
40
|
this.instance();
|
|
40
|
-
return this._outputSchema === void 0 ? this._outputSchema =
|
|
41
|
+
return this._outputSchema === void 0 ? this._outputSchema = schema.outputSchema.call(this) : this._outputSchema;
|
|
41
42
|
}
|
|
42
43
|
static querySchema() {
|
|
43
44
|
this.instance();
|
|
44
|
-
return this._querySchema === void 0 ? this._querySchema =
|
|
45
|
+
return this._querySchema === void 0 ? this._querySchema = schema.querySchema.call(this) : this._querySchema;
|
|
45
46
|
}
|
|
46
47
|
static createSchema() {
|
|
47
48
|
this.instance();
|
|
48
|
-
return this._createSchema === void 0 ? this._createSchema =
|
|
49
|
+
return this._createSchema === void 0 ? this._createSchema = schema.createSchema.call(this) : this._createSchema;
|
|
49
50
|
}
|
|
50
51
|
static updateSchema() {
|
|
51
52
|
this.instance();
|
|
52
|
-
return this._updateSchema === void 0 ? this._updateSchema =
|
|
53
|
+
return this._updateSchema === void 0 ? this._updateSchema = schema.updateSchema.call(this) : this._updateSchema;
|
|
53
54
|
}
|
|
54
55
|
static pkeySchema() {
|
|
55
56
|
this.instance();
|
|
56
|
-
return this._pkeySchema === void 0 ? this._pkeySchema =
|
|
57
|
+
return this._pkeySchema === void 0 ? this._pkeySchema = schema.pkeySchema.call(this) : this._pkeySchema;
|
|
57
58
|
}
|
|
58
59
|
static getFilePath() {
|
|
59
60
|
if (filePath) return filePath;
|
|
@@ -390,7 +391,7 @@ const makeBelongsToMethod = (tableConfig, table, relation, relationName, query)
|
|
|
390
391
|
for (let i = 0; i < len; i++) obj[primaryKeys[i]] = params[foreignKeys[i]];
|
|
391
392
|
return query.where(obj);
|
|
392
393
|
},
|
|
393
|
-
virtualColumn: new BelongsToVirtualColumn(pqb_internal.
|
|
394
|
+
virtualColumn: new BelongsToVirtualColumn(pqb_internal.internalSchemaConfig, relationName, state),
|
|
394
395
|
joinQuery: joinQueryChainHOF((0, pqb_internal.getPrimaryKeys)(query), reverseJoin, (joiningQuery, baseQuery) => join(baseQuery, joiningQuery, primaryKeys, foreignKeys)),
|
|
395
396
|
reverseJoin
|
|
396
397
|
};
|
|
@@ -632,7 +633,7 @@ const makeHasOneMethod = (tableConfig, table, relation, relationName, query) =>
|
|
|
632
633
|
...values
|
|
633
634
|
});
|
|
634
635
|
},
|
|
635
|
-
virtualColumn: new HasOneVirtualColumn(pqb_internal.
|
|
636
|
+
virtualColumn: new HasOneVirtualColumn(pqb_internal.internalSchemaConfig, relationName, state),
|
|
636
637
|
joinQuery: joinQueryChainHOF(relPKeys, reverseJoin, (joiningQuery, baseQuery) => joinHasRelation(baseQuery, joiningQuery, primaryKeys, foreignKeys, len)),
|
|
637
638
|
reverseJoin,
|
|
638
639
|
modifyRelatedQuery(relationQuery) {
|
|
@@ -817,7 +818,7 @@ const makeHasManyMethod = (tableConfig, table, relation, relationName, query) =>
|
|
|
817
818
|
...values
|
|
818
819
|
});
|
|
819
820
|
},
|
|
820
|
-
virtualColumn: new HasManyVirtualColumn(pqb_internal.
|
|
821
|
+
virtualColumn: new HasManyVirtualColumn(pqb_internal.internalSchemaConfig, relationName, state),
|
|
821
822
|
joinQuery: joinQueryChainHOF(relPKeys, reverseJoin, (joiningQuery, baseQuery) => joinHasRelation(baseQuery, joiningQuery, primaryKeys, foreignKeys, len)),
|
|
822
823
|
reverseJoin,
|
|
823
824
|
modifyRelatedQuery(relationQuery) {
|
|
@@ -1057,7 +1058,7 @@ const makeHasAndBelongsToManyMethod = (tableConfig, table, qb, relation, relatio
|
|
|
1057
1058
|
});
|
|
1058
1059
|
return on ? (0, pqb_internal._queryDefaults)(q, on) : q;
|
|
1059
1060
|
},
|
|
1060
|
-
virtualColumn: new HasAndBelongsToManyVirtualColumn(subQuery, pqb_internal.
|
|
1061
|
+
virtualColumn: new HasAndBelongsToManyVirtualColumn(subQuery, pqb_internal.internalSchemaConfig, relationName, state),
|
|
1061
1062
|
joinQuery: joinQueryChainHOF((0, pqb_internal.getPrimaryKeys)(query), reverseJoin, (joiningQuery, baseQuery) => joinQuery(joiningQuery, (0, pqb_internal.getQueryAs)(baseQuery), (0, pqb_internal.getQueryAs)(joiningQuery), {
|
|
1062
1063
|
...joiningQuery.q.joinedShapes,
|
|
1063
1064
|
[baseQuery.q.as || baseQuery.table]: baseQuery.q.shape
|
|
@@ -1419,13 +1420,16 @@ const assignTablesToOrm = (tables, result, adapter, qb, asyncStorage, commonOpti
|
|
|
1419
1420
|
const bundleOrchidORMTables = (tables) => {
|
|
1420
1421
|
const result = {};
|
|
1421
1422
|
let dbAwareInstance;
|
|
1422
|
-
for (const key in tables) result[key] = {
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
return
|
|
1427
|
-
|
|
1428
|
-
|
|
1423
|
+
for (const key in tables) result[key] = {
|
|
1424
|
+
table: tables[key].instance().table,
|
|
1425
|
+
makeHelper(arg) {
|
|
1426
|
+
let fn;
|
|
1427
|
+
return (...args) => {
|
|
1428
|
+
if (!fn) fn = dbAwareInstance[key].makeHelper(arg);
|
|
1429
|
+
return fn(...args);
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1429
1433
|
Object.defineProperty(result, orchidORMBundleMetadataKey, {
|
|
1430
1434
|
enumerable: false,
|
|
1431
1435
|
value: {
|
|
@@ -1463,7 +1467,7 @@ const privateOrchidORMWithAdapter = ({ log, logger, autoPreparedStatements, noPr
|
|
|
1463
1467
|
} else {
|
|
1464
1468
|
adapter = options.adapter;
|
|
1465
1469
|
asyncStorage = new node_async_hooks.AsyncLocalStorage();
|
|
1466
|
-
qb = (0, pqb_internal._initQueryBuilder)(adapter, (0, pqb_internal.makeColumnTypes)(pqb_internal.defaultSchemaConfig), asyncStorage, commonOptions, options);
|
|
1470
|
+
qb = (0, pqb_internal._initQueryBuilder)(adapter, (0, pqb_internal.makeColumnTypes)((0, pqb_internal.defaultSchemaConfig)(adapter.driverAdapter.schemaConfig)), asyncStorage, commonOptions, options);
|
|
1467
1471
|
}
|
|
1468
1472
|
qb.internal.rls = options.rls;
|
|
1469
1473
|
const result = {
|