bun-query-builder 0.2.58 → 0.2.60
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/bin/cli.js +31 -40
- package/dist/browser.d.ts +2 -2
- package/dist/chunk-bbz0pmj9.js +40 -0
- package/dist/chunk-kjkkmrp8.js +2 -0
- package/dist/chunk-mjedm810.js +7 -0
- package/dist/chunk-mvk2rcqm.js +3 -0
- package/dist/chunk-vw813qrt.js +446 -0
- package/dist/client.d.ts +19 -1
- package/dist/orm.d.ts +4 -2
- package/dist/sql-fragments.d.ts +30 -0
- package/dist/src/browser.js +1 -1
- package/dist/src/dynamodb/index.js +1 -1
- package/dist/src/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-1mmf5p5n.js +0 -445
- package/dist/chunk-asdkg5va.js +0 -3
- package/dist/chunk-d2b8tt64.js +0 -40
- package/dist/chunk-j9778t8e.js +0 -7
- package/dist/chunk-rgnkzv8c.js +0 -2
- /package/dist/{chunk-739qq8wk.js → chunk-fn0m2c0v.js} +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -128,6 +128,24 @@ declare interface RawExpression {
|
|
|
128
128
|
export declare interface WhereRaw {
|
|
129
129
|
raw: SqlFragment
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* # `PaginateOptions`
|
|
133
|
+
*
|
|
134
|
+
* The unambiguous spelling of a paginate() call.
|
|
135
|
+
*
|
|
136
|
+
* `db.selectFrom(t).paginate(perPage, page)` and `Model.query().paginate(page,
|
|
137
|
+
* perPage)` take the same two numbers in opposite orders, and both parameters
|
|
138
|
+
* are `number` — so transposing them is not a type error, it just returns a
|
|
139
|
+
* different page. Passing this object instead says which is which.
|
|
140
|
+
*
|
|
141
|
+
* Both APIs accept it and both keep their positional forms, so this adds a
|
|
142
|
+
* safe spelling without moving anyone's existing call. See #1092.
|
|
143
|
+
*/
|
|
144
|
+
export declare interface PaginateOptions {
|
|
145
|
+
perPage?: number
|
|
146
|
+
page?: number
|
|
147
|
+
tx?: { unsafe: (sql: string, params?: unknown[]) => unknown }
|
|
148
|
+
}
|
|
131
149
|
export declare interface BaseSelectQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSelected, TJoined extends string = TTable,> {
|
|
132
150
|
distinct: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
133
151
|
distinctOn: (...columns: (keyof DB[TTable]['columns'] & string | string)[]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
@@ -279,7 +297,7 @@ export declare interface BaseSelectQueryBuilder<DB extends AnyDatabaseSchema, TT
|
|
|
279
297
|
explain: () => Promise<Record<string, unknown>[]>
|
|
280
298
|
simple: () => unknown
|
|
281
299
|
toText?: () => string
|
|
282
|
-
paginate: (perPage: number, page?: number, opts?: { tx?: { unsafe: (sql: string, params?: unknown[]) => unknown } }) => Promise<{ data: SelectedRow<DB, TTable, TSelected>[], meta: { perPage: number, page: number, total: number, lastPage: number } }>
|
|
300
|
+
paginate: ((perPage: number, page?: number, opts?: { tx?: { unsafe: (sql: string, params?: unknown[]) => unknown } }) => Promise<{ data: SelectedRow<DB, TTable, TSelected>[], meta: { perPage: number, page: number, total: number, lastPage: number } }>) & ((options: PaginateOptions) => Promise<{ data: SelectedRow<DB, TTable, TSelected>[], meta: { perPage: number, page: number, total: number, lastPage: number } }>)
|
|
283
301
|
simplePaginate: (perPage: number, page?: number) => Promise<{ data: SelectedRow<DB, TTable, TSelected>[], meta: { perPage: number, page: number, hasMore: boolean } }>
|
|
284
302
|
toSQL: () => string
|
|
285
303
|
execute: () => Promise<SelectedRow<DB, TTable, TSelected>[]>
|
package/dist/orm.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Database, type SQLQueryBindings } from 'bun:sqlite';
|
|
2
2
|
import type { FactoryFaker } from './faker-compat';
|
|
3
|
+
import type { PaginateOptions } from './client';
|
|
3
4
|
import type { RelationCardinality } from './type-inference';
|
|
4
5
|
import type { SupportedDialect } from './types';
|
|
5
6
|
export type {
|
|
@@ -508,7 +509,7 @@ export type ModelStatic<TDef extends ModelDefinition> = StaticWhereOverloads<TDe
|
|
|
508
509
|
count: () => Promise<number>
|
|
509
510
|
exists: () => Promise<boolean>
|
|
510
511
|
doesntExist: () => Promise<boolean>
|
|
511
|
-
paginate: (page?: number, perPage?: number) => Promise<{
|
|
512
|
+
paginate: (page?: number | PaginateOptions, perPage?: number) => Promise<{
|
|
512
513
|
data: ModelRecord<TDef>[]
|
|
513
514
|
total: number
|
|
514
515
|
page: number
|
|
@@ -680,7 +681,7 @@ declare class ModelQueryBuilder<TDef extends ModelDefinition, TSelected extends
|
|
|
680
681
|
increment<K extends NumericColumns<TDef>>(column: K, amount?: number): Promise<number>;
|
|
681
682
|
decrement<K extends NumericColumns<TDef>>(column: K, amount?: number): Promise<number>;
|
|
682
683
|
chunk(size: number, callback: (items: ModelInstance<TDef, TSelected>[]) => void | false | Promise<void | false>): Promise<void>;
|
|
683
|
-
paginate(page?: number, perPage?: number): Promise<{
|
|
684
|
+
paginate(page?: number | PaginateOptions, perPage?: number): Promise<{
|
|
684
685
|
data: ModelInstance<TDef, TSelected>[]
|
|
685
686
|
total: number
|
|
686
687
|
page: number
|
|
@@ -690,6 +691,7 @@ declare class ModelQueryBuilder<TDef extends ModelDefinition, TSelected extends
|
|
|
690
691
|
isEmpty: boolean
|
|
691
692
|
from: number | null
|
|
692
693
|
to: number | null
|
|
694
|
+
meta: { perPage: number, page: number, total: number, lastPage: number }
|
|
693
695
|
}>;
|
|
694
696
|
pluck<K extends ColumnName<TDef>>(column: K): Promise<(K extends keyof ModelAttributes<TDef> ? ModelAttributes<TDef>[K] : unknown)[]>;
|
|
695
697
|
max<K extends ColumnName<TDef>>(column: K): Promise<(K extends keyof ModelAttributes<TDef> ? ModelAttributes<TDef>[K] : number) | null>;
|
package/dist/sql-fragments.d.ts
CHANGED
|
@@ -52,6 +52,28 @@ export declare function renderInPredicate(column: string, values: readonly unkno
|
|
|
52
52
|
* to apply unconditionally.
|
|
53
53
|
*/
|
|
54
54
|
export declare function toDialectPlaceholders(sql: string, dialect: SupportedDialect): string;
|
|
55
|
+
/* … *\/` block comments, which nest
|
|
56
|
+
* - `$$…$$` / `$tag$…$tag$` dollar-quoted strings, without mistaking a `$1`
|
|
57
|
+
* placeholder for the start of one
|
|
58
|
+
*
|
|
59
|
+
* Backslash escapes inside a literal are deliberately NOT honoured. Whether
|
|
60
|
+
* `'a\'` ends the string depends on the dialect and, on Postgres, on a server
|
|
61
|
+
* setting — so this matches the standard (and what the previous literal-aware
|
|
62
|
+
* scanner did) rather than inventing a rule that would be wrong somewhere.
|
|
63
|
+
*
|
|
64
|
+
* A keyword must be preceded by a non-word character, and never matches at
|
|
65
|
+
* index 0: a statement that opens with a clause keyword has nothing before it
|
|
66
|
+
* for the clause to attach to.
|
|
67
|
+
*
|
|
68
|
+
* @param sql the statement to scan
|
|
69
|
+
* @param keywords patterns to look for. Each MUST carry the sticky (`y`) flag;
|
|
70
|
+
* they are matched at a position rather than against a slice, and are tried
|
|
71
|
+
* in the order given — so longer keywords must come before any single-word
|
|
72
|
+
* prefix of them (`ORDER BY` before a hypothetical `ORDER`).
|
|
73
|
+
* @param limit stop after this many hits. Callers that only want the first
|
|
74
|
+
* clause boundary pass 1 rather than scanning the rest of the statement.
|
|
75
|
+
*/
|
|
76
|
+
export declare function scanTopLevelKeywords(sql: string, keywords: ReadonlyArray<{ key: string, pattern: RegExp }>, limit?: unknown): TopLevelKeyword[];
|
|
55
77
|
/**
|
|
56
78
|
* Constant predicates, for the cases where a collection is empty.
|
|
57
79
|
*
|
|
@@ -87,3 +109,11 @@ export declare interface WhereTerm {
|
|
|
87
109
|
conn: 'AND' | 'OR'
|
|
88
110
|
sql: string
|
|
89
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* A top-level keyword found by {@link scanTopLevelKeywords}.
|
|
114
|
+
*/
|
|
115
|
+
export declare interface TopLevelKeyword {
|
|
116
|
+
key: string
|
|
117
|
+
start: number
|
|
118
|
+
length: number
|
|
119
|
+
}
|
package/dist/src/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Mb as a,Nb as b,Ob as c,Pb as d,Qb as e,Rb as f,Sb as g,Tb as h,Ub as i,Vb as j,Wb as k}from"../chunk-
|
|
2
|
+
import{Mb as a,Nb as b,Ob as c,Pb as d,Qb as e,Rb as f,Sb as g,Tb as h,Ub as i,Vb as j,Wb as k}from"../chunk-mvk2rcqm.js";import"../chunk-fn0m2c0v.js";k();export{e as BrowserQueryBuilder,d as BrowserQueryError,i as browserAuth,f as browserQuery,a as configureBrowser,g as createBrowserDb,h as createBrowserModel,j as default,b as getBrowserConfig,c as isBrowser};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$b as c,Zb as a,_b as b,ac as d,bc as e,cc as f,dc as g,ec as h,fc as i,gc as j,hc as k,ic as l,jc as m,kc as n,lc as o,mc as p,nc as q,oc as r}from"../../chunk-
|
|
2
|
+
import{$b as c,Zb as a,_b as b,ac as d,bc as e,cc as f,dc as g,ec as h,fc as i,gc as j,hc as k,ic as l,jc as m,kc as n,lc as o,mc as p,nc as q,oc as r}from"../../chunk-mjedm810.js";import"../../chunk-fn0m2c0v.js";export{a as DynamoDBClient,m as DynamoDBMigrationDriver,l as DynamoDBMigrationTracker,p as EntityQueryBuilder,k as MIGRATIONS_TABLE,d as Model,i as buildDynamoDBMigrationPlan,c as configureModels,h as convertSchemaToDefinition,b as createClient,r as createDynamo,n as createMigrationDriver,q as dynamo,g as extractModelSchema,f as extractTableDefinition,e as hashTableDefinition,j as isDefinitionEqual,o as migrateModels};
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{$ as aa,$a as ib,A,Aa,Ab as $b,B,Ba as Ka,Bb as ac,C,Ca as La,Cb as bc,D,Da as Ma,Db as cc,E,Ea as Na,Eb as dc,F,Fa as Oa,Fb as ec,G,Ga as Pa,Gb as fc,H,Ha as Qa,Hb as gc,I,Ia as Ra,Ib as hc,J,Ja as Sa,Jb as ic,K,Ka as Ta,Kb as jc,L,La as Ua,Lb as kc,M,Ma as Va,N,Na as Wa,O,Oa as Xa,P,Pa as Ya,Q,Qa as Za,R,Ra as _a,S,Sa as $a,T,Ta as ab,U,Ua as bb,V,Va as cb,W,Wa as db,X,Xa as eb,Y,Ya as fb,Z,Za as gb,_,_a as hb,a,aa as ba,ab as jb,b,ba as ca,bb as kb,c,ca as fa,cb as lb,d,da as ga,db as mb,e,ea as ha,eb as nb,f,fa as ia,fb as ob,g,ga as ja,gb as pb,h,hb as qb,i,ib as rb,j,jb as sb,k,ka,kb as tb,l,la,lb as ub,m,ma,mb as Nb,n,na,nb as Ob,o,oa,ob as Pb,p,pa,pb as Qb,q,qa,qb as Rb,r,ra,rb as Sb,s,sa,sb as Tb,t,ta,tb as Ub,u,ua,ub as Vb,v,va,vb as Wb,w,wa,wb as Xb,x,xa,xb as Yb,y,ya,yb as Zb,z,za,zb as _b}from"../chunk-vw813qrt.js";import{Mb as Ba,Nb as Ca,Ob as Da,Pb as Ea,Qb as Fa,Rb as Ga,Sb as Ha,Tb as Ia,Ub as Ja}from"../chunk-mvk2rcqm.js";import{$b as xb,Xb as da,Yb as ea,Zb as vb,_b as wb,ac as yb,bc as zb,cc as Ab,dc as Bb,ec as Cb,fc as Db,gc as Eb,hc as Fb,ic as Gb,jc as Hb,kc as Ib,lc as Jb,mc as Kb,nc as Lb,oc as Mb}from"../chunk-mjedm810.js";import"../chunk-fn0m2c0v.js";export{Qa as BelongsToManyRelationBuilder,Fa as BrowserQueryBuilder,Ea as BrowserQueryError,j as DEFAULT_SQLITE_PRAGMAS,vb as DynamoDBClient,da as DynamoDBDriverImpl,bb as DynamoDBItemBuilder,Hb as DynamoDBMigrationDriver,Gb as DynamoDBMigrationTracker,ab as DynamoDBQueryBuilder,rb as DynamoDBToolingAdapter,Kb as EntityQueryBuilder,Rb as GENERATED_MARKER,Fb as MIGRATIONS_TABLE,yb as Model,Z as MySQLDriver,_ as PostgresDriver,ca as SQLiteDriver,ec as Seeder,aa as SingleStoreDriver,fb as SingleTableManager,kb as SingleTablePatterns,hb as SingleTableQueryBuilder,gb as SingleTableRepository,$b as UTC_CLOCK_DEFAULT,ba as VitessDriver,l as applySqliteBootstrapPragmas,jc as auditSchemaDrift,Ja as browserAuth,Ga as browserQuery,Nb as buildDatabaseSchema,Db as buildDynamoDBMigrationPlan,Vb as buildMigrationPlan,Pb as buildSchemaMeta,D as cacheClear,F as cacheConfig,E as cacheStats,_b as canonicalStorageType,ac as canonicalizeDefault,za as checkSchema,La as clearLocalModels,Ya as clearModelRegistry,B as clearQueryCache,c as config,Ba as configureBrowser,xb as configureModels,Oa as configureOrm,Cb as convertSchemaToDefinition,Ha as createBrowserDb,Ia as createBrowserModel,wb as createClient,Mb as createDynamo,eb as createDynamoDBClient,ea as createDynamoDBDriver,db as createDynamoDBItemBuilder,cb as createDynamoDBQueryBuilder,sb as createDynamoDBToolingAdapter,Ka as createFakerCompatLayer,Ib as createMigrationDriver,Ra as createModel,A as createQueryBuilder,jb as createRepository,ib as createSingleTableManager,Sa as createTableFromModel,L as dbInfo,N as dbOptimize,M as dbStats,O as dbWipe,b as defaultConfig,i as defineConfig,_a as defineModel,dc as defineModels,fc as defineSeeder,K as dumpDatabase,Lb as dynamo,z as escapeStringLiteral,ia as executeMigration,P as explain,qa as explainAllQueries,I as exportData,Ma as extractChanges,Na as extractInsertId,Bb as extractModelSchema,Ab as extractTableDefinition,gc as familyOfDeclared,hc as familyOfSqlType,Q as file,kc as formatSchemaDrift,va as freshDatabase,tb as generateAccessPatterns,ra as generateDiagram,bc as generateDiffOperations,cc as generateDiffSql,Yb as generateDiffSqlString,ha as generateMigration,W as generateModelSource,Wb as generateSql,Xb as generateSqlString,Va as getAllModels,Ca as getBrowserConfig,g as getConfig,Pa as getDatabase,fa as getDialectDriver,Ua as getModel,Wa as getModelRegistry,e as getPlaceholder,f as getPlaceholders,Xa as hasModel,Zb as hashMigrationPlan,zb as hashTableDefinition,J as importData,r as inflectSingular,R as inspectTable,T as introspect,X as introspectDatabase,Da as isBrowser,Eb as isDefinitionEqual,Sb as isGeneratedMigrationSql,Ub as isLosslessTypeChange,a as isMysqlLike,u as iterateAllPivots,Qb as lastCreatedMigrationFiles,Ob as loadModels,Y as makeModel,ua as makeSeeder,pb as marshallObject,ka as migrateGenerate,na as migrateList,Jb as migrateModels,la as migrateRollback,ma as migrateStatus,Tb as migrationBody,V as modelNameForTable,oa as modelShow,N as optimizeDatabase,mb as parseStacksModels,pa as ping,qa as queryExplainAll,x as quoteColumnForDialect,w as raw,$a as registerBrowserModels,Za as registerModel,ra as relationDiagram,m as resetConnection,ja as resetDatabase,d as resolveDialect,lb as resolveKeyPattern,t as resolvePivot,k as resolveSqlitePragmas,n as runBenchmark,ta as runSeeder,sa as runSeeders,ic as satisfies,ga as saveMigrationSnapshot,Ta as seedModel,h as setConfig,C as setQueryCacheMaxSize,oa as showModel,s as singularizerFor,wa as sql,U as sqlTypeToAttr,ub as stacksModelToEntity,G as startConsole,q as stripTrailingS,S as tableInfo,p as tableNameFor,y as temporalLiteral,H as tinker,v as toDialectPlaceholders,nb as toDynamoDBItem,ob as toModelInstance,o as toTableName,qb as unmarshallItem,xa as unsafe,ya as validateSchema,Aa as waitReady,O as wipeDatabase};
|
package/package.json
CHANGED