@omer-x/buttler 1.3.3 → 1.3.4
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/package.json +1 -1
- package/ui/.next/BUILD_ID +1 -1
- package/ui/.next/app-build-manifest.json +7 -7
- package/ui/.next/app-path-routes-manifest.json +1 -1
- package/ui/.next/build-manifest.json +2 -2
- package/ui/.next/prerender-manifest.json +1 -1
- package/ui/.next/server/app/_not-found.html +1 -1
- package/ui/.next/server/app/_not-found.rsc +1 -1
- package/ui/.next/server/app/api/db/backup/route.js +1 -1
- package/ui/.next/server/app/index.html +1 -1
- package/ui/.next/server/app/index.rsc +1 -1
- package/ui/.next/server/app/services/[id]/databases/page.js +1 -1
- package/ui/.next/server/app/services/[id]/edit/page.js +1 -1
- package/ui/.next/server/app/services/[id]/networks/page.js +1 -1
- package/ui/.next/server/app/services/[id]/page.js +1 -1
- package/ui/.next/server/app/services/page.js +1 -1
- package/ui/.next/server/app/settings/page.js +1 -1
- package/ui/.next/server/app/settings.html +1 -1
- package/ui/.next/server/app/settings.rsc +3 -3
- package/ui/.next/server/app/webhook/route.js +1 -1
- package/ui/.next/server/app-paths-manifest.json +1 -1
- package/ui/.next/server/chunks/218.js +1 -1
- package/ui/.next/server/chunks/806.js +1 -1
- package/ui/.next/server/chunks/82.js +2 -2
- package/ui/.next/server/chunks/964.js +1 -1
- package/ui/.next/server/pages/404.html +1 -1
- package/ui/.next/server/pages/500.html +1 -1
- package/ui/.next/server/server-reference-manifest.js +1 -1
- package/ui/.next/server/server-reference-manifest.json +1 -1
- /package/ui/.next/static/{IifEZlDC1laLTspmZHpxY → Eb8kU-qZnUvDCvrt1p9AE}/_buildManifest.js +0 -0
- /package/ui/.next/static/{IifEZlDC1laLTspmZHpxY → Eb8kU-qZnUvDCvrt1p9AE}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";exports.id=806,exports.ids=[806],exports.modules={63703:(e,t,i)=>{i.d(t,{f:()=>em});var s=i(87550),r=i(77799);class n{static [r.i]="ConsoleLogWriter";write(e){console.log(e)}}class a{static [r.i]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new n}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}}class l{static [r.i]="NoopLogger";logQuery(){}}var o=i(23555),u=i(7078),d=i(83408),c=i(65258),h=i(18611);class f{constructor(e){this.table=e}static [r.i]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class m{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [r.i]="TableAliasProxyHandler";get(e,t){if(t===c.XI.Symbol.IsAlias)return!0;if(t===c.XI.Symbol.Name||this.replaceOriginalName&&t===c.XI.Symbol.OriginalName)return this.alias;if(t===h.n)return{...e[h.n],name:this.alias,isAlias:!0};if(t===c.XI.Symbol.Columns){let t=e[c.XI.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(s=>{i[s]=new Proxy(t[s],new f(new Proxy(e,this)))}),i}let i=e[t];return(0,r.is)(i,u.V)?new Proxy(i,new f(new Proxy(e,this))):i}}class p{constructor(e){this.alias=e}static [r.i]=null;get(e,t){return"sourceTable"===t?g(e.sourceTable,this.alias):e[t]}}function g(e,t){return new Proxy(e,new m(t,!1))}function y(e,t){return new Proxy(e,new f(new Proxy(e.table,new m(t,!1))))}function v(e,t){return new d.Xs.Aliased(b(e.sql,t),e.fieldAlias)}function b(e,t){return d.ll.join(e.queryChunks.map(e=>(0,r.is)(e,u.V)?y(e,t):(0,r.is)(e,d.Xs)?b(e,t):(0,r.is)(e,d.Xs.Aliased)?v(e,t):e))}var _=i(73322);class w{static [r.i]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===h.n)return{...e[h.n],selectedFields:new Proxy(e[h.n].selectedFields,this)};if("symbol"==typeof t)return e[t];let i=((0,r.is)(e,_.n)?e._.selectedFields:(0,r.is)(e,d.Ss)?e[h.n].selectedFields:e)[t];if((0,r.is)(i,d.Xs.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if((0,r.is)(i,d.Xs)){if("sql"===this.config.sqlBehavior)return i;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return(0,r.is)(i,u.V)?this.config.alias?new Proxy(i,new f(new Proxy(i.table,new m(this.config.alias,this.config.replaceOriginalName??!1)))):i:"object"!=typeof i||null===i?i:new Proxy(i,new w(this.config))}}function S(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function x(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,i)=>e+(0===i?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}function k(e){return e}class T{static [r.i]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?S:"camelCase"===e?x:k}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[c.XI.Symbol.Schema]??"public",i=e.table[c.XI.Symbol.OriginalName],s=`${t}.${i}.${e.name}`;return this.cache[s]||this.cacheTable(e.table),this.cache[s]}cacheTable(e){let t=e[c.XI.Symbol.Schema]??"public",i=e[c.XI.Symbol.OriginalName],s=`${t}.${i}`;if(!this.cachedTables[s]){for(let t of Object.values(e[c.XI.Symbol.Columns])){let e=`${s}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[s]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class N extends Error{static [r.i]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class C extends N{static [r.i]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}var $=i(47579),O=i(55251),j=i(21300),A=i(78199);class I extends d.Ss{static [r.i]="SQLiteViewBase"}class L{static [r.i]="SQLiteDialect";casing;constructor(e){this.casing=new T(e?.casing)}escapeName(e){return`"${e}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[(0,d.ll)`with `];for(let[i,s]of e.entries())t.push((0,d.ll)`${d.ll.identifier(s._.alias)} as (${s._.sql})`),i<e.length-1&&t.push((0,d.ll)`, `);return t.push((0,d.ll)` `),d.ll.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:s,limit:r,orderBy:n}){let a=this.buildWithCTE(s),l=i?(0,d.ll)` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,o=t?(0,d.ll)` where ${t}`:void 0,u=this.buildOrderBy(n),c=this.buildLimit(r);return(0,d.ll)`${a}delete from ${e}${o}${l}${u}${c}`}buildUpdateSet(e,t){let i=e[c.XI.Symbol.Columns],s=Object.keys(i).filter(e=>void 0!==t[e]||i[e]?.onUpdateFn!==void 0),r=s.length;return d.ll.join(s.flatMap((e,s)=>{let n=i[e],a=t[e]??d.ll.param(n.onUpdateFn(),n),l=(0,d.ll)`${d.ll.identifier(this.casing.getColumnCasing(n))} = ${a}`;return s<r-1?[l,d.ll.raw(", ")]:[l]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:r,joins:n,from:a,limit:l,orderBy:o}){let u=this.buildWithCTE(r),c=this.buildUpdateSet(e,t),h=a&&d.ll.join([d.ll.raw(" from "),this.buildFromTable(a)]),f=this.buildJoins(n),m=s?(0,d.ll)` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,p=i?(0,d.ll)` where ${i}`:void 0,g=this.buildOrderBy(o),y=this.buildLimit(l);return(0,d.ll)`${u}update ${e} set ${c}${h}${f}${p}${m}${g}${y}`}buildSelection(e,{isSingleTable:t=!1}={}){let i=e.length,s=e.flatMap(({field:e},s)=>{let n=[];if((0,r.is)(e,d.Xs.Aliased)&&e.isSelectionField)n.push(d.ll.identifier(e.fieldAlias));else if((0,r.is)(e,d.Xs.Aliased)||(0,r.is)(e,d.Xs)){let i=(0,r.is)(e,d.Xs.Aliased)?e.sql:e;t?n.push(new d.Xs(i.queryChunks.map(e=>(0,r.is)(e,u.V)?d.ll.identifier(this.casing.getColumnCasing(e)):e))):n.push(i),(0,r.is)(e,d.Xs.Aliased)&&n.push((0,d.ll)` as ${d.ll.identifier(e.fieldAlias)}`)}else if((0,r.is)(e,u.V)){let i=e.table[c.XI.Symbol.Name];t?n.push(d.ll.identifier(this.casing.getColumnCasing(e))):n.push((0,d.ll)`${d.ll.identifier(i)}.${d.ll.identifier(this.casing.getColumnCasing(e))}`)}return s<i-1&&n.push((0,d.ll)`, `),n});return d.ll.join(s)}buildJoins(e){if(!e||0===e.length)return;let t=[];if(e)for(let[i,s]of e.entries()){0===i&&t.push((0,d.ll)` `);let n=s.table;if((0,r.is)(n,j.jo)){let e=n[j.jo.Symbol.Name],i=n[j.jo.Symbol.Schema],r=n[j.jo.Symbol.OriginalName],a=e===r?void 0:s.alias;t.push((0,d.ll)`${d.ll.raw(s.joinType)} join ${i?(0,d.ll)`${d.ll.identifier(i)}.`:void 0}${d.ll.identifier(r)}${a&&(0,d.ll)` ${d.ll.identifier(a)}`} on ${s.on}`)}else t.push((0,d.ll)`${d.ll.raw(s.joinType)} join ${n} on ${s.on}`);i<e.length-1&&t.push((0,d.ll)` `)}return d.ll.join(t)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?(0,d.ll)` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push((0,d.ll)`, `);return t.length>0?(0,d.ll)` order by ${d.ll.join(t)}`:void 0}buildFromTable(e){return(0,r.is)(e,c.XI)&&e[c.XI.Symbol.OriginalName]!==e[c.XI.Symbol.Name]?(0,d.ll)`${d.ll.identifier(e[c.XI.Symbol.OriginalName])} ${d.ll.identifier(e[c.XI.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:s,having:n,table:a,joins:l,orderBy:o,groupBy:f,limit:m,offset:p,distinct:g,setOperators:y}){let v=i??(0,A.He)(t);for(let e of v){let t;if((0,r.is)(e.field,u.V)&&(0,c.Io)(e.field.table)!==((0,r.is)(a,_.n)?a._.alias:(0,r.is)(a,I)?a[h.n].name:(0,r.is)(a,d.Xs)?void 0:(0,c.Io)(a))&&(t=e.field.table,!l?.some(({alias:e})=>e===(t[c.XI.Symbol.IsAlias]?c.Io(t):t[c.XI.Symbol.BaseName])))){let t=(0,c.Io)(e.field.table);throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let b=!l||0===l.length,w=this.buildWithCTE(e),S=g?(0,d.ll)` distinct`:void 0,x=this.buildSelection(v,{isSingleTable:b}),k=this.buildFromTable(a),T=this.buildJoins(l),N=s?(0,d.ll)` where ${s}`:void 0,C=n?(0,d.ll)` having ${n}`:void 0,$=[];if(f)for(let[e,t]of f.entries())$.push(t),e<f.length-1&&$.push((0,d.ll)`, `);let O=$.length>0?(0,d.ll)` group by ${d.ll.join($)}`:void 0,j=this.buildOrderBy(o),L=this.buildLimit(m),Q=p?(0,d.ll)` offset ${p}`:void 0,q=(0,d.ll)`${w}select${S} ${x} from ${k}${T}${N}${O}${C}${j}${L}${Q}`;return y.length>0?this.buildSetOperations(q,y):q}buildSetOperations(e,t){let[i,...s]=t;if(!i)throw Error("Cannot pass undefined values to any set operator");return 0===s.length?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:i,rightSelect:s,limit:n,orderBy:a,offset:l}}){let o;let u=(0,d.ll)`${e.getSQL()} `,c=(0,d.ll)`${s.getSQL()}`;if(a&&a.length>0){let e=[];for(let t of a)if((0,r.is)(t,O.v))e.push(d.ll.identifier(t.name));else if((0,r.is)(t,d.Xs)){for(let e=0;e<t.queryChunks.length;e++){let i=t.queryChunks[e];(0,r.is)(i,O.v)&&(t.queryChunks[e]=d.ll.identifier(this.casing.getColumnCasing(i)))}e.push((0,d.ll)`${t}`)}else e.push((0,d.ll)`${t}`);o=(0,d.ll)` order by ${d.ll.join(e,(0,d.ll)`, `)}`}let h="object"==typeof n||"number"==typeof n&&n>=0?(0,d.ll)` limit ${n}`:void 0,f=d.ll.raw(`${t} ${i?"all ":""}`),m=l?(0,d.ll)` offset ${l}`:void 0;return(0,d.ll)`${u}${f}${c}${o}${h}${m}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:s,withList:n,select:a}){let l=[],o=Object.entries(e[c.XI.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),u=o.map(([,e])=>d.ll.identifier(this.casing.getColumnCasing(e)));if(a)(0,r.is)(t,d.Xs)?l.push(t):l.push(t.getSQL());else for(let[e,i]of(l.push(d.ll.raw("values ")),t.entries())){let s=[];for(let[e,t]of o){let n=i[e];if(void 0===n||(0,r.is)(n,d.Iw)&&void 0===n.value){let e;if(null!==t.default&&void 0!==t.default)e=(0,r.is)(t.default,d.Xs)?t.default:d.ll.param(t.default,t);else if(void 0!==t.defaultFn){let i=t.defaultFn();e=(0,r.is)(i,d.Xs)?i:d.ll.param(i,t)}else if(t.default||void 0===t.onUpdateFn)e=(0,d.ll)`null`;else{let i=t.onUpdateFn();e=(0,r.is)(i,d.Xs)?i:d.ll.param(i,t)}s.push(e)}else s.push(n)}l.push(s),e<t.length-1&&l.push((0,d.ll)`, `)}let h=this.buildWithCTE(n),f=d.ll.join(l),m=s?(0,d.ll)` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,p=i?(0,d.ll)` on conflict ${i}`:void 0;return(0,d.ll)`${h}insert into ${e} ${u} ${f}${p}${m}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:s,tableConfig:n,queryConfig:a,tableAlias:l,nestedQueryRelation:h,joinOn:f}){let m,p=[],w,S,x=[],k,T=[];if(!0===a)p=Object.entries(n.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:y(t,l),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let s=Object.fromEntries(Object.entries(n.columns).map(([e,t])=>[e,y(t,l)]));if(a.where){let e="function"==typeof a.where?a.where(s,(0,o.mm)()):a.where;k=e&&b(e,l)}let h=[],f=[];if(a.columns){let e=!1;for(let[t,i]of Object.entries(a.columns))void 0!==i&&t in n.columns&&(e||!0!==i||(e=!0),f.push(t));f.length>0&&(f=e?f.filter(e=>a.columns?.[e]===!0):Object.keys(n.columns).filter(e=>!f.includes(e)))}else f=Object.keys(n.columns);for(let e of f){let t=n.columns[e];h.push({tsKey:e,value:t})}let m=[];if(a.with&&(m=Object.entries(a.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:n.relations[e]}))),a.extras)for(let[e,t]of Object.entries("function"==typeof a.extras?a.extras(s,{sql:d.ll}):a.extras))h.push({tsKey:e,value:v(t,l)});for(let{tsKey:e,value:t}of h)p.push({dbKey:(0,r.is)(t,d.Xs.Aliased)?t.fieldAlias:n.columns[e].name,tsKey:e,field:(0,r.is)(t,u.V)?y(t,l):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let g="function"==typeof a.orderBy?a.orderBy(s,(0,o.rl)()):a.orderBy??[];for(let{tsKey:s,queryConfig:n,relation:h}of(Array.isArray(g)||(g=[g]),x=g.map(e=>(0,r.is)(e,u.V)?y(e,l):b(e,l)),w=a.limit,S=a.offset,m)){let a=(0,o.W0)(t,i,h),u=i[(0,c.Lf)(h.referencedTable)],f=`${l}_${s}`,m=(0,$.Uo)(...a.fields.map((e,t)=>(0,$.eq)(y(a.references[t],f),y(e,l)))),g=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[u],tableConfig:t[u],queryConfig:(0,r.is)(h,o.pD)?!0===n?{limit:1}:{...n,limit:1}:n,tableAlias:f,joinOn:m,nestedQueryRelation:h}),v=(0,d.ll)`(${g.sql})`.as(s);p.push({dbKey:s,tsKey:s,field:v,relationTableTsKey:u,isJson:!0,selection:g.selection})}}if(0===p.length)throw new N({message:`No fields selected for table "${n.tsName}" ("${l}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});if(k=(0,$.Uo)(f,k),h){let e=(0,d.ll)`json_array(${d.ll.join(p.map(({field:e})=>(0,r.is)(e,O.v)?d.ll.identifier(this.casing.getColumnCasing(e)):(0,r.is)(e,d.Xs.Aliased)?e.sql:e),(0,d.ll)`, `)})`;(0,r.is)(h,o.iv)&&(e=(0,d.ll)`coalesce(json_group_array(${e}), json_array())`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:n.tsName,selection:p}];void 0!==w||void 0!==S||x.length>0?(m=this.buildSelectQuery({table:g(s,l),fields:{},fieldsFlat:[{path:[],field:d.ll.raw("*")}],where:k,limit:w,offset:S,orderBy:x,setOperators:[]}),k=void 0,w=void 0,S=void 0,x=void 0):m=g(s,l),m=this.buildSelectQuery({table:(0,r.is)(m,j.jo)?m:new _.n(m,{},l),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:(0,r.is)(e,u.V)?y(e,l):e})),joins:T,where:k,limit:w,offset:S,orderBy:x,setOperators:[]})}else m=this.buildSelectQuery({table:g(s,l),fields:{},fieldsFlat:p.map(({field:e})=>({path:[],field:(0,r.is)(e,u.V)?y(e,l):e})),joins:T,where:k,limit:w,offset:S,orderBy:x,setOperators:[]});return{tableTsKey:n.tsName,sql:m,selection:p}}}class Q extends L{static [r.i]="SQLiteSyncDialect";migrate(e,t,i){let s=void 0===i?"__drizzle_migrations":"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",r=(0,d.ll)`
|
|
1
|
+
"use strict";exports.id=806,exports.ids=[806],exports.modules={86084:(e,t,i)=>{i.d(t,{f:()=>em});var s=i(87550),r=i(77799);class n{static [r.i]="ConsoleLogWriter";write(e){console.log(e)}}class a{static [r.i]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new n}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}}class l{static [r.i]="NoopLogger";logQuery(){}}var o=i(23555),u=i(7078),d=i(83408),c=i(65258),h=i(18611);class f{constructor(e){this.table=e}static [r.i]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class m{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [r.i]="TableAliasProxyHandler";get(e,t){if(t===c.XI.Symbol.IsAlias)return!0;if(t===c.XI.Symbol.Name||this.replaceOriginalName&&t===c.XI.Symbol.OriginalName)return this.alias;if(t===h.n)return{...e[h.n],name:this.alias,isAlias:!0};if(t===c.XI.Symbol.Columns){let t=e[c.XI.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(s=>{i[s]=new Proxy(t[s],new f(new Proxy(e,this)))}),i}let i=e[t];return(0,r.is)(i,u.V)?new Proxy(i,new f(new Proxy(e,this))):i}}class p{constructor(e){this.alias=e}static [r.i]=null;get(e,t){return"sourceTable"===t?g(e.sourceTable,this.alias):e[t]}}function g(e,t){return new Proxy(e,new m(t,!1))}function y(e,t){return new Proxy(e,new f(new Proxy(e.table,new m(t,!1))))}function v(e,t){return new d.Xs.Aliased(b(e.sql,t),e.fieldAlias)}function b(e,t){return d.ll.join(e.queryChunks.map(e=>(0,r.is)(e,u.V)?y(e,t):(0,r.is)(e,d.Xs)?b(e,t):(0,r.is)(e,d.Xs.Aliased)?v(e,t):e))}var _=i(73322);class w{static [r.i]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===h.n)return{...e[h.n],selectedFields:new Proxy(e[h.n].selectedFields,this)};if("symbol"==typeof t)return e[t];let i=((0,r.is)(e,_.n)?e._.selectedFields:(0,r.is)(e,d.Ss)?e[h.n].selectedFields:e)[t];if((0,r.is)(i,d.Xs.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if((0,r.is)(i,d.Xs)){if("sql"===this.config.sqlBehavior)return i;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return(0,r.is)(i,u.V)?this.config.alias?new Proxy(i,new f(new Proxy(i.table,new m(this.config.alias,this.config.replaceOriginalName??!1)))):i:"object"!=typeof i||null===i?i:new Proxy(i,new w(this.config))}}function S(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function x(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,i)=>e+(0===i?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}function k(e){return e}class T{static [r.i]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?S:"camelCase"===e?x:k}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[c.XI.Symbol.Schema]??"public",i=e.table[c.XI.Symbol.OriginalName],s=`${t}.${i}.${e.name}`;return this.cache[s]||this.cacheTable(e.table),this.cache[s]}cacheTable(e){let t=e[c.XI.Symbol.Schema]??"public",i=e[c.XI.Symbol.OriginalName],s=`${t}.${i}`;if(!this.cachedTables[s]){for(let t of Object.values(e[c.XI.Symbol.Columns])){let e=`${s}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[s]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class N extends Error{static [r.i]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class C extends N{static [r.i]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}var $=i(47579),O=i(55251),j=i(21300),A=i(78199);class I extends d.Ss{static [r.i]="SQLiteViewBase"}class L{static [r.i]="SQLiteDialect";casing;constructor(e){this.casing=new T(e?.casing)}escapeName(e){return`"${e}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[(0,d.ll)`with `];for(let[i,s]of e.entries())t.push((0,d.ll)`${d.ll.identifier(s._.alias)} as (${s._.sql})`),i<e.length-1&&t.push((0,d.ll)`, `);return t.push((0,d.ll)` `),d.ll.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:s,limit:r,orderBy:n}){let a=this.buildWithCTE(s),l=i?(0,d.ll)` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,o=t?(0,d.ll)` where ${t}`:void 0,u=this.buildOrderBy(n),c=this.buildLimit(r);return(0,d.ll)`${a}delete from ${e}${o}${l}${u}${c}`}buildUpdateSet(e,t){let i=e[c.XI.Symbol.Columns],s=Object.keys(i).filter(e=>void 0!==t[e]||i[e]?.onUpdateFn!==void 0),r=s.length;return d.ll.join(s.flatMap((e,s)=>{let n=i[e],a=t[e]??d.ll.param(n.onUpdateFn(),n),l=(0,d.ll)`${d.ll.identifier(this.casing.getColumnCasing(n))} = ${a}`;return s<r-1?[l,d.ll.raw(", ")]:[l]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:r,joins:n,from:a,limit:l,orderBy:o}){let u=this.buildWithCTE(r),c=this.buildUpdateSet(e,t),h=a&&d.ll.join([d.ll.raw(" from "),this.buildFromTable(a)]),f=this.buildJoins(n),m=s?(0,d.ll)` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,p=i?(0,d.ll)` where ${i}`:void 0,g=this.buildOrderBy(o),y=this.buildLimit(l);return(0,d.ll)`${u}update ${e} set ${c}${h}${f}${p}${m}${g}${y}`}buildSelection(e,{isSingleTable:t=!1}={}){let i=e.length,s=e.flatMap(({field:e},s)=>{let n=[];if((0,r.is)(e,d.Xs.Aliased)&&e.isSelectionField)n.push(d.ll.identifier(e.fieldAlias));else if((0,r.is)(e,d.Xs.Aliased)||(0,r.is)(e,d.Xs)){let i=(0,r.is)(e,d.Xs.Aliased)?e.sql:e;t?n.push(new d.Xs(i.queryChunks.map(e=>(0,r.is)(e,u.V)?d.ll.identifier(this.casing.getColumnCasing(e)):e))):n.push(i),(0,r.is)(e,d.Xs.Aliased)&&n.push((0,d.ll)` as ${d.ll.identifier(e.fieldAlias)}`)}else if((0,r.is)(e,u.V)){let i=e.table[c.XI.Symbol.Name];t?n.push(d.ll.identifier(this.casing.getColumnCasing(e))):n.push((0,d.ll)`${d.ll.identifier(i)}.${d.ll.identifier(this.casing.getColumnCasing(e))}`)}return s<i-1&&n.push((0,d.ll)`, `),n});return d.ll.join(s)}buildJoins(e){if(!e||0===e.length)return;let t=[];if(e)for(let[i,s]of e.entries()){0===i&&t.push((0,d.ll)` `);let n=s.table;if((0,r.is)(n,j.jo)){let e=n[j.jo.Symbol.Name],i=n[j.jo.Symbol.Schema],r=n[j.jo.Symbol.OriginalName],a=e===r?void 0:s.alias;t.push((0,d.ll)`${d.ll.raw(s.joinType)} join ${i?(0,d.ll)`${d.ll.identifier(i)}.`:void 0}${d.ll.identifier(r)}${a&&(0,d.ll)` ${d.ll.identifier(a)}`} on ${s.on}`)}else t.push((0,d.ll)`${d.ll.raw(s.joinType)} join ${n} on ${s.on}`);i<e.length-1&&t.push((0,d.ll)` `)}return d.ll.join(t)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?(0,d.ll)` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push((0,d.ll)`, `);return t.length>0?(0,d.ll)` order by ${d.ll.join(t)}`:void 0}buildFromTable(e){return(0,r.is)(e,c.XI)&&e[c.XI.Symbol.OriginalName]!==e[c.XI.Symbol.Name]?(0,d.ll)`${d.ll.identifier(e[c.XI.Symbol.OriginalName])} ${d.ll.identifier(e[c.XI.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:s,having:n,table:a,joins:l,orderBy:o,groupBy:f,limit:m,offset:p,distinct:g,setOperators:y}){let v=i??(0,A.He)(t);for(let e of v){let t;if((0,r.is)(e.field,u.V)&&(0,c.Io)(e.field.table)!==((0,r.is)(a,_.n)?a._.alias:(0,r.is)(a,I)?a[h.n].name:(0,r.is)(a,d.Xs)?void 0:(0,c.Io)(a))&&(t=e.field.table,!l?.some(({alias:e})=>e===(t[c.XI.Symbol.IsAlias]?c.Io(t):t[c.XI.Symbol.BaseName])))){let t=(0,c.Io)(e.field.table);throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let b=!l||0===l.length,w=this.buildWithCTE(e),S=g?(0,d.ll)` distinct`:void 0,x=this.buildSelection(v,{isSingleTable:b}),k=this.buildFromTable(a),T=this.buildJoins(l),N=s?(0,d.ll)` where ${s}`:void 0,C=n?(0,d.ll)` having ${n}`:void 0,$=[];if(f)for(let[e,t]of f.entries())$.push(t),e<f.length-1&&$.push((0,d.ll)`, `);let O=$.length>0?(0,d.ll)` group by ${d.ll.join($)}`:void 0,j=this.buildOrderBy(o),L=this.buildLimit(m),Q=p?(0,d.ll)` offset ${p}`:void 0,q=(0,d.ll)`${w}select${S} ${x} from ${k}${T}${N}${O}${C}${j}${L}${Q}`;return y.length>0?this.buildSetOperations(q,y):q}buildSetOperations(e,t){let[i,...s]=t;if(!i)throw Error("Cannot pass undefined values to any set operator");return 0===s.length?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:i,rightSelect:s,limit:n,orderBy:a,offset:l}}){let o;let u=(0,d.ll)`${e.getSQL()} `,c=(0,d.ll)`${s.getSQL()}`;if(a&&a.length>0){let e=[];for(let t of a)if((0,r.is)(t,O.v))e.push(d.ll.identifier(t.name));else if((0,r.is)(t,d.Xs)){for(let e=0;e<t.queryChunks.length;e++){let i=t.queryChunks[e];(0,r.is)(i,O.v)&&(t.queryChunks[e]=d.ll.identifier(this.casing.getColumnCasing(i)))}e.push((0,d.ll)`${t}`)}else e.push((0,d.ll)`${t}`);o=(0,d.ll)` order by ${d.ll.join(e,(0,d.ll)`, `)}`}let h="object"==typeof n||"number"==typeof n&&n>=0?(0,d.ll)` limit ${n}`:void 0,f=d.ll.raw(`${t} ${i?"all ":""}`),m=l?(0,d.ll)` offset ${l}`:void 0;return(0,d.ll)`${u}${f}${c}${o}${h}${m}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:s,withList:n,select:a}){let l=[],o=Object.entries(e[c.XI.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),u=o.map(([,e])=>d.ll.identifier(this.casing.getColumnCasing(e)));if(a)(0,r.is)(t,d.Xs)?l.push(t):l.push(t.getSQL());else for(let[e,i]of(l.push(d.ll.raw("values ")),t.entries())){let s=[];for(let[e,t]of o){let n=i[e];if(void 0===n||(0,r.is)(n,d.Iw)&&void 0===n.value){let e;if(null!==t.default&&void 0!==t.default)e=(0,r.is)(t.default,d.Xs)?t.default:d.ll.param(t.default,t);else if(void 0!==t.defaultFn){let i=t.defaultFn();e=(0,r.is)(i,d.Xs)?i:d.ll.param(i,t)}else if(t.default||void 0===t.onUpdateFn)e=(0,d.ll)`null`;else{let i=t.onUpdateFn();e=(0,r.is)(i,d.Xs)?i:d.ll.param(i,t)}s.push(e)}else s.push(n)}l.push(s),e<t.length-1&&l.push((0,d.ll)`, `)}let h=this.buildWithCTE(n),f=d.ll.join(l),m=s?(0,d.ll)` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,p=i?(0,d.ll)` on conflict ${i}`:void 0;return(0,d.ll)`${h}insert into ${e} ${u} ${f}${p}${m}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:s,tableConfig:n,queryConfig:a,tableAlias:l,nestedQueryRelation:h,joinOn:f}){let m,p=[],w,S,x=[],k,T=[];if(!0===a)p=Object.entries(n.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:y(t,l),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let s=Object.fromEntries(Object.entries(n.columns).map(([e,t])=>[e,y(t,l)]));if(a.where){let e="function"==typeof a.where?a.where(s,(0,o.mm)()):a.where;k=e&&b(e,l)}let h=[],f=[];if(a.columns){let e=!1;for(let[t,i]of Object.entries(a.columns))void 0!==i&&t in n.columns&&(e||!0!==i||(e=!0),f.push(t));f.length>0&&(f=e?f.filter(e=>a.columns?.[e]===!0):Object.keys(n.columns).filter(e=>!f.includes(e)))}else f=Object.keys(n.columns);for(let e of f){let t=n.columns[e];h.push({tsKey:e,value:t})}let m=[];if(a.with&&(m=Object.entries(a.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:n.relations[e]}))),a.extras)for(let[e,t]of Object.entries("function"==typeof a.extras?a.extras(s,{sql:d.ll}):a.extras))h.push({tsKey:e,value:v(t,l)});for(let{tsKey:e,value:t}of h)p.push({dbKey:(0,r.is)(t,d.Xs.Aliased)?t.fieldAlias:n.columns[e].name,tsKey:e,field:(0,r.is)(t,u.V)?y(t,l):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let g="function"==typeof a.orderBy?a.orderBy(s,(0,o.rl)()):a.orderBy??[];for(let{tsKey:s,queryConfig:n,relation:h}of(Array.isArray(g)||(g=[g]),x=g.map(e=>(0,r.is)(e,u.V)?y(e,l):b(e,l)),w=a.limit,S=a.offset,m)){let a=(0,o.W0)(t,i,h),u=i[(0,c.Lf)(h.referencedTable)],f=`${l}_${s}`,m=(0,$.Uo)(...a.fields.map((e,t)=>(0,$.eq)(y(a.references[t],f),y(e,l)))),g=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[u],tableConfig:t[u],queryConfig:(0,r.is)(h,o.pD)?!0===n?{limit:1}:{...n,limit:1}:n,tableAlias:f,joinOn:m,nestedQueryRelation:h}),v=(0,d.ll)`(${g.sql})`.as(s);p.push({dbKey:s,tsKey:s,field:v,relationTableTsKey:u,isJson:!0,selection:g.selection})}}if(0===p.length)throw new N({message:`No fields selected for table "${n.tsName}" ("${l}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});if(k=(0,$.Uo)(f,k),h){let e=(0,d.ll)`json_array(${d.ll.join(p.map(({field:e})=>(0,r.is)(e,O.v)?d.ll.identifier(this.casing.getColumnCasing(e)):(0,r.is)(e,d.Xs.Aliased)?e.sql:e),(0,d.ll)`, `)})`;(0,r.is)(h,o.iv)&&(e=(0,d.ll)`coalesce(json_group_array(${e}), json_array())`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:n.tsName,selection:p}];void 0!==w||void 0!==S||x.length>0?(m=this.buildSelectQuery({table:g(s,l),fields:{},fieldsFlat:[{path:[],field:d.ll.raw("*")}],where:k,limit:w,offset:S,orderBy:x,setOperators:[]}),k=void 0,w=void 0,S=void 0,x=void 0):m=g(s,l),m=this.buildSelectQuery({table:(0,r.is)(m,j.jo)?m:new _.n(m,{},l),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:(0,r.is)(e,u.V)?y(e,l):e})),joins:T,where:k,limit:w,offset:S,orderBy:x,setOperators:[]})}else m=this.buildSelectQuery({table:g(s,l),fields:{},fieldsFlat:p.map(({field:e})=>({path:[],field:(0,r.is)(e,u.V)?y(e,l):e})),joins:T,where:k,limit:w,offset:S,orderBy:x,setOperators:[]});return{tableTsKey:n.tsName,sql:m,selection:p}}}class Q extends L{static [r.i]="SQLiteSyncDialect";migrate(e,t,i){let s=void 0===i?"__drizzle_migrations":"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",r=(0,d.ll)`
|
|
2
2
|
CREATE TABLE IF NOT EXISTS ${d.ll.identifier(s)} (
|
|
3
3
|
id SERIAL PRIMARY KEY,
|
|
4
4
|
hash text NOT NULL,
|