@naturalcycles/db-lib
Advanced tools
Comparing version 8.54.1 to 8.54.2
@@ -10,2 +10,2 @@ "use strict"; | ||
DBLibError["OBJECT_IS_IMMUTABLE"] = "OBJECT_IS_IMMUTABLE"; | ||
})(DBLibError = exports.DBLibError || (exports.DBLibError = {})); | ||
})(DBLibError || (exports.DBLibError = DBLibError = {})); |
import { AnyObject, AsyncMapper, JsonSchemaObject, JsonSchemaRootObject, ObjectWithId, Promisable, Saved, UnixTimestampMillisNumber, Unsaved, ZodSchema } from '@naturalcycles/js-lib'; | ||
import { AjvSchema, ObjectSchemaTyped, ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { AjvSchema, ObjectSchema, ReadableTyped } from '@naturalcycles/nodejs-lib'; | ||
import { DBDeleteByIdsOperation, DBModelType, DBOperation, DBPatch, DBSaveBatchOperation, RunQueryResult } from '../db.model'; | ||
@@ -148,3 +148,3 @@ import { DBQuery, RunnableDBQuery } from '../query/dbQuery'; | ||
*/ | ||
validateAndConvert<IN, OUT = IN>(obj: Partial<IN>, schema: ObjectSchemaTyped<IN> | AjvSchema<IN> | ZodSchema<IN> | undefined, modelType: DBModelType, opt?: CommonDaoOptions): OUT; | ||
validateAndConvert<IN, OUT = IN>(obj: Partial<IN>, schema: ObjectSchema<IN> | AjvSchema<IN> | ZodSchema<IN> | undefined, modelType: DBModelType, opt?: CommonDaoOptions): OUT; | ||
getTableSchema(): Promise<JsonSchemaRootObject<DBM>>; | ||
@@ -151,0 +151,0 @@ createTable(schema: JsonSchemaObject<DBM>, opt?: CommonDaoCreateOptions): Promise<void>; |
import { CommonLogger, ErrorMode, ObjectWithId, Promisable, Saved, ZodError, ZodSchema } from '@naturalcycles/js-lib'; | ||
import { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchemaTyped, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib'; | ||
import { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchema, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib'; | ||
import { CommonDB } from '../common.db'; | ||
@@ -113,5 +113,5 @@ import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'; | ||
*/ | ||
dbmSchema?: ObjectSchemaTyped<DBM> | AjvSchema<DBM> | ZodSchema<DBM>; | ||
bmSchema?: ObjectSchemaTyped<BM> | AjvSchema<BM> | ZodSchema<BM>; | ||
tmSchema?: ObjectSchemaTyped<TM> | AjvSchema<TM> | ZodSchema<TM>; | ||
dbmSchema?: ObjectSchema<DBM> | AjvSchema<DBM> | ZodSchema<DBM>; | ||
bmSchema?: ObjectSchema<BM> | AjvSchema<BM> | ZodSchema<BM>; | ||
tmSchema?: ObjectSchema<TM> | AjvSchema<TM> | ZodSchema<TM>; | ||
excludeFromIndexes?: (keyof DBM)[]; | ||
@@ -118,0 +118,0 @@ /** |
@@ -22,2 +22,2 @@ "use strict"; | ||
CommonDaoLogLevel[CommonDaoLogLevel["DATA_FULL"] = 30] = "DATA_FULL"; | ||
})(CommonDaoLogLevel = exports.CommonDaoLogLevel || (exports.CommonDaoLogLevel = {})); | ||
})(CommonDaoLogLevel || (exports.CommonDaoLogLevel = CommonDaoLogLevel = {})); |
@@ -8,3 +8,3 @@ "use strict"; | ||
DBRelation["ONE_TO_MANY"] = "ONE_TO_MANY"; | ||
})(DBRelation = exports.DBRelation || (exports.DBRelation = {})); | ||
})(DBRelation || (exports.DBRelation = DBRelation = {})); | ||
var DBModelType; | ||
@@ -15,3 +15,3 @@ (function (DBModelType) { | ||
DBModelType["TM"] = "TM"; | ||
})(DBModelType = exports.DBModelType || (exports.DBModelType = {})); | ||
})(DBModelType || (exports.DBModelType = DBModelType = {})); | ||
/** | ||
@@ -18,0 +18,0 @@ * Allows to construct a query similar to: |
@@ -18,5 +18,5 @@ /// <reference types="node" /> | ||
} | ||
export declare const testItemBMSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<TestItemBM, TestItemBM>; | ||
export declare const testItemDBMSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<TestItemDBM, TestItemDBM>; | ||
export declare const testItemTMSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<TestItemTM, TestItemTM>; | ||
export declare const testItemBMSchema: import("joi").ObjectSchema<TestItemBM>; | ||
export declare const testItemDBMSchema: import("joi").ObjectSchema<TestItemDBM>; | ||
export declare const testItemTMSchema: import("joi").ObjectSchema<TestItemTM>; | ||
export declare const testItemBMJsonSchema: JsonSchemaObject<TestItemBM>; | ||
@@ -23,0 +23,0 @@ export declare const testItemDBMJsonSchema: JsonSchemaObject<TestItemDBM>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CommonTimeSeriesDao = void 0; | ||
const js_lib_1 = require("@naturalcycles/js-lib"); | ||
const __1 = require(".."); | ||
@@ -23,3 +24,3 @@ const dbQuery_1 = require("../query/dbQuery"); | ||
.map(t => /^(.*)_TIMESERIES_RAW$/.exec(t)?.[1]) | ||
.filter(Boolean); | ||
.filter(js_lib_1._isTruthy); | ||
} | ||
@@ -26,0 +27,0 @@ // convenience method |
import { CommonDBOptions, CommonDBSaveOptions } from '../db.model'; | ||
import { DBQuery, DBQueryFilter, DBQueryOrder } from '../query/dbQuery'; | ||
export declare const commonDBOptionsSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<CommonDBOptions, CommonDBOptions>; | ||
export declare const commonDBSaveOptionsSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<CommonDBSaveOptions<any>, CommonDBSaveOptions<any>>; | ||
export declare const dbQueryFilterOperatorSchema: import("@naturalcycles/nodejs-lib/dist/validation/joi/string.extensions").ExtendedStringSchema; | ||
export declare const dbQueryFilterSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQueryFilter<import("@naturalcycles/js-lib").AnyObjectWithId<string | number>>, DBQueryFilter<import("@naturalcycles/js-lib").AnyObjectWithId<string | number>>>; | ||
export declare const dbQueryOrderSchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQueryOrder<import("@naturalcycles/js-lib").AnyObjectWithId<string | number>>, DBQueryOrder<import("@naturalcycles/js-lib").AnyObjectWithId<string | number>>>; | ||
export declare const dbQuerySchema: import("@naturalcycles/nodejs-lib").ObjectSchemaTyped<DBQuery<any>, DBQuery<any>>; | ||
import { DBQuery, DBQueryFilter, DBQueryFilterOperator, DBQueryOrder } from '../query/dbQuery'; | ||
export declare const commonDBOptionsSchema: import("joi").ObjectSchema<CommonDBOptions>; | ||
export declare const commonDBSaveOptionsSchema: import("joi").ObjectSchema<CommonDBSaveOptions<any>>; | ||
export declare const dbQueryFilterOperatorSchema: import("@naturalcycles/nodejs-lib/dist/validation/joi/string.extensions").StringSchema<DBQueryFilterOperator>; | ||
export declare const dbQueryFilterSchema: import("joi").ObjectSchema<DBQueryFilter<import("@naturalcycles/js-lib").AnyObjectWithId<string | number>>>; | ||
export declare const dbQueryOrderSchema: import("joi").ObjectSchema<DBQueryOrder<import("@naturalcycles/js-lib").AnyObjectWithId<string | number>>>; | ||
export declare const dbQuerySchema: import("joi").ObjectSchema<DBQuery<any>>; |
@@ -13,3 +13,3 @@ "use strict"; | ||
}).concat(exports.commonDBOptionsSchema); | ||
exports.dbQueryFilterOperatorSchema = nodejs_lib_1.stringSchema.valid(...dbQuery_1.dbQueryFilterOperatorValues); | ||
exports.dbQueryFilterOperatorSchema = nodejs_lib_1.Joi.string().valid(...dbQuery_1.dbQueryFilterOperatorValues); | ||
exports.dbQueryFilterSchema = (0, nodejs_lib_1.objectSchema)({ | ||
@@ -16,0 +16,0 @@ name: nodejs_lib_1.stringSchema, |
@@ -43,3 +43,3 @@ { | ||
}, | ||
"version": "8.54.1", | ||
"version": "8.54.2", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -46,0 +46,0 @@ "keywords": [ |
@@ -8,3 +8,3 @@ ## @naturalcycles/db-lib | ||
[![loc](https://badgen.net/codeclimate/loc/NaturalCycles/db-lib)](https://github.com/NaturalCycles/db-lib) | ||
[![Actions](https://github.com/NaturalCycles/db-lib/workflows/default/badge.svg)](https://github.com/NaturalCycles/db-lib/actions) | ||
[![Actions](https://github.com/NaturalCycles/db-lib/workflows/ci/badge.svg)](https://github.com/NaturalCycles/db-lib/actions) | ||
@@ -11,0 +11,0 @@ Defines 3 things: |
@@ -55,3 +55,3 @@ import { | ||
public cfg!: FileDBCfg | ||
cfg!: FileDBCfg | ||
@@ -58,0 +58,0 @@ override async ping(): Promise<void> { |
@@ -42,3 +42,3 @@ import * as fs from 'node:fs' | ||
public cfg!: LocalFilePersistencePluginCfg | ||
cfg!: LocalFilePersistencePluginCfg | ||
@@ -45,0 +45,0 @@ async ping(): Promise<void> {} |
@@ -14,3 +14,3 @@ import { | ||
JoiValidationError, | ||
ObjectSchemaTyped, | ||
ObjectSchema, | ||
TransformLogProgressOptions, | ||
@@ -152,5 +152,5 @@ TransformMapOptions, | ||
*/ | ||
dbmSchema?: ObjectSchemaTyped<DBM> | AjvSchema<DBM> | ZodSchema<DBM> | ||
bmSchema?: ObjectSchemaTyped<BM> | AjvSchema<BM> | ZodSchema<BM> | ||
tmSchema?: ObjectSchemaTyped<TM> | AjvSchema<TM> | ZodSchema<TM> | ||
dbmSchema?: ObjectSchema<DBM> | AjvSchema<DBM> | ZodSchema<DBM> | ||
bmSchema?: ObjectSchema<BM> | AjvSchema<BM> | ZodSchema<BM> | ||
tmSchema?: ObjectSchema<TM> | AjvSchema<TM> | ZodSchema<TM> | ||
@@ -157,0 +157,0 @@ excludeFromIndexes?: (keyof DBM)[] |
@@ -33,3 +33,3 @@ import { | ||
JoiValidationError, | ||
ObjectSchemaTyped, | ||
ObjectSchema, | ||
ReadableTyped, | ||
@@ -457,3 +457,3 @@ stringId, | ||
if (this.cfg.hooks!.afterLoad) { | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm)) as DBM | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm))! | ||
if (dbm === null) return SKIP | ||
@@ -508,3 +508,3 @@ } | ||
if (this.cfg.hooks!.afterLoad) { | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm)) as DBM | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm))! | ||
if (dbm === null) return SKIP | ||
@@ -556,3 +556,3 @@ } | ||
if (this.cfg.hooks!.afterLoad) { | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm)) as DBM | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm))! | ||
if (dbm === null) return SKIP | ||
@@ -599,3 +599,3 @@ } | ||
if (this.cfg.hooks!.afterLoad) { | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm)) as DBM | ||
dbm = (await this.cfg.hooks!.afterLoad(dbm))! | ||
if (dbm === null) return SKIP | ||
@@ -773,3 +773,3 @@ } | ||
if (this.cfg.hooks!.beforeSave) { | ||
dbm = (await this.cfg.hooks!.beforeSave(dbm)) as DBM | ||
dbm = (await this.cfg.hooks!.beforeSave(dbm))! | ||
if (dbm === null && !opt.tx) return bm as any | ||
@@ -861,3 +861,3 @@ } | ||
if (this.cfg.hooks!.beforeSave) { | ||
row = (await this.cfg.hooks!.beforeSave(row)) as DBM | ||
row = (await this.cfg.hooks!.beforeSave(row))! | ||
if (row === null) return dbm | ||
@@ -1188,3 +1188,3 @@ } | ||
obj: Partial<IN>, | ||
schema: ObjectSchemaTyped<IN> | AjvSchema<IN> | ZodSchema<IN> | undefined, | ||
schema: ObjectSchema<IN> | AjvSchema<IN> | ZodSchema<IN> | undefined, | ||
modelType: DBModelType, | ||
@@ -1242,3 +1242,3 @@ opt: CommonDaoOptions = {}, | ||
// Joi | ||
const vr = getValidationResult<IN, OUT>(obj as IN, schema, objectName) | ||
const vr = getValidationResult(obj, schema, objectName) | ||
error = vr.error | ||
@@ -1245,0 +1245,0 @@ convertedValue = vr.value |
@@ -247,3 +247,6 @@ import { | ||
*/ | ||
constructor(public dao: CommonDao<BM, DBM, TM, ID>, table?: string) { | ||
constructor( | ||
public dao: CommonDao<BM, DBM, TM, ID>, | ||
table?: string, | ||
) { | ||
super(table || dao.cfg.table) | ||
@@ -250,0 +253,0 @@ } |
@@ -115,3 +115,3 @@ import { pDelay, pMap, _filterObject, _pick, _sortBy } from '@naturalcycles/js-lib' | ||
const queryAll = () => DBQuery.create<TestItemDBM>(TEST_TABLE) | ||
const queryAll = (): DBQuery<TestItemDBM> => DBQuery.create<TestItemDBM>(TEST_TABLE) | ||
@@ -118,0 +118,0 @@ test('ping', async () => { |
@@ -38,3 +38,3 @@ import { jsonSchema, _range, BaseDBEntity, Saved, JsonSchemaObject } from '@naturalcycles/js-lib' | ||
b1: binarySchema.optional(), | ||
}).concat(baseDBEntitySchema) | ||
}).concat(baseDBEntitySchema as any) | ||
@@ -47,3 +47,3 @@ export const testItemDBMSchema = objectSchema<TestItemDBM>({ | ||
b1: binarySchema.optional(), | ||
}).concat(savedDBEntitySchema) | ||
}).concat(savedDBEntitySchema as any) | ||
@@ -50,0 +50,0 @@ export const testItemTMSchema = objectSchema<TestItemTM>({ |
@@ -1,2 +0,2 @@ | ||
import { ObjectWithId } from '@naturalcycles/js-lib' | ||
import { _isTruthy, ObjectWithId } from '@naturalcycles/js-lib' | ||
import { DBTransaction } from '..' | ||
@@ -29,4 +29,4 @@ import { DBQuery } from '../query/dbQuery' | ||
return (await this.cfg.db.getTables()) | ||
.map(t => /^(.*)_TIMESERIES_RAW$/.exec(t)?.[1] as string) | ||
.filter(Boolean) | ||
.map(t => /^(.*)_TIMESERIES_RAW$/.exec(t)?.[1]) | ||
.filter(_isTruthy) | ||
} | ||
@@ -33,0 +33,0 @@ |
@@ -6,2 +6,3 @@ import { | ||
integerSchema, | ||
Joi, | ||
objectSchema, | ||
@@ -11,3 +12,9 @@ stringSchema, | ||
import { CommonDBOptions, CommonDBSaveOptions } from '../db.model' | ||
import { DBQuery, DBQueryFilter, dbQueryFilterOperatorValues, DBQueryOrder } from '../query/dbQuery' | ||
import { | ||
DBQuery, | ||
DBQueryFilter, | ||
DBQueryFilterOperator, | ||
dbQueryFilterOperatorValues, | ||
DBQueryOrder, | ||
} from '../query/dbQuery' | ||
@@ -23,3 +30,5 @@ export const commonDBOptionsSchema = objectSchema<CommonDBOptions>({ | ||
export const dbQueryFilterOperatorSchema = stringSchema.valid(...dbQueryFilterOperatorValues) | ||
export const dbQueryFilterOperatorSchema = Joi.string<DBQueryFilterOperator>().valid( | ||
...dbQueryFilterOperatorValues, | ||
) | ||
@@ -26,0 +35,0 @@ export const dbQueryFilterSchema = objectSchema<DBQueryFilter>({ |
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
10571
404001