@stacksjs/query-builder 0.70.229 → 0.70.231
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 +5 -0
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createQueryBuilder as createBunQueryBuilder } from 'bun-query-builder';
|
|
2
|
+
import { setConfig as setBunQueryBuilderConfig } from 'bun-query-builder';
|
|
2
3
|
import * as bunQueryBuilder from 'bun-query-builder';
|
|
3
4
|
import type { DatabaseSchema } from 'bun-query-builder';
|
|
5
|
+
export declare function registerPersistentQueryHooks(hooks: QueryHooks): () => void;
|
|
6
|
+
export declare function setConfig(config: QueryBuilderConfig): void;
|
|
4
7
|
/**
|
|
5
8
|
* Apply the bootstrap pragmas to the connection of the CURRENT process-wide
|
|
6
9
|
* config. bun-query-builder's `qb.unsafe()` routes through its global
|
|
@@ -122,6 +125,8 @@ export declare interface IdentifierValidation {
|
|
|
122
125
|
reason?: 'invalid-shape' | 'not-in-allowlist' | 'empty' | 'too-long'
|
|
123
126
|
}
|
|
124
127
|
export type StacksDialect = import('bun-query-builder').SupportedDialect | 'singlestore';
|
|
128
|
+
declare type QueryHooks = import('bun-query-builder').QueryHooks;
|
|
129
|
+
declare type QueryBuilderConfig = Parameters<typeof setBunQueryBuilderConfig>[0];
|
|
125
130
|
// bun-query-builder types `unsafe()` as returning `Promise<any>`, but at
|
|
126
131
|
// runtime it returns a Bun SQL Statement that has `.execute()`.
|
|
127
132
|
declare type UnsafeReturn = Promise<any> & { execute: () => Promise<any> }
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{setConfig as
|
|
2
|
+
import{setConfig as G}from"bun-query-builder";import*as U from"bun-query-builder";import{config as L,createQueryBuilder as C}from"bun-query-builder";export*from"bun-query-builder";import{saveMigrationSnapshot as y}from"bun-query-builder";var W=new Set;function V(j,z,J){for(let K of W)try{let N=K[j];N?.(z)}catch{}try{let K=J?.[j];K?.(z)}catch{}}function D(j){return{...j,onQueryStart:(z)=>V("onQueryStart",z,j),onQueryEnd:(z)=>V("onQueryEnd",z,j),onQueryError:(z)=>V("onQueryError",z,j),onSlowQuery:(z)=>V("onSlowQuery",z,j)}}function O(j){return W.add(j),()=>W.delete(j)}function F(j){G({...j,hooks:D(j.hooks)})}var Y=["PRAGMA journal_mode = WAL","PRAGMA foreign_keys = ON","PRAGMA busy_timeout = 5000","PRAGMA wal_autocheckpoint = 1"];function I(j){for(let z of Y)try{j.unsafe(z).execute().catch(()=>{})}catch{}}var X=new WeakSet;function Z(){try{let j=U.getDatabase?.();if(!j||typeof j.run!=="function"||X.has(j))return;for(let z of Y)try{j.run(z)}catch{}X.add(j)}catch{}}function T(j){U.configureOrm(j),Z()}function P(j){let z=C(j);if(!j?.sql&&L.dialect==="sqlite")I(z),Z();return z}var B=new Map;function h(j,z){let J=U.registerModel;if(typeof J==="function")return J(j,z);B.set(j,z);let K=typeof z?.getDefinition==="function"?z.getDefinition():z?.definition;if(K&&typeof K==="object")U.defineModel(K);return z}var M=/^[A-Z_][A-Z0-9_]*$/i;function _(j,z={}){if(typeof j!=="string"||j.length===0)return{valid:!1,reason:"empty"};if(j.length>64)return{valid:!1,reason:"too-long"};if(!M.test(j))return{valid:!1,reason:"invalid-shape"};if(z.allowlist&&!z.allowlist.includes(j))return{valid:!1,reason:"not-in-allowlist"};return{valid:!0}}function A(j,z={}){let J=_(j,z);if(J.valid)return;let K=z.context?` in ${z.context}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(j)} as a SQL identifier${K} \u2014 ${J.reason}`)}var $=new Set(["=","!=","<>","<","<=",">",">=","like","not like","ilike","not ilike","in","not in","is","is not","between","not between"]);function q(j){return typeof j==="string"&&$.has(j.toLowerCase())}function E(j,z){if(q(j))return;let J=z?` in ${z}`:"";throw Error(`[query-builder] Refusing to use ${JSON.stringify(j)} as a SQL operator${J} \u2014 not in the allowed set (${[...$].join(", ")})`)}F({snapshotDir:"storage/framework/database"});export{_ as validateIdentifier,F as setConfig,y as saveMigrationSnapshot,O as registerPersistentQueryHooks,h as registerModel,q as isSafeOperator,P as createQueryBuilder,T as configureOrm,Z as bootstrapModelExecutorPragmas,E as assertSafeOperator,A as assertSafeIdentifier,I as applySqlitePragmas,Y as SQLITE_BOOTSTRAP_PRAGMAS,P as QueryBuilder};
|
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.70.
|
|
5
|
+
"version": "0.70.231",
|
|
6
6
|
"description": "The Stacks Query Builder integration",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"prepublishOnly": "bun run build"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@stacksjs/database": "0.70.
|
|
54
|
+
"@stacksjs/database": "0.70.231",
|
|
55
55
|
"better-dx": "^0.2.17",
|
|
56
|
-
"@stacksjs/types": "0.70.
|
|
56
|
+
"@stacksjs/types": "0.70.231"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"bun-query-builder": "^0.1.63"
|