@stacksjs/query-builder 0.74.23 → 0.74.25

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
@@ -26,9 +26,9 @@ export declare function applySqlitePragmas(instance: SqlitePragmaExecutor): void
26
26
  * `getDatabase()` returns the executor's live handle for the sqlite dialect
27
27
  * (creating the executor if needed) and throws for mysql/postgres — where
28
28
  * there is nothing to bootstrap, hence the silent catch. Safe to call
29
- * repeatedly: the WeakSet makes it a no-op after the first hit per
30
- * connection, and a config change that swaps the executor's Database
31
- * produces a fresh (unseen) handle that gets bootstrapped on the next call.
29
+ * repeatedly: the WeakMap makes it a no-op while the connection and pragma
30
+ * list remain unchanged. A new handle or changed list is bootstrapped on
31
+ * the next call.
32
32
  */
33
33
  export declare function bootstrapModelExecutorPragmas(): void;
34
34
  /**
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{setConfig as d}from"bun-query-builder";import*as o from"bun-query-builder";import{config as c,createQueryBuilder as p}from"bun-query-builder";export*from"bun-query-builder";import{saveMigrationSnapshot as O}from"bun-query-builder";var s=new Set;function i(e,n,t){for(let r of s)try{let y=r[e];y?.(n)}catch{}try{let r=t?.[e];r?.(n)}catch{}}function g(e){return{...e,onQueryStart:(n)=>i("onQueryStart",n,e),onQueryEnd:(n)=>i("onQueryEnd",n,e),onQueryError:(n)=>i("onQueryError",n,e),onSlowQuery:(n)=>i("onSlowQuery",n,e)}}function h(e){return s.add(e),()=>s.delete(e)}function Q(e){d({...e,hooks:g(e.hooks)})}var u=["PRAGMA journal_mode = WAL","PRAGMA foreign_keys = ON","PRAGMA busy_timeout = 5000","PRAGMA wal_autocheckpoint = 1"];function w(e){for(let n of u)try{e.unsafe(n).execute().catch(()=>{})}catch{}}var a=new WeakSet;function l(){try{let e=o.getDatabase?.();if(!e||typeof e.run!=="function"||a.has(e))return;for(let n of u)try{e.run(n)}catch{}a.add(e)}catch{}}function R(e){o.configureOrm(e),l()}function v(e){let n=p(e);if(!e?.sql&&c.dialect==="sqlite")w(n),l();return n}var k=new Map;function P(e,n){let t=o.registerModel;if(typeof t==="function")return t(e,n);k.set(e,n);let r=typeof n?.getDefinition==="function"?n.getDefinition():n?.definition;if(r&&typeof r==="object")o.defineModel(r);return n}var m=/^[A-Z_][A-Z0-9_]*$/i;function b(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(!m.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 D(e,n={}){let t=b(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 f=new Set(["=","!=","<>","<","<=",">",">=","like","not like","ilike","not ilike","in","not in","is","is not","between","not between"]);function S(e){return typeof e==="string"&&f.has(e.toLowerCase())}function E(e,n){if(S(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 (${[...f].join(", ")})`)}Q({snapshotDir:"storage/framework/database"});export{v as QueryBuilder,u as SQLITE_BOOTSTRAP_PRAGMAS,w as applySqlitePragmas,D as assertSafeIdentifier,E as assertSafeOperator,l as bootstrapModelExecutorPragmas,R as configureOrm,v as createQueryBuilder,S as isSafeOperator,P as registerModel,h as registerPersistentQueryHooks,O as saveMigrationSnapshot,Q as setConfig,b as validateIdentifier};
2
+ import{setConfig as d}from"bun-query-builder";import*as o from"bun-query-builder";import{config as u,createQueryBuilder as p}from"bun-query-builder";export*from"bun-query-builder";import{saveMigrationSnapshot as _}from"bun-query-builder";var s=new Set;function i(e,t,n){for(let r of s)try{let c=r[e];c?.(t)}catch{}try{let r=n?.[e];r?.(t)}catch{}}function g(e){return{...e,onQueryStart:(t)=>i("onQueryStart",t,e),onQueryEnd:(t)=>i("onQueryEnd",t,e),onQueryError:(t)=>i("onQueryError",t,e),onSlowQuery:(t)=>i("onSlowQuery",t,e)}}function R(e){return s.add(e),()=>s.delete(e)}function Q(e){d({...e,hooks:g(e.hooks)})}var w=["PRAGMA journal_mode = WAL","PRAGMA foreign_keys = ON","PRAGMA busy_timeout = 5000","PRAGMA wal_autocheckpoint = 1"];function l(){return[...w,...u.sqlite?.pragmas??[]]}function m(e){for(let t of l())try{e.unsafe(t).execute().catch(()=>{})}catch{}}var a=new WeakMap;function f(){try{let e=o.getDatabase?.();if(!e||typeof e.run!=="function")return;let t=l(),n=JSON.stringify(t);if(a.get(e)===n)return;for(let r of t)try{e.run(r)}catch{}a.set(e,n)}catch{}}function P(e){o.configureOrm(e),f()}function v(e){let t=p(e);if(!e?.sql&&u.dialect==="sqlite")m(t),f();return t}var k=new Map;function D(e,t){let n=o.registerModel;if(typeof n==="function")return n(e,t);k.set(e,t);let r=typeof t?.getDefinition==="function"?t.getDefinition():t?.definition;if(r&&typeof r==="object")o.defineModel(r);return t}var b=/^[A-Z_][A-Z0-9_]*$/i;function S(e,t={}){if(typeof e!=="string"||e.length===0)return{valid:!1,reason:"empty"};if(e.length>64)return{valid:!1,reason:"too-long"};if(!b.test(e))return{valid:!1,reason:"invalid-shape"};if(t.allowlist&&!t.allowlist.includes(e))return{valid:!1,reason:"not-in-allowlist"};return{valid:!0}}function E(e,t={}){let n=S(e,t);if(n.valid)return;let r=t.context?` in ${t.context}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(e)} as a SQL identifier${r} - ${n.reason}`)}var y=new Set(["=","!=","<>","<","<=",">",">=","like","not like","ilike","not ilike","in","not in","is","is not","between","not between"]);function x(e){return typeof e==="string"&&y.has(e.toLowerCase())}function A(e,t){if(x(e))return;let n=t?` in ${t}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(e)} as a SQL operator${n} - not in the allowed set (${[...y].join(", ")})`)}Q({snapshotDir:"storage/framework/database"});export{v as QueryBuilder,w as SQLITE_BOOTSTRAP_PRAGMAS,m as applySqlitePragmas,E as assertSafeIdentifier,A as assertSafeOperator,f as bootstrapModelExecutorPragmas,P as configureOrm,v as createQueryBuilder,x as isSafeOperator,D as registerModel,R as registerPersistentQueryHooks,_ as saveMigrationSnapshot,Q as setConfig,S 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.74.23",
5
+ "version": "0.74.25",
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.2.62"
59
+ "bun-query-builder": "^0.2.67"
60
60
  },
61
61
  "devDependencies": {
62
- "@stacksjs/database": "0.74.23",
62
+ "@stacksjs/database": "0.74.25",
63
63
  "better-dx": "^0.2.24",
64
- "@stacksjs/types": "0.74.23"
64
+ "@stacksjs/types": "0.74.25"
65
65
  }
66
66
  }