bun-query-builder 0.2.54 → 0.2.55

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.
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ca as a,da as b,ea as c,fa as d,ga as e,ha as f,ia as g}from"./chunk-9ps7fkza.js";import"./chunk-7e64yq76.js";import"./chunk-y718nsbf.js";import"./chunk-x8tfs1sw.js";export{a as saveMigrationSnapshot,d as resetDatabase,b as generateMigration,c as executeMigration,e as deleteMigrationFiles,f as copyModelsToGenerated,g as clearGeneratedDirectory};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var{defineProperty:e,getOwnPropertyNames:g,getOwnPropertyDescriptor:h}=Object,i=Object.prototype.hasOwnProperty;function j(a){return this[a]}var m=(a)=>{var b=(f??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of g(a))if(!i.call(b,d))e(b,d,{get:j.bind(a,d),enumerable:!(c=h(a,d))||c.enumerable})}return f.set(a,b),b},f;var k=(a)=>a;function l(a,b){this[a]=k.bind(null,b)}var n=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:l.bind(b,c)})};var o=(a,b)=>()=>(a&&(b=a(a=0)),b);var p=import.meta.require;
3
- export{m as nc,n as oc,o as pc,p as qc};
3
+ export{m as oc,n as pc,o as qc,p as rc};
@@ -4,4 +4,4 @@ class y{config;entityMappings=new Map;constructor(W){if(this.config=W,W.entityMa
4
4
  `,S=w.map((B)=>B.toLowerCase()).join(";"),A=await b($),r=[W,L,H,R,S,A].join(`
5
5
  `),l=await b(r),f="AWS4-HMAC-SHA256",c=`${z}/${Q}/${J}/aws4_request`,n=[f,X,c,l].join(`
6
6
  `),s=await e(U.secretAccessKey,z,Q,J),i=await P(s,n),t=Array.from(new Uint8Array(i)).map((B)=>B.toString(16).padStart(2,"0")).join(""),a=`${f} Credential=${U.accessKeyId}/${c}, SignedHeaders=${S}, Signature=${t}`;return{...j,authorization:a}}class I{config;endpoint;credentials;constructor(W){if(this.config=W,this.endpoint=W.endpoint??`https://dynamodb.${W.region}.amazonaws.com`,this.credentials=W.credentials??{accessKeyId:process.env.AWS_ACCESS_KEY_ID??"",secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY??"",sessionToken:process.env.AWS_SESSION_TOKEN},!this.credentials.accessKeyId||!this.credentials.secretAccessKey)throw Error("AWS credentials not provided. Set credentials in config or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY environment variables.")}async execute(W,Y){let Z=new URL(this.endpoint),$=JSON.stringify(Y),U={"content-type":"application/x-amz-json-1.0","x-amz-target":`DynamoDB_20120810.${W}`},Q=await WW("POST",Z,U,$,this.credentials,this.config.region,"dynamodb"),J=await fetch(Z.toString(),{method:"POST",headers:Q,body:$});if(!J.ok){let F=await J.text(),X;try{let z=JSON.parse(F);X=z.message??z.Message??F}catch{X=F}throw Error(`DynamoDB ${W} failed: ${J.status} - ${X}`)}return J.json()}async query(W){return this.execute("Query",W)}async scan(W){return this.execute("Scan",W)}async getItem(W){return this.execute("GetItem",W)}async putItem(W){return this.execute("PutItem",W)}async updateItem(W){return this.execute("UpdateItem",W)}async deleteItem(W){return this.execute("DeleteItem",W)}async batchGetItem(W){return this.execute("BatchGetItem",W)}async batchWriteItem(W){return this.execute("BatchWriteItem",W)}async transactWriteItems(W){return this.execute("TransactWriteItems",W)}async describeTable(W){return this.execute("DescribeTable",{TableName:W})}async createTable(W){return this.execute("CreateTable",W)}async deleteTable(W){return this.execute("DeleteTable",{TableName:W})}async listTables(W){return this.execute("ListTables",W??{})}async updateTable(W){return this.execute("UpdateTable",W)}async updateTimeToLive(W){return this.execute("UpdateTimeToLive",W)}async describeTimeToLive(W){return this.execute("DescribeTimeToLive",{TableName:W})}}function q(W){return new I(W)}var O={region:process.env.AWS_REGION??"us-east-1"},h=null,k=null;function YW(W){O={...O,...W},h=null,k=null}function _(){if(!h)h=q({region:O.region??"us-east-1",endpoint:O.endpoint,credentials:O.credentials});return h}function E(){if(!k)k=D({region:O.region??"us-east-1",endpoint:O.endpoint,credentials:O.credentials});return k}class v{static tableName="";static pkAttribute="pk";static skAttribute="sk";static pkPrefix="";static skPrefix="METADATA";static entityTypeAttribute="_et";static keyDelimiter="#";static primaryKey="id";static timestamps=!0;static createdAtField="createdAt";static updatedAtField="updatedAt";_attributes={};_original={};_exists=!1;constructor(W={}){this._attributes={...W},this._original={...W};for(let[Y,Z]of Object.entries(W))this[Y]=Z}static query(){return new g(this)}static async find(W){let Y=this,Z=_(),$=E(),U=`${Y.pkPrefix}${Y.keyDelimiter}${W}`,Q=Y.skPrefix;try{let J=await Z.getItem({TableName:Y.tableName,Key:$.marshall({[Y.pkAttribute]:U,[Y.skAttribute]:Q})});if(!J.Item)return null;let F=$.unmarshall(J.Item),X=new Y(F);return X._exists=!0,X}catch(J){return console.error("Find error:",J),null}}static async findOrFail(W){let Y=await this.find(W);if(!Y)throw Error(`${this.name} not found with id: ${W}`);return Y}static async all(){return this.query().get()}static async create(W){let Y=this,Z=_(),$=E(),U=W[Y.primaryKey];if(!U)throw Error(`${Y.primaryKey} is required`);let Q=`${Y.pkPrefix}${Y.keyDelimiter}${U}`,J=Y.skPrefix,F=new Date().toISOString(),X={...W,[Y.pkAttribute]:Q,[Y.skAttribute]:J,[Y.entityTypeAttribute]:Y.name};if(Y.timestamps)X[Y.createdAtField]=F,X[Y.updatedAtField]=F;await Z.putItem({TableName:Y.tableName,Item:$.marshall(X),ConditionExpression:`attribute_not_exists(${Y.pkAttribute})`});let z=new Y(X);return z._exists=!0,z}static async updateOrCreate(W,Y){let Z=this,$=W[Z.primaryKey],U=await Z.find($);if(U)return await U.update(Y),U;return Z.create({...W,...Y})}static where(W,Y,Z){return this.query().where(W,Y,Z)}static wherePk(W){return this.query().wherePk(W)}getKey(){let W=this.constructor;return this[W.primaryKey]}getAttribute(W){return this._attributes[W]}setAttribute(W,Y){return this._attributes[W]=Y,this[W]=Y,this}getAttributes(){return{...this._attributes}}isDirty(W){if(W)return this._attributes[W]!==this._original[W];return JSON.stringify(this._attributes)!==JSON.stringify(this._original)}getDirty(){let W={};for(let[Y,Z]of Object.entries(this._attributes))if(Z!==this._original[Y])W[Y]=Z;return W}async save(){if(this._exists){let W=this.getDirty();if(Object.keys(W).length>0)await this.update(W)}else{let Y=await this.constructor.create(this._attributes);this._attributes=Y._attributes,this._original={...this._attributes},this._exists=!0}return this}async update(W){let Y=this.constructor,Z=_(),$=E(),U=this.getKey(),Q=`${Y.pkPrefix}${Y.keyDelimiter}${U}`,J=Y.skPrefix,F=new Date().toISOString(),X={...W};if(Y.timestamps)X[Y.updatedAtField]=F;let z=[],L={},H={},j=0;for(let[w,R]of Object.entries(X)){let S=`#attr${j}`,A=`:val${j}`;L[S]=w,H[A]=$.marshall({v:R}).v,z.push(`${S} = ${A}`),j++}await Z.updateItem({TableName:Y.tableName,Key:$.marshall({[Y.pkAttribute]:Q,[Y.skAttribute]:J}),UpdateExpression:`SET ${z.join(", ")}`,ExpressionAttributeNames:L,ExpressionAttributeValues:H});for(let[w,R]of Object.entries(X))this._attributes[w]=R,this[w]=R;return this._original={...this._attributes},this}async delete(){let W=this.constructor,Y=_(),Z=E(),$=this.getKey(),U=`${W.pkPrefix}${W.keyDelimiter}${$}`,Q=W.skPrefix;return await Y.deleteItem({TableName:W.tableName,Key:Z.marshall({[W.pkAttribute]:U,[W.skAttribute]:Q})}),this._exists=!1,!0}async refresh(){let Y=await this.constructor.find(this.getKey());if(Y){this._attributes=Y._attributes,this._original={...this._attributes};for(let[Z,$]of Object.entries(this._attributes))this[Z]=$}return this}toObject(){let W=this.constructor,Y={...this._attributes};return delete Y[W.pkAttribute],delete Y[W.skAttribute],delete Y[W.entityTypeAttribute],Y}toJSON(){return this.toObject()}}class g{ModelClass;_pkValue;_skCondition;_indexName;_filterConditions=[];_projectionAttrs=[];_limitValue;_scanForward=!0;_consistentReadValue=!1;_startKey;constructor(W){this.ModelClass=W}wherePk(W){return this._pkValue=`${this.ModelClass.pkPrefix}${this.ModelClass.keyDelimiter}${W}`,this}where(W,Y,Z){if(Z===void 0)this._filterConditions.push({attribute:W,operator:"=",value:Y});else this._filterConditions.push({attribute:W,operator:Y,value:Z});return this}whereIn(W,Y){return this._filterConditions.push({attribute:W,operator:"IN",values:Y}),this}whereBetween(W,Y,Z){return this._filterConditions.push({attribute:W,operator:"BETWEEN",value:Y,values:[Y,Z]}),this}whereBeginsWith(W,Y){return this._filterConditions.push({attribute:W,operator:"begins_with",value:Y}),this}whereExists(W){return this._filterConditions.push({attribute:W,operator:"attribute_exists"}),this}whereNotExists(W){return this._filterConditions.push({attribute:W,operator:"attribute_not_exists"}),this}orderBy(W){return this._scanForward=W==="asc",this}limit(W){return this._limitValue=W,this}select(...W){return this._projectionAttrs.push(...W),this}index(W){return this._indexName=W,this}consistentRead(){return this._consistentReadValue=!0,this}startFrom(W){return this._startKey=W,this}buildRequest(){let W=E(),Y={TableName:this.ModelClass.tableName};if(this._indexName)Y.IndexName=this._indexName;let Z={},$={},U=0,Q=[];if(this._pkValue){let J=`#pk${U}`,F=`:pk${U}`;Z[J]=this.ModelClass.pkAttribute,$[F]={S:this._pkValue},Q.push(`${J} = ${F}`),U++}if(this._skCondition){let J=`#sk${U}`;switch(Z[J]=this.ModelClass.skAttribute,this._skCondition.type){case"eq":{let F=`:sk${U}`;$[F]={S:this._skCondition.value},Q.push(`${J} = ${F}`);break}case"begins_with":{let F=`:sk${U}`;$[F]={S:this._skCondition.value},Q.push(`begins_with(${J}, ${F})`);break}}U++}if(Q.length>0)Y.KeyConditionExpression=Q.join(" AND ");if(this._filterConditions.length>0){let J=[];for(let F of this._filterConditions){let X=`#flt${U}`;if(Z[X]=F.attribute,F.operator==="attribute_exists")J.push(`attribute_exists(${X})`);else if(F.operator==="attribute_not_exists")J.push(`attribute_not_exists(${X})`);else if(F.operator==="IN"&&F.values){let z=F.values.map((L,H)=>`:flt${U}_${H}`);F.values.forEach((L,H)=>{$[`:flt${U}_${H}`]=W.marshall({v:L}).v}),J.push(`${X} IN (${z.join(", ")})`)}else if(F.operator==="BETWEEN"&&F.values){let z=`:flt${U}a`,L=`:flt${U}b`;$[z]=W.marshall({v:F.values[0]}).v,$[L]=W.marshall({v:F.values[1]}).v,J.push(`${X} BETWEEN ${z} AND ${L}`)}else if(F.operator==="begins_with"){let z=`:flt${U}`;$[z]=W.marshall({v:F.value}).v,J.push(`begins_with(${X}, ${z})`)}else{let z=`:flt${U}`;$[z]=W.marshall({v:F.value}).v,J.push(`${X} ${F.operator} ${z}`)}U++}Y.FilterExpression=J.join(" AND ")}if(this._projectionAttrs.length>0){let J=[];for(let F of this._projectionAttrs){let X=`#proj${U}`;Z[X]=F,J.push(X),U++}Y.ProjectionExpression=J.join(", ")}if(Object.keys(Z).length>0)Y.ExpressionAttributeNames=Z;if(Object.keys($).length>0)Y.ExpressionAttributeValues=$;if(this._limitValue!==void 0)Y.Limit=this._limitValue;if(Y.ScanIndexForward=this._scanForward,this._consistentReadValue)Y.ConsistentRead=!0;if(this._startKey)Y.ExclusiveStartKey=W.marshall(this._startKey);return Y}async get(){let W=_(),Y=E(),Z=this.buildRequest();return((this._pkValue!==void 0?await W.query(Z):await W.scan(Z)).Items??[]).map((J)=>{let F=Y.unmarshall(J),X=new this.ModelClass(F);return X._exists=!0,X})}async first(){return this._limitValue=1,(await this.get())[0]??null}async count(){let W=_(),Y=this.buildRequest();return Y.Select="COUNT",(this._pkValue!==void 0?await W.query(Y):await W.scan(Y)).Count??0}async paginate(W,Y){let Z=E();if(Y)this._startKey=Y;this._limitValue=W;let $=_(),U=this.buildRequest(),J=this._pkValue!==void 0?await $.query(U):await $.scan(U);return{items:(J.Items??[]).map((X)=>{let z=Z.unmarshall(X),L=new this.ModelClass(z);return L._exists=!0,L}),lastKey:J.LastEvaluatedKey?Z.unmarshall(J.LastEvaluatedKey):void 0}}}function T(W){let Y=JSON.stringify({tableName:W.tableName,keySchema:W.keySchema,attributeDefinitions:[...W.attributeDefinitions||[]].sort(($,U)=>$.name.localeCompare(U.name)),globalSecondaryIndexes:[...W.globalSecondaryIndexes||[]].sort(($,U)=>$.indexName.localeCompare(U.indexName)),localSecondaryIndexes:[...W.localSecondaryIndexes||[]].sort(($,U)=>$.indexName.localeCompare(U.indexName)),billingMode:W.billingMode,ttlAttribute:W.ttlAttribute,streamSpecification:W.streamSpecification}),Z=0;for(let $=0;$<Y.length;$++){let U=Y.charCodeAt($);Z=(Z<<5)-Z+U,Z=Z&Z}return Math.abs(Z).toString(16).padStart(8,"0")}function C(W){let Y=p(W);return m(Y)}function p(W){return{tableName:W.tableName||"",pkAttribute:W.pkAttribute||"pk",skAttribute:W.skAttribute||"sk",pkPrefix:W.pkPrefix||"",skPrefix:W.skPrefix||"METADATA",entityTypeAttribute:W.entityTypeAttribute||"_et",timestamps:W.timestamps!==!1,ttlAttribute:W.ttlAttribute,gsis:W.gsis,lsis:W.lsis,billingMode:W.billingMode||"PAY_PER_REQUEST",provisionedThroughput:W.provisionedThroughput,streamEnabled:W.streamEnabled,streamViewType:W.streamViewType}}function m(W){let Y=[{name:W.pkAttribute,type:"S"},{name:W.skAttribute,type:"S"}],Z=[];if(W.gsis)for(let $ of W.gsis){if(!Y.some((U)=>U.name===$.pkAttribute))Y.push({name:$.pkAttribute,type:"S"});if($.skAttribute&&!Y.some((U)=>U.name===$.skAttribute))Y.push({name:$.skAttribute,type:"S"});Z.push({indexName:$.indexName,keySchema:{partitionKey:$.pkAttribute,sortKey:$.skAttribute},projection:{type:Array.isArray($.projection)?"INCLUDE":$.projection||"ALL",nonKeyAttributes:Array.isArray($.projection)?$.projection:void 0},provisionedThroughput:$.provisionedThroughput})}return{tableName:W.tableName,keySchema:{partitionKey:W.pkAttribute,sortKey:W.skAttribute},attributeDefinitions:Y,globalSecondaryIndexes:Z.length>0?Z:void 0,billingMode:W.billingMode,provisionedThroughput:W.provisionedThroughput,ttlAttribute:W.ttlAttribute,streamSpecification:W.streamEnabled?{enabled:!0,viewType:W.streamViewType||"NEW_AND_OLD_IMAGES"}:void 0}}function K(W,Y){let Z=[],$=Y.tableName;if(!W)Z.push({type:"CREATE_TABLE",tableName:$,details:{definition:Y}});else{let U=W.keySchema.partitionKey!==Y.keySchema.partitionKey,Q=W.keySchema.sortKey!==Y.keySchema.sortKey;if(U||Q)console.warn(`[Migration] Table ${$}: Key schema changes require table recreation. Current: pk=${W.keySchema.partitionKey}, sk=${W.keySchema.sortKey}. Target: pk=${Y.keySchema.partitionKey}, sk=${Y.keySchema.sortKey}. This operation is not supported automatically.`);let J=W.globalSecondaryIndexes||[],F=Y.globalSecondaryIndexes||[],X=new Set(J.map((j)=>j.indexName)),z=new Set(F.map((j)=>j.indexName));for(let j of F)if(!X.has(j.indexName))Z.push({type:"ADD_GSI",tableName:$,details:{gsi:j}});for(let j of J)if(!z.has(j.indexName))Z.push({type:"DELETE_GSI",tableName:$,details:{indexName:j.indexName}});if(W.billingMode!==Y.billingMode&&Y.billingMode)Z.push({type:"UPDATE_BILLING_MODE",tableName:$,details:{billingMode:Y.billingMode,provisionedThroughput:Y.provisionedThroughput}});if(W.ttlAttribute!==Y.ttlAttribute)Z.push({type:"UPDATE_TTL",tableName:$,details:{ttlAttribute:Y.ttlAttribute||null,enabled:!!Y.ttlAttribute}});let L=W.streamSpecification?.enabled,H=Y.streamSpecification?.enabled;if(L!==H)if(H)Z.push({type:"ENABLE_STREAM",tableName:$,details:{viewType:Y.streamSpecification?.viewType||"NEW_AND_OLD_IMAGES"}});else Z.push({type:"DISABLE_STREAM",tableName:$,details:{}})}return{tableName:$,operations:Z,timestamp:new Date().toISOString(),hash:T(Y)}}function ZW(W,Y){return T(W)===T(Y)}var G="_qb_migrations",V="MIGRATION",d="VERSION";class M{client;initialized=!1;constructor(W){this.client=W}async ensureMigrationsTable(){if(this.initialized)return;try{await this.client.describeTable(G),this.initialized=!0}catch(W){if(W.message?.includes("ResourceNotFoundException")||W.message?.includes("not found"))console.log(`[Migration] Creating migrations table: ${G}`),await this.client.createTable({TableName:G,KeySchema:[{AttributeName:"pk",KeyType:"HASH"},{AttributeName:"sk",KeyType:"RANGE"}],AttributeDefinitions:[{AttributeName:"pk",AttributeType:"S"},{AttributeName:"sk",AttributeType:"S"}],BillingMode:"PAY_PER_REQUEST"}),await this.waitForTableActive(G),this.initialized=!0;else throw W}}async waitForTableActive(W,Y=30){for(let Z=0;Z<Y;Z++){try{if((await this.client.describeTable(W)).Table?.TableStatus==="ACTIVE")return}catch{}await new Promise(($)=>setTimeout($,1000))}throw Error(`Table ${W} did not become active within ${Y} seconds`)}async getLatestState(W){await this.ensureMigrationsTable();let Y=`${V}#${W}`,Z=await this.client.query({TableName:G,KeyConditionExpression:"pk = :pk",ExpressionAttributeValues:{":pk":{S:Y}},ScanIndexForward:!1,Limit:1});if(!Z.Items||Z.Items.length===0)return null;return this.unmarshallState(Z.Items[0])}async getHistory(W){await this.ensureMigrationsTable();let Y=`${V}#${W}`,Z=await this.client.query({TableName:G,KeyConditionExpression:"pk = :pk",ExpressionAttributeValues:{":pk":{S:Y}},ScanIndexForward:!1});if(!Z.Items)return[];return Z.Items.map(($)=>this.unmarshallState($))}async recordMigration(W,Y,Z){await this.ensureMigrationsTable();let $=await this.getLatestState(W),U=Z??($?$.version+1:1),Q=`${V}#${W}`,J=`${d}#${String(U).padStart(6,"0")}`,F={tableName:W,hash:T(Y),definition:Y,appliedAt:new Date().toISOString(),version:U};return await this.client.putItem({TableName:G,Item:this.marshallState(F,Q,J)}),console.log(`[Migration] Recorded migration for ${W} (version ${U})`),F}async listTrackedTables(){await this.ensureMigrationsTable();let W=await this.client.scan({TableName:G,ProjectionExpression:"pk"});if(!W.Items)return[];let Y=new Set;for(let Z of W.Items){let U=(Z.pk?.S||"").replace(`${V}#`,"");if(U)Y.add(U)}return Array.from(Y)}async hasMigrations(W){return await this.getLatestState(W)!==null}async deleteMigrationHistory(W){await this.ensureMigrationsTable();let Y=await this.getHistory(W),Z=`${V}#${W}`;for(let $ of Y){let U=`${d}#${String($.version).padStart(6,"0")}`;await this.client.deleteItem({TableName:G,Key:{pk:{S:Z},sk:{S:U}}})}console.log(`[Migration] Deleted migration history for ${W}`)}marshallState(W,Y,Z){return{pk:{S:Y},sk:{S:Z},tableName:{S:W.tableName},hash:{S:W.hash},definition:{S:JSON.stringify(W.definition)},appliedAt:{S:W.appliedAt},version:{N:String(W.version)}}}unmarshallState(W){return{tableName:W.tableName?.S||"",hash:W.hash?.S||"",definition:JSON.parse(W.definition?.S||"{}"),appliedAt:W.appliedAt?.S||"",version:Number(W.version?.N||0)}}}class N{client;tracker;config;constructor(W){this.config=W,this.client=q({region:W.region,endpoint:W.endpoint,credentials:W.credentials}),this.tracker=new M(this.client)}async execute(W){let Y={tableName:W.tableName,success:!0,operations:[]};if(W.operations.length===0)return this.log(`[Migration] No changes needed for ${W.tableName}`),Y;this.log(`[Migration] Executing ${W.operations.length} operations for ${W.tableName}`);try{for(let Z of W.operations)await this.executeOperation(Z),Y.operations.push(Z.type);this.log(`[Migration] Successfully applied ${Y.operations.length} operations to ${W.tableName}`)}catch(Z){Y.success=!1,Y.error=Z.message,console.error(`[Migration] Failed to execute migration for ${W.tableName}:`,Z)}return Y}async executeOperation(W){if(this.log(`[Migration] Executing ${W.type} on ${W.tableName}`),this.config.dryRun){this.log(`[Migration] DRY RUN: Would execute ${W.type}`,W.details);return}switch(W.type){case"CREATE_TABLE":await this.createTable(W.details.definition);break;case"DELETE_TABLE":await this.deleteTable(W.tableName);break;case"ADD_GSI":await this.addGSI(W.tableName,W.details.gsi);break;case"DELETE_GSI":await this.deleteGSI(W.tableName,W.details.indexName);break;case"UPDATE_TTL":await this.updateTTL(W.tableName,W.details.ttlAttribute,W.details.enabled);break;case"UPDATE_BILLING_MODE":await this.updateBillingMode(W.tableName,W.details.billingMode,W.details.provisionedThroughput);break;case"ENABLE_STREAM":await this.enableStream(W.tableName,W.details.viewType);break;case"DISABLE_STREAM":await this.disableStream(W.tableName);break;default:throw Error(`Unknown migration operation type: ${W.type}`)}}async createTable(W){let Y={TableName:W.tableName,KeySchema:[{AttributeName:W.keySchema.partitionKey,KeyType:"HASH"}],AttributeDefinitions:W.attributeDefinitions.map((Z)=>({AttributeName:Z.name,AttributeType:Z.type})),BillingMode:W.billingMode||"PAY_PER_REQUEST"};if(W.keySchema.sortKey)Y.KeySchema.push({AttributeName:W.keySchema.sortKey,KeyType:"RANGE"});if(W.billingMode==="PROVISIONED"&&W.provisionedThroughput)Y.ProvisionedThroughput={ReadCapacityUnits:W.provisionedThroughput.readCapacityUnits,WriteCapacityUnits:W.provisionedThroughput.writeCapacityUnits};if(W.globalSecondaryIndexes&&W.globalSecondaryIndexes.length>0)Y.GlobalSecondaryIndexes=W.globalSecondaryIndexes.map((Z)=>({IndexName:Z.indexName,KeySchema:[{AttributeName:Z.keySchema.partitionKey,KeyType:"HASH"},...Z.keySchema.sortKey?[{AttributeName:Z.keySchema.sortKey,KeyType:"RANGE"}]:[]],Projection:{ProjectionType:Z.projection.type,...Z.projection.nonKeyAttributes?{NonKeyAttributes:Z.projection.nonKeyAttributes}:{}},...Z.provisionedThroughput?{ProvisionedThroughput:{ReadCapacityUnits:Z.provisionedThroughput.readCapacityUnits,WriteCapacityUnits:Z.provisionedThroughput.writeCapacityUnits}}:{}}));if(W.localSecondaryIndexes&&W.localSecondaryIndexes.length>0)Y.LocalSecondaryIndexes=W.localSecondaryIndexes.map((Z)=>({IndexName:Z.indexName,KeySchema:[{AttributeName:W.keySchema.partitionKey,KeyType:"HASH"},{AttributeName:Z.sortKey,KeyType:"RANGE"}],Projection:{ProjectionType:Z.projection.type,...Z.projection.nonKeyAttributes?{NonKeyAttributes:Z.projection.nonKeyAttributes}:{}}}));if(W.streamSpecification?.enabled)Y.StreamSpecification={StreamEnabled:!0,StreamViewType:W.streamSpecification.viewType||"NEW_AND_OLD_IMAGES"};if(this.log(`[Migration] Creating table: ${W.tableName}`),await this.client.createTable(Y),await this.waitForTableActive(W.tableName),W.ttlAttribute)await this.updateTTL(W.tableName,W.ttlAttribute,!0);this.log(`[Migration] Table created: ${W.tableName}`)}async deleteTable(W){this.log(`[Migration] Deleting table: ${W}`),await this.client.deleteTable(W),this.log(`[Migration] Table deleted: ${W}`)}async addGSI(W,Y){this.log(`[Migration] Adding GSI ${Y.indexName} to ${W}`);let Z=await this.client.describeTable(W),$=new Set(Z.Table?.AttributeDefinitions?.map((J)=>J.AttributeName)||[]),U=[];if(!$.has(Y.keySchema.partitionKey))U.push({AttributeName:Y.keySchema.partitionKey,AttributeType:"S"});if(Y.keySchema.sortKey&&!$.has(Y.keySchema.sortKey))U.push({AttributeName:Y.keySchema.sortKey,AttributeType:"S"});let Q={TableName:W,AttributeDefinitions:U.length>0?U:void 0,GlobalSecondaryIndexUpdates:[{Create:{IndexName:Y.indexName,KeySchema:[{AttributeName:Y.keySchema.partitionKey,KeyType:"HASH"},...Y.keySchema.sortKey?[{AttributeName:Y.keySchema.sortKey,KeyType:"RANGE"}]:[]],Projection:{ProjectionType:Y.projection.type,...Y.projection.nonKeyAttributes?{NonKeyAttributes:Y.projection.nonKeyAttributes}:{}},...Y.provisionedThroughput?{ProvisionedThroughput:{ReadCapacityUnits:Y.provisionedThroughput.readCapacityUnits,WriteCapacityUnits:Y.provisionedThroughput.writeCapacityUnits}}:{}}}]};await this.executeUpdateTable(Q),await this.waitForGSIActive(W,Y.indexName),this.log(`[Migration] GSI ${Y.indexName} added to ${W}`)}async deleteGSI(W,Y){this.log(`[Migration] Deleting GSI ${Y} from ${W}`);let Z={TableName:W,GlobalSecondaryIndexUpdates:[{Delete:{IndexName:Y}}]};await this.executeUpdateTable(Z),this.log(`[Migration] GSI ${Y} deleted from ${W}`)}async updateTTL(W,Y,Z){this.log(`[Migration] Updating TTL on ${W}: ${Z?Y:"disabled"}`);let $={TableName:W,TimeToLiveSpecification:{Enabled:Z,AttributeName:Y||"ttl"}};await this.executeUpdateTimeToLive($),this.log(`[Migration] TTL updated on ${W}`)}async updateBillingMode(W,Y,Z){this.log(`[Migration] Updating billing mode on ${W} to ${Y}`);let $={TableName:W,BillingMode:Y};if(Y==="PROVISIONED"&&Z)$.ProvisionedThroughput={ReadCapacityUnits:Z.readCapacityUnits,WriteCapacityUnits:Z.writeCapacityUnits};await this.executeUpdateTable($),await this.waitForTableActive(W),this.log(`[Migration] Billing mode updated on ${W}`)}async enableStream(W,Y){this.log(`[Migration] Enabling stream on ${W} with view type ${Y}`);let Z={TableName:W,StreamSpecification:{StreamEnabled:!0,StreamViewType:Y}};await this.executeUpdateTable(Z),await this.waitForTableActive(W),this.log(`[Migration] Stream enabled on ${W}`)}async disableStream(W){this.log(`[Migration] Disabling stream on ${W}`);let Y={TableName:W,StreamSpecification:{StreamEnabled:!1}};await this.executeUpdateTable(Y),await this.waitForTableActive(W),this.log(`[Migration] Stream disabled on ${W}`)}async executeUpdateTable(W){await this.client.updateTable(W)}async executeUpdateTimeToLive(W){await this.client.updateTimeToLive(W)}async waitForTableActive(W,Y=60){this.log(`[Migration] Waiting for table ${W} to become active...`);for(let Z=0;Z<Y;Z++){try{let U=(await this.client.describeTable(W)).Table?.TableStatus;if(U==="ACTIVE")return;this.log(`[Migration] Table status: ${U}, waiting...`)}catch{}await new Promise(($)=>setTimeout($,2000))}throw Error(`Table ${W} did not become active within ${Y*2} seconds`)}async waitForGSIActive(W,Y,Z=120){this.log(`[Migration] Waiting for GSI ${Y} to become active...`);for(let $=0;$<Z;$++){try{let Q=(await this.client.describeTable(W)).Table?.GlobalSecondaryIndexes?.find((F)=>F.IndexName===Y);if(Q?.IndexStatus==="ACTIVE")return;let J=Q?.IndexStatus||"CREATING";this.log(`[Migration] GSI status: ${J}, waiting...`)}catch{}await new Promise((U)=>setTimeout(U,5000))}throw Error(`GSI ${Y} did not become active within ${Z*5} seconds`)}async migrateModel(W){let Y=C(W),Z=null;try{let Q=await this.client.describeTable(Y.tableName);if(Q.Table)Z=this.tableInfoToDefinition(Q.Table)}catch(Q){if(!Q.message?.includes("ResourceNotFoundException")&&!Q.message?.includes("not found"))throw Q}let $=K(Z,Y),U=await this.execute($);if(U.success&&!this.config.dryRun)U.state=await this.tracker.recordMigration(Y.tableName,Y);return U}async migrateModels(W){let Y=[];for(let Z of W)try{let $=await this.migrateModel(Z);Y.push($)}catch($){Y.push({tableName:Z.tableName||"unknown",success:!1,operations:[],error:$.message})}return Y}async getStatus(){let W=new Map,Y=await this.tracker.listTrackedTables();for(let Z of Y){let $=await this.tracker.getLatestState(Z);W.set(Z,$)}return W}tableInfoToDefinition(W){let Y={partitionKey:"",sortKey:void 0};for(let U of W.KeySchema||[])if(U.KeyType==="HASH")Y.partitionKey=U.AttributeName;else if(U.KeyType==="RANGE")Y.sortKey=U.AttributeName;let Z=(W.AttributeDefinitions||[]).map((U)=>({name:U.AttributeName,type:U.AttributeType})),$=(W.GlobalSecondaryIndexes||[]).map((U)=>{let Q={partitionKey:"",sortKey:void 0};for(let J of U.KeySchema||[])if(J.KeyType==="HASH")Q.partitionKey=J.AttributeName;else if(J.KeyType==="RANGE")Q.sortKey=J.AttributeName;return{indexName:U.IndexName,keySchema:Q,projection:{type:U.Projection?.ProjectionType||"ALL",nonKeyAttributes:U.Projection?.NonKeyAttributes},provisionedThroughput:U.ProvisionedThroughput?{readCapacityUnits:U.ProvisionedThroughput.ReadCapacityUnits,writeCapacityUnits:U.ProvisionedThroughput.WriteCapacityUnits}:void 0}});return{tableName:W.TableName,keySchema:Y,attributeDefinitions:Z,globalSecondaryIndexes:$.length>0?$:void 0,billingMode:W.BillingModeSummary?.BillingMode||"PAY_PER_REQUEST",provisionedThroughput:W.ProvisionedThroughput?{readCapacityUnits:W.ProvisionedThroughput.ReadCapacityUnits,writeCapacityUnits:W.ProvisionedThroughput.WriteCapacityUnits}:void 0,ttlAttribute:W.TimeToLiveDescription?.AttributeName,streamSpecification:W.StreamSpecification?{enabled:W.StreamSpecification.StreamEnabled,viewType:W.StreamSpecification.StreamViewType}:void 0}}log(...W){if(this.config.verbose||this.config.dryRun)console.log(...W)}}function u(W){return new N(W)}async function $W(W,Y){return u(Y).migrateModels(W)}class o{driver;client;tableName;pkAttribute;skAttribute;entityTypeAttr;delimiter;_entityType;_pkValue;_skCondition;_indexName;_projectionAttrs=[];_filterConditions=[];_limitValue;_scanForward=!0;_consistentRead=!1;_startKey;constructor(W,Y,Z,$){this.driver=W,this.client=Y,this.tableName=Z,this.pkAttribute=$.pkAttribute,this.skAttribute=$.skAttribute,this.entityTypeAttr=$.entityTypeAttribute,this.delimiter=$.keyDelimiter}entity(W){return this._entityType=W,this}pk(W){return this._pkValue=W,this}get sk(){let W=this;return{equals(Y){return W._skCondition={type:"eq",value:Y},W},beginsWith(Y){return W._skCondition={type:"begins_with",value:Y},W},between(Y,Z){return W._skCondition={type:"between",value:Y,value2:Z},W},lt(Y){return W._skCondition={type:"lt",value:Y},W},lte(Y){return W._skCondition={type:"lte",value:Y},W},gt(Y){return W._skCondition={type:"gt",value:Y},W},gte(Y){return W._skCondition={type:"gte",value:Y},W}}}index(W){return this._indexName=W,this}project(...W){return this._projectionAttrs.push(...W),this}filter(W,Y,Z){return this._filterConditions.push({attribute:W,operator:Y,value:Z}),this}where(W,Y){return this.filter(W,"=",Y)}whereIn(W,Y){return this._filterConditions.push({attribute:W,operator:"IN",values:Y}),this}limit(W){return this._limitValue=W,this}asc(){return this._scanForward=!0,this}desc(){return this._scanForward=!1,this}consistent(){return this._consistentRead=!0,this}startFrom(W){return this._startKey=W,this}toRequest(){let W={TableName:this.tableName};if(this._indexName)W.IndexName=this._indexName;let Y=[],Z={},$={},U=0;if(this._pkValue){let Q=`#pk${U}`,J=`:pk${U}`;Z[Q]=this.pkAttribute,$[J]={S:this._pkValue},Y.push(`${Q} = ${J}`),U++}if(this._skCondition){let Q=`#sk${U}`;switch(Z[Q]=this.skAttribute,this._skCondition.type){case"eq":{let J=`:sk${U}`;$[J]={S:this._skCondition.value},Y.push(`${Q} = ${J}`);break}case"begins_with":{let J=`:sk${U}`;$[J]={S:this._skCondition.value},Y.push(`begins_with(${Q}, ${J})`);break}case"between":{let J=`:sk${U}a`,F=`:sk${U}b`;$[J]={S:this._skCondition.value},$[F]={S:this._skCondition.value2},Y.push(`${Q} BETWEEN ${J} AND ${F}`);break}case"lt":{let J=`:sk${U}`;$[J]={S:this._skCondition.value},Y.push(`${Q} < ${J}`);break}case"lte":{let J=`:sk${U}`;$[J]={S:this._skCondition.value},Y.push(`${Q} <= ${J}`);break}case"gt":{let J=`:sk${U}`;$[J]={S:this._skCondition.value},Y.push(`${Q} > ${J}`);break}case"gte":{let J=`:sk${U}`;$[J]={S:this._skCondition.value},Y.push(`${Q} >= ${J}`);break}}U++}if(Y.length>0)W.KeyConditionExpression=Y.join(" AND ");if(this._filterConditions.length>0){let Q=[];for(let J of this._filterConditions){let F=`#flt${U}`;if(Z[F]=J.attribute,J.operator==="IN"&&J.values){let X=J.values.map((z,L)=>`:flt${U}_${L}`);J.values.forEach((z,L)=>{$[`:flt${U}_${L}`]=this.driver.marshall({v:z}).v}),Q.push(`${F} IN (${X.join(", ")})`)}else{let X=`:flt${U}`;$[X]=this.driver.marshall({v:J.value}).v,Q.push(`${F} ${J.operator} ${X}`)}U++}W.FilterExpression=Q.join(" AND ")}if(this._projectionAttrs.length>0){let Q=[];for(let J of this._projectionAttrs){let F=`#proj${U}`;Z[F]=J,Q.push(F),U++}W.ProjectionExpression=Q.join(", ")}if(Object.keys(Z).length>0)W.ExpressionAttributeNames=Z;if(Object.keys($).length>0)W.ExpressionAttributeValues=$;if(this._limitValue!==void 0)W.Limit=this._limitValue;if(W.ScanIndexForward=this._scanForward,this._consistentRead)W.ConsistentRead=!0;if(this._startKey)W.ExclusiveStartKey=this.driver.marshall(this._startKey);return W}async get(){if(!this.client)throw Error("DynamoDB client not configured. Call dynamo.connection() first.");let W=this.toRequest();return((this._pkValue!==void 0?await this.client.query(W):await this.client.scan(W)).Items??[]).map(($)=>this.driver.unmarshall($))}async first(){return this._limitValue=1,(await this.get())[0]}async getAll(){let W=[],Y;do{if(Y)this._startKey=Y;let Z=this.toRequest(),U=this._pkValue!==void 0?await this.client.query(Z):await this.client.scan(Z),Q=(U.Items??[]).map((J)=>this.driver.unmarshall(J));W.push(...Q),Y=U.LastEvaluatedKey?this.driver.unmarshall(U.LastEvaluatedKey):void 0}while(Y);return W}async count(){if(!this.client)throw Error("DynamoDB client not configured. Call dynamo.connection() first.");let W=this.toRequest();return W.Select="COUNT",(this._pkValue!==void 0?await this.client.query(W):await this.client.scan(W)).Count??0}}class x{driver;client;tableName="";pkAttribute="pk";skAttribute="sk";entityTypeAttr="_et";delimiter="#";entityMappings=new Map;connection(W){let Y={region:W.region,tableName:W.table,endpoint:W.endpoint,credentials:W.credentials};return this.driver=D(Y),this.tableName=W.table,this.pkAttribute=W.pkAttribute??"pk",this.skAttribute=W.skAttribute??"sk",this.entityTypeAttr=W.entityTypeAttribute??"_et",this.delimiter=W.keyDelimiter??"#",this}setClient(W){return this.client=W,this}registerEntity(W){if(this.entityMappings.set(W.entityType,W),this.driver)this.driver.registerEntity(W);return this}entity(W){if(!this.driver)throw Error("DynamoDB not configured. Call dynamo.connection() first.");return new o(this.driver,this.client,this.tableName,{pkAttribute:this.pkAttribute,skAttribute:this.skAttribute,entityTypeAttribute:this.entityTypeAttr,keyDelimiter:this.delimiter}).entity(W)}async batchWrite(W){if(!this.client)throw Error("DynamoDB client not configured. Call setClient() first.");if(!this.driver)throw Error("DynamoDB not configured. Call dynamo.connection() first.");let Y=[];for(let Z of W)if(Z.put){let $={...Z.put.item,[this.entityTypeAttr]:Z.put.entity};Y.push({PutRequest:{Item:this.driver.marshall($)}})}else if(Z.delete)Y.push({DeleteRequest:{Key:this.driver.marshall({[this.pkAttribute]:Z.delete.pk,[this.skAttribute]:Z.delete.sk})}});if(Y.length>0)await this.client.batchWriteItem({RequestItems:{[this.tableName]:Y}})}async transactWrite(W){if(!this.client)throw Error("DynamoDB client not configured. Call setClient() first.");if(!this.driver)throw Error("DynamoDB not configured. Call dynamo.connection() first.");let Y=[];for(let Z of W)if(Z.put){let $={...Z.put.item,[this.entityTypeAttr]:Z.put.entity},U={Put:{TableName:this.tableName,Item:this.driver.marshall($)}};if(Z.put.condition)U.Put.ConditionExpression=Z.put.condition;Y.push(U)}else if(Z.update){let $={[this.pkAttribute]:Z.update.pk};if(Z.update.sk)$[this.skAttribute]=Z.update.sk;let U=[],Q={},J={},F=0;if(Z.update.set){let X=[];for(let[z,L]of Object.entries(Z.update.set)){let H=`#set${F}`,j=`:set${F}`;Q[H]=z,J[j]=this.driver.marshall({v:L}).v,X.push(`${H} = ${j}`),F++}if(X.length>0)U.push(`SET ${X.join(", ")}`)}if(Z.update.add){let X=[];for(let[z,L]of Object.entries(Z.update.add)){let H=`#add${F}`,j=`:add${F}`;Q[H]=z,J[j]={N:String(L)},X.push(`${H} ${j}`),F++}if(X.length>0)U.push(`ADD ${X.join(", ")}`)}if(Z.update.remove&&Z.update.remove.length>0){let X=[];for(let z of Z.update.remove){let L=`#rem${F}`;Q[L]=z,X.push(L),F++}U.push(`REMOVE ${X.join(", ")}`)}Y.push({Update:{TableName:this.tableName,Key:this.driver.marshall($),UpdateExpression:U.join(" "),ExpressionAttributeNames:Q,ExpressionAttributeValues:J}})}else if(Z.delete){let $={Delete:{TableName:this.tableName,Key:this.driver.marshall({[this.pkAttribute]:Z.delete.pk,[this.skAttribute]:Z.delete.sk})}};if(Z.delete.condition)$.Delete.ConditionExpression=Z.delete.condition;Y.push($)}else if(Z.conditionCheck)Y.push({ConditionCheck:{TableName:this.tableName,Key:this.driver.marshall({[this.pkAttribute]:Z.conditionCheck.pk,[this.skAttribute]:Z.conditionCheck.sk}),ConditionExpression:Z.conditionCheck.condition}});if(Y.length>0)await this.client.transactWriteItems({TransactItems:Y})}getDriver(){return this.driver}}var TW=new x;function SW(){return new x}
7
- export{y as Vb,D as Wb,I as Xb,q as Yb,YW as Zb,v as _b,T as $b,C as ac,p as bc,m as cc,K as dc,ZW as ec,G as fc,M as gc,N as hc,u as ic,$W as jc,o as kc,TW as lc,SW as mc};
7
+ export{y as Wb,D as Xb,I as Yb,q as Zb,YW as _b,v as $b,T as ac,C as bc,p as cc,m as dc,K as ec,ZW as fc,G as gc,M as hc,N as ic,u as jc,$W as kc,o as lc,TW as mc,SW as nc};
package/dist/client.d.ts CHANGED
@@ -31,6 +31,41 @@ import type { SchemaMeta } from './meta';
31
31
  * ```
32
32
  */
33
33
  export declare function raw(strings: TemplateStringsArray | string, ...values: unknown[]): RawExpression;
34
+ /**
35
+ * Render a SELECT-list entry to its SQL text, unwrapping SQL fragments instead
36
+ * of letting them stringify to "[object Object]" (stacksjs/bun-query-builder#1016).
37
+ *
38
+ * Handles every fragment shape in play:
39
+ * - plain column string → as-is
40
+ * - RawExpression `{ raw: string }` → `.raw` (sql.raw(...) markers)
41
+ * - tagged-template builder `{ raw(): string }`→ `raw()`
42
+ * - `{ sql: string, parameters }` fragment → `.sql` (the shape a `sql`…``
43
+ * tagged template emits)
44
+ * - anything else with a useful `toString` → `String(col)`
45
+ * Text-only, mirroring `selectRaw` — bound parameters inside a select-list
46
+ * fragment are not threaded (the documented use is literal expressions like
47
+ * `count(*) as c`).
48
+ */
49
+ /**
50
+ * A plain identifier, quoted for MySQL. Anything else is left exactly as written.
51
+ *
52
+ * MySQL reserves words this schema uses as ordinary column names - `condition`,
53
+ * `uses`, `key`, `groups`, `rank` - and an unquoted one is a syntax error at
54
+ * that point in the statement, not a bad-column error. ReviewOS met it as a
55
+ * `SELECT` of a workflow job's columns failing 167 times in one run: the
56
+ * columns are perfectly legal, and only the spelling was wrong.
57
+ *
58
+ * Only a bare `name` or a qualified `table.name` is quoted. An expression, an
59
+ * alias, a `count(*)`, a `*`, anything already quoted: untouched, because
60
+ * quoting those would break them.
61
+ *
62
+ * MySQL only, deliberately. On Postgres a quoted identifier becomes
63
+ * case-*sensitive*, so quoting `createdAt` would stop it matching the
64
+ * `createdat` the server actually stored - a fix that breaks a working query.
65
+ * MySQL's identifiers are case-insensitive on every platform this runs on, so
66
+ * the quoting changes nothing but the parse.
67
+ */
68
+ export declare function quoteColumnForDialect(name: string, dialect?: unknown): string;
34
69
  /**
35
70
  * Format a value for safe interpolation into a relationship-subquery
36
71
  * fragment. Numbers / booleans / null pass through; everything else is
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Kb as a,Lb as b,Mb as c,Nb as d,Ob as e,Pb as f,Qb as g,Rb as h,Sb as i,Tb as j,Ub as k}from"../chunk-fkjeeh31.js";import"../chunk-c6mb5jxz.js";k();export{c as isBrowser,b as getBrowserConfig,j as default,h as createBrowserModel,g as createBrowserDb,a as configureBrowser,f as browserQuery,i as browserAuth,d as BrowserQueryError,e as BrowserQueryBuilder};
2
+ import{Lb as a,Mb as b,Nb as c,Ob as d,Pb as e,Qb as f,Rb as g,Sb as h,Tb as i,Ub as j,Vb as k}from"../chunk-7e64yq76.js";import"../chunk-x8tfs1sw.js";k();export{c as isBrowser,b as getBrowserConfig,j as default,h as createBrowserModel,g as createBrowserDb,a as configureBrowser,f as browserQuery,i as browserAuth,d as BrowserQueryError,e as BrowserQueryBuilder};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$b as e,Xb as a,Yb as b,Zb as c,_b as d,ac as f,bc as g,cc as h,dc as i,ec as j,fc as k,gc as l,hc as m,ic as n,jc as o,kc as p,lc as q,mc as r}from"../../chunk-605xwkdk.js";import"../../chunk-c6mb5jxz.js";export{o as migrateModels,j as isDefinitionEqual,e as hashTableDefinition,f as extractTableDefinition,g as extractModelSchema,q as dynamo,n as createMigrationDriver,r as createDynamo,b as createClient,h as convertSchemaToDefinition,c as configureModels,i as buildDynamoDBMigrationPlan,d as Model,k as MIGRATIONS_TABLE,p as EntityQueryBuilder,l as DynamoDBMigrationTracker,m as DynamoDBMigrationDriver,a as DynamoDBClient};
2
+ import{$b as d,Yb as a,Zb as b,_b as c,ac as e,bc as f,cc as g,dc as h,ec as i,fc as j,gc as k,hc as l,ic as m,jc as n,kc as o,lc as p,mc as q,nc as r}from"../../chunk-y718nsbf.js";import"../../chunk-x8tfs1sw.js";export{o as migrateModels,j as isDefinitionEqual,e as hashTableDefinition,f as extractTableDefinition,g as extractModelSchema,q as dynamo,n as createMigrationDriver,r as createDynamo,b as createClient,h as convertSchemaToDefinition,c as configureModels,i as buildDynamoDBMigrationPlan,d as Model,k as MIGRATIONS_TABLE,p as EntityQueryBuilder,l as DynamoDBMigrationTracker,m as DynamoDBMigrationDriver,a as DynamoDBClient};
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$,$a as hb,A,Aa as Ia,Ab as _b,B,Ba as Ja,Bb as $b,C,Ca as Ka,Cb as ac,D,Da as La,Db as bc,E,Ea as Ma,Eb as cc,F,Fa as Na,Fb as dc,G,Ga as Oa,Gb as ec,H,Ha as Pa,Hb as fc,I,Ia as Qa,Ib as gc,J,Ja as Ra,Jb as hc,K,Ka as Sa,L,La as Ta,M,Ma as Ua,N,Na as Va,O,Oa as Wa,P,Pa as Xa,Q,Qa as Ya,R,Ra as Za,S,Sa as _a,T,Ta as $a,U,Ua as ab,V,Va as bb,W,Wa as cb,X,Xa as db,Y,Ya as eb,Z,Za as fb,_,_a as gb,a,aa as ca,ab as ib,b,ba as da,bb as jb,c,ca as ea,cb as kb,d,da as fa,db as lb,e,ea as ga,eb as mb,f,fb as nb,g,gb as ob,h,hb as pb,i,ia as ha,ib as qb,j,ja as ia,jb as rb,k,ka as ja,kb as Kb,l,la as ka,lb as Lb,m,ma as la,mb as Mb,n,na as ma,nb as Nb,o,oa as na,ob as Ob,p,pa as oa,pb as Pb,q,qa as pa,qb as Qb,r,ra as qa,rb as Rb,s,sa as ra,sb as Sb,t,ta as sa,tb as Tb,u,ua as ta,ub as Ub,v,va as ua,vb as Vb,w,wa as va,wb as Wb,x,xa as wa,xb as Xb,y,ya as xa,yb as Yb,z,za as Ha,zb as Zb}from"../chunk-yw12p1mp.js";import{Kb as ya,Lb as za,Mb as Aa,Nb as Ba,Ob as Ca,Pb as Da,Qb as Ea,Rb as Fa,Sb as Ga}from"../chunk-fkjeeh31.js";import{$b as wb,Vb as aa,Wb as ba,Xb as sb,Yb as tb,Zb as ub,_b as vb,ac as xb,bc as yb,cc as zb,dc as Ab,ec as Bb,fc as Cb,gc as Db,hc as Eb,ic as Fb,jc as Gb,kc as Hb,lc as Ib,mc as Jb}from"../chunk-605xwkdk.js";import"../chunk-c6mb5jxz.js";export{M as wipeDatabase,xa as waitReady,va as validateSchema,ua as unsafe,nb as unmarshallItem,o as toTableName,lb as toModelInstance,kb as toDynamoDBItem,v as toDialectPlaceholders,F as tinker,p as tableNameFor,Q as tableInfo,q as stripTrailingS,E as startConsole,rb as stacksModelToEntity,S as sqlTypeToAttr,ta as sql,s as singularizerFor,la as showModel,A as setQueryCacheMaxSize,h as setConfig,Qa as seedModel,da as saveMigrationSnapshot,fc as satisfies,pa as runSeeders,qa as runSeeder,n as runBenchmark,k as resolveSqlitePragmas,t as resolvePivot,ib as resolveKeyPattern,d as resolveDialect,ga as resetDatabase,m as resetConnection,oa as relationDiagram,Wa as registerModel,Ya as registerBrowserModels,w as raw,na as queryExplainAll,ma as ping,jb as parseStacksModels,L as optimizeDatabase,la as modelShow,T as modelNameForTable,Qb as migrationBody,ja as migrateStatus,ia as migrateRollback,Gb as migrateModels,ka as migrateList,ha as migrateGenerate,mb as marshallObject,ra as makeSeeder,W as makeModel,Lb as loadModels,Nb as lastCreatedMigrationFiles,u as iterateAllPivots,a as isMysqlLike,Rb as isLosslessTypeChange,Pb as isGeneratedMigrationSql,Bb as isDefinitionEqual,Aa as isBrowser,V as introspectDatabase,R as introspect,P as inspectTable,r as inflectSingular,H as importData,wb as hashTableDefinition,Wb as hashMigrationPlan,Ua as hasModel,f as getPlaceholders,e as getPlaceholder,Ta as getModelRegistry,Ra as getModel,ca as getDialectDriver,Ma as getDatabase,g as getConfig,za as getBrowserConfig,Sa as getAllModels,Ub as generateSqlString,Tb as generateSql,U as generateModelSource,ea as generateMigration,Vb as generateDiffSqlString,$b as generateDiffSql,_b as generateDiffOperations,oa as generateDiagram,qb as generateAccessPatterns,sa as freshDatabase,hc as formatSchemaDrift,O as file,ec as familyOfSqlType,dc as familyOfDeclared,xb as extractTableDefinition,yb as extractModelSchema,Ka as extractInsertId,Ja as extractChanges,G as exportData,na as explainAllQueries,N as explain,fa as executeMigration,x as escapeStringLiteral,Ib as dynamo,I as dumpDatabase,cc as defineSeeder,ac as defineModels,Xa as defineModel,i as defineConfig,b as defaultConfig,M as dbWipe,K as dbStats,L as dbOptimize,J as dbInfo,Pa as createTableFromModel,fb as createSingleTableManager,gb as createRepository,y as createQueryBuilder,Oa as createModel,Fb as createMigrationDriver,Ha as createFakerCompatLayer,pb as createDynamoDBToolingAdapter,$a as createDynamoDBQueryBuilder,ab as createDynamoDBItemBuilder,ba as createDynamoDBDriver,bb as createDynamoDBClient,Jb as createDynamo,tb as createClient,Fa as createBrowserModel,Ea as createBrowserDb,zb as convertSchemaToDefinition,La as configureOrm,ub as configureModels,ya as configureBrowser,c as config,z as clearQueryCache,Va as clearModelRegistry,Ia as clearLocalModels,wa as checkSchema,Zb as canonicalizeDefault,Xb as canonicalStorageType,C as cacheStats,D as cacheConfig,B as cacheClear,Mb as buildSchemaMeta,Sb as buildMigrationPlan,Ab as buildDynamoDBMigrationPlan,Kb as buildDatabaseSchema,Da as browserQuery,Ga as browserAuth,gc as auditSchemaDrift,l as applySqliteBootstrapPragmas,_ as VitessDriver,Yb as UTC_CLOCK_DEFAULT,db as SingleTableRepository,eb as SingleTableQueryBuilder,hb as SingleTablePatterns,cb as SingleTableManager,Z as SingleStoreDriver,bc as Seeder,$ as SQLiteDriver,Y as PostgresDriver,X as MySQLDriver,vb as Model,Cb as MIGRATIONS_TABLE,Ob as GENERATED_MARKER,Hb as EntityQueryBuilder,ob as DynamoDBToolingAdapter,Za as DynamoDBQueryBuilder,Db as DynamoDBMigrationTracker,Eb as DynamoDBMigrationDriver,_a as DynamoDBItemBuilder,aa as DynamoDBDriverImpl,sb as DynamoDBClient,j as DEFAULT_SQLITE_PRAGMAS,Ba as BrowserQueryError,Ca as BrowserQueryBuilder,Na as BelongsToManyRelationBuilder};
2
+ import{$,$a as hb,A,Aa as Ia,Ab as _b,B,Ba as Ja,Bb as $b,C,Ca as Ka,Cb as ac,D,Da as La,Db as bc,E,Ea as Ma,Eb as cc,F,Fa as Na,Fb as dc,G,Ga as Oa,Gb as ec,H,Ha as Pa,Hb as fc,I,Ia as Qa,Ib as gc,J,Ja as Ra,Jb as hc,K,Ka as Sa,Kb as ic,L,La as Ta,M,Ma as Ua,N,Na as Va,O,Oa as Wa,P,Pa as Xa,Q,Qa as Ya,R,Ra as Za,S,Sa as _a,T,Ta as $a,U,Ua as ab,V,Va as bb,W,Wa as cb,X,Xa as db,Y,Ya as eb,Z,Za as fb,_,_a as gb,a,aa,ab as ib,b,ba as da,bb as jb,c,ca as ea,cb as kb,d,da as fa,db as lb,e,ea as ga,eb as mb,f,fa as ha,fb as nb,g,gb as ob,h,hb as pb,i,ib as qb,j,ja as ia,jb as rb,k,ka as ja,kb as sb,l,la as ka,lb as Lb,m,ma as la,mb as Mb,n,na as ma,nb as Nb,o,oa as na,ob as Ob,p,pa as oa,pb as Pb,q,qa as pa,qb as Qb,r,ra as qa,rb as Rb,s,sa as ra,sb as Sb,t,ta as sa,tb as Tb,u,ua as ta,ub as Ub,v,va as ua,vb as Vb,w,wa as va,wb as Wb,x,xa as wa,xb as Xb,y,ya as xa,yb as Yb,z,za as ya,zb as Zb}from"../chunk-9ps7fkza.js";import{Lb as za,Mb as Aa,Nb as Ba,Ob as Ca,Pb as Da,Qb as Ea,Rb as Fa,Sb as Ga,Tb as Ha}from"../chunk-7e64yq76.js";import{$b as wb,Wb as ba,Xb as ca,Yb as tb,Zb as ub,_b as vb,ac as xb,bc as yb,cc as zb,dc as Ab,ec as Bb,fc as Cb,gc as Db,hc as Eb,ic as Fb,jc as Gb,kc as Hb,lc as Ib,mc as Jb,nc as Kb}from"../chunk-y718nsbf.js";import"../chunk-x8tfs1sw.js";export{N as wipeDatabase,ya as waitReady,wa as validateSchema,va as unsafe,ob as unmarshallItem,o as toTableName,mb as toModelInstance,lb as toDynamoDBItem,v as toDialectPlaceholders,G as tinker,p as tableNameFor,R as tableInfo,q as stripTrailingS,F as startConsole,sb as stacksModelToEntity,T as sqlTypeToAttr,ua as sql,s as singularizerFor,ma as showModel,B as setQueryCacheMaxSize,h as setConfig,Ra as seedModel,ea as saveMigrationSnapshot,gc as satisfies,qa as runSeeders,ra as runSeeder,n as runBenchmark,k as resolveSqlitePragmas,t as resolvePivot,jb as resolveKeyPattern,d as resolveDialect,ha as resetDatabase,m as resetConnection,pa as relationDiagram,Xa as registerModel,Za as registerBrowserModels,w as raw,x as quoteColumnForDialect,oa as queryExplainAll,na as ping,kb as parseStacksModels,M as optimizeDatabase,ma as modelShow,U as modelNameForTable,Rb as migrationBody,ka as migrateStatus,ja as migrateRollback,Hb as migrateModels,la as migrateList,ia as migrateGenerate,nb as marshallObject,sa as makeSeeder,X as makeModel,Mb as loadModels,Ob as lastCreatedMigrationFiles,u as iterateAllPivots,a as isMysqlLike,Sb as isLosslessTypeChange,Qb as isGeneratedMigrationSql,Cb as isDefinitionEqual,Ba as isBrowser,W as introspectDatabase,S as introspect,Q as inspectTable,r as inflectSingular,I as importData,xb as hashTableDefinition,Xb as hashMigrationPlan,Va as hasModel,f as getPlaceholders,e as getPlaceholder,Ua as getModelRegistry,Sa as getModel,da as getDialectDriver,Na as getDatabase,g as getConfig,Aa as getBrowserConfig,Ta as getAllModels,Vb as generateSqlString,Ub as generateSql,V as generateModelSource,fa as generateMigration,Wb as generateDiffSqlString,ac as generateDiffSql,$b as generateDiffOperations,pa as generateDiagram,rb as generateAccessPatterns,ta as freshDatabase,ic as formatSchemaDrift,P as file,fc as familyOfSqlType,ec as familyOfDeclared,yb as extractTableDefinition,zb as extractModelSchema,La as extractInsertId,Ka as extractChanges,H as exportData,oa as explainAllQueries,O as explain,ga as executeMigration,y as escapeStringLiteral,Jb as dynamo,J as dumpDatabase,dc as defineSeeder,bc as defineModels,Ya as defineModel,i as defineConfig,b as defaultConfig,N as dbWipe,L as dbStats,M as dbOptimize,K as dbInfo,Qa as createTableFromModel,gb as createSingleTableManager,hb as createRepository,z as createQueryBuilder,Pa as createModel,Gb as createMigrationDriver,Ia as createFakerCompatLayer,qb as createDynamoDBToolingAdapter,ab as createDynamoDBQueryBuilder,bb as createDynamoDBItemBuilder,ca as createDynamoDBDriver,cb as createDynamoDBClient,Kb as createDynamo,ub as createClient,Ga as createBrowserModel,Fa as createBrowserDb,Ab as convertSchemaToDefinition,Ma as configureOrm,vb as configureModels,za as configureBrowser,c as config,A as clearQueryCache,Wa as clearModelRegistry,Ja as clearLocalModels,xa as checkSchema,_b as canonicalizeDefault,Yb as canonicalStorageType,D as cacheStats,E as cacheConfig,C as cacheClear,Nb as buildSchemaMeta,Tb as buildMigrationPlan,Bb as buildDynamoDBMigrationPlan,Lb as buildDatabaseSchema,Ea as browserQuery,Ha as browserAuth,hc as auditSchemaDrift,l as applySqliteBootstrapPragmas,$ as VitessDriver,Zb as UTC_CLOCK_DEFAULT,eb as SingleTableRepository,fb as SingleTableQueryBuilder,ib as SingleTablePatterns,db as SingleTableManager,_ as SingleStoreDriver,cc as Seeder,aa as SQLiteDriver,Z as PostgresDriver,Y as MySQLDriver,wb as Model,Db as MIGRATIONS_TABLE,Pb as GENERATED_MARKER,Ib as EntityQueryBuilder,pb as DynamoDBToolingAdapter,_a as DynamoDBQueryBuilder,Eb as DynamoDBMigrationTracker,Fb as DynamoDBMigrationDriver,$a as DynamoDBItemBuilder,ba as DynamoDBDriverImpl,tb as DynamoDBClient,j as DEFAULT_SQLITE_PRAGMAS,Ca as BrowserQueryError,Da as BrowserQueryBuilder,Oa as BelongsToManyRelationBuilder};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.2.54",
4
+ "version": "0.2.55",
5
5
  "description": "A simple yet performant query builder for TypeScript. Built with Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ba as a,ca as b,da as c,ea as d,fa as e,ga as f,ha as g}from"./chunk-yw12p1mp.js";import"./chunk-fkjeeh31.js";import"./chunk-605xwkdk.js";import"./chunk-c6mb5jxz.js";export{a as saveMigrationSnapshot,d as resetDatabase,b as generateMigration,c as executeMigration,e as deleteMigrationFiles,f as copyModelsToGenerated,g as clearGeneratedDirectory};