bun-query-builder 0.3.4 → 0.3.5
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 +13 -13
- package/dist/chunk-3rp9etrz.js +2 -0
- package/dist/chunk-455vt4nn.js +67 -0
- package/dist/chunk-pa426cqs.js +384 -0
- package/dist/chunk-r6myba29.js +3 -0
- package/dist/chunk-s66vynk9.js +3 -0
- package/dist/{chunk-mbt007va.js → chunk-vxh8ktv7.js} +5 -5
- package/dist/{chunk-jwwbnv83.js → chunk-xk3qn91x.js} +2 -2
- package/dist/chunk-zkgctd8f.js +2 -0
- package/dist/client.d.ts +2 -2
- package/dist/config.d.ts +9 -0
- package/dist/db.d.ts +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/libsql.d.ts +169 -0
- package/dist/src/browser.js +1 -1
- package/dist/src/dynamodb/index.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/runtime.js +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-afbb8bx3.js +0 -384
- package/dist/chunk-cwf5anrk.js +0 -2
- package/dist/chunk-ne1tyjpr.js +0 -2
- package/dist/chunk-qa7wq5xr.js +0 -67
- package/dist/chunk-wq450xdk.js +0 -3
- package/dist/chunk-yr0kc2zt.js +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var n={baseUrl:""};function en(e){n={...n,...e}}function tn(){return n}function nn(){return typeof window<"u"&&typeof document<"u"}async function w(){if(n.getToken){let e=n.getToken();return e instanceof Promise?e:e}if(typeof localStorage<"u")return localStorage.getItem("auth_token");return null}async function l(){let e={"Content-Type":"application/json",Accept:"application/json",...n.headers},t=await w();if(t)e.Authorization=`Bearer ${t}`;return e}async function u(e){if(e.status===401)throw n.onUnauthorized?.(),new g("Unauthorized",401);if(!e.ok){let r=await e.json().catch(()=>({message:"Request failed"}));throw new g(r.message||`HTTP ${e.status}`,e.status)}let t=await e.json();if(n.transformResponse)return n.transformResponse(t);return t}class g extends Error{status;constructor(e,t){super(e);this.name="BrowserQueryError",this.status=t}}class Ye{state;constructor(e){this.state={table:e,wheres:[],orderBy:[],selectColumns:["*"],withRelations:[]}}select(...e){return this.state.selectColumns=e,this}where(e,t,r){if(r===void 0)this.state.wheres.push({column:e,operator:"=",value:t,boolean:"and"});else this.state.wheres.push({column:e,operator:t,value:r,boolean:"and"});return this}orWhere(e,t,r){throw TypeError("[browser] orWhere() is not supported by this client. The query-param format it builds has no spelling for a disjunction, so the term would be sent as a plain filter and the server would read it as AND \u2014 silently returning a superset of the rows you asked for. Express the alternatives as a single filter (whereIn), or issue one request per branch and merge the results.")}andWhere(e,t,r){return r===void 0?this.where(e,t):this.where(e,t,r)}whereNull(e){return this.where(e,"is",null)}whereNotNull(e){return this.where(e,"is not",null)}whereIn(e,t){return this.where(e,"in",t)}whereNotIn(e,t){return this.where(e,"not in",t)}orderBy(e,t="asc"){return this.state.orderBy.push({column:e,direction:t}),this}orderByDesc(e){return this.orderBy(e,"desc")}latest(e="created_at"){return this.orderBy(e,"desc")}oldest(e="created_at"){return this.orderBy(e,"asc")}limit(e){return this.state.limitValue=e,this}offset(e){return this.state.offsetValue=e,this}skip(e){return this.offset(e)}take(e){return this.limit(e)}with(...e){return this.state.withRelations.push(...e),this}buildQueryParams(){let e=new URLSearchParams;for(let t of this.state.wheres)if(t.operator==="=")e.append(t.column,String(t.value));else if(t.operator==="in"&&Array.isArray(t.value))e.append(`${t.column}[]`,t.value.join(","));else if(t.operator==="is"&&t.value===null)e.append(`filter[${t.column}][is]`,"null");else if(t.operator==="is not"&&t.value===null)e.append(`filter[${t.column}][is_not]`,"null");else e.append(`filter[${t.column}][${t.operator}]`,String(t.value));if(this.state.orderBy.length>0){let t=this.state.orderBy.map((r)=>`${r.direction==="desc"?"-":""}${r.column}`).join(",");e.append("sort",t)}if(this.state.limitValue!==void 0)e.append("limit",String(this.state.limitValue));if(this.state.offsetValue!==void 0)e.append("offset",String(this.state.offsetValue));if(this.state.selectColumns.length>0&&!this.state.selectColumns.includes("*"))e.append("fields",this.state.selectColumns.join(","));if(this.state.withRelations.length>0)e.append("include",this.state.withRelations.join(","));return e}buildUrl(e){let t=`${n.baseUrl}/${this.state.table}`;if(e!==void 0)return`${t}/${e}`;let s=this.buildQueryParams().toString();return s?`${t}?${s}`:t}async get(){let e=this.buildUrl(),t=await fetch(e,{method:"GET",headers:await l()}),r=await u(t);return Array.isArray(r)?r:r.data}async first(){return this.limit(1),(await this.get())[0]??null}async firstOrFail(){let e=await this.first();if(!e)throw new g(`No ${this.state.table} found`,404);return e}async find(e){let t=this.buildUrl(e);try{let r=await fetch(t,{method:"GET",headers:await l()});if(r.status===404)return null;let s=await u(r);return"data"in s&&!Array.isArray(s.data)?s.data:s}catch{return null}}async findOrFail(e){let t=await this.find(e);if(!t)throw new g(`${this.state.table} with id ${e} not found`,404);return t}async count(){let e=this.buildQueryParams();e.append("count","true");let t=`${n.baseUrl}/${this.state.table}?${e.toString()}`,r=await fetch(t,{method:"GET",headers:await l()});return(await u(r)).count}async exists(){return await this.count()>0}async create(e){let t=`${n.baseUrl}/${this.state.table}`,r=n.transformRequest?n.transformRequest(e):e,s=await fetch(t,{method:"POST",headers:await l(),body:JSON.stringify(r)}),a=await u(s);return"data"in a&&!Array.isArray(a.data)?a.data:a}async insert(e){return this.create(e)}async update(e,t){let r=`${n.baseUrl}/${this.state.table}/${e}`,s=n.transformRequest?n.transformRequest(t):t,a=await fetch(r,{method:"PATCH",headers:await l(),body:JSON.stringify(s)}),i=await u(a);return"data"in i&&!Array.isArray(i.data)?i.data:i}async delete(e){let t=`${n.baseUrl}/${this.state.table}/${e}`;return(await fetch(t,{method:"DELETE",headers:await l()})).ok}async destroy(e){return this.delete(e)}async paginate(e=1,t=15){this.limit(t).offset((e-1)*t);let r=this.buildQueryParams();r.append("paginate","true");let s=`${n.baseUrl}/${this.state.table}?${r.toString()}`,a=await fetch(s,{method:"GET",headers:await l()});return u(a)}toState(){return{...this.state}}}function Xe(e){return new Ye(e)}function rn(){return new Proxy({},{get:(e,t)=>()=>Xe(t)})}class h{_attributes;_definition;constructor(e,t={}){this._definition=e,this._attributes={...t}}get(e){return this._attributes[e]}set(e,t){this._attributes[e]=t}get attributes(){return{...this._attributes}}get id(){let e=this._definition.primaryKey||"id";return this._attributes[e]}toJSON(){let e=new Set;for(let[r,s]of Object.entries(this._definition.attributes))if(s.hidden)e.add(r);let t={};for(let[r,s]of Object.entries(this._attributes))if(!e.has(r))t[r]=s;return t}}class o{_definition;_wheres=[];_orderBy=[];_limit;_offset;_select=["*"];_withRelations=[];constructor(e){this._definition=e}getTablePath(){return typeof this._definition.traits?.useApi==="object"&&this._definition.traits.useApi?.uri||this._definition.table}where(e,t,r){if(r===void 0)this._wheres.push({column:e,operator:"=",value:t,boolean:"and"});else this._wheres.push({column:e,operator:t,value:r,boolean:"and"});return this}orWhere(e,t,r){throw TypeError("[browser] orWhere() is not supported by this client. The query-param format it builds has no spelling for a disjunction, so the term would be sent as a plain filter and the server would read it as AND \u2014 silently returning a superset of the rows you asked for. Express the alternatives as a single filter (whereIn), or issue one request per branch and merge the results.")}whereIn(e,t){return this._wheres.push({column:e,operator:"in",value:t,boolean:"and"}),this}whereNotIn(e,t){return this._wheres.push({column:e,operator:"not in",value:t,boolean:"and"}),this}whereNull(e){return this._wheres.push({column:e,operator:"is",value:null,boolean:"and"}),this}whereNotNull(e){return this._wheres.push({column:e,operator:"is not",value:null,boolean:"and"}),this}whereLike(e,t){return this._wheres.push({column:e,operator:"like",value:t,boolean:"and"}),this}orderBy(e,t="asc"){return this._orderBy.push({column:e,direction:t}),this}orderByDesc(e){return this.orderBy(e,"desc")}orderByAsc(e){return this.orderBy(e,"asc")}limit(e){return this._limit=e,this}take(e){return this.limit(e)}offset(e){return this._offset=e,this}skip(e){return this.offset(e)}select(...e){return this._select=e,this}with(...e){return this._withRelations.push(...e),this}latest(e="created_at"){return this.orderByDesc(e)}oldest(e="created_at"){return this.orderByAsc(e)}buildQueryParams(){let e=new URLSearchParams;for(let t of this._wheres)if(t.operator==="=")e.append(t.column,String(t.value));else if(t.operator==="in"&&Array.isArray(t.value))e.append(`${t.column}[]`,t.value.join(","));else if(t.operator==="is"&&t.value===null)e.append(`filter[${t.column}][is]`,"null");else if(t.operator==="is not"&&t.value===null)e.append(`filter[${t.column}][is_not]`,"null");else e.append(`filter[${t.column}][${t.operator}]`,String(t.value));if(this._orderBy.length>0){let t=this._orderBy.map((r)=>`${r.direction==="desc"?"-":""}${r.column}`).join(",");e.append("sort",t)}if(this._limit!==void 0)e.append("limit",String(this._limit));if(this._offset!==void 0)e.append("offset",String(this._offset));if(this._select.length>0&&!this._select.includes("*"))e.append("fields",this._select.join(","));if(this._withRelations.length>0)e.append("include",this._withRelations.join(","));return e}buildUrl(e){let t=`${n.baseUrl}/${this.getTablePath()}`;if(e!==void 0)return`${t}/${e}`;let s=this.buildQueryParams().toString();return s?`${t}?${s}`:t}async get(){let e=this.buildUrl(),t=await fetch(e,{method:"GET",headers:await l()}),r=await u(t);return(Array.isArray(r)?r:r.data).map((a)=>new h(this._definition,a))}async first(){return this._limit=1,(await this.get())[0]??null}async firstOrFail(){let e=await this.first();if(!e)throw new g(`No ${this._definition.name} found`,404);return e}async find(e){let t=this.buildUrl(e);try{let r=await fetch(t,{method:"GET",headers:await l()});if(r.status===404)return null;let s=await u(r),a="data"in s&&!Array.isArray(s.data)?s.data:s;return new h(this._definition,a)}catch{return null}}async findOrFail(e){let t=await this.find(e);if(!t)throw new g(`${this._definition.name} with id ${e} not found`,404);return t}async count(){let e=this.buildQueryParams();e.append("count","true");let t=`${n.baseUrl}/${this.getTablePath()}?${e.toString()}`,r=await fetch(t,{method:"GET",headers:await l()});return(await u(r)).count}async exists(){return await this.count()>0}async pluck(e){return this._select=[e],(await this.get()).map((r)=>r.get(e))}async paginate(e=1,t=15){this._limit=t,this._offset=(e-1)*t;let r=this.buildQueryParams();r.append("paginate","true");let s=`${n.baseUrl}/${this.getTablePath()}?${r.toString()}`,a=await fetch(s,{method:"GET",headers:await l()}),i=await u(a);return{...i,data:i.data.map((d)=>new h(this._definition,d))}}}function Le(e){return new Proxy({query:()=>new o(e),where(r,s,a){return new o(e).where(r,s,a)},orWhere(r,s,a){return new o(e).orWhere(r,s,a)},whereIn(r,s){return new o(e).whereIn(r,s)},whereNotIn(r,s){return new o(e).whereNotIn(r,s)},whereNull(r){return new o(e).whereNull(r)},whereNotNull(r){return new o(e).whereNotNull(r)},whereLike(r,s){return new o(e).whereLike(r,s)},orderBy(r,s="asc"){return new o(e).orderBy(r,s)},orderByDesc(r){return new o(e).orderByDesc(r)},select(...r){return new o(e).select(...r)},limit:(r)=>new o(e).limit(r),take:(r)=>new o(e).take(r),skip:(r)=>new o(e).skip(r),latest:(r="created_at")=>new o(e).latest(r),oldest:(r="created_at")=>new o(e).oldest(r),async find(r){return new o(e).find(r)},async findOrFail(r){return new o(e).findOrFail(r)},async all(){return new o(e).get()},async first(){return new o(e).first()},async firstOrFail(){return new o(e).firstOrFail()},async count(){return new o(e).count()},async exists(){return new o(e).exists()},async paginate(r,s){return new o(e).paginate(r,s)},async pluck(r){return new o(e).pluck(r)},async create(r){let s=typeof e.traits?.useApi==="object"&&e.traits.useApi?.uri||e.table,a=`${n.baseUrl}/${s}`,i=n.transformRequest?n.transformRequest(r):r,d=await fetch(a,{method:"POST",headers:await l(),body:JSON.stringify(i)}),c=await u(d),f="data"in c&&!Array.isArray(c.data)?c.data:c;return new h(e,f)},async update(r,s){let a=typeof e.traits?.useApi==="object"&&e.traits.useApi?.uri||e.table,i=`${n.baseUrl}/${a}/${r}`,d=n.transformRequest?n.transformRequest(s):s,c=await fetch(i,{method:"PATCH",headers:await l(),body:JSON.stringify(d)}),f=await u(c),y="data"in f&&!Array.isArray(f.data)?f.data:f;return new h(e,y)},async delete(r){let s=typeof e.traits?.useApi==="object"&&e.traits.useApi?.uri||e.table,a=`${n.baseUrl}/${s}/${r}`;return(await fetch(a,{method:"DELETE",headers:await l()})).ok},async destroy(r){return this.delete(r)},getDefinition:()=>e,getTable:()=>e.table},{get(r,s){if(typeof s==="string"&&s.startsWith("where")&&s.length>5){let a=s.slice(5),i=a.charAt(0).toLowerCase()+a.slice(1);if(i in e.attributes||i==="id"||i===e.primaryKey)return(d)=>new o(e).where(i,d)}return Reflect.get(r,s)}})}var sn={async login(e){let t=await fetch(`${n.baseUrl}/login`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...n.headers},body:JSON.stringify(e)});if(!t.ok){let a=await t.json().catch(()=>({message:"Login failed"}));throw new g(a.message||"Login failed",t.status)}let r=await t.json(),s=r.data||r;if(typeof localStorage<"u"&&s.token)localStorage.setItem("auth_token",s.token);return s},async register(e){let t=await fetch(`${n.baseUrl}/register`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...n.headers},body:JSON.stringify(e)});if(!t.ok){let a=await t.json().catch(()=>({message:"Registration failed"}));throw new g(a.message||"Registration failed",t.status)}let r=await t.json(),s=r.data||r;if(typeof localStorage<"u"&&s.token)localStorage.setItem("auth_token",s.token);return s},async logout(){if(await w())try{await fetch(`${n.baseUrl}/logout`,{method:"POST",headers:await l()})}catch{}if(typeof localStorage<"u")localStorage.removeItem("auth_token")},async user(){if(!await w())return null;try{let t=await fetch(`${n.baseUrl}/user`,{method:"GET",headers:await l()});if(t.status===401)return n.onUnauthorized?.(),null;if(!t.ok)return null;let r=await t.json();return r.user||r}catch{return null}},async check(){return await this.user()!==null},getToken:w},kn=Xe;
|
|
3
|
-
export{
|
|
2
|
+
var n={baseUrl:""};function fn(e){n={...n,...e}}function mn(){return n}function hn(){return typeof window<"u"&&typeof document<"u"}async function w(){if(n.getToken){let e=n.getToken();return e instanceof Promise?e:e}if(typeof localStorage<"u")return localStorage.getItem("auth_token");return null}async function l(){let e={"Content-Type":"application/json",Accept:"application/json",...n.headers},t=await w();if(t)e.Authorization=`Bearer ${t}`;return e}async function u(e){if(e.status===401)throw n.onUnauthorized?.(),new p("Unauthorized",401);if(!e.ok){let r=await e.json().catch(()=>({message:"Request failed"}));throw new p(r.message||`HTTP ${e.status}`,e.status)}let t=await e.json();if(n.transformResponse)return n.transformResponse(t);return t}class p extends Error{status;constructor(e,t){super(e);this.name="BrowserQueryError",this.status=t}}class rt{state;constructor(e){this.state={table:e,wheres:[],orderBy:[],selectColumns:["*"],withRelations:[]}}select(...e){return this.state.selectColumns=e,this}where(e,t,r){if(r===void 0)this.state.wheres.push({column:e,operator:"=",value:t,boolean:"and"});else this.state.wheres.push({column:e,operator:t,value:r,boolean:"and"});return this}orWhere(e,t,r){throw TypeError("[browser] orWhere() is not supported by this client. The query-param format it builds has no spelling for a disjunction, so the term would be sent as a plain filter and the server would read it as AND \u2014 silently returning a superset of the rows you asked for. Express the alternatives as a single filter (whereIn), or issue one request per branch and merge the results.")}andWhere(e,t,r){return r===void 0?this.where(e,t):this.where(e,t,r)}whereNull(e){return this.where(e,"is",null)}whereNotNull(e){return this.where(e,"is not",null)}whereIn(e,t){return this.where(e,"in",t)}whereNotIn(e,t){return this.where(e,"not in",t)}orderBy(e,t="asc"){return this.state.orderBy.push({column:e,direction:t}),this}orderByDesc(e){return this.orderBy(e,"desc")}latest(e="created_at"){return this.orderBy(e,"desc")}oldest(e="created_at"){return this.orderBy(e,"asc")}limit(e){return this.state.limitValue=e,this}offset(e){return this.state.offsetValue=e,this}skip(e){return this.offset(e)}take(e){return this.limit(e)}with(...e){return this.state.withRelations.push(...e),this}buildQueryParams(){let e=new URLSearchParams;for(let t of this.state.wheres)if(t.operator==="=")e.append(t.column,String(t.value));else if(t.operator==="in"&&Array.isArray(t.value))e.append(`${t.column}[]`,t.value.join(","));else if(t.operator==="is"&&t.value===null)e.append(`filter[${t.column}][is]`,"null");else if(t.operator==="is not"&&t.value===null)e.append(`filter[${t.column}][is_not]`,"null");else e.append(`filter[${t.column}][${t.operator}]`,String(t.value));if(this.state.orderBy.length>0){let t=this.state.orderBy.map((r)=>`${r.direction==="desc"?"-":""}${r.column}`).join(",");e.append("sort",t)}if(this.state.limitValue!==void 0)e.append("limit",String(this.state.limitValue));if(this.state.offsetValue!==void 0)e.append("offset",String(this.state.offsetValue));if(this.state.selectColumns.length>0&&!this.state.selectColumns.includes("*"))e.append("fields",this.state.selectColumns.join(","));if(this.state.withRelations.length>0)e.append("include",this.state.withRelations.join(","));return e}buildUrl(e){let t=`${n.baseUrl}/${this.state.table}`;if(e!==void 0)return`${t}/${e}`;let s=this.buildQueryParams().toString();return s?`${t}?${s}`:t}async get(){let e=this.buildUrl(),t=await fetch(e,{method:"GET",headers:await l()}),r=await u(t);return Array.isArray(r)?r:r.data}async first(){return this.limit(1),(await this.get())[0]??null}async firstOrFail(){let e=await this.first();if(!e)throw new p(`No ${this.state.table} found`,404);return e}async find(e){let t=this.buildUrl(e);try{let r=await fetch(t,{method:"GET",headers:await l()});if(r.status===404)return null;let s=await u(r);return"data"in s&&!Array.isArray(s.data)?s.data:s}catch{return null}}async findOrFail(e){let t=await this.find(e);if(!t)throw new p(`${this.state.table} with id ${e} not found`,404);return t}async count(){let e=this.buildQueryParams();e.append("count","true");let t=`${n.baseUrl}/${this.state.table}?${e.toString()}`,r=await fetch(t,{method:"GET",headers:await l()});return(await u(r)).count}async exists(){return await this.count()>0}async create(e){let t=`${n.baseUrl}/${this.state.table}`,r=n.transformRequest?n.transformRequest(e):e,s=await fetch(t,{method:"POST",headers:await l(),body:JSON.stringify(r)}),a=await u(s);return"data"in a&&!Array.isArray(a.data)?a.data:a}async insert(e){return this.create(e)}async update(e,t){let r=`${n.baseUrl}/${this.state.table}/${e}`,s=n.transformRequest?n.transformRequest(t):t,a=await fetch(r,{method:"PATCH",headers:await l(),body:JSON.stringify(s)}),i=await u(a);return"data"in i&&!Array.isArray(i.data)?i.data:i}async delete(e){let t=`${n.baseUrl}/${this.state.table}/${e}`;return(await fetch(t,{method:"DELETE",headers:await l()})).ok}async destroy(e){return this.delete(e)}async paginate(e=1,t=15){this.limit(t).offset((e-1)*t);let r=this.buildQueryParams();r.append("paginate","true");let s=`${n.baseUrl}/${this.state.table}?${r.toString()}`,a=await fetch(s,{method:"GET",headers:await l()});return u(a)}toState(){return{...this.state}}}function it(e){return new rt(e)}function gn(){return new Proxy({},{get:(e,t)=>()=>it(t)})}class h{_attributes;_definition;constructor(e,t={}){this._definition=e,this._attributes={...t}}get(e){return this._attributes[e]}set(e,t){this._attributes[e]=t}get attributes(){return{...this._attributes}}get id(){let e=this._definition.primaryKey||"id";return this._attributes[e]}toJSON(){let e=new Set;for(let[r,s]of Object.entries(this._definition.attributes))if(s.hidden)e.add(r);let t={};for(let[r,s]of Object.entries(this._attributes))if(!e.has(r))t[r]=s;return t}}class o{_definition;_wheres=[];_orderBy=[];_limit;_offset;_select=["*"];_withRelations=[];constructor(e){this._definition=e}getTablePath(){return typeof this._definition.traits?.useApi==="object"&&this._definition.traits.useApi?.uri||this._definition.table}where(e,t,r){if(r===void 0)this._wheres.push({column:e,operator:"=",value:t,boolean:"and"});else this._wheres.push({column:e,operator:t,value:r,boolean:"and"});return this}orWhere(e,t,r){throw TypeError("[browser] orWhere() is not supported by this client. The query-param format it builds has no spelling for a disjunction, so the term would be sent as a plain filter and the server would read it as AND \u2014 silently returning a superset of the rows you asked for. Express the alternatives as a single filter (whereIn), or issue one request per branch and merge the results.")}whereIn(e,t){return this._wheres.push({column:e,operator:"in",value:t,boolean:"and"}),this}whereNotIn(e,t){return this._wheres.push({column:e,operator:"not in",value:t,boolean:"and"}),this}whereNull(e){return this._wheres.push({column:e,operator:"is",value:null,boolean:"and"}),this}whereNotNull(e){return this._wheres.push({column:e,operator:"is not",value:null,boolean:"and"}),this}whereLike(e,t){return this._wheres.push({column:e,operator:"like",value:t,boolean:"and"}),this}orderBy(e,t="asc"){return this._orderBy.push({column:e,direction:t}),this}orderByDesc(e){return this.orderBy(e,"desc")}orderByAsc(e){return this.orderBy(e,"asc")}limit(e){return this._limit=e,this}take(e){return this.limit(e)}offset(e){return this._offset=e,this}skip(e){return this.offset(e)}select(...e){return this._select=e,this}with(...e){return this._withRelations.push(...e),this}latest(e="created_at"){return this.orderByDesc(e)}oldest(e="created_at"){return this.orderByAsc(e)}buildQueryParams(){let e=new URLSearchParams;for(let t of this._wheres)if(t.operator==="=")e.append(t.column,String(t.value));else if(t.operator==="in"&&Array.isArray(t.value))e.append(`${t.column}[]`,t.value.join(","));else if(t.operator==="is"&&t.value===null)e.append(`filter[${t.column}][is]`,"null");else if(t.operator==="is not"&&t.value===null)e.append(`filter[${t.column}][is_not]`,"null");else e.append(`filter[${t.column}][${t.operator}]`,String(t.value));if(this._orderBy.length>0){let t=this._orderBy.map((r)=>`${r.direction==="desc"?"-":""}${r.column}`).join(",");e.append("sort",t)}if(this._limit!==void 0)e.append("limit",String(this._limit));if(this._offset!==void 0)e.append("offset",String(this._offset));if(this._select.length>0&&!this._select.includes("*"))e.append("fields",this._select.join(","));if(this._withRelations.length>0)e.append("include",this._withRelations.join(","));return e}buildUrl(e){let t=`${n.baseUrl}/${this.getTablePath()}`;if(e!==void 0)return`${t}/${e}`;let s=this.buildQueryParams().toString();return s?`${t}?${s}`:t}async get(){let e=this.buildUrl(),t=await fetch(e,{method:"GET",headers:await l()}),r=await u(t);return(Array.isArray(r)?r:r.data).map((a)=>new h(this._definition,a))}async first(){return this._limit=1,(await this.get())[0]??null}async firstOrFail(){let e=await this.first();if(!e)throw new p(`No ${this._definition.name} found`,404);return e}async find(e){let t=this.buildUrl(e);try{let r=await fetch(t,{method:"GET",headers:await l()});if(r.status===404)return null;let s=await u(r),a="data"in s&&!Array.isArray(s.data)?s.data:s;return new h(this._definition,a)}catch{return null}}async findOrFail(e){let t=await this.find(e);if(!t)throw new p(`${this._definition.name} with id ${e} not found`,404);return t}async count(){let e=this.buildQueryParams();e.append("count","true");let t=`${n.baseUrl}/${this.getTablePath()}?${e.toString()}`,r=await fetch(t,{method:"GET",headers:await l()});return(await u(r)).count}async exists(){return await this.count()>0}async pluck(e){return this._select=[e],(await this.get()).map((r)=>r.get(e))}async paginate(e=1,t=15){this._limit=t,this._offset=(e-1)*t;let r=this.buildQueryParams();r.append("paginate","true");let s=`${n.baseUrl}/${this.getTablePath()}?${r.toString()}`,a=await fetch(s,{method:"GET",headers:await l()}),i=await u(a);return{...i,data:i.data.map((d)=>new h(this._definition,d))}}}function qe(e){return new Proxy({query:()=>new o(e),where(r,s,a){return new o(e).where(r,s,a)},orWhere(r,s,a){return new o(e).orWhere(r,s,a)},whereIn(r,s){return new o(e).whereIn(r,s)},whereNotIn(r,s){return new o(e).whereNotIn(r,s)},whereNull(r){return new o(e).whereNull(r)},whereNotNull(r){return new o(e).whereNotNull(r)},whereLike(r,s){return new o(e).whereLike(r,s)},orderBy(r,s="asc"){return new o(e).orderBy(r,s)},orderByDesc(r){return new o(e).orderByDesc(r)},select(...r){return new o(e).select(...r)},limit:(r)=>new o(e).limit(r),take:(r)=>new o(e).take(r),skip:(r)=>new o(e).skip(r),latest:(r="created_at")=>new o(e).latest(r),oldest:(r="created_at")=>new o(e).oldest(r),async find(r){return new o(e).find(r)},async findOrFail(r){return new o(e).findOrFail(r)},async all(){return new o(e).get()},async first(){return new o(e).first()},async firstOrFail(){return new o(e).firstOrFail()},async count(){return new o(e).count()},async exists(){return new o(e).exists()},async paginate(r,s){return new o(e).paginate(r,s)},async pluck(r){return new o(e).pluck(r)},async create(r){let s=typeof e.traits?.useApi==="object"&&e.traits.useApi?.uri||e.table,a=`${n.baseUrl}/${s}`,i=n.transformRequest?n.transformRequest(r):r,d=await fetch(a,{method:"POST",headers:await l(),body:JSON.stringify(i)}),c=await u(d),f="data"in c&&!Array.isArray(c.data)?c.data:c;return new h(e,f)},async update(r,s){let a=typeof e.traits?.useApi==="object"&&e.traits.useApi?.uri||e.table,i=`${n.baseUrl}/${a}/${r}`,d=n.transformRequest?n.transformRequest(s):s,c=await fetch(i,{method:"PATCH",headers:await l(),body:JSON.stringify(d)}),f=await u(c),y="data"in f&&!Array.isArray(f.data)?f.data:f;return new h(e,y)},async delete(r){let s=typeof e.traits?.useApi==="object"&&e.traits.useApi?.uri||e.table,a=`${n.baseUrl}/${s}/${r}`;return(await fetch(a,{method:"DELETE",headers:await l()})).ok},async destroy(r){return this.delete(r)},getDefinition:()=>e,getTable:()=>e.table},{get(r,s){if(typeof s==="string"&&s.startsWith("where")&&s.length>5){let a=s.slice(5),i=a.charAt(0).toLowerCase()+a.slice(1);if(i in e.attributes||i==="id"||i===e.primaryKey)return(d)=>new o(e).where(i,d)}return Reflect.get(r,s)}})}var pn={async login(e){let t=await fetch(`${n.baseUrl}/login`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...n.headers},body:JSON.stringify(e)});if(!t.ok){let a=await t.json().catch(()=>({message:"Login failed"}));throw new p(a.message||"Login failed",t.status)}let r=await t.json(),s=r.data||r;if(typeof localStorage<"u"&&s.token)localStorage.setItem("auth_token",s.token);return s},async register(e){let t=await fetch(`${n.baseUrl}/register`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...n.headers},body:JSON.stringify(e)});if(!t.ok){let a=await t.json().catch(()=>({message:"Registration failed"}));throw new p(a.message||"Registration failed",t.status)}let r=await t.json(),s=r.data||r;if(typeof localStorage<"u"&&s.token)localStorage.setItem("auth_token",s.token);return s},async logout(){if(await w())try{await fetch(`${n.baseUrl}/logout`,{method:"POST",headers:await l()})}catch{}if(typeof localStorage<"u")localStorage.removeItem("auth_token")},async user(){if(!await w())return null;try{let t=await fetch(`${n.baseUrl}/user`,{method:"GET",headers:await l()});if(t.status===401)return n.onUnauthorized?.(),null;if(!t.ok)return null;let r=await t.json();return r.user||r}catch{return null}},async check(){return await this.user()!==null},getToken:w},Kn=it;
|
|
3
|
+
export{fn,mn,hn,p,rt,it,gn,qe,pn,Kn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xt,Zt,en,tn,nn,_t,rn,sn}from"./chunk-s66vynk9.js";import"./chunk-455vt4nn.js";import"./chunk-xk3qn91x.js";export{nn as clearModelRegistry,rn as defineModel,Zt as getAllModels,Xt as getModel,en as getModelRegistry,tn as hasModel,sn as registerBrowserModels,_t as registerModel};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { config } from './config';
|
|
2
|
-
import { resetConnection } from './db';
|
|
2
|
+
import { resetConnection, resolveLibSQLTarget } from './db';
|
|
3
3
|
import type { AnyDatabaseSchema } from './schema';
|
|
4
4
|
import type { DeferredInsert } from './sqlite-deferred-inserts';
|
|
5
5
|
import type { DriverConnection } from './db';
|
|
@@ -731,4 +731,4 @@ declare class QueryCache {
|
|
|
731
731
|
clear(): void;
|
|
732
732
|
setMaxSize(size: number): void;
|
|
733
733
|
}
|
|
734
|
-
export { resetConnection };
|
|
734
|
+
export { resetConnection, resolveLibSQLTarget };
|
package/dist/config.d.ts
CHANGED
|
@@ -70,6 +70,15 @@ declare function mergeObject(target: Record<string, unknown>, source: Record<str
|
|
|
70
70
|
* carried were unreachable.
|
|
71
71
|
*/
|
|
72
72
|
export declare function resolveDialect(explicit?: string | null): SupportedDialect;
|
|
73
|
+
/**
|
|
74
|
+
* Collapse a connection name onto the dialect whose SQL it speaks.
|
|
75
|
+
*
|
|
76
|
+
* `turso` and `libsql` are SQLite behind a network transport (see
|
|
77
|
+
* `src/libsql.ts`): they render SQLite SQL and are reached through
|
|
78
|
+
* `database.url`, so as a DIALECT they are `sqlite`. `DB_CONNECTION=turso`
|
|
79
|
+
* otherwise arrived here verbatim and every dialect switch fell through.
|
|
80
|
+
*/
|
|
81
|
+
export declare function normalizeDialectName(name: string): SupportedDialect;
|
|
73
82
|
/**
|
|
74
83
|
* Get the placeholder format for the current dialect.
|
|
75
84
|
* PostgreSQL uses $1, $2, $3... while MySQL and SQLite use ?
|
package/dist/db.d.ts
CHANGED
|
@@ -85,6 +85,16 @@ export declare function resolvePoolOptions(pool?: PoolConfig): {
|
|
|
85
85
|
* For SQLite, uses bun:sqlite directly for better compiled binary support.
|
|
86
86
|
* Handles connection errors gracefully by falling back to in-memory SQLite.
|
|
87
87
|
*/
|
|
88
|
+
/**
|
|
89
|
+
* The libSQL server a sqlite-dialect config points at, or null for a file.
|
|
90
|
+
*
|
|
91
|
+
* libSQL is SQLite's SQL behind a network transport, so it is selected by the
|
|
92
|
+
* URL rather than by a dialect of its own: every grammar branch keyed on
|
|
93
|
+
* `sqlite` stays correct, and only the connection differs. `database.url`
|
|
94
|
+
* is the documented place; a URL in `database.database` is accepted too,
|
|
95
|
+
* since that slot is the "where is it" field for sqlite.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveLibSQLTarget(dbConfig?: DatabaseConfig, dialect?: SupportedDialect): { url: string, authToken?: string } | null;
|
|
88
98
|
export declare function getBunSql(): SQL;
|
|
89
99
|
export declare function getOrCreateBunSql(forceNew?: boolean): SQL;
|
|
90
100
|
/**
|
package/dist/index.d.ts
CHANGED
package/dist/libsql.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { SQL } from 'bun';
|
|
2
|
+
/** True when a URL names a libSQL server rather than a local SQLite file. */
|
|
3
|
+
export declare function isLibSQLUrl(url: unknown): url is string;
|
|
4
|
+
/**
|
|
5
|
+
* Where the pipeline endpoint is, and the token a URL carried, if any.
|
|
6
|
+
*
|
|
7
|
+
* Exported for tests. The returned `baseUrl` has no credentials and no query
|
|
8
|
+
* string, so it is safe to put in an error message.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveLibSQLEndpoint(url: string): { baseUrl: string, authToken?: string };
|
|
11
|
+
/** Turn a statement-level Hrana error into a SQLite-shaped `LibSQLError`. */
|
|
12
|
+
export declare function toLibSQLError(error: HranaError): LibSQLError;
|
|
13
|
+
/**
|
|
14
|
+
* Encode one bound value for Hrana.
|
|
15
|
+
*
|
|
16
|
+
* Matches what `bun:sqlite` binds, with two deliberate differences, both of
|
|
17
|
+
* which turn silent data loss into something visible:
|
|
18
|
+
* - a `Date` is sent as its ISO-8601 string (`bun:sqlite` binds NULL);
|
|
19
|
+
* - any other object throws (`bun:sqlite` binds NULL).
|
|
20
|
+
*/
|
|
21
|
+
export declare function encodeLibSQLValue(value: unknown): HranaValue;
|
|
22
|
+
/** Decode one Hrana value into what `bun:sqlite` would have returned. */
|
|
23
|
+
export declare function decodeLibSQLValue(value: HranaValue, largeIntegers?: LibSQLLargeIntegerMode): unknown;
|
|
24
|
+
export declare function toLibSQLRows(result: HranaStatementResult, largeIntegers?: LibSQLLargeIntegerMode): LibSQLRows;
|
|
25
|
+
/** Build a Hrana statement, rewriting `$n` to SQLite's positional `?`. */
|
|
26
|
+
export declare function toHranaStatement(sql: string, params?: LibSQLParams): HranaStatement;
|
|
27
|
+
/**
|
|
28
|
+
* Build a connection to a libSQL server with the surface of Bun's `SQL`.
|
|
29
|
+
*
|
|
30
|
+
* Nothing is sent until the first query.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createLibSQLSQL(options: LibSQLConnectionOptions): SQL;
|
|
33
|
+
/** Whether a connection object was built by {@link createLibSQLSQL}. */
|
|
34
|
+
export declare function isLibSQLConnection(connection: unknown): boolean;
|
|
35
|
+
/** A statement as Hrana expects it. */
|
|
36
|
+
export declare interface HranaStatement {
|
|
37
|
+
sql: string
|
|
38
|
+
args?: HranaValue[]
|
|
39
|
+
named_args?: Array<{ name: string, value: HranaValue }>
|
|
40
|
+
want_rows?: boolean
|
|
41
|
+
}
|
|
42
|
+
declare interface HranaColumn {
|
|
43
|
+
name: string | null
|
|
44
|
+
decltype?: string | null
|
|
45
|
+
}
|
|
46
|
+
/** The result of one executed statement. */
|
|
47
|
+
export declare interface HranaStatementResult {
|
|
48
|
+
cols: HranaColumn[]
|
|
49
|
+
rows: HranaValue[][]
|
|
50
|
+
affected_row_count: number
|
|
51
|
+
last_insert_rowid: string | null
|
|
52
|
+
}
|
|
53
|
+
declare interface HranaError {
|
|
54
|
+
message: string
|
|
55
|
+
code?: string | null
|
|
56
|
+
}
|
|
57
|
+
declare interface HranaPipelineResponse {
|
|
58
|
+
baton: string | null
|
|
59
|
+
base_url: string | null
|
|
60
|
+
results: HranaStreamResult[]
|
|
61
|
+
}
|
|
62
|
+
export declare interface LibSQLConnectionOptions {
|
|
63
|
+
url: string
|
|
64
|
+
authToken?: string
|
|
65
|
+
timeoutMs?: number
|
|
66
|
+
largeIntegers?: LibSQLLargeIntegerMode
|
|
67
|
+
fetch?: typeof fetch
|
|
68
|
+
}
|
|
69
|
+
export declare interface LibSQLErrorDetails {
|
|
70
|
+
code: string
|
|
71
|
+
errno?: number
|
|
72
|
+
libsqlCode?: string
|
|
73
|
+
status?: number
|
|
74
|
+
cause?: unknown
|
|
75
|
+
}
|
|
76
|
+
/** One statement in a `batch()`. */
|
|
77
|
+
export declare interface LibSQLBatchStatement {
|
|
78
|
+
sql: string
|
|
79
|
+
args?: LibSQLParams
|
|
80
|
+
}
|
|
81
|
+
/** A Hrana value, as it appears on the wire. */
|
|
82
|
+
export type HranaValue = | { type: 'null' }
|
|
83
|
+
| { type: 'integer', value: string }
|
|
84
|
+
| { type: 'float', value: number }
|
|
85
|
+
| { type: 'text', value: string }
|
|
86
|
+
| { type: 'blob', base64: string }
|
|
87
|
+
declare type HranaRequest = | { type: 'execute', stmt: HranaStatement }
|
|
88
|
+
| { type: 'batch', batch: { steps: Array<{ stmt: HranaStatement, condition?: HranaCondition | null }> } }
|
|
89
|
+
| { type: 'get_autocommit' }
|
|
90
|
+
| { type: 'close' }
|
|
91
|
+
declare type HranaCondition = | { type: 'ok', step: number }
|
|
92
|
+
| { type: 'error', step: number }
|
|
93
|
+
| { type: 'not', cond: HranaCondition }
|
|
94
|
+
declare type HranaResponse = | { type: 'execute', result: HranaStatementResult }
|
|
95
|
+
| { type: 'batch', result: { step_results: Array<HranaStatementResult | null>, step_errors: Array<HranaError | null> } }
|
|
96
|
+
| { type: 'get_autocommit', is_autocommit: boolean }
|
|
97
|
+
| { type: 'close' }
|
|
98
|
+
declare type HranaStreamResult = | { type: 'ok', response: HranaResponse }
|
|
99
|
+
| { type: 'error', error: HranaError }
|
|
100
|
+
/** How integers beyond `Number.MAX_SAFE_INTEGER` are returned. */
|
|
101
|
+
export type LibSQLLargeIntegerMode = 'bigint' | 'string';
|
|
102
|
+
/**
|
|
103
|
+
* A query result in the shape the sqlite code paths read.
|
|
104
|
+
*
|
|
105
|
+
* Always an array of rows - empty for a statement that returns none - so a
|
|
106
|
+
* caller that destructures rows never gets a non-iterable. The write metadata
|
|
107
|
+
* rides along under every name a caller looks for it: `changes` and
|
|
108
|
+
* `lastInsertRowid` (bun:sqlite's `run()`), `count` (Bun's network drivers).
|
|
109
|
+
*/
|
|
110
|
+
export type LibSQLRows = Array<Record<string, unknown>> & {
|
|
111
|
+
changes: number
|
|
112
|
+
count: number
|
|
113
|
+
lastInsertRowid: number | bigint | string | null
|
|
114
|
+
columns: string[]
|
|
115
|
+
}
|
|
116
|
+
/** Positional or named parameters, as callers pass them. */
|
|
117
|
+
export type LibSQLParams = readonly unknown[] | Record<string, unknown>;
|
|
118
|
+
/**
|
|
119
|
+
* An error from a libSQL server or the transport to it.
|
|
120
|
+
*
|
|
121
|
+
* Carries `code`/`errno` in the shape `bun:sqlite`'s `SQLiteError` does, so a
|
|
122
|
+
* unique-violation check written for SQLite matches here too. Never carries
|
|
123
|
+
* the auth token: messages are built from the server's reply and the host.
|
|
124
|
+
*/
|
|
125
|
+
export declare class LibSQLError extends Error {
|
|
126
|
+
readonly code: string;
|
|
127
|
+
readonly errno?: number;
|
|
128
|
+
readonly libsqlCode?: string;
|
|
129
|
+
readonly status?: number;
|
|
130
|
+
constructor(message: string, details: LibSQLErrorDetails);
|
|
131
|
+
}
|
|
132
|
+
/** The HTTP side: one POST per pipeline, with transport errors made legible. */
|
|
133
|
+
declare class HranaHttp {
|
|
134
|
+
readonly baseUrl: string;
|
|
135
|
+
constructor(options: LibSQLConnectionOptions);
|
|
136
|
+
pipeline(baseUrl: string, baton: string | null, requests: HranaRequest[]): Promise<HranaPipelineResponse>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A server-side connection kept open across requests by its baton.
|
|
140
|
+
*
|
|
141
|
+
* A baton is good for exactly one request, so requests are chained: each waits
|
|
142
|
+
* for the previous reply. That also makes concurrent queries on one transaction
|
|
143
|
+
* handle safe - they queue instead of racing for the baton.
|
|
144
|
+
*/
|
|
145
|
+
declare class HranaStream {
|
|
146
|
+
closed: boolean;
|
|
147
|
+
constructor(http: HranaHttp, prelude: () => HranaRequest[]);
|
|
148
|
+
send(requests: HranaRequest[], options?: { close?: boolean }): Promise<HranaStreamResult[]>;
|
|
149
|
+
close(): Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Shared, per-connection state: the HTTP client, the session pragma, and the
|
|
153
|
+
* stream a raw BEGIN pinned the connection to.
|
|
154
|
+
*/
|
|
155
|
+
declare class LibSQLSession {
|
|
156
|
+
readonly http: HranaHttp;
|
|
157
|
+
readonly largeIntegers: LibSQLLargeIntegerMode;
|
|
158
|
+
foreignKeys: string | null;
|
|
159
|
+
pinned: HranaStream | null;
|
|
160
|
+
closed: boolean;
|
|
161
|
+
constructor(options: LibSQLConnectionOptions);
|
|
162
|
+
prelude: unknown;
|
|
163
|
+
openStream(): HranaStream;
|
|
164
|
+
assertOpen(): void;
|
|
165
|
+
rows(result: HranaStatementResult): LibSQLRows;
|
|
166
|
+
notePragma(sql: string): void;
|
|
167
|
+
execute(stmt: HranaStatement): Promise<LibSQLRows>;
|
|
168
|
+
close(): Promise<void>;
|
|
169
|
+
}
|
package/dist/src/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{fn,mn,hn,p,rt,it,gn,qe,pn,Kn}from"../chunk-xk3qn91x.js";export{rt as BrowserQueryBuilder,p as BrowserQueryError,pn as browserAuth,it as browserQuery,fn as configureBrowser,gn as createBrowserDb,qe as createBrowserModel,Kn as default,mn as getBrowserConfig,hn as isBrowser};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{J,x,kt,Qe,v,Ae,Ge,Je,Me,Ct,f,z,Ne,ze,Rt,Ye,zt,Yt}from"../../chunk-vxh8ktv7.js";export{J as DynamoDBClient,Ne as DynamoDBMigrationDriver,z as DynamoDBMigrationTracker,Ye as EntityQueryBuilder,f as MIGRATIONS_TABLE,Qe as Model,Me as buildDynamoDBMigrationPlan,kt as configureModels,Je as convertSchemaToDefinition,x as createClient,Yt as createDynamo,ze as createMigrationDriver,zt as dynamo,Ge as extractModelSchema,Ae as extractTableDefinition,v as hashTableDefinition,Ct as isDefinitionEqual,Rt as migrateModels};
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{X,Z,ee,te,I,ne,re,ie,se,L,ae,K,F,oe,le,j,ce,ue,st,We,at,C,de,o,fe,me,he,ge,h,ot,w,R,A,pe,ye,q,be,W,Te,U,V,M,H,we,Se,De,Ee,Q,$e,xe,S,g,yn,bn,Tn,lt,ct,ut,dt,ft,wn,mt,Wt,Sn,Dn,En,$n,ht,xn,vn,kn,ve,d,gt,pt,yt,bt,Tt,Ut,G,ke,Cn,Rn,wt,Ue,y,Ve,He,Vt,An,Ht,Mn,St,Dt,Et,Qt,Gt}from"../chunk-pa426cqs.js";import{E,Nn,Jt,c,$t,xt,i,Ce,Re}from"../chunk-r6myba29.js";import{vt,u,J,x,kt,Qe,v,Ae,Ge,Je,Me,Ct,f,z,Ne,ze,Rt,Ye,zt,Yt}from"../chunk-vxh8ktv7.js";import{At,Mt,Nt,Ot,On,Bn,Pn,Bt,Pt,_n,In,Xt,Zt,en,tn,nn,_t,rn,sn}from"../chunk-s66vynk9.js";import{n,Xe,e,B,Ze,t,s,P,Pe,an,et,on,a,_e,It,Lt,ln,Ie,Kt,Ln,Ft,jt,k,_,cn,Ke,T,un,dn,m,nt}from"../chunk-455vt4nn.js";import{fn,mn,hn,p,rt,it,gn,qe,pn}from"../chunk-xk3qn91x.js";export{Bt as BelongsToManyRelationBuilder,rt as BrowserQueryBuilder,p as BrowserQueryError,Ft as DEFAULT_SQLITE_PRAGMAS,J as DynamoDBClient,vt as DynamoDBDriverImpl,g as DynamoDBItemBuilder,Ne as DynamoDBMigrationDriver,z as DynamoDBMigrationTracker,S as DynamoDBQueryBuilder,ht as DynamoDBToolingAdapter,Ye as EntityQueryBuilder,yt as GENERATED_MARKER,a as LibSQLError,f as MIGRATIONS_TABLE,Qe as Model,o as MySQLDriver,fe as PostgresDriver,ge as SQLiteDriver,Ht as Seeder,me as SingleStoreDriver,lt as SingleTableManager,wn as SingleTablePatterns,ut as SingleTableQueryBuilder,ct as SingleTableRepository,y as UTC_CLOCK_DEFAULT,he as VitessDriver,k as applySqliteBootstrapPragmas,Qt as auditSchemaDrift,pn as browserAuth,it as browserQuery,ve as buildDatabaseSchema,Me as buildDynamoDBMigrationPlan,G as buildMigrationPlan,gt as buildSchemaMeta,Z as cacheClear,te as cacheConfig,ee as cacheStats,Ue as canonicalStorageType,Ve as canonicalizeDefault,$e as checkSchema,Mt as clearLocalModels,nn as clearModelRegistry,Ce as clearQueryCache,e as config,fn as configureBrowser,kt as configureModels,On as configureOrm,Je as convertSchemaToDefinition,gn as createBrowserDb,qe as createBrowserModel,x as createClient,Yt as createDynamo,Tn as createDynamoDBClient,u as createDynamoDBDriver,bn as createDynamoDBItemBuilder,yn as createDynamoDBQueryBuilder,xn as createDynamoDBToolingAdapter,At as createFakerCompatLayer,Kt as createLibSQLSQL,ze as createMigrationDriver,Pt as createModel,i as createQueryBuilder,ft as createRepository,dt as createSingleTableManager,_n as createTableFromModel,L as dbInfo,K as dbOptimize,ae as dbStats,F as dbWipe,Lt as decodeLibSQLValue,Xe as defaultConfig,an as defineConfig,rn as defineModel,An as defineModels,Mn as defineSeeder,se as dumpDatabase,zt as dynamo,It as encodeLibSQLValue,xt as escapeStringLiteral,R as executeMigration,oe as explain,U as explainAllQueries,re as exportData,Nt as extractChanges,Ot as extractInsertId,Ge as extractModelSchema,Ae as extractTableDefinition,St as familyOfDeclared,Dt as familyOfSqlType,le as file,Gt as formatSchemaDrift,Se as freshDatabase,vn as generateAccessPatterns,V as generateDiagram,He as generateDiffOperations,Vt as generateDiffSql,Rn as generateDiffSqlString,w as generateMigration,at as generateModelSource,ke as generateSql,Cn as generateSqlString,Zt as getAllModels,mn as getBrowserConfig,P as getConfig,Pn as getDatabase,h as getDialectDriver,Xt as getModel,en as getModelRegistry,t as getPlaceholder,s as getPlaceholders,tn as hasModel,wt as hashMigrationPlan,v as hashTableDefinition,ie as importData,dn as inflectSingular,j as inspectTable,ue as introspect,C as introspectDatabase,hn as isBrowser,Ct as isDefinitionEqual,bt as isGeneratedMigrationSql,Ln as isLibSQLConnection,et as isLibSQLUrl,Ut as isLosslessTypeChange,n as isMysqlLike,Nn as iterateAllPivots,pt as lastCreatedMigrationFiles,d as loadModels,de as makeModel,we as makeSeeder,En as marshallObject,pe as migrateGenerate,be as migrateList,Rt as migrateModels,ye as migrateRollback,q as migrateStatus,Tt as migrationBody,We as modelNameForTable,W as modelShow,Ze as normalizeDialectName,K as optimizeDatabase,Wt as parseStacksModels,Te as ping,U as queryExplainAll,c as quoteColumnForDialect,Jt as raw,sn as registerBrowserModels,_t as registerModel,V as relationDiagram,Bn as releaseOrm,cn as resetConnection,A as resetDatabase,B as resolveDialect,mt as resolveKeyPattern,on as resolveLibSQLEndpoint,_ as resolveLibSQLTarget,E as resolvePivot,jt as resolveSqlitePragmas,X as runBenchmark,H as runSeeder,M as runSeeders,Et as satisfies,ot as saveMigrationSnapshot,In as seedModel,Pe as setConfig,Re as setQueryCacheMaxSize,W as showModel,m as singularizerFor,De as sql,st as sqlTypeToAttr,kn as stacksModelToEntity,I as startConsole,un as stripTrailingS,ce as tableInfo,T as tableNameFor,$t as temporalLiteral,ne as tinker,nt as toDialectPlaceholders,Sn as toDynamoDBItem,Ie as toHranaStatement,_e as toLibSQLError,ln as toLibSQLRows,Dn as toModelInstance,Ke as toTableName,$n as unmarshallItem,Ee as unsafe,Q as validateSchema,xe as waitReady,F as wipeDatabase};
|
package/dist/src/runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{n,
|
|
2
|
+
import{n,Xe,e,B,Ze,t,s,P,Pe,an,Ft,jt,k,_,cn}from"../chunk-455vt4nn.js";import{Jt,c,$t,xt,i,Ce,Re}from"../chunk-r6myba29.js";export{Ft as DEFAULT_SQLITE_PRAGMAS,k as applySqliteBootstrapPragmas,Ce as clearQueryCache,e as config,i as createQueryBuilder,Xe as defaultConfig,an as defineConfig,xt as escapeStringLiteral,P as getConfig,t as getPlaceholder,s as getPlaceholders,n as isMysqlLike,Ze as normalizeDialectName,c as quoteColumnForDialect,Jt as raw,cn as resetConnection,B as resolveDialect,_ as resolveLibSQLTarget,jt as resolveSqlitePragmas,Pe as setConfig,Re as setQueryCacheMaxSize,$t as temporalLiteral};
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED