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

reactivedb

Package Overview
Dependencies
Maintainers
5
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactivedb - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1-alpha.0-rxnotreeshake

rx.d.ts

2

interface/index.d.ts
/// <reference types="lovefield" />
import { Observable, PartialObserver } from 'rxjs';
import { Observable, PartialObserver } from '../rx';
import { RDBType, Relationship, LeafType, StatementType, JoinMode, DataStoreType } from './enum';

@@ -4,0 +4,0 @@ export declare type DeepPartial<T> = {

{
"name": "reactivedb",
"version": "0.11.0",
"version": "0.11.1-alpha.0-rxnotreeshake",
"description": "Reactive ORM for Lovefield",

@@ -5,0 +5,0 @@ "main": "./index.js",

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

import { Observable, PartialObserver } from 'rxjs'
import { Observable, PartialObserver } from '../rx'
import { RDBType, Relationship, LeafType, StatementType, JoinMode, DataStoreType } from './enum'

@@ -3,0 +3,0 @@

@@ -1,3 +0,2 @@

import { throwError, ConnectableObservable, Observable, Subscription, from, of as just } from 'rxjs'
import { concatMap, map, tap } from 'rxjs/operators'
import * as rx from '../rx'
import * as lf from 'lovefield'

@@ -52,3 +51,3 @@ import * as Exception from '../exception'

public readonly database$: ConnectableObservable<lf.Database>
public readonly database$: rx.ConnectableObservable<lf.Database>
public readonly inTransaction: boolean = false

@@ -62,3 +61,3 @@

private storedIds = new Set<string>()
private subscription: Subscription | null = null
private subscription: rx.Subscription | null = null

@@ -116,3 +115,3 @@ private findSchema = (name: string): ParsedSchema => {

const dump = (db: lf.Database) => db.export()
return this.database$.pipe(concatMap(dump))
return this.database$.pipe(rx.concatMap(dump))
}

@@ -136,16 +135,16 @@

}
return this.database$.pipe(concatMap(load))
return this.database$.pipe(rx.concatMap(load))
}
insert<T>(tableName: string, raw: T[]): Observable<ExecutorResult>
insert<T>(tableName: string, raw: T[]): rx.Observable<ExecutorResult>
insert<T>(tableName: string, raw: T): Observable<ExecutorResult>
insert<T>(tableName: string, raw: T): rx.Observable<ExecutorResult>
insert<T>(tableName: string, raw: T | T[]): Observable<ExecutorResult>
insert<T>(tableName: string, raw: T | T[]): rx.Observable<ExecutorResult>
insert<T>(tableName: string, raw: T | T[]): Observable<ExecutorResult> {
insert<T>(tableName: string, raw: T | T[]): rx.Observable<ExecutorResult> {
const insert = (db: lf.Database) => {
const maybeSchema = this.tryCatchFindSchema({ op: 'insert' })(tableName)
if (isException(maybeSchema)) {
return throwError(maybeSchema.unwrapped)
return rx.throw(maybeSchema.unwrapped)
}

@@ -190,16 +189,16 @@ const schema = maybeSchema.unwrapped

return this.executor(db, queries).pipe(tap(onError))
return this.executor(db, queries).pipe(rx.tap(onError))
}
return this.database$.pipe(concatMap(insert))
return this.database$.pipe(rx.concatMap(insert))
}
get<T>(tableName: string, query: Query<T> = {}, mode: JoinMode = JoinMode.imlicit): QueryToken<T> {
const selector$ = this.database$.pipe(map((db) => this.buildSelector(db, tableName, query, mode)))
const selector$ = this.database$.pipe(rx.map((db) => this.buildSelector(db, tableName, query, mode)))
return new QueryToken<T>(selector$)
}
update<T>(tableName: string, clause: Predicate<T>, raw: Partial<T>): Observable<ExecutorResult> {
update<T>(tableName: string, clause: Predicate<T>, raw: Partial<T>): rx.Observable<ExecutorResult> {
const type = getType(raw)
if (type !== 'Object') {
return throwError(Exception.InvalidType(['Object', type]))
return rx.throw(Exception.InvalidType(['Object', type]))
}

@@ -209,3 +208,3 @@

if (isException(maybeSchema)) {
return throwError(maybeSchema.unwrapped)
return rx.throw(maybeSchema.unwrapped)
}

@@ -248,13 +247,13 @@ const schema = maybeSchema.unwrapped

}
return this.database$.pipe(concatMap(update))
return this.database$.pipe(rx.concatMap(update))
}
delete<T>(tableName: string, clause: Predicate<T> = {}): Observable<ExecutorResult> {
delete<T>(tableName: string, clause: Predicate<T> = {}): rx.Observable<ExecutorResult> {
const maybePK = this.tryCatchFindPrimaryKey({ op: 'delete' })(tableName)
if (isException(maybePK)) {
return throwError(maybePK.unwrapped)
return rx.throw(maybePK.unwrapped)
}
const pk = maybePK.unwrapped
const deletion = (db: lf.Database): Observable<ExecutorResult> => {
const deletion = (db: lf.Database): rx.Observable<ExecutorResult> => {
const [table] = Database.getTables(db, tableName)

@@ -280,18 +279,18 @@ const column = table[pk]

return this.executor(db, [query]).pipe(tap(onError))
return this.executor(db, [query]).pipe(rx.tap(onError))
}
return from(prefetch.exec()).pipe(concatMap(deleteByScopedIds))
return rx.from(prefetch.exec()).pipe(rx.concatMap(deleteByScopedIds))
}
return this.database$.pipe(concatMap(deletion))
return this.database$.pipe(rx.concatMap(deletion))
}
upsert<T>(tableName: string, raw: T): Observable<ExecutorResult>
upsert<T>(tableName: string, raw: T): rx.Observable<ExecutorResult>
upsert<T>(tableName: string, raw: T[]): Observable<ExecutorResult>
upsert<T>(tableName: string, raw: T[]): rx.Observable<ExecutorResult>
upsert<T>(tableName: string, raw: T | T[]): Observable<ExecutorResult>
upsert<T>(tableName: string, raw: T | T[]): rx.Observable<ExecutorResult>
upsert<T>(tableName: string, raw: T | T[]): Observable<ExecutorResult> {
upsert<T>(tableName: string, raw: T | T[]): rx.Observable<ExecutorResult> {
const upsert = (db: lf.Database) => {

@@ -313,14 +312,14 @@ const sharing = new Map<any, Mutation>()

return this.executor(db, queries).pipe(tap(onError))
return this.executor(db, queries).pipe(rx.tap(onError))
} else {
return just({ result: false, insert: 0, update: 0, delete: 0, select: 0 })
return rx.of({ result: false, insert: 0, update: 0, delete: 0, select: 0 })
}
}
return this.database$.pipe(concatMap(upsert))
return this.database$.pipe(rx.concatMap(upsert))
}
remove<T>(tableName: string, clause: Clause<T> = {}): Observable<ExecutorResult> {
remove<T>(tableName: string, clause: Clause<T> = {}): rx.Observable<ExecutorResult> {
const maybeSchema = this.tryCatchFindSchema({ op: 'remove' })(tableName)
if (isException(maybeSchema)) {
return throwError(maybeSchema.unwrapped)
return rx.throw(maybeSchema.unwrapped)
}

@@ -350,4 +349,4 @@ const schema = maybeSchema.unwrapped

return disposeHandler(rootEntities, scope).pipe(
tap(() => removedIds.forEach((id: string) => this.storedIds.delete(id))),
concatMap(() => {
rx.tap(() => removedIds.forEach((id: string) => this.storedIds.delete(id))),
rx.concatMap(() => {
if (this.inTransaction) {

@@ -357,3 +356,3 @@ this.attachTx(onError)

}
return this.executor(db, queries).pipe(tap(onError))
return this.executor(db, queries).pipe(rx.tap(onError))
}),

@@ -367,3 +366,3 @@ )

}
return this.executor(db, queries).pipe(tap(onError))
return this.executor(db, queries).pipe(rx.tap(onError))
}

@@ -373,11 +372,11 @@ }

const prefetch = predicatableQuery(db, table, predicate!, StatementType.Select)
return from(prefetch.exec()).pipe(concatMap(removeByRootEntities))
return rx.from(prefetch.exec()).pipe(rx.concatMap(removeByRootEntities))
}
return this.database$.pipe(concatMap(remove))
return this.database$.pipe(rx.concatMap(remove))
}
dispose(): Observable<never> | Observable<ExecutorResult> {
dispose(): rx.Observable<never> | rx.Observable<ExecutorResult> {
if (!this.connected) {
return throwError(Exception.NotConnected())
return rx.throw(Exception.NotConnected())
}

@@ -391,3 +390,3 @@

return this.executor(db, deletions).pipe(
tap(() => {
rx.tap(() => {
db.close()

@@ -402,3 +401,3 @@ this.schemas.clear()

return this.database$.pipe(concatMap(cleanUp))
return this.database$.pipe(rx.concatMap(cleanUp))
}

@@ -413,5 +412,5 @@

return from(tx.exec(queries)).pipe(
tap(transactionErrorHandler),
map((ret) => {
return rx.from(tx.exec(queries)).pipe(
rx.tap(transactionErrorHandler),
rx.map((ret) => {
return {

@@ -425,7 +424,7 @@ result: true,

transaction(): Observable<Transaction<Database>> {
transaction(): rx.Observable<Transaction<Database>> {
type ProxyProperty = Pick<Database, 'attachTx' | 'executor' | 'inTransaction'>
return this.database$.pipe(
map((db) => {
rx.map((db) => {
const tx = db.createTransaction()

@@ -447,3 +446,3 @@ const transactionQueries: lf.query.Builder[] = []

transactionQueries.push(...queries)
return just(null)
return rx.of(null)
}

@@ -463,6 +462,6 @@ },

.reduce((acc, curr) => {
return acc.pipe(tap(curr))
}, from(tx.exec(transactionQueries)))
return acc.pipe(rx.tap(curr))
}, rx.from(tx.exec(transactionQueries)))
.pipe(
map((r) => {
rx.map((r) => {
return {

@@ -924,3 +923,3 @@ result: true,

if (isException(maybePredicate)) {
return throwError(maybePredicate.unwrapped)
return rx.throw(maybePredicate.unwrapped)
}

@@ -930,3 +929,3 @@ const predicate = maybePredicate.unwrapped

return from<T[]>(query.exec() as any)
return rx.from<T[]>(query.exec() as any)
}

@@ -933,0 +932,0 @@

import * as lf from 'lovefield'
import { Observable, ConnectableObservable, ReplaySubject, Observer } from 'rxjs'
import { publishReplay } from 'rxjs/operators'
import * as rx from '../../rx'
import { LfFactoryInit } from '../../interface'
export const rawDb$ = new ReplaySubject<lf.raw.BackStore>(1)
export const rawDb$ = new rx.ReplaySubject<lf.raw.BackStore>(1)

@@ -17,4 +16,4 @@ function onUpgrade(rawDb: lf.raw.BackStore) {

config: LfFactoryInit,
): ConnectableObservable<lf.Database> => {
return Observable.create((observer: Observer<lf.Database>) => {
): rx.ConnectableObservable<lf.Database> => {
return rx.Observable.create((observer: rx.Observer<lf.Database>) => {
(config as any).onUpgrade = onUpgrade

@@ -32,3 +31,3 @@ if (config.storeType >= 3) {

.catch((e) => observer.error(e))
}).pipe(publishReplay(1))
}).pipe(rx.publishReplay(1))
}

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

import { Observable } from 'rxjs'
import { Observable } from '../../rx'

@@ -3,0 +3,0 @@ export const mapFn = <U>(dist$: Observable<U[]>) => dist$

@@ -1,3 +0,2 @@

import { Observable, OperatorFunction } from 'rxjs'
import { map } from 'rxjs/operators'
import { map, Observable, OperatorFunction } from '../../rx'
import { Query } from '../../interface'

@@ -4,0 +3,0 @@ import { mapFn } from './mapFn'

@@ -1,3 +0,2 @@

import { Observable, OperatorFunction, from } from 'rxjs'
import { combineAll, map, publishReplay, refCount, skipWhile, switchMap, take, tap } from 'rxjs/operators'
import * as rx from '../../rx'
import { Selector } from './Selector'

@@ -10,35 +9,35 @@ import { ProxySelector } from './ProxySelector'

const skipWhileProxySelector = skipWhile((v) => v instanceof ProxySelector) as <T>(
x: Observable<SelectorMeta<T>>,
) => Observable<Selector<T>>
const skipWhileProxySelector = rx.skipWhile((v) => v instanceof ProxySelector) as <T>(
x: rx.Observable<SelectorMeta<T>>,
) => rx.Observable<Selector<T>>
export class QueryToken<T> {
selector$: Observable<SelectorMeta<T>>
selector$: rx.Observable<SelectorMeta<T>>
private consumed = false
constructor(selector$: Observable<SelectorMeta<T>>) {
constructor(selector$: rx.Observable<SelectorMeta<T>>) {
this.selector$ = selector$.pipe(
publishReplay(1),
refCount(),
rx.publishReplay(1),
rx.refCount(),
)
}
map<K>(fn: OperatorFunction<T[], K[]>) {
this.selector$ = this.selector$.pipe(tap((selector) => (selector as any).map(fn)))
map<K>(fn: rx.OperatorFunction<T[], K[]>) {
this.selector$ = this.selector$.pipe(rx.tap((selector) => (selector as any).map(fn)))
return (this as any) as QueryToken<K>
}
values(): Observable<T[]> {
values(): rx.Observable<T[]> {
assert(!this.consumed, TokenConsumed)
this.consumed = true
return this.selector$.pipe(switchMap((s) => s.values()), take(1))
return this.selector$.pipe(rx.switchMap((s) => s.values()), rx.take(1))
}
changes(): Observable<T[]> {
changes(): rx.Observable<T[]> {
assert(!this.consumed, TokenConsumed)
this.consumed = true
return this.selector$.pipe(switchMap((s) => s.changes()))
return this.selector$.pipe(rx.switchMap((s) => s.changes()))
}

@@ -48,6 +47,6 @@

tokens.unshift(this)
const newSelector$ = from(tokens).pipe(
map((token) => token.selector$.pipe(skipWhileProxySelector)),
combineAll<Selector<T>>(),
map((r) => {
const newSelector$ = rx.from(tokens).pipe(
rx.map((token) => token.selector$.pipe(skipWhileProxySelector)),
rx.combineAll<Selector<T>>(),
rx.map((r) => {
const first = r.shift()

@@ -62,6 +61,6 @@ return first!.concat(...r)

tokens.unshift(this)
const newSelector$ = from(tokens).pipe(
map((token) => token.selector$.pipe(skipWhileProxySelector)),
combineAll<Selector<T>>(),
map((r) => {
const newSelector$ = rx.from(tokens).pipe(
rx.map((token) => token.selector$.pipe(skipWhileProxySelector)),
rx.combineAll<Selector<T>>(),
rx.map((r) => {
const first = r.shift()

@@ -75,4 +74,4 @@ return first!.combine(...r)

toString() {
return this.selector$.pipe(map((r) => r.toString()))
return this.selector$.pipe(rx.map((r) => r.toString()))
}
}

@@ -1,14 +0,2 @@

import { Observable, Observer, OperatorFunction, from, asyncScheduler } from 'rxjs'
import {
filter,
combineAll,
debounceTime,
map,
mergeMap,
publishReplay,
reduce,
refCount,
scan,
switchMap,
} from 'rxjs/operators'
import * as rx from '../../rx'
import * as lf from 'lovefield'

@@ -57,9 +45,9 @@ import * as Exception from '../../exception'

const dist = new Selector<U>(originalToken.db, fakeQuery as any, {} as any)
dist.change$ = from(metaDatas).pipe(
map((metas) => metas.mapFn(metas.change$)),
combineAll<U[]>(),
map((r) => r.reduce((acc, val) => acc.concat(val))),
debounceTime(0, asyncScheduler),
publishReplay(1),
refCount(),
dist.change$ = rx.from(metaDatas).pipe(
rx.map((metas) => metas.mapFn(metas.change$)),
rx.combineAll<U[]>(),
rx.map((r) => r.reduce((acc, val) => acc.concat(val))),
rx.debounceTime(0, rx.async),
rx.publishReplay(1),
rx.refCount(),
)

@@ -69,5 +57,5 @@ dist.values = () => {

dist.consumed = true
return from(metaDatas).pipe(
mergeMap((metaData) => metaData.values()),
reduce((acc, val) => acc.concat(val)),
return rx.from(metaDatas).pipe(
rx.mergeMap((metaData) => metaData.values()),
rx.reduce((acc, val) => acc.concat(val)),
)

@@ -96,9 +84,9 @@ }

private mapFn: (stream$: Observable<T[]>) => Observable<any[]> = mapFn
private mapFn: (stream$: rx.Observable<T[]>) => rx.Observable<any[]> = mapFn
public select: string
private _change$: Observable<T[]> | null = null
private _change$: rx.Observable<T[]> | null = null
private get change$(): Observable<T[]> {
private get change$(): rx.Observable<T[]> {
if (this._change$) {

@@ -112,3 +100,3 @@ return this._change$

const observeOn = (query: lf.query.Select) =>
Observable.create((observer: Observer<T[]>) => {
rx.Observable.create((observer: rx.Observer<T[]>) => {
const listener = () => {

@@ -122,16 +110,16 @@ this.getValue(query)

return () => this.db.unobserve(query, listener)
}) as Observable<T[]>
}) as rx.Observable<T[]>
const changesOnQuery =
limit || skip
? this.buildPrefetchingObserve().pipe(switchMap((pks) => observeOn(this.getQuery(this.inPKs(pks)))))
? this.buildPrefetchingObserve().pipe(rx.switchMap((pks) => observeOn(this.getQuery(this.inPKs(pks)))))
: observeOn(this.getQuery())
return lfIssueFix(changesOnQuery).pipe(
publishReplay(1),
refCount(),
rx.publishReplay(1),
rx.refCount(),
)
}
private set change$(dist$: Observable<T[]>) {
private set change$(dist$: rx.Observable<T[]>) {
this._change$ = dist$

@@ -202,3 +190,3 @@ }

values(): Observable<T[]> | never {
values(): rx.Observable<T[]> | never {
if (typeof this.limit !== 'undefined' || typeof this.skip !== 'undefined') {

@@ -209,5 +197,5 @@ const p = this.rangeQuery

.then((pks) => this.getValue(this.getQuery(this.inPKs(pks))))
return this.mapFn(from(p))
return this.mapFn(rx.from(p))
} else {
return this.mapFn(from(this.getValue(this.getQuery()) as Promise<T[]>))
return this.mapFn(rx.from(this.getValue(this.getQuery()) as Promise<T[]>))
}

@@ -236,7 +224,7 @@ }

changes(): Observable<T[]> | never {
changes(): rx.Observable<T[]> | never {
return this.mapFn(this.change$)
}
map<K>(fn: OperatorFunction<T[], K[]>) {
map<K>(fn: rx.OperatorFunction<T[], K[]>) {
this.mapFn = fn

@@ -288,4 +276,4 @@ return (this as any) as Selector<K>

private buildPrefetchingObserve(): Observable<(string | number)[]> {
return Observable.create((observer: Observer<(string | number)[]>) => {
private buildPrefetchingObserve(): rx.Observable<(string | number)[]> {
return rx.Observable.create((observer: rx.Observer<(string | number)[]>) => {
const { rangeQuery } = this

@@ -315,3 +303,3 @@ const listener = () => {

*/
const lfIssueFix = <T>(changes: Observable<T[]>) => {
const lfIssueFix = <T>(changes: rx.Observable<T[]>) => {
const doKeep = (prev: T[] | null, curr: T[] | null, idx: number) =>

@@ -321,5 +309,5 @@ idx === 1 && prev && prev.length && curr && curr.length ? null : curr

return changes.pipe(
scan(doKeep, null),
filter(isNonNullable),
rx.scan(doKeep, null),
rx.filter(isNonNullable),
)
}

@@ -1,11 +0,10 @@

import { throwError, Observable, EMPTY } from 'rxjs'
import { skip } from 'rxjs/operators'
import * as rx from '../rx'
// think it as asynchronous assert
export function valid<T>(condition: any, error: Error): Observable<never> | Observable<T> {
export function valid<T>(condition: any, error: Error): rx.Observable<never> | rx.Observable<T> {
if (!condition) {
return throwError(error)
return rx.throw(error)
}
return EMPTY.pipe(skip(1))
return rx.empty().pipe(rx.skip(1))
}

@@ -1,1 +0,1 @@

export default '0.11.0'
export default '0.11.1-alpha.0-rxnotreeshake'

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

import { ConnectableObservable, Observable } from 'rxjs';
import * as rx from '../rx';
import * as lf from 'lovefield';

@@ -11,3 +11,3 @@ import { QueryToken } from './modules';

static getTables(db: lf.Database, ...tableNames: string[]): lf.schema.Table[];
readonly database$: ConnectableObservable<lf.Database>;
readonly database$: rx.ConnectableObservable<lf.Database>;
readonly inTransaction: boolean;

@@ -37,17 +37,17 @@ private schemaDefs;

connect(): void;
dump(): Observable<Object>;
load(data: any): Observable<void>;
insert<T>(tableName: string, raw: T[]): Observable<ExecutorResult>;
insert<T>(tableName: string, raw: T): Observable<ExecutorResult>;
insert<T>(tableName: string, raw: T | T[]): Observable<ExecutorResult>;
dump(): rx.Observable<Object>;
load(data: any): rx.Observable<void>;
insert<T>(tableName: string, raw: T[]): rx.Observable<ExecutorResult>;
insert<T>(tableName: string, raw: T): rx.Observable<ExecutorResult>;
insert<T>(tableName: string, raw: T | T[]): rx.Observable<ExecutorResult>;
get<T>(tableName: string, query?: Query<T>, mode?: JoinMode): QueryToken<T>;
update<T>(tableName: string, clause: Predicate<T>, raw: Partial<T>): Observable<ExecutorResult>;
delete<T>(tableName: string, clause?: Predicate<T>): Observable<ExecutorResult>;
upsert<T>(tableName: string, raw: T): Observable<ExecutorResult>;
upsert<T>(tableName: string, raw: T[]): Observable<ExecutorResult>;
upsert<T>(tableName: string, raw: T | T[]): Observable<ExecutorResult>;
remove<T>(tableName: string, clause?: Clause<T>): Observable<ExecutorResult>;
dispose(): Observable<never> | Observable<ExecutorResult>;
update<T>(tableName: string, clause: Predicate<T>, raw: Partial<T>): rx.Observable<ExecutorResult>;
delete<T>(tableName: string, clause?: Predicate<T>): rx.Observable<ExecutorResult>;
upsert<T>(tableName: string, raw: T): rx.Observable<ExecutorResult>;
upsert<T>(tableName: string, raw: T[]): rx.Observable<ExecutorResult>;
upsert<T>(tableName: string, raw: T | T[]): rx.Observable<ExecutorResult>;
remove<T>(tableName: string, clause?: Clause<T>): rx.Observable<ExecutorResult>;
dispose(): rx.Observable<never> | rx.Observable<ExecutorResult>;
attachTx(_: TransactionEffects): void;
executor(db: lf.Database, queries: lf.query.Builder[]): Observable<{
executor(db: lf.Database, queries: lf.query.Builder[]): rx.Observable<{
insert: number;

@@ -58,3 +58,3 @@ update: number;

}>;
transaction(): Observable<Transaction<Database>>;
transaction(): rx.Observable<Transaction<Database>>;
private buildTables;

@@ -61,0 +61,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var rx = require("../rx");
var lf = require("lovefield");

@@ -80,3 +79,3 @@ var Exception = require("../exception");

var dump = function (db) { return db.export(); };
return this.database$.pipe(operators_1.concatMap(dump));
return this.database$.pipe(rx.concatMap(dump));
};

@@ -99,3 +98,3 @@ Database.prototype.load = function (data) {

};
return this.database$.pipe(operators_1.concatMap(load));
return this.database$.pipe(rx.concatMap(load));
};

@@ -107,3 +106,3 @@ Database.prototype.insert = function (tableName, raw) {

if (utils_1.isException(maybeSchema)) {
return rxjs_1.throwError(maybeSchema.unwrapped);
return rx.throw(maybeSchema.unwrapped);
}

@@ -140,5 +139,5 @@ var schema = maybeSchema.unwrapped;

}
return _this.executor(db, queries).pipe(operators_1.tap(onError));
return _this.executor(db, queries).pipe(rx.tap(onError));
};
return this.database$.pipe(operators_1.concatMap(insert));
return this.database$.pipe(rx.concatMap(insert));
};

@@ -149,3 +148,3 @@ Database.prototype.get = function (tableName, query, mode) {

if (mode === void 0) { mode = enum_1.JoinMode.imlicit; }
var selector$ = this.database$.pipe(operators_1.map(function (db) { return _this.buildSelector(db, tableName, query, mode); }));
var selector$ = this.database$.pipe(rx.map(function (db) { return _this.buildSelector(db, tableName, query, mode); }));
return new modules_1.QueryToken(selector$);

@@ -157,7 +156,7 @@ };

if (type !== 'Object') {
return rxjs_1.throwError(Exception.InvalidType(['Object', type]));
return rx.throw(Exception.InvalidType(['Object', type]));
}
var maybeSchema = this.tryCatchFindSchema({ op: 'update' })(tableName);
if (utils_1.isException(maybeSchema)) {
return rxjs_1.throwError(maybeSchema.unwrapped);
return rx.throw(maybeSchema.unwrapped);
}

@@ -196,3 +195,3 @@ var schema = maybeSchema.unwrapped;

};
return this.database$.pipe(operators_1.concatMap(update));
return this.database$.pipe(rx.concatMap(update));
};

@@ -204,3 +203,3 @@ Database.prototype.delete = function (tableName, clause) {

if (utils_1.isException(maybePK)) {
return rxjs_1.throwError(maybePK.unwrapped);
return rx.throw(maybePK.unwrapped);
}

@@ -225,7 +224,7 @@ var pk = maybePK.unwrapped;

}
return _this.executor(db, [query]).pipe(operators_1.tap(onError));
return _this.executor(db, [query]).pipe(rx.tap(onError));
};
return rxjs_1.from(prefetch.exec()).pipe(operators_1.concatMap(deleteByScopedIds));
return rx.from(prefetch.exec()).pipe(rx.concatMap(deleteByScopedIds));
};
return this.database$.pipe(operators_1.concatMap(deletion));
return this.database$.pipe(rx.concatMap(deletion));
};

@@ -247,9 +246,9 @@ Database.prototype.upsert = function (tableName, raw) {

}
return _this.executor(db, queries).pipe(operators_1.tap(onError));
return _this.executor(db, queries).pipe(rx.tap(onError));
}
else {
return rxjs_1.of({ result: false, insert: 0, update: 0, delete: 0, select: 0 });
return rx.of({ result: false, insert: 0, update: 0, delete: 0, select: 0 });
}
};
return this.database$.pipe(operators_1.concatMap(upsert));
return this.database$.pipe(rx.concatMap(upsert));
};

@@ -261,3 +260,3 @@ Database.prototype.remove = function (tableName, clause) {

if (utils_1.isException(maybeSchema)) {
return rxjs_1.throwError(maybeSchema.unwrapped);
return rx.throw(maybeSchema.unwrapped);
}

@@ -281,3 +280,3 @@ var schema = maybeSchema.unwrapped;

var scope = _this.createScopedHandler(db, queries, removedIds);
return disposeHandler(rootEntities, scope).pipe(operators_1.tap(function () { return removedIds.forEach(function (id) { return _this.storedIds.delete(id); }); }), operators_1.concatMap(function () {
return disposeHandler(rootEntities, scope).pipe(rx.tap(function () { return removedIds.forEach(function (id) { return _this.storedIds.delete(id); }); }), rx.concatMap(function () {
if (_this.inTransaction) {

@@ -287,3 +286,3 @@ _this.attachTx(onError);

}
return _this.executor(db, queries).pipe(operators_1.tap(onError));
return _this.executor(db, queries).pipe(rx.tap(onError));
}));

@@ -297,9 +296,9 @@ }

}
return _this.executor(db, queries).pipe(operators_1.tap(onError));
return _this.executor(db, queries).pipe(rx.tap(onError));
}
};
var prefetch = helper_1.predicatableQuery(db, table, predicate, enum_1.StatementType.Select);
return rxjs_1.from(prefetch.exec()).pipe(operators_1.concatMap(removeByRootEntities));
return rx.from(prefetch.exec()).pipe(rx.concatMap(removeByRootEntities));
};
return this.database$.pipe(operators_1.concatMap(remove));
return this.database$.pipe(rx.concatMap(remove));
};

@@ -309,3 +308,3 @@ Database.prototype.dispose = function () {

if (!this.connected) {
return rxjs_1.throwError(Exception.NotConnected());
return rx.throw(Exception.NotConnected());
}

@@ -317,3 +316,3 @@ var cleanUp = function (db) {

.map(function (t) { return db.delete().from(t); });
return _this.executor(db, deletions).pipe(operators_1.tap(function () {
return _this.executor(db, deletions).pipe(rx.tap(function () {
db.close();

@@ -326,3 +325,3 @@ _this.schemas.clear();

};
return this.database$.pipe(operators_1.concatMap(cleanUp));
return this.database$.pipe(rx.concatMap(cleanUp));
};

@@ -334,3 +333,3 @@ Database.prototype.attachTx = function (_) {

var tx = db.createTransaction();
return rxjs_1.from(tx.exec(queries)).pipe(operators_1.tap(transactionErrorHandler), operators_1.map(function (ret) {
return rx.from(tx.exec(queries)).pipe(rx.tap(transactionErrorHandler), rx.map(function (ret) {
return tslib_1.__assign({ result: true }, helper_1.mergeTransactionResult(queries, ret));

@@ -341,3 +340,3 @@ }));

var _this = this;
return this.database$.pipe(operators_1.map(function (db) {
return this.database$.pipe(rx.map(function (db) {
var tx = db.createTransaction();

@@ -358,3 +357,3 @@ var transactionQueries = [];

transactionQueries.push.apply(transactionQueries, queries);
return rxjs_1.of(null);
return rx.of(null);
};

@@ -373,5 +372,5 @@ },

.reduce(function (acc, curr) {
return acc.pipe(operators_1.tap(curr));
}, rxjs_1.from(tx.exec(transactionQueries)))
.pipe(operators_1.map(function (r) {
return acc.pipe(rx.tap(curr));
}, rx.from(tx.exec(transactionQueries)))
.pipe(rx.map(function (r) {
return tslib_1.__assign({ result: true }, helper_1.mergeTransactionResult(transactionQueries, r));

@@ -737,7 +736,7 @@ }));

if (utils_1.isException(maybePredicate)) {
return rxjs_1.throwError(maybePredicate.unwrapped);
return rx.throw(maybePredicate.unwrapped);
}
var predicate = maybePredicate.unwrapped;
var query = helper_1.predicatableQuery(db, table, predicate, enum_1.StatementType.Select);
return rxjs_1.from(query.exec());
return rx.from(query.exec());
};

@@ -744,0 +743,0 @@ return [get, remove];

import * as lf from 'lovefield';
import { ConnectableObservable, ReplaySubject } from 'rxjs';
import * as rx from '../../rx';
import { LfFactoryInit } from '../../interface';
export declare const rawDb$: ReplaySubject<lf.raw.BackStore>;
export declare const lfFactory: (schemaBuilder: lf.schema.Builder, config: LfFactoryInit) => ConnectableObservable<lf.Database>;
export declare const rawDb$: rx.ReplaySubject<lf.raw.BackStore>;
export declare const lfFactory: (schemaBuilder: lf.schema.Builder, config: LfFactoryInit) => rx.ConnectableObservable<lf.Database>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
exports.rawDb$ = new rxjs_1.ReplaySubject(1);
var rx = require("../../rx");
exports.rawDb$ = new rx.ReplaySubject(1);
function onUpgrade(rawDb) {

@@ -12,3 +11,3 @@ exports.rawDb$.next(rawDb);

exports.lfFactory = function (schemaBuilder, config) {
return rxjs_1.Observable.create(function (observer) {
return rx.Observable.create(function (observer) {
config.onUpgrade = onUpgrade;

@@ -25,4 +24,4 @@ if (config.storeType >= 3) {

.catch(function (e) { return observer.error(e); });
}).pipe(operators_1.publishReplay(1));
}).pipe(rx.publishReplay(1));
};
//# sourceMappingURL=db-factory.js.map

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

import { Observable } from 'rxjs';
import { Observable } from '../../rx';
export declare const mapFn: <U>(dist$: Observable<U[]>) => Observable<U[]>;

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

import { Observable, OperatorFunction } from 'rxjs';
import { Observable, OperatorFunction } from '../../rx';
import { Query } from '../../interface';

@@ -3,0 +3,0 @@ export declare class ProxySelector<T> {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var operators_1 = require("rxjs/operators");
var rx_1 = require("../../rx");
var mapFn_1 = require("./mapFn");

@@ -10,3 +10,3 @@ var ProxySelector = /** @class */ (function () {

this.mapFn = mapFn_1.mapFn;
this.request$ = request$.pipe(operators_1.map(function (r) { return (Array.isArray(r) ? r : [r]); }));
this.request$ = request$.pipe(rx_1.map(function (r) { return (Array.isArray(r) ? r : [r]); }));
}

@@ -13,0 +13,0 @@ ProxySelector.prototype.values = function () {

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

import { Observable, OperatorFunction } from 'rxjs';
import * as rx from '../../rx';
import { Selector } from './Selector';

@@ -6,11 +6,11 @@ import { ProxySelector } from './ProxySelector';

export declare class QueryToken<T> {
selector$: Observable<SelectorMeta<T>>;
selector$: rx.Observable<SelectorMeta<T>>;
private consumed;
constructor(selector$: Observable<SelectorMeta<T>>);
map<K>(fn: OperatorFunction<T[], K[]>): QueryToken<K>;
values(): Observable<T[]>;
changes(): Observable<T[]>;
constructor(selector$: rx.Observable<SelectorMeta<T>>);
map<K>(fn: rx.OperatorFunction<T[], K[]>): QueryToken<K>;
values(): rx.Observable<T[]>;
changes(): rx.Observable<T[]>;
concat(...tokens: QueryToken<T>[]): QueryToken<T>;
combine(...tokens: QueryToken<any>[]): QueryToken<T>;
toString(): Observable<string>;
toString(): rx.Observable<string>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var rx = require("../../rx");
var ProxySelector_1 = require("./ProxySelector");
var assert_1 = require("../../utils/assert");
var token_1 = require("../../exception/token");
var skipWhileProxySelector = operators_1.skipWhile(function (v) { return v instanceof ProxySelector_1.ProxySelector; });
var skipWhileProxySelector = rx.skipWhile(function (v) { return v instanceof ProxySelector_1.ProxySelector; });
var QueryToken = /** @class */ (function () {
function QueryToken(selector$) {
this.consumed = false;
this.selector$ = selector$.pipe(operators_1.publishReplay(1), operators_1.refCount());
this.selector$ = selector$.pipe(rx.publishReplay(1), rx.refCount());
}
QueryToken.prototype.map = function (fn) {
this.selector$ = this.selector$.pipe(operators_1.tap(function (selector) { return selector.map(fn); }));
this.selector$ = this.selector$.pipe(rx.tap(function (selector) { return selector.map(fn); }));
return this;

@@ -21,3 +20,3 @@ };

this.consumed = true;
return this.selector$.pipe(operators_1.switchMap(function (s) { return s.values(); }), operators_1.take(1));
return this.selector$.pipe(rx.switchMap(function (s) { return s.values(); }), rx.take(1));
};

@@ -27,3 +26,3 @@ QueryToken.prototype.changes = function () {

this.consumed = true;
return this.selector$.pipe(operators_1.switchMap(function (s) { return s.changes(); }));
return this.selector$.pipe(rx.switchMap(function (s) { return s.changes(); }));
};

@@ -36,3 +35,3 @@ QueryToken.prototype.concat = function () {

tokens.unshift(this);
var newSelector$ = rxjs_1.from(tokens).pipe(operators_1.map(function (token) { return token.selector$.pipe(skipWhileProxySelector); }), operators_1.combineAll(), operators_1.map(function (r) {
var newSelector$ = rx.from(tokens).pipe(rx.map(function (token) { return token.selector$.pipe(skipWhileProxySelector); }), rx.combineAll(), rx.map(function (r) {
var _a;

@@ -50,3 +49,3 @@ var first = r.shift();

tokens.unshift(this);
var newSelector$ = rxjs_1.from(tokens).pipe(operators_1.map(function (token) { return token.selector$.pipe(skipWhileProxySelector); }), operators_1.combineAll(), operators_1.map(function (r) {
var newSelector$ = rx.from(tokens).pipe(rx.map(function (token) { return token.selector$.pipe(skipWhileProxySelector); }), rx.combineAll(), rx.map(function (r) {
var _a;

@@ -59,3 +58,3 @@ var first = r.shift();

QueryToken.prototype.toString = function () {
return this.selector$.pipe(operators_1.map(function (r) { return r.toString(); }));
return this.selector$.pipe(rx.map(function (r) { return r.toString(); }));
};

@@ -62,0 +61,0 @@ return QueryToken;

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

import { Observable, OperatorFunction } from 'rxjs';
import * as rx from '../../rx';
import * as lf from 'lovefield';

@@ -27,7 +27,7 @@ import { PredicateProvider } from './PredicateProvider';

toString(): string;
values(): Observable<T[]> | never;
values(): rx.Observable<T[]> | never;
combine(...selectors: Selector<T>[]): Selector<T>;
concat(...selectors: Selector<T>[]): Selector<T>;
changes(): Observable<T[]> | never;
map<K>(fn: OperatorFunction<T[], K[]>): Selector<K>;
changes(): rx.Observable<T[]> | never;
map<K>(fn: rx.OperatorFunction<T[], K[]>): Selector<K>;
private inPKs;

@@ -34,0 +34,0 @@ private getValue;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var rx = require("../../rx");
var lf = require("lovefield");

@@ -52,7 +51,7 @@ var Exception = require("../../exception");

var dist = new Selector(originalToken.db, fakeQuery, {});
dist.change$ = rxjs_1.from(metaDatas).pipe(operators_1.map(function (metas) { return metas.mapFn(metas.change$); }), operators_1.combineAll(), operators_1.map(function (r) { return r.reduce(function (acc, val) { return acc.concat(val); }); }), operators_1.debounceTime(0, rxjs_1.asyncScheduler), operators_1.publishReplay(1), operators_1.refCount());
dist.change$ = rx.from(metaDatas).pipe(rx.map(function (metas) { return metas.mapFn(metas.change$); }), rx.combineAll(), rx.map(function (r) { return r.reduce(function (acc, val) { return acc.concat(val); }); }), rx.debounceTime(0, rx.async), rx.publishReplay(1), rx.refCount());
dist.values = function () {
utils_1.assert(!dist.consumed, Exception.TokenConsumed);
dist.consumed = true;
return rxjs_1.from(metaDatas).pipe(operators_1.mergeMap(function (metaData) { return metaData.values(); }), operators_1.reduce(function (acc, val) { return acc.concat(val); }));
return rx.from(metaDatas).pipe(rx.mergeMap(function (metaData) { return metaData.values(); }), rx.reduce(function (acc, val) { return acc.concat(val); }));
};

@@ -88,3 +87,3 @@ dist.toString = function () {

var observeOn = function (query) {
return rxjs_1.Observable.create(function (observer) {
return rx.Observable.create(function (observer) {
var listener = function () {

@@ -101,5 +100,5 @@ _this.getValue(query)

var changesOnQuery = limit || skip
? this.buildPrefetchingObserve().pipe(operators_1.switchMap(function (pks) { return observeOn(_this.getQuery(_this.inPKs(pks))); }))
? this.buildPrefetchingObserve().pipe(rx.switchMap(function (pks) { return observeOn(_this.getQuery(_this.inPKs(pks))); }))
: observeOn(this.getQuery());
return lfIssueFix(changesOnQuery).pipe(operators_1.publishReplay(1), operators_1.refCount());
return lfIssueFix(changesOnQuery).pipe(rx.publishReplay(1), rx.refCount());
},

@@ -164,6 +163,6 @@ set: function (dist$) {

.then(function (pks) { return _this.getValue(_this.getQuery(_this.inPKs(pks))); });
return this.mapFn(rxjs_1.from(p));
return this.mapFn(rx.from(p));
}
else {
return this.mapFn(rxjs_1.from(this.getValue(this.getQuery())));
return this.mapFn(rx.from(this.getValue(this.getQuery())));
}

@@ -243,3 +242,3 @@ };

var _this = this;
return rxjs_1.Observable.create(function (observer) {
return rx.Observable.create(function (observer) {
var rangeQuery = _this.rangeQuery;

@@ -272,4 +271,4 @@ var listener = function () {

};
return changes.pipe(operators_1.scan(doKeep, null), operators_1.filter(utils_1.isNonNullable));
return changes.pipe(rx.scan(doKeep, null), rx.filter(utils_1.isNonNullable));
};
//# sourceMappingURL=Selector.js.map

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

import { Observable } from 'rxjs';
export declare function valid<T>(condition: any, error: Error): Observable<never> | Observable<T>;
import * as rx from '../rx';
export declare function valid<T>(condition: any, error: Error): rx.Observable<never> | rx.Observable<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var rx = require("../rx");
// think it as asynchronous assert
function valid(condition, error) {
if (!condition) {
return rxjs_1.throwError(error);
return rx.throw(error);
}
return rxjs_1.EMPTY.pipe(operators_1.skip(1));
return rx.empty().pipe(rx.skip(1));
}
exports.valid = valid;
//# sourceMappingURL=valid.js.map

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

declare const _default: "0.11.0";
declare const _default: "0.11.1-alpha.0-rxnotreeshake";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '0.11.0';
exports.default = '0.11.1-alpha.0-rxnotreeshake';
//# sourceMappingURL=version.js.map

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

Sorry, the diff of this file is not supported yet

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