Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kmore

Package Overview
Dependencies
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kmore - npm Package Compare versions

Comparing version 21.0.0 to 22.0.0

51

dist/index.cjs.js

@@ -5,3 +5,3 @@ /**

*
* @version 20.0.1
* @version 21.0.0
* @author waiting

@@ -21,3 +21,2 @@ * @license MIT

var rxjs = require('rxjs');
var operators = require('rxjs/operators');

@@ -136,2 +135,4 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

const globalSubject = new rxjs.Subject();
const globalEvent = globalSubject.asObservable();
function bindOnQuery(subject, identifier, data) {

@@ -213,2 +214,4 @@ const queryUid = pickQueryUidFrom(data);

this.instanceId = instanceId;
this.listenEvent = true;
this.subject = globalSubject;
const dbhBindEvent = dbh

@@ -220,16 +223,20 @@ .on('query', (data) => bindOnQuery(this.subject, void 0, data))

this.refTables = this.createRefTables(this.dbh, 'ref_');
this.subject = new rxjs.Subject();
}
register(eventFilterCallback, identifier) {
const stream$ = this.subject.asObservable();
const ret$ = stream$.pipe(operators.filter((ev) => {
const flag = typeof eventFilterCallback === 'function'
? eventFilterCallback(ev, identifier)
: true;
return flag;
}));
return ret$;
}
// register<K = unknown, T = unknown>(
// eventFilterCallback?: (ev: KmoreEvent<T>, identifier?: K) => boolean,
// identifier?: K,
// ): Observable<KmoreEvent<T>> {
// const stream$ = this.subject.asObservable() as Observable<KmoreEvent<T>>
// const ret$ = stream$.pipe(
// filter((ev) => {
// const flag = typeof eventFilterCallback === 'function'
// ? eventFilterCallback(ev, identifier)
// : true
// return flag
// }),
// )
// return ret$
// }
unsubscribe() {
this.subject.closed || this.subject.unsubscribe();
this.listenEvent = false;
}

@@ -242,5 +249,4 @@ createRefTables(dbh, prefix) {

...defaultPropDescriptor,
value: (identifier) => {
const id = typeof identifier === 'undefined' ? this.instanceId : identifier;
return this.extRefTableFnProperty(dbh, refName, id);
value: () => {
return this.extRefTableFnProperty(dbh, refName);
}, // must dynamically!!

@@ -255,10 +261,4 @@ });

}
extRefTableFnProperty(dbh, refName, identifier) {
let refTable = dbh(refName);
if (typeof identifier !== 'undefined') {
refTable = refTable
.on('query', (data) => bindOnQuery(this.subject, identifier, data))
.on('query-response', (_, respRaw) => bindOnQueryResp(this.subject, identifier, _, respRaw))
.on('query-error', (err, data) => bindOnQueryError(this.subject, identifier, err, data));
}
extRefTableFnProperty(dbh, refName) {
const refTable = dbh(refName);
return refTable;

@@ -279,2 +279,3 @@ }

exports.getCurrentTime = getCurrentTime;
exports.globalEvent = globalEvent;
exports.kmoreFactory = kmoreFactory;

@@ -281,0 +282,0 @@ exports.mergeDoWithInitData = mergeDoWithInitData;

@@ -1,5 +0,7 @@

import { Subject } from 'rxjs';
import { Observable, Subject } from 'rxjs';
import { KmoreEvent, OnQueryData, OnQueryErrorData, OnQueryErrorErr, OnQueryRespRaw, QueryResponse } from './types';
export declare const globalSubject: Subject<KmoreEvent>;
export declare const globalEvent: Observable<KmoreEvent>;
export declare function bindOnQuery(subject: Subject<KmoreEvent>, identifier: unknown, data: OnQueryData): void;
export declare function bindOnQueryResp(subject: Subject<KmoreEvent>, identifier: unknown, _: QueryResponse, respRaw: OnQueryRespRaw): void;
export declare function bindOnQueryError(subject: Subject<KmoreEvent>, identifier: unknown, err: OnQueryErrorErr, data: OnQueryErrorData): void;

@@ -0,2 +1,5 @@

import { Subject } from 'rxjs';
import { initKmoreEvent } from './config';
export const globalSubject = new Subject();
export const globalEvent = globalSubject.asObservable();
export function bindOnQuery(subject, identifier, data) {

@@ -3,0 +6,0 @@ const queryUid = pickQueryUidFrom(data);

@@ -5,1 +5,2 @@ export * from './helper';

export * from './types';
export { globalEvent } from './event';

@@ -5,1 +5,2 @@ export * from './helper';

export * from './types';
export { globalEvent } from './event';
import type { DbDict } from 'kmore-types';
import { Knex } from 'knex';
import { Observable, Subject } from 'rxjs';
import { Subject } from 'rxjs';
import { DbQueryBuilder, KmoreEvent, KnexConfig } from './types';

@@ -11,3 +11,2 @@ export declare class Kmore<D = unknown> {

readonly refTables: DbQueryBuilder<D, 'ref_'>;
protected readonly subject: Subject<KmoreEvent>;
/**

@@ -35,7 +34,8 @@ * Generics parameter, do NOT access as variable!

readonly Dict: DbDict<D>;
protected listenEvent: boolean;
protected readonly subject: Subject<KmoreEvent>;
constructor(config: KnexConfig, dict: DbDict<D>, dbh: Knex, instanceId: string | symbol);
register<K = unknown, T = unknown>(eventFilterCallback?: (ev: KmoreEvent<T>, identifier?: K) => boolean, identifier?: K): Observable<KmoreEvent<T>>;
unsubscribe(): void;
protected createRefTables(dbh: Knex, prefix: string): DbQueryBuilder<D>;
protected extRefTableFnProperty(dbh: Knex, refName: string, identifier?: unknown): Knex.QueryBuilder;
protected extRefTableFnProperty(dbh: Knex, refName: string): Knex.QueryBuilder;
}

@@ -42,0 +42,0 @@ export interface KmoreFactoryOpts<D> {

import { knex } from 'knex';
import { Subject } from 'rxjs';
import { filter } from 'rxjs/operators';
import { defaultPropDescriptor } from './config';
import { bindOnQuery, bindOnQueryError, bindOnQueryResp } from './event';
import { bindOnQuery, bindOnQueryError, bindOnQueryResp, globalSubject, } from './event';
export class Kmore {

@@ -12,2 +10,4 @@ constructor(config, dict, dbh, instanceId) {

this.instanceId = instanceId;
this.listenEvent = true;
this.subject = globalSubject;
const dbhBindEvent = dbh

@@ -19,16 +19,20 @@ .on('query', (data) => bindOnQuery(this.subject, void 0, data))

this.refTables = this.createRefTables(this.dbh, 'ref_');
this.subject = new Subject();
}
register(eventFilterCallback, identifier) {
const stream$ = this.subject.asObservable();
const ret$ = stream$.pipe(filter((ev) => {
const flag = typeof eventFilterCallback === 'function'
? eventFilterCallback(ev, identifier)
: true;
return flag;
}));
return ret$;
}
// register<K = unknown, T = unknown>(
// eventFilterCallback?: (ev: KmoreEvent<T>, identifier?: K) => boolean,
// identifier?: K,
// ): Observable<KmoreEvent<T>> {
// const stream$ = this.subject.asObservable() as Observable<KmoreEvent<T>>
// const ret$ = stream$.pipe(
// filter((ev) => {
// const flag = typeof eventFilterCallback === 'function'
// ? eventFilterCallback(ev, identifier)
// : true
// return flag
// }),
// )
// return ret$
// }
unsubscribe() {
this.subject.closed || this.subject.unsubscribe();
this.listenEvent = false;
}

@@ -41,5 +45,4 @@ createRefTables(dbh, prefix) {

...defaultPropDescriptor,
value: (identifier) => {
const id = typeof identifier === 'undefined' ? this.instanceId : identifier;
return this.extRefTableFnProperty(dbh, refName, id);
value: () => {
return this.extRefTableFnProperty(dbh, refName);
}, // must dynamically!!

@@ -54,10 +57,4 @@ });

}
extRefTableFnProperty(dbh, refName, identifier) {
let refTable = dbh(refName);
if (typeof identifier !== 'undefined') {
refTable = refTable
.on('query', (data) => bindOnQuery(this.subject, identifier, data))
.on('query-response', (_, respRaw) => bindOnQueryResp(this.subject, identifier, _, respRaw))
.on('query-error', (err, data) => bindOnQueryError(this.subject, identifier, err, data));
}
extRefTableFnProperty(dbh, refName) {
const refTable = dbh(refName);
return refTable;

@@ -64,0 +61,0 @@ }

@@ -14,3 +14,3 @@ import { Knex } from 'knex';

};
export declare type TbQueryBuilder<TRecord> = (identifier?: unknown) => Knex.QueryBuilder<TRecord, TRecord[]>;
export declare type TbQueryBuilder<TRecord> = () => Knex.QueryBuilder<TRecord, TRecord[]>;
export interface KmoreEvent<T = unknown> {

@@ -17,0 +17,0 @@ type: 'query' | 'queryError' | 'queryResponse' | 'unknown';

{
"name": "kmore",
"author": "waiting",
"version": "21.0.0",
"version": "22.0.0",
"description": "A SQL query builder based on knex with powerful TypeScript type support",

@@ -42,3 +42,3 @@ "keywords": [

"cross-env": "7",
"kmore-types": "^21.0.0",
"kmore-types": "^22.0.0",
"knex": "^0.95.0",

@@ -104,3 +104,3 @@ "pg": "^8.2.1",

},
"gitHead": "7edffcf20df6deb6f536d23b7a1352733a637b33"
"gitHead": "6b8edf5236046338100aafa132c6627bfb3780fd"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc