@stacksjs/query-builder 0.75.40 → 0.75.42

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/index.d.ts CHANGED
@@ -131,8 +131,10 @@ export declare interface IdentifierValidation {
131
131
  * wire protocol and identical DML, so it collapses onto the `mysql` renderer
132
132
  * (see `toQueryBuilderDialect` in @stacksjs/database) and diverges only in
133
133
  * DDL and transaction semantics, which the framework handles itself.
134
+ * `turso` is SQLite's SQL over a libSQL server: it renders as `sqlite`, and
135
+ * bun-query-builder picks the network transport from its libSQL URL.
134
136
  */
135
- export type StacksDialect = import('bun-query-builder').SupportedDialect | 'singlestore' | 'vitess';
137
+ export type StacksDialect = import('bun-query-builder').SupportedDialect | 'singlestore' | 'vitess' | 'turso';
136
138
  declare type QueryHooks = import('bun-query-builder').QueryHooks;
137
139
  declare type QueryBuilderConfig = Parameters<typeof setBunQueryBuilderConfig>[0] & {
138
140
  /** Directory containing the active SQL migration corpus. */
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{setConfig as s}from"bun-query-builder";import*as o from"bun-query-builder";import{config as l,createQueryBuilder as Q}from"bun-query-builder";export*from"bun-query-builder";import{saveMigrationSnapshot as L}from"bun-query-builder";var i=new Set,u;function w(e){return Boolean(e&&Object.values(e).some((n)=>n!==void 0))}function m(e,n,t){for(let r of i)try{let k=r[e];k?.(n)}catch{}try{let r=t?.[e];r?.(n)}catch{}}var b=["onQueryStart","onQueryEnd","onQueryError","onSlowQuery"];function S(e,n){if(n?.[e]!==void 0)return!0;for(let t of i)if(t[e]!==void 0)return!0;return!1}function h(e){let n={...e};for(let t of b)if(S(t,e))n[t]=(r)=>m(t,r,e);return n}function d(){return i.size>0||w(u)?h(u):void 0}function c(e){if(s({hooks:void 0}),e)s({hooks:e})}function a(){c(d())}function A(e){return i.add(e),a(),()=>{if(i.delete(e))a()}}function x(e){if(Object.prototype.hasOwnProperty.call(e,"hooks"))u=e.hooks;let{hooks:n,...t}=e;s(t),c(d())}var B=["PRAGMA journal_mode = WAL","PRAGMA foreign_keys = ON","PRAGMA busy_timeout = 5000","PRAGMA wal_autocheckpoint = 100"];function y(){return[...B,...l.sqlite?.pragmas??[]]}function H(e){for(let n of y())try{e.unsafe(n).execute().catch(()=>{})}catch{}}var f=new WeakMap;function p(){try{let e=o.getDatabase?.();if(!e||typeof e.run!=="function")return;let n=y(),t=JSON.stringify(n);if(f.get(e)===t)return;for(let r of n)try{e.run(r)}catch{}f.set(e,t)}catch{}}function q(e){o.configureOrm(e),p()}function M(e){let n=Q(e);if(!e?.sql&&l.dialect==="sqlite")H(n),p();return n}var P=new Map;function _(e,n){let t=o.registerModel;if(typeof t==="function")return t(e,n);P.set(e,n);let r=typeof n?.getDefinition==="function"?n.getDefinition():n?.definition;if(r&&typeof r==="object")o.defineModel(r);return n}var R=/^[A-Z_][A-Z0-9_]*$/i;function v(e,n={}){if(typeof e!=="string"||e.length===0)return{valid:!1,reason:"empty"};if(e.length>64)return{valid:!1,reason:"too-long"};if(!R.test(e))return{valid:!1,reason:"invalid-shape"};if(n.allowlist&&!n.allowlist.includes(e))return{valid:!1,reason:"not-in-allowlist"};return{valid:!0}}function C(e,n={}){let t=v(e,n);if(t.valid)return;let r=n.context?` in ${n.context}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(e)} as a SQL identifier${r} - ${t.reason}`)}var g=new Set(["=","!=","<>","<","<=",">",">=","like","not like","ilike","not ilike","in","not in","is","is not","between","not between"]);function D(e){return typeof e==="string"&&g.has(e.toLowerCase())}function T(e,n){if(D(e))return;let t=n?` in ${n}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(e)} as a SQL operator${t} - not in the allowed set (${[...g].join(", ")})`)}x({snapshotDir:"storage/framework/database"});export{M as QueryBuilder,B as SQLITE_BOOTSTRAP_PRAGMAS,H as applySqlitePragmas,C as assertSafeIdentifier,T as assertSafeOperator,p as bootstrapModelExecutorPragmas,q as configureOrm,M as createQueryBuilder,D as isSafeOperator,_ as registerModel,A as registerPersistentQueryHooks,L as saveMigrationSnapshot,x as setConfig,v as validateIdentifier};
2
+ import{setConfig as s}from"bun-query-builder";import*as o from"bun-query-builder";import{config as l,createQueryBuilder as k}from"bun-query-builder";export*from"bun-query-builder";import{saveMigrationSnapshot as j}from"bun-query-builder";var i=new Set,u;function w(e){return Boolean(e&&Object.values(e).some((n)=>n!==void 0))}function b(e,n,r){for(let t of i)try{let Q=t[e];Q?.(n)}catch{}try{let t=r?.[e];t?.(n)}catch{}}var m=["onQueryStart","onQueryEnd","onQueryError","onSlowQuery"];function S(e,n){if(n?.[e]!==void 0)return!0;for(let r of i)if(r[e]!==void 0)return!0;return!1}function h(e){let n={...e};for(let r of m)if(S(r,e))n[r]=(t)=>b(r,t,e);return n}function d(){return i.size>0||w(u)?h(u):void 0}function c(e){if(s({hooks:void 0}),e)s({hooks:e})}function a(){c(d())}function A(e){return i.add(e),a(),()=>{if(i.delete(e))a()}}function x(e){if(Object.prototype.hasOwnProperty.call(e,"hooks"))u=e.hooks;let{hooks:n,...r}=e;s(r),c(d())}var B=["PRAGMA journal_mode = WAL","PRAGMA foreign_keys = ON","PRAGMA busy_timeout = 5000","PRAGMA wal_autocheckpoint = 100"];function y(){return[...B,...l.sqlite?.pragmas??[]]}function v(e){for(let n of y())try{e.unsafe(n).execute().catch(()=>{})}catch{}}var f=new WeakMap;function p(){try{let e=o.getDatabase?.();if(!e||typeof e.run!=="function")return;let n=y(),r=JSON.stringify(n);if(f.get(e)===r)return;for(let t of n)try{e.run(t)}catch{}f.set(e,r)}catch{}}function q(e){o.configureOrm(e),p()}function M(e){let n=k(e);if(!e?.sql&&l.dialect==="sqlite"&&!o.resolveLibSQLTarget())v(n),p();return n}var H=new Map;function _(e,n){let r=o.registerModel;if(typeof r==="function")return r(e,n);H.set(e,n);let t=typeof n?.getDefinition==="function"?n.getDefinition():n?.definition;if(t&&typeof t==="object")o.defineModel(t);return n}var P=/^[A-Z_][A-Z0-9_]*$/i;function R(e,n={}){if(typeof e!=="string"||e.length===0)return{valid:!1,reason:"empty"};if(e.length>64)return{valid:!1,reason:"too-long"};if(!P.test(e))return{valid:!1,reason:"invalid-shape"};if(n.allowlist&&!n.allowlist.includes(e))return{valid:!1,reason:"not-in-allowlist"};return{valid:!0}}function T(e,n={}){let r=R(e,n);if(r.valid)return;let t=n.context?` in ${n.context}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(e)} as a SQL identifier${t} - ${r.reason}`)}var g=new Set(["=","!=","<>","<","<=",">",">=","like","not like","ilike","not ilike","in","not in","is","is not","between","not between"]);function D(e){return typeof e==="string"&&g.has(e.toLowerCase())}function C(e,n){if(D(e))return;let r=n?` in ${n}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(e)} as a SQL operator${r} - not in the allowed set (${[...g].join(", ")})`)}x({snapshotDir:"storage/framework/database"});export{M as QueryBuilder,B as SQLITE_BOOTSTRAP_PRAGMAS,v as applySqlitePragmas,T as assertSafeIdentifier,C as assertSafeOperator,p as bootstrapModelExecutorPragmas,q as configureOrm,M as createQueryBuilder,D as isSafeOperator,_ as registerModel,A as registerPersistentQueryHooks,j as saveMigrationSnapshot,x as setConfig,R as validateIdentifier};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/query-builder",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.40",
5
+ "version": "0.75.42",
6
6
  "description": "The Stacks Query Builder integration",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -56,11 +56,11 @@
56
56
  "prepublishOnly": "bun run build"
57
57
  },
58
58
  "dependencies": {
59
- "bun-query-builder": "^0.3.4"
59
+ "bun-query-builder": "^0.3.5"
60
60
  },
61
61
  "devDependencies": {
62
- "@stacksjs/database": "0.75.40",
62
+ "@stacksjs/database": "0.75.42",
63
63
  "better-dx": "^0.2.24",
64
- "@stacksjs/types": "0.75.40"
64
+ "@stacksjs/types": "0.75.42"
65
65
  }
66
66
  }