Comparing version 40.1.0 to 41.0.0
import type { DbDict } from 'kmore-types'; | ||
import type { Knex } from 'knex'; | ||
import { KmoreBase, ProxyGetOptions } from './base.js'; | ||
import { postProcessResponse } from './helper.js'; | ||
import { CaseType, DbQueryBuilder, EventCallbacks, KmoreQueryBuilder, KmoreTransaction, KmoreTransactionConfig, KnexConfig, QueryContext } from './types.js'; | ||
export declare class Kmore<D = any, Context = any> { | ||
import { CaseType, DbQueryBuilder, EventCallbacks, KmoreQueryBuilder, KmoreTransaction, KmoreTransactionConfig, KnexConfig, QueryContext, TrxIdQueryMap } from './types.js'; | ||
export declare class Kmore<D = any, Context = any> extends KmoreBase<D, Context> { | ||
/** | ||
@@ -79,3 +80,2 @@ * Original table names, without case convertion. | ||
protected postProcessResponse(result: any, queryContext?: QueryContext): unknown; | ||
protected createQueryBuilderGetProxy(builder: KmoreQueryBuilder): KmoreQueryBuilder; | ||
/** | ||
@@ -114,12 +114,2 @@ * Create a proxy for `then` method on QueryBuilder, not on QueryResponse | ||
export declare function createDbh(knexConfig: KnexConfig): Knex; | ||
/** | ||
* kmoreTrxId => Set<kmoreQueryId> | ||
*/ | ||
declare type TrxIdQueryMap = Map<symbol, Set<symbol>>; | ||
interface ProxyGetOptions { | ||
target: KmoreQueryBuilder; | ||
propKey: string | symbol; | ||
receiver: unknown; | ||
} | ||
export {}; | ||
//# sourceMappingURL=kmore.d.ts.map |
@@ -7,9 +7,10 @@ /* eslint-disable max-lines-per-function */ | ||
import { default as _knex } from 'knex'; | ||
// import * as _knex from 'knex' | ||
import { KmoreBase } from './base.js'; | ||
import { defaultPropDescriptor, initialConfig } from './config.js'; | ||
import { callCbOnQuery, callCbOnQueryError, callCbOnQueryResp, callCbOnStart, } from './event.js'; | ||
import { postProcessResponse, wrapIdentifier } from './helper.js'; | ||
import { createQueryBuilderGetProxy } from './proxy.get.js'; | ||
import { extRefTableFnPropertySmartJoin } from './smart-join.js'; | ||
import { CaseType, KmoreProxyKey, } from './types.js'; | ||
export class Kmore { | ||
export class Kmore extends KmoreBase { | ||
/** | ||
@@ -72,2 +73,3 @@ * Original table names, without case convertion. | ||
constructor(options) { | ||
super(); | ||
const dbId = options.dbId ? options.dbId : Date.now().toString(); | ||
@@ -214,2 +216,3 @@ this.dbId = dbId; | ||
} | ||
/* -------------- protected -------------- */ | ||
createTrxProxy(trx) { | ||
@@ -273,3 +276,3 @@ // eslint-disable-next-line @typescript-eslint/unbound-method | ||
let refTable = this.dbh(refName); | ||
refTable = this.createQueryBuilderGetProxy(refTable); | ||
refTable = createQueryBuilderGetProxy(this, refTable); | ||
refTable = this.extRefTableFnPropertyCallback(refTable, caseConvert, ctx, kmoreQueryId); | ||
@@ -370,19 +373,2 @@ refTable = this.extRefTableFnPropertyTransacting(refTable, ctx); | ||
} | ||
createQueryBuilderGetProxy(builder) { | ||
const ret = new Proxy(builder, { | ||
get: (target, propKey, receiver) => { | ||
switch (propKey) { | ||
case 'then': | ||
return this.proxyGetThen({ target, propKey, receiver }); | ||
default: | ||
return Reflect.get(target, propKey, receiver); | ||
} | ||
}, | ||
}); | ||
void Object.defineProperty(ret, 'createQueryBuilderGetProxyKey', { | ||
...defaultPropDescriptor, | ||
value: Date.now(), | ||
}); | ||
return ret; | ||
} | ||
/** | ||
@@ -389,0 +375,0 @@ * Create a proxy for `then` method on QueryBuilder, not on QueryResponse |
@@ -214,2 +214,6 @@ import type { TraceContext, Span } from '@mwcp/otel'; | ||
} | ||
/** | ||
* kmoreTrxId => Set<kmoreQueryId> | ||
*/ | ||
export declare type TrxIdQueryMap = Map<symbol, Set<symbol>>; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "kmore", | ||
"author": "waiting", | ||
"version": "40.1.0", | ||
"version": "41.0.0", | ||
"description": "A SQL query builder based on knex with powerful TypeScript type support", | ||
@@ -46,4 +46,4 @@ "keywords": [ | ||
"cross-env": "7", | ||
"kmore-cli": "^40.0.0", | ||
"kmore-types": "^40.0.0", | ||
"kmore-cli": "^41.0.0", | ||
"kmore-types": "^41.0.0", | ||
"knex": "^2.3.0", | ||
@@ -82,3 +82,3 @@ "pg": "^8.7.3" | ||
}, | ||
"gitHead": "a9b94b2ce191c821aa8dc5cdc5d1d2479ca91ad9" | ||
"gitHead": "8a5bc07b7eab21a8df46b7420779b47f996992e0" | ||
} |
@@ -10,4 +10,4 @@ /* eslint-disable max-lines-per-function */ | ||
import { default as _knex } from 'knex' | ||
// import * as _knex from 'knex' | ||
import { KmoreBase, ProxyGetOptions } from './base.js' | ||
import { defaultPropDescriptor, initialConfig } from './config.js' | ||
@@ -22,2 +22,3 @@ import { | ||
import { PostProcessInput, postProcessResponse, wrapIdentifier } from './helper.js' | ||
import { createQueryBuilderGetProxy } from './proxy.get.js' | ||
import { extRefTableFnPropertySmartJoin } from './smart-join.js' | ||
@@ -39,6 +40,7 @@ import { | ||
QueryResponse, | ||
TrxIdQueryMap, | ||
} from './types.js' | ||
export class Kmore<D = any, Context = any> { | ||
export class Kmore<D = any, Context = any> extends KmoreBase<D, Context> { | ||
@@ -111,2 +113,4 @@ /** | ||
constructor(options: KmoreFactoryOpts<D, Context>) { | ||
super() | ||
const dbId = options.dbId ? options.dbId : Date.now().toString() | ||
@@ -292,4 +296,4 @@ this.dbId = dbId | ||
/* -------------- protected -------------- */ | ||
protected createTrxProxy(trx: KmoreTransaction): KmoreTransaction { | ||
@@ -375,3 +379,3 @@ // eslint-disable-next-line @typescript-eslint/unbound-method | ||
refTable = this.createQueryBuilderGetProxy(refTable) | ||
refTable = createQueryBuilderGetProxy(this, refTable) | ||
refTable = this.extRefTableFnPropertyCallback( | ||
@@ -523,21 +527,2 @@ refTable as KmoreQueryBuilder, | ||
protected createQueryBuilderGetProxy(builder: KmoreQueryBuilder): KmoreQueryBuilder { | ||
const ret = new Proxy(builder, { | ||
get: (target: KmoreQueryBuilder, propKey: string | symbol, receiver: unknown) => { | ||
switch (propKey) { | ||
case 'then': | ||
return this.proxyGetThen({ target, propKey, receiver }) | ||
default: | ||
return Reflect.get(target, propKey, receiver) | ||
} | ||
}, | ||
}) | ||
void Object.defineProperty(ret, 'createQueryBuilderGetProxyKey', { | ||
...defaultPropDescriptor, | ||
value: Date.now(), | ||
}) | ||
return ret | ||
} | ||
/** | ||
@@ -682,13 +667,1 @@ * Create a proxy for `then` method on QueryBuilder, not on QueryResponse | ||
/** | ||
* kmoreTrxId => Set<kmoreQueryId> | ||
*/ | ||
type TrxIdQueryMap = Map<symbol, Set<symbol>> | ||
interface ProxyGetOptions { | ||
target: KmoreQueryBuilder | ||
propKey: string | symbol | ||
receiver: unknown | ||
} |
@@ -288,1 +288,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
* kmoreTrxId => Set<kmoreQueryId> | ||
*/ | ||
export type TrxIdQueryMap = Map<symbol, Set<symbol>> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229191
57
3813