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

@naturalcycles/db-lib

Package Overview
Dependencies
Maintainers
3
Versions
302
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@naturalcycles/db-lib - npm Package Compare versions

Comparing version 8.43.4 to 8.43.5

2

dist/adapter/cachedb/cache.db.d.ts
/// <reference types="node" />
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib';

@@ -4,0 +4,0 @@ import { BaseCommonDB } from '../../base.common.db';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CacheDB = void 0;
const stream_1 = require("stream");
const node_stream_1 = require("node:stream");
const base_common_db_1 = require("../../base.common.db");

@@ -163,3 +163,3 @@ /**

if (opt.skipCache || this.cfg.skipCache)
return stream_1.Readable.from([]);
return node_stream_1.Readable.from([]);
const stream = this.cfg.cacheDB.streamQuery(q, opt);

@@ -166,0 +166,0 @@ // if (this.cfg.logCached) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalFilePersistencePlugin = void 0;
const stream_1 = require("stream");
const zlib_1 = require("zlib");
const node_stream_1 = require("node:stream");
const node_zlib_1 = require("node:zlib");
const js_lib_1 = require("@naturalcycles/js-lib");

@@ -32,3 +32,3 @@ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");

return [];
const transformUnzip = this.cfg.gzip ? [(0, zlib_1.createUnzip)()] : [];
const transformUnzip = this.cfg.gzip ? [(0, node_zlib_1.createUnzip)()] : [];
const rows = [];

@@ -51,5 +51,5 @@ await (0, nodejs_lib_1._pipeline)([

const filePath = `${this.cfg.storagePath}/${table}.${ext}`;
const transformZip = this.cfg.gzip ? [(0, zlib_1.createGzip)()] : [];
const transformZip = this.cfg.gzip ? [(0, node_zlib_1.createGzip)()] : [];
await (0, nodejs_lib_1._pipeline)([
stream_1.Readable.from(rows),
node_stream_1.Readable.from(rows),
(0, nodejs_lib_1.transformToNDJson)(),

@@ -56,0 +56,0 @@ ...transformZip,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryDB = void 0;
const stream_1 = require("stream");
const zlib_1 = require("zlib");
const node_stream_1 = require("node:stream");
const node_zlib_1 = require("node:zlib");
const js_lib_1 = require("@naturalcycles/js-lib");

@@ -125,3 +125,3 @@ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");

const table = this.cfg.tablesPrefix + q.table;
return stream_1.Readable.from((0, __1.queryInMemory)(q, Object.values(this.data[table] || {})));
return node_stream_1.Readable.from((0, __1.queryInMemory)(q, Object.values(this.data[table] || {})));
}

@@ -160,3 +160,3 @@ async commitTransaction(tx, opt) {

await fs.emptyDir(persistentStoragePath);
const transformZip = persistZip ? [(0, zlib_1.createGzip)()] : [];
const transformZip = persistZip ? [(0, node_zlib_1.createGzip)()] : [];
let tables = 0;

@@ -171,3 +171,3 @@ // infinite concurrency for now

await (0, nodejs_lib_1._pipeline)([
stream_1.Readable.from(rows),
node_stream_1.Readable.from(rows),
(0, nodejs_lib_1.transformToNDJson)(),

@@ -196,3 +196,3 @@ ...transformZip,

const table = file.split('.ndjson')[0];
const transformUnzip = file.endsWith('.gz') ? [(0, zlib_1.createUnzip)()] : [];
const transformUnzip = file.endsWith('.gz') ? [(0, node_zlib_1.createUnzip)()] : [];
const rows = [];

@@ -199,0 +199,0 @@ await (0, nodejs_lib_1._pipeline)([

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryKeyValueDB = void 0;
const stream_1 = require("stream");
const node_stream_1 = require("node:stream");
class InMemoryKeyValueDB {

@@ -29,9 +29,9 @@ constructor(cfg = {}) {

streamIds(table, limit) {
return stream_1.Readable.from(Object.keys(this.data[table] || {}).slice(0, limit));
return node_stream_1.Readable.from(Object.keys(this.data[table] || {}).slice(0, limit));
}
streamValues(table, limit) {
return stream_1.Readable.from(Object.values(this.data[table] || {}).slice(0, limit));
return node_stream_1.Readable.from(Object.values(this.data[table] || {}).slice(0, limit));
}
streamEntries(table, limit) {
return stream_1.Readable.from(Object.entries(this.data[table] || {}).slice(0, limit));
return node_stream_1.Readable.from(Object.entries(this.data[table] || {}).slice(0, limit));
}

@@ -38,0 +38,0 @@ async count(table) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCommonDB = void 0;
const stream_1 = require("stream");
const node_stream_1 = require("node:stream");
const dbTransaction_util_1 = require("./transaction/dbTransaction.util");

@@ -42,3 +42,3 @@ /**

streamQuery(_q) {
return stream_1.Readable.from([]);
return node_stream_1.Readable.from([]);
}

@@ -45,0 +45,0 @@ /**

@@ -410,3 +410,5 @@ "use strict";

return stream;
return stream.pipe((0, nodejs_lib_1.transformMapSimple)(dbm => this.anyToDBM(dbm, opt), {
return stream
.on('error', err => stream.emit('error', err))
.pipe((0, nodejs_lib_1.transformMapSimple)(dbm => this.anyToDBM(dbm, opt), {
errorMode: js_lib_1.ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors

@@ -437,2 +439,3 @@ }));

// .pipe(transformMap<DBM, Saved<BM>>(dbm => this.dbmToBM(dbm, opt), safeOpt))
.on('error', err => stream.emit('error', err))
.pipe((0, nodejs_lib_1.transformMap)(async (dbm) => await this.dbmToBM(dbm, opt), {

@@ -454,5 +457,9 @@ errorMode: js_lib_1.ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors

opt.errorMode || (opt.errorMode = js_lib_1.ErrorMode.SUPPRESS);
return this.cfg.db.streamQuery(q.select(['id']), opt).pipe((0, nodejs_lib_1.transformMapSimple)(objectWithId => objectWithId.id, {
const stream = this.cfg.db
.streamQuery(q.select(['id']), opt)
.on('error', err => stream.emit('error', err))
.pipe((0, nodejs_lib_1.transformMapSimple)(objectWithId => objectWithId.id, {
errorMode: js_lib_1.ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors
}));
return stream;
}

@@ -459,0 +466,0 @@ async streamQueryIdsForEach(q, mapper, opt = {}) {

@@ -213,2 +213,2 @@ import { CommonLogger, ErrorMode, ObjectWithId, Saved } from '@naturalcycles/js-lib';

}
export declare type CommonDaoCreateOptions = CommonDBCreateOptions;
export type CommonDaoCreateOptions = CommonDBCreateOptions;

@@ -10,3 +10,3 @@ import { ObjectWithId } from '@naturalcycles/js-lib';

*/
export declare type CommonDBSaveMethod = 'upsert' | 'insert' | 'update';
export type CommonDBSaveMethod = 'upsert' | 'insert' | 'update';
export interface CommonDBOptions {

@@ -31,3 +31,3 @@ }

}
export declare type CommonDBStreamOptions = CommonDBOptions;
export type CommonDBStreamOptions = CommonDBOptions;
export interface CommonDBCreateOptions extends CommonDBOptions {

@@ -45,3 +45,3 @@ /**

}
export declare type DBOperation = DBSaveBatchOperation | DBDeleteByIdsOperation;
export type DBOperation = DBSaveBatchOperation | DBDeleteByIdsOperation;
export interface DBSaveBatchOperation<ROW extends Partial<ObjectWithId> = any> {

@@ -48,0 +48,0 @@ type: 'saveBatch';

@@ -106,5 +106,9 @@ "use strict";

// readableMap(this.cfg.db.streamValues(this.cfg.table, limit), async buf => await this.cfg.hooks!.mapBufferToValue(buf))
return this.cfg.db.streamValues(this.cfg.table, limit).pipe((0, nodejs_lib_1.transformMap)(async (buf) => await this.cfg.hooks.mapBufferToValue(buf), {
const stream = this.cfg.db
.streamValues(this.cfg.table, limit)
.on('error', err => stream.emit('error', err))
.pipe((0, nodejs_lib_1.transformMap)(async (buf) => await this.cfg.hooks.mapBufferToValue(buf), {
errorMode: js_lib_1.ErrorMode.SUPPRESS, // cause .pipe cannot propagate errors
}));
return stream;
}

@@ -115,7 +119,11 @@ streamEntries(limit) {

}
return this.cfg.db.streamEntries(this.cfg.table, limit).pipe((0, nodejs_lib_1.transformMap)(async ([id, buf]) => [id, await this.cfg.hooks.mapBufferToValue(buf)], {
const stream = this.cfg.db
.streamEntries(this.cfg.table, limit)
.on('error', err => stream.emit('error', err))
.pipe((0, nodejs_lib_1.transformMap)(async ([id, buf]) => [id, await this.cfg.hooks.mapBufferToValue(buf)], {
errorMode: js_lib_1.ErrorMode.SUPPRESS, // cause .pipe cannot propagate errors
}));
return stream;
}
}
exports.CommonKeyValueDao = CommonKeyValueDao;
/// <reference types="node" />
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
import { CommonDBCreateOptions } from '../db.model';
export declare type KeyValueDBTuple = [key: string, value: Buffer];
export type KeyValueDBTuple = [key: string, value: Buffer];
/**

@@ -6,0 +6,0 @@ * Common interface for Key-Value database implementations.

/// <reference types="node" />
import { ZlibOptions } from 'zlib';
import { ZlibOptions } from 'node:zlib';
import { AsyncMapper, ErrorMode } from '@naturalcycles/js-lib';

@@ -4,0 +4,0 @@ import { NDJsonStats, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dbPipelineBackup = void 0;
const zlib_1 = require("zlib");
const node_zlib_1 = require("node:zlib");
const js_lib_1 = require("@naturalcycles/js-lib");

@@ -68,3 +68,3 @@ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");

(0, nodejs_lib_1.transformToNDJson)({ strict, sortObjects }),
...(gzip ? [(0, zlib_1.createGzip)(zlibOptions)] : []),
...(gzip ? [(0, node_zlib_1.createGzip)(zlibOptions)] : []),
fs.createWriteStream(filePath),

@@ -71,0 +71,0 @@ ]);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dbPipelineRestore = void 0;
const zlib_1 = require("zlib");
const node_zlib_1 = require("node:zlib");
const js_lib_1 = require("@naturalcycles/js-lib");

@@ -71,3 +71,3 @@ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");

fs.createReadStream(filePath),
...(gzip ? [(0, zlib_1.createUnzip)()] : []),
...(gzip ? [(0, node_zlib_1.createUnzip)()] : []),
(0, nodejs_lib_1.transformSplit)(),

@@ -74,0 +74,0 @@ (0, nodejs_lib_1.transformJsonParse)({ strict }),

@@ -25,3 +25,3 @@ import { AnyObjectWithId, ObjectWithId, AsyncMapper, Saved, AnyObject } from '@naturalcycles/js-lib';

*/
export declare type DBQueryFilterOperator = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'in' | 'not-in' | 'array-contains' | 'array-contains-any';
export type DBQueryFilterOperator = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'in' | 'not-in' | 'array-contains' | 'array-contains-any';
export declare const dbQueryFilterOperatorValues: DBQueryFilterOperator[];

@@ -28,0 +28,0 @@ export interface DBQueryFilter<ROW extends ObjectWithId = AnyObjectWithId> {

@@ -10,3 +10,3 @@ import { CommonDB } from '../common.db';

*/
export declare type TimeSeriesDataPoint = [number, number | null];
export type TimeSeriesDataPoint = [number, number | null];
export interface TimeSeriesRow {

@@ -13,0 +13,0 @@ id: number;

@@ -44,3 +44,3 @@ {

},
"version": "8.43.4",
"version": "8.43.5",
"description": "Lowest Common Denominator API to supported Databases",

@@ -47,0 +47,0 @@ "keywords": [

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

import { Readable } from 'stream'
import { Readable } from 'node:stream'
import {

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

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

import { Readable } from 'stream'
import { createGzip, createUnzip } from 'zlib'
import { Readable } from 'node:stream'
import { createGzip, createUnzip } from 'node:zlib'
import { pMap, ObjectWithId } from '@naturalcycles/js-lib'

@@ -4,0 +4,0 @@ import {

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

import { Readable } from 'stream'
import { createGzip, createUnzip } from 'zlib'
import { Readable } from 'node:stream'
import { createGzip, createUnzip } from 'node:zlib'
import {

@@ -4,0 +4,0 @@ generateJsonSchemaFromData,

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

import { Readable } from 'stream'
import { Readable } from 'node:stream'
import { StringMap } from '@naturalcycles/js-lib'

@@ -3,0 +3,0 @@ import { ReadableTyped } from '@naturalcycles/nodejs-lib'

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

import { Readable } from 'stream'
import { Readable } from 'node:stream'
import { JsonSchemaObject, JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'

@@ -3,0 +3,0 @@ import { ReadableTyped } from '@naturalcycles/nodejs-lib'

@@ -501,7 +501,9 @@ import {

return stream.pipe(
transformMapSimple<any, DBM>(dbm => this.anyToDBM(dbm, opt), {
errorMode: ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors
}),
)
return stream
.on('error', err => stream.emit('error', err))
.pipe(
transformMapSimple<any, DBM>(dbm => this.anyToDBM(dbm, opt), {
errorMode: ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors
}),
)
}

@@ -533,2 +535,3 @@

// .pipe(transformMap<DBM, Saved<BM>>(dbm => this.dbmToBM(dbm, opt), safeOpt))
.on('error', err => stream.emit('error', err))
.pipe(

@@ -555,7 +558,12 @@ transformMap<DBM, Saved<BM>>(async dbm => await this.dbmToBM(dbm, opt), {

return this.cfg.db.streamQuery<DBM>(q.select(['id']), opt).pipe(
transformMapSimple<DBM, ID>(objectWithId => objectWithId.id, {
errorMode: ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors
}),
)
const stream: ReadableTyped<ID> = this.cfg.db
.streamQuery<DBM>(q.select(['id']), opt)
.on('error', err => stream.emit('error', err))
.pipe(
transformMapSimple<DBM, ID>(objectWithId => objectWithId.id, {
errorMode: ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors
}),
)
return stream
}

@@ -562,0 +570,0 @@

@@ -166,7 +166,12 @@ import { AppError, ErrorMode, KeyValueTuple, pMap } from '@naturalcycles/js-lib'

// readableMap(this.cfg.db.streamValues(this.cfg.table, limit), async buf => await this.cfg.hooks!.mapBufferToValue(buf))
return this.cfg.db.streamValues(this.cfg.table, limit).pipe(
transformMap(async buf => await this.cfg.hooks!.mapBufferToValue!(buf), {
errorMode: ErrorMode.SUPPRESS, // cause .pipe cannot propagate errors
}),
)
const stream: ReadableTyped<Buffer> = this.cfg.db
.streamValues(this.cfg.table, limit)
.on('error', err => stream.emit('error', err))
.pipe(
transformMap(async buf => await this.cfg.hooks!.mapBufferToValue!(buf), {
errorMode: ErrorMode.SUPPRESS, // cause .pipe cannot propagate errors
}),
)
return stream
}

@@ -179,8 +184,13 @@

return this.cfg.db.streamEntries(this.cfg.table, limit).pipe(
transformMap(async ([id, buf]) => [id, await this.cfg.hooks!.mapBufferToValue!(buf)], {
errorMode: ErrorMode.SUPPRESS, // cause .pipe cannot propagate errors
}),
)
const stream: ReadableTyped<KeyValueTuple<string, T>> = this.cfg.db
.streamEntries(this.cfg.table, limit)
.on('error', err => stream.emit('error', err))
.pipe(
transformMap(async ([id, buf]) => [id, await this.cfg.hooks!.mapBufferToValue!(buf)], {
errorMode: ErrorMode.SUPPRESS, // cause .pipe cannot propagate errors
}),
)
return stream
}
}

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

import { createGzip, ZlibOptions } from 'zlib'
import { createGzip, ZlibOptions } from 'node:zlib'
import {

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

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

import { createUnzip } from 'zlib'
import { createUnzip } from 'node:zlib'
import {

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

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