Comparing version 2.0.0-alpha.3 to 2.0.0-alpha.4
{ | ||
"dependencies": { | ||
"deleteById": "^1.0.0", | ||
"deleteById": "^2.0.0", | ||
"deploy": "^1.0.0", | ||
"entry": "^0.2.0", | ||
"find": "^1.0.0", | ||
"findById": "^2.0.0", | ||
"findByIds": "^2.0.0", | ||
"find": "^2.0.0", | ||
"findById": "^3.0.0", | ||
"findByIds": "^3.0.0", | ||
"readFileContentsById": "^1.0.0", | ||
"getServerInfo": "^1.0.0", | ||
"save": "^1.0.0", | ||
"getServerInfo": "^1.1.0", | ||
"save": "^2.0.0", | ||
"setup": "^1.0.0", | ||
@@ -13,0 +13,0 @@ "teardown": "^1.0.0" |
@@ -10,2 +10,16 @@ # Changelog | ||
## [2.0.0-alpha.4] - 2022-04-12 | ||
### Breaking changes | ||
- Change database I/O for records to use delimited strings instead of arrays ([#60](https://github.com/STORIS/mvom/pull/60)) | ||
- A new non-enumerable `_originalRecordString` property now exists on the Model instance | ||
- Model instances can no longer be constructed from arrays. Delimited strings can be used instead. | ||
- The `Document` constructor is now protected and should not be instantiated directly. Use of the static `createDocumentFromRecordString` should be used instead. | ||
### Added | ||
- Allow http/s agent to be passed to Connection ([#45](https://github.com/STORIS/mvom/pull/45)) | ||
- Allow type information to be specified for dictionaries that are not part of the data definitions ([#53](https://github.com/STORIS/mvom/pull/53)) | ||
## [2.0.0-alpha.3] - 2022-03-22 | ||
@@ -350,3 +364,4 @@ | ||
[unreleased]: https://github.com/storis/mvom/compare/2.0.0-alpha.3...HEAD | ||
[unreleased]: https://github.com/storis/mvom/compare/2.0.0-alpha.4...HEAD | ||
[2.0.0-alpha.4]: https://github.com/storis/mvom/compare/2.0.0-alpha.3...2.0.0-alpha.4 | ||
[2.0.0-alpha.3]: https://github.com/storis/mvom/compare/2.0.0-alpha.2...2.0.0-alpha.3 | ||
@@ -353,0 +368,0 @@ [2.0.0-alpha.2]: https://github.com/storis/mvom/compare/2.0.0-alpha.1...2.0.0-alpha.2 |
import type Connection from './Connection'; | ||
import Document from './Document'; | ||
import type { QueryConstructorOptions } from './Query'; | ||
import { type Filter } from './Query'; | ||
import type Schema from './Schema'; | ||
import type { GenericObject, MvRecord } from './types'; | ||
import type { DbServerDelimiters, GenericObject } from './types'; | ||
export interface ModelConstructorOptions<TSchema extends GenericObject> { | ||
@@ -10,3 +11,3 @@ _id?: string | null; | ||
data?: TSchema; | ||
record?: MvRecord; | ||
record?: string; | ||
} | ||
@@ -25,3 +26,3 @@ export declare type ModelConstructor = ReturnType<typeof compileModel>; | ||
/** Define a new model */ | ||
declare const compileModel: <TSchema extends GenericObject = GenericObject>(connection: Connection, schema: Schema | null, file: string) => { | ||
declare const compileModel: <TSchema extends GenericObject = GenericObject>(connection: Connection, schema: Schema | null, file: string, dbServerDelimiters: DbServerDelimiters) => { | ||
new (options: ModelConstructorOptions<TSchema>): { | ||
@@ -33,2 +34,4 @@ [key: string]: unknown; | ||
_id: string | null; | ||
/** Original record string that model was generated from */ | ||
readonly _originalRecordString: string | null; | ||
/** Private id tracking property */ | ||
@@ -38,11 +41,13 @@ "__#2@#_id": string | null; | ||
save(): Promise<any>; | ||
_raw?: MvRecord | undefined; | ||
transformationErrors: import("./errors/TransformDataError").default[]; | ||
/** Convert model instance to multivalue string */ | ||
"__#2@#convertToMvString"(): string; | ||
_raw?: import("./types").MvRecord | undefined; | ||
_transformationErrors: import("./errors/TransformDataError").default[]; | ||
readonly "__#1@#schema": Schema | null; | ||
"__#1@#record": MvRecord; | ||
"__#1@#record": import("./types").MvRecord; | ||
readonly "__#1@#isSubdocument": boolean; | ||
transformDocumentToRecord(): MvRecord; | ||
transformDocumentToRecord(): import("./types").MvRecord; | ||
buildForeignKeyDefinitions(): import("./Document").BuildForeignKeyDefinitionsResult[]; | ||
validate(): Promise<Map<string, string | string[]>>; | ||
"__#1@#transformRecordToDocument"(record: MvRecord): void; | ||
"__#1@#transformRecordToDocument"(): void; | ||
}; | ||
@@ -55,2 +60,4 @@ /** Connection instance which constructed this model definition */ | ||
readonly schema: Schema | null; | ||
/** Database server delimiters */ | ||
"__#2@#dbServerDelimiters": DbServerDelimiters; | ||
/** Delete a document */ | ||
@@ -63,2 +70,4 @@ deleteById(id: string): Promise<{ | ||
_id: string | null; | ||
/** Original record string that model was generated from */ | ||
readonly _originalRecordString: string | null; | ||
/** Private id tracking property */ | ||
@@ -68,11 +77,13 @@ "__#2@#_id": string | null; | ||
save(): Promise<any>; | ||
_raw?: MvRecord | undefined; | ||
transformationErrors: import("./errors/TransformDataError").default[]; | ||
/** Convert model instance to multivalue string */ | ||
"__#2@#convertToMvString"(): string; | ||
_raw?: import("./types").MvRecord | undefined; | ||
_transformationErrors: import("./errors/TransformDataError").default[]; | ||
readonly "__#1@#schema": Schema | null; | ||
"__#1@#record": MvRecord; | ||
"__#1@#record": import("./types").MvRecord; | ||
readonly "__#1@#isSubdocument": boolean; | ||
transformDocumentToRecord(): MvRecord; | ||
transformDocumentToRecord(): import("./types").MvRecord; | ||
buildForeignKeyDefinitions(): import("./Document").BuildForeignKeyDefinitionsResult[]; | ||
validate(): Promise<Map<string, string | string[]>>; | ||
"__#1@#transformRecordToDocument"(record: MvRecord): void; | ||
"__#1@#transformRecordToDocument"(): void; | ||
} | null>; | ||
@@ -86,2 +97,4 @@ /** Find documents via query */ | ||
_id: string | null; | ||
/** Original record string that model was generated from */ | ||
readonly _originalRecordString: string | null; | ||
/** Private id tracking property */ | ||
@@ -91,11 +104,13 @@ "__#2@#_id": string | null; | ||
save(): Promise<any>; | ||
_raw?: MvRecord | undefined; | ||
transformationErrors: import("./errors/TransformDataError").default[]; | ||
/** Convert model instance to multivalue string */ | ||
"__#2@#convertToMvString"(): string; | ||
_raw?: import("./types").MvRecord | undefined; | ||
_transformationErrors: import("./errors/TransformDataError").default[]; | ||
readonly "__#1@#schema": Schema | null; | ||
"__#1@#record": MvRecord; | ||
"__#1@#record": import("./types").MvRecord; | ||
readonly "__#1@#isSubdocument": boolean; | ||
transformDocumentToRecord(): MvRecord; | ||
transformDocumentToRecord(): import("./types").MvRecord; | ||
buildForeignKeyDefinitions(): import("./Document").BuildForeignKeyDefinitionsResult[]; | ||
validate(): Promise<Map<string, string | string[]>>; | ||
"__#1@#transformRecordToDocument"(record: MvRecord): void; | ||
"__#1@#transformRecordToDocument"(): void; | ||
}[]>; | ||
@@ -111,2 +126,4 @@ /** Find documents via query, returning them along with a count */ | ||
_id: string | null; | ||
/** Original record string that model was generated from */ | ||
readonly _originalRecordString: string | null; | ||
/** Private id tracking property */ | ||
@@ -116,11 +133,13 @@ "__#2@#_id": string | null; | ||
save(): Promise<any>; | ||
_raw?: MvRecord | undefined; | ||
transformationErrors: import("./errors/TransformDataError").default[]; | ||
/** Convert model instance to multivalue string */ | ||
"__#2@#convertToMvString"(): string; | ||
_raw?: import("./types").MvRecord | undefined; | ||
_transformationErrors: import("./errors/TransformDataError").default[]; | ||
readonly "__#1@#schema": Schema | null; | ||
"__#1@#record": MvRecord; | ||
"__#1@#record": import("./types").MvRecord; | ||
readonly "__#1@#isSubdocument": boolean; | ||
transformDocumentToRecord(): MvRecord; | ||
transformDocumentToRecord(): import("./types").MvRecord; | ||
buildForeignKeyDefinitions(): import("./Document").BuildForeignKeyDefinitionsResult[]; | ||
validate(): Promise<Map<string, string | string[]>>; | ||
"__#1@#transformRecordToDocument"(record: MvRecord): void; | ||
"__#1@#transformRecordToDocument"(): void; | ||
} | null>; | ||
@@ -134,2 +153,4 @@ /** Find multiple documents by their ids */ | ||
_id: string | null; | ||
/** Original record string that model was generated from */ | ||
readonly _originalRecordString: string | null; | ||
/** Private id tracking property */ | ||
@@ -139,15 +160,46 @@ "__#2@#_id": string | null; | ||
save(): Promise<any>; | ||
_raw?: MvRecord | undefined; | ||
transformationErrors: import("./errors/TransformDataError").default[]; | ||
/** Convert model instance to multivalue string */ | ||
"__#2@#convertToMvString"(): string; | ||
_raw?: import("./types").MvRecord | undefined; | ||
_transformationErrors: import("./errors/TransformDataError").default[]; | ||
readonly "__#1@#schema": Schema | null; | ||
"__#1@#record": MvRecord; | ||
"__#1@#record": import("./types").MvRecord; | ||
readonly "__#1@#isSubdocument": boolean; | ||
transformDocumentToRecord(): MvRecord; | ||
transformDocumentToRecord(): import("./types").MvRecord; | ||
buildForeignKeyDefinitions(): import("./Document").BuildForeignKeyDefinitionsResult[]; | ||
validate(): Promise<Map<string, string | string[]>>; | ||
"__#1@#transformRecordToDocument"(record: MvRecord): void; | ||
"__#1@#transformRecordToDocument"(): void; | ||
} | null)[]>; | ||
/** Read a DIR file type record directly from file system as Base64 string by its id */ | ||
readFileContentsById(id: string): Promise<string>; | ||
/** Create a new Model instance from a record string */ | ||
"__#2@#createModelFromRecordString"(recordString: string, _id: string, __v?: string | null | undefined): { | ||
[key: string]: unknown; | ||
/** Document version hash */ | ||
readonly __v: string | null; | ||
/** Id of model instance */ | ||
_id: string | null; | ||
/** Original record string that model was generated from */ | ||
readonly _originalRecordString: string | null; | ||
/** Private id tracking property */ | ||
"__#2@#_id": string | null; | ||
/** Save a document to the database */ | ||
save(): Promise<any>; | ||
/** Convert model instance to multivalue string */ | ||
"__#2@#convertToMvString"(): string; | ||
_raw?: import("./types").MvRecord | undefined; | ||
_transformationErrors: import("./errors/TransformDataError").default[]; | ||
readonly "__#1@#schema": Schema | null; | ||
"__#1@#record": import("./types").MvRecord; | ||
readonly "__#1@#isSubdocument": boolean; | ||
transformDocumentToRecord(): import("./types").MvRecord; | ||
buildForeignKeyDefinitions(): import("./Document").BuildForeignKeyDefinitionsResult[]; | ||
validate(): Promise<Map<string, string | string[]>>; | ||
"__#1@#transformRecordToDocument"(): void; | ||
}; | ||
createSubdocumentFromRecord(schema: Schema, record: import("./types").MvRecord): Document; | ||
createSubdocumentFromData(schema: Schema, data: GenericObject): Document; | ||
createDocumentFromRecordString(schema: Schema, recordString: string, dbServerDelimiters: DbServerDelimiters): Document; | ||
convertMvStringToArray(recordString: string, dbServerDelimiters: DbServerDelimiters): import("./types").MvRecord; | ||
}; | ||
export default compileModel; |
@@ -22,3 +22,3 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
const compileModel = (connection, schema, file) => { | ||
const compileModel = (connection, schema, file, dbServerDelimiters) => { | ||
connection.logMessage('debug', `creating new model for file ${file}`); | ||
@@ -36,6 +36,7 @@ /** Model constructor */ | ||
static schema = schema; | ||
/** Database server delimiters */ | ||
static #dbServerDelimiters = dbServerDelimiters; | ||
/** Document version hash */ | ||
// add definite assignment assertion since property is assigned through defineProperty | ||
/** Private id tracking property */ | ||
@@ -51,5 +52,6 @@ #_id; | ||
} = options; | ||
const mvRecord = record != null ? _Document.default.convertMvStringToArray(record, Model.#dbServerDelimiters) : []; | ||
const documentConstructorOptions = { | ||
data, | ||
record | ||
record: mvRecord | ||
}; | ||
@@ -59,15 +61,24 @@ super(Model.schema, documentConstructorOptions); | ||
this.__v = __v; | ||
Object.defineProperty(this, '_id', { | ||
enumerable: true, | ||
get: () => this.#_id, | ||
set: value => { | ||
if (this.#_id != null) { | ||
throw new Error('_id value cannot be changed once set'); | ||
this._originalRecordString = record ?? null; | ||
Object.defineProperties(this, { | ||
_id: { | ||
enumerable: true, | ||
get: () => this.#_id, | ||
set: value => { | ||
if (this.#_id != null) { | ||
throw new Error('_id value cannot be changed once set'); | ||
} | ||
this.#_id = value; | ||
} | ||
this.#_id = value; | ||
}, | ||
_originalRecordString: { | ||
enumerable: false, | ||
writable: false, | ||
configurable: false | ||
} | ||
}); | ||
Model.connection.logMessage('debug', `creating new instance of model for file ${Model.file}`); | ||
this.transformationErrors.forEach(error => { | ||
this._transformationErrors.forEach(error => { | ||
// errors occurred while transforming data from multivalue format - log them | ||
@@ -95,7 +106,3 @@ Model.connection.logMessage('warn', `error transforming data -- file: ${Model.file}; _id: ${this._id}; class: ${error.transformClass}; value: ${error.transformValue}`); | ||
} = data.result; | ||
return new Model({ | ||
_id, | ||
__v, | ||
record | ||
}); | ||
return Model.#createModelFromRecordString(record, _id, __v); | ||
} | ||
@@ -116,7 +123,3 @@ /** Find documents via query */ | ||
} = document; | ||
return new Model({ | ||
_id, | ||
__v, | ||
record | ||
}); | ||
return Model.#createModelFromRecordString(record, _id, __v); | ||
}); | ||
@@ -139,7 +142,3 @@ } | ||
} = document; | ||
return new Model({ | ||
_id, | ||
__v, | ||
record | ||
}); | ||
return Model.#createModelFromRecordString(record, _id, __v); | ||
}); | ||
@@ -175,7 +174,3 @@ return { | ||
} = data.result; | ||
return new Model({ | ||
_id, | ||
__v, | ||
record | ||
}); | ||
return Model.#createModelFromRecordString(record, _id, __v); | ||
} | ||
@@ -224,2 +219,12 @@ /** Find multiple documents by their ids */ | ||
} | ||
/** Create a new Model instance from a record string */ | ||
static #createModelFromRecordString(recordString, _id, __v) { | ||
return new Model({ | ||
_id, | ||
__v, | ||
record: recordString | ||
}); | ||
} | ||
/** Save a document to the database */ | ||
@@ -247,6 +252,4 @@ | ||
__v: this.__v, | ||
record: this.transformDocumentToRecord(), | ||
foreignKeyDefinitions: this.buildForeignKeyDefinitions(), | ||
clearAttributes: Model.schema === null // clears all attributes before writing new record | ||
record: this.#convertToMvString(), | ||
foreignKeyDefinitions: this.buildForeignKeyDefinitions() | ||
}); | ||
@@ -258,7 +261,3 @@ const { | ||
} = data.result; | ||
return new Model({ | ||
_id, | ||
__v, | ||
record | ||
}); | ||
return Model.#createModelFromRecordString(record, _id, __v); | ||
} catch (err) { | ||
@@ -274,3 +273,15 @@ // enrich caught error object with additional information and rethrow | ||
} | ||
/** Convert model instance to multivalue string */ | ||
#convertToMvString() { | ||
const { | ||
am, | ||
vm, | ||
svm | ||
} = Model.#dbServerDelimiters; | ||
const mvRecord = this.transformDocumentToRecord(); | ||
return mvRecord.map(attribute => Array.isArray(attribute) ? attribute.map(value => Array.isArray(value) ? value.join(svm) : value).join(vm) : attribute).join(am); | ||
} | ||
}; | ||
@@ -277,0 +288,0 @@ }; |
@@ -0,1 +1,4 @@ | ||
/// <reference types="node" /> | ||
import type http from 'http'; | ||
import type https from 'https'; | ||
import { type ModelConstructor } from './compileModel'; | ||
@@ -26,2 +29,6 @@ import type Schema from './Schema'; | ||
timeout?: number; | ||
/** Optional http agent */ | ||
httpAgent?: http.Agent; | ||
/** Optional https agent */ | ||
httpsAgent?: https.Agent; | ||
} | ||
@@ -52,11 +59,10 @@ export declare enum ConnectionStatus { | ||
private serverFeatureSet; | ||
/** Time that the connection information cache will expire */ | ||
private cacheExpiry; | ||
/** Maximum age of the cache before it must be refreshed */ | ||
private readonly cacheMaxAge; | ||
/** +/- in milliseconds between database server time and local server time */ | ||
private timeDrift; | ||
/** Multivalue database server information */ | ||
private dbServerInfo?; | ||
/** Axios instance */ | ||
private readonly axiosInstance; | ||
private constructor(); | ||
/** Create a connection */ | ||
static createConnection( | ||
@@ -63,0 +69,0 @@ /** URI of the MVIS which facilitates access to the mv database */ |
@@ -55,11 +55,4 @@ "use strict"; | ||
}; | ||
/** Time that the connection information cache will expire */ | ||
cacheExpiry = 0; | ||
/** Maximum age of the cache before it must be refreshed */ | ||
/** +/- in milliseconds between database server time and local server time */ | ||
timeDrift = 0; | ||
/** Axios instance */ | ||
constructor( | ||
@@ -75,3 +68,7 @@ /** URI of the MVIS which facilitates access to the mv database */ | ||
/** Request timeout (ms) */ | ||
timeout) { | ||
timeout, options) { | ||
const { | ||
httpAgent, | ||
httpsAgent | ||
} = options; | ||
this.account = account; | ||
@@ -86,7 +83,15 @@ this.logger = logger; | ||
clarifyTimeoutError: true | ||
} | ||
}, | ||
...(httpAgent && { | ||
httpAgent | ||
}), | ||
...(httpsAgent && { | ||
httpsAgent | ||
}) | ||
}); | ||
this.logMessage('debug', 'creating new connection instance'); | ||
} | ||
/** Create a connection */ | ||
static createConnection( | ||
@@ -100,3 +105,5 @@ /** URI of the MVIS which facilitates access to the mv database */ | ||
cacheMaxAge = 3600, | ||
timeout = 0 | ||
timeout = 0, | ||
httpAgent, | ||
httpsAgent | ||
} = options; | ||
@@ -116,3 +123,6 @@ | ||
return new Connection(mvisUri, account, logger, cacheMaxAge, timeout); | ||
return new Connection(mvisUri, account, logger, cacheMaxAge, timeout, { | ||
httpAgent, | ||
httpsAgent | ||
}); | ||
} | ||
@@ -166,6 +176,6 @@ /** Return the packaged specific version number of a feature */ | ||
this.status = ConnectionStatus.connected; | ||
await this.getDbServerInfo(); // establish baseline for database server information | ||
this.logMessage('info', 'connection opened'); | ||
this.status = ConnectionStatus.connected; | ||
} | ||
@@ -258,4 +268,6 @@ /** Deploy database features */ | ||
async getDbDate() { | ||
await this.getDbServerInfo(); | ||
return (0, _dateFns.format)((0, _dateFns.addMilliseconds)(Date.now(), this.timeDrift), _constants.ISOCalendarDateFormat); | ||
const { | ||
timeDrift | ||
} = await this.getDbServerInfo(); | ||
return (0, _dateFns.format)((0, _dateFns.addMilliseconds)(Date.now(), timeDrift), _constants.ISOCalendarDateFormat); | ||
} | ||
@@ -266,4 +278,6 @@ /** Get the current ISOCalendarDateTime from the database */ | ||
async getDbDateTime() { | ||
await this.getDbServerInfo(); | ||
return (0, _dateFns.format)((0, _dateFns.addMilliseconds)(Date.now(), this.timeDrift), _constants.ISOCalendarDateTimeFormat); | ||
const { | ||
timeDrift | ||
} = await this.getDbServerInfo(); | ||
return (0, _dateFns.format)((0, _dateFns.addMilliseconds)(Date.now(), timeDrift), _constants.ISOCalendarDateTimeFormat); | ||
} | ||
@@ -274,4 +288,6 @@ /** Get the current ISOTime from the database */ | ||
async getDbTime() { | ||
await this.getDbServerInfo(); | ||
return (0, _dateFns.format)((0, _dateFns.addMilliseconds)(Date.now(), this.timeDrift), _constants.ISOTimeFormat); | ||
const { | ||
timeDrift | ||
} = await this.getDbServerInfo(); | ||
return (0, _dateFns.format)((0, _dateFns.addMilliseconds)(Date.now(), timeDrift), _constants.ISOTimeFormat); | ||
} | ||
@@ -282,3 +298,3 @@ /** Define a new model */ | ||
model(schema, file) { | ||
if (this.status !== ConnectionStatus.connected) { | ||
if (this.status !== ConnectionStatus.connected || this.dbServerInfo == null) { | ||
this.logMessage('error', 'Cannot create model until database connection has been established'); | ||
@@ -288,3 +304,6 @@ throw new Error('Cannot create model until database connection has been established'); | ||
return (0, _compileModel.default)(this, schema, file); | ||
const { | ||
delimiters | ||
} = this.dbServerInfo; | ||
return (0, _compileModel.default)(this, schema, file, delimiters); | ||
} | ||
@@ -321,12 +340,24 @@ /** Log a message to logger including account name */ | ||
async getDbServerInfo() { | ||
if (Date.now() > this.cacheExpiry) { | ||
if (this.dbServerInfo == null || Date.now() > this.dbServerInfo.cacheExpiry) { | ||
if (this.status !== ConnectionStatus.connected) { | ||
this.logMessage('error', 'Cannot get database server info until database connection has been established'); | ||
throw new Error('Cannot get database server info until database connection has been established'); | ||
} | ||
this.logMessage('debug', 'getting db server information'); | ||
const data = await this.executeDbFeature('getServerInfo', {}); | ||
const { | ||
date, | ||
time | ||
} = data; | ||
this.timeDrift = (0, _dateFns.differenceInMilliseconds)((0, _dateFns.addMilliseconds)((0, _dateFns.addDays)(_constants.mvEpoch, date), time), Date.now()); | ||
this.cacheExpiry = Date.now() + this.cacheMaxAge * 1000; | ||
time, | ||
delimiters | ||
} = await this.executeDbFeature('getServerInfo', {}); | ||
const timeDrift = (0, _dateFns.differenceInMilliseconds)((0, _dateFns.addMilliseconds)((0, _dateFns.addDays)(_constants.mvEpoch, date), time), Date.now()); | ||
const cacheExpiry = Date.now() + this.cacheMaxAge * 1000; | ||
this.dbServerInfo = { | ||
cacheExpiry, | ||
timeDrift, | ||
delimiters | ||
}; | ||
} | ||
return this.dbServerInfo; | ||
} | ||
@@ -333,0 +364,0 @@ /** Get the state of database server features */ |
import { TransformDataError } from './errors'; | ||
import type Schema from './Schema'; | ||
import type { GenericObject, MvRecord } from './types'; | ||
import type { DbServerDelimiters, GenericObject, MvRecord } from './types'; | ||
export interface DocumentConstructorOptions { | ||
@@ -20,4 +20,12 @@ data?: GenericObject; | ||
/** Array of any errors which occurred during transformation from the database */ | ||
transformationErrors: TransformDataError[]; | ||
constructor(schema: Schema | null, options: DocumentConstructorOptions); | ||
_transformationErrors: TransformDataError[]; | ||
protected constructor(schema: Schema | null, options: DocumentConstructorOptions); | ||
/** Create a new Subdocument instance from a record array */ | ||
static createSubdocumentFromRecord(schema: Schema, record: MvRecord): Document; | ||
/** Create a new Subdocument instance from data */ | ||
static createSubdocumentFromData(schema: Schema, data: GenericObject): Document; | ||
/** Create a new Document instance from a record string */ | ||
static createDocumentFromRecordString(schema: Schema, recordString: string, dbServerDelimiters: DbServerDelimiters): Document; | ||
/** Convert a multivalue string to an array */ | ||
static convertMvStringToArray(recordString: string, dbServerDelimiters: DbServerDelimiters): MvRecord; | ||
/** Transform document structure to multivalue array structure */ | ||
@@ -24,0 +32,0 @@ transformDocumentToRecord(): MvRecord; |
@@ -36,7 +36,7 @@ "use strict"; | ||
this.#schema = schema; | ||
this.#record = []; | ||
this.#record = record ?? []; | ||
this.#isSubdocument = isSubdocument; | ||
this.transformationErrors = []; | ||
this._transformationErrors = []; | ||
Object.defineProperties(this, { | ||
transformationErrors: { | ||
_transformationErrors: { | ||
configurable: false, | ||
@@ -47,10 +47,69 @@ enumerable: false, | ||
}); | ||
this.#transformRecordToDocument(); // load the data passed to constructor into document instance | ||
if (record != null) { | ||
this.#transformRecordToDocument(record); | ||
} // load the data passed to constructor into document instance | ||
(0, _lodash.assignIn)(this, data); | ||
} | ||
/** Create a new Subdocument instance from a record array */ | ||
(0, _lodash.assignIn)(this, data); | ||
static createSubdocumentFromRecord(schema, record) { | ||
return new Document(schema, { | ||
record, | ||
isSubdocument: true | ||
}); | ||
} | ||
/** Create a new Subdocument instance from data */ | ||
static createSubdocumentFromData(schema, data) { | ||
return new Document(schema, { | ||
data, | ||
isSubdocument: true | ||
}); | ||
} | ||
/** Create a new Document instance from a record string */ | ||
static createDocumentFromRecordString(schema, recordString, dbServerDelimiters) { | ||
const record = Document.convertMvStringToArray(recordString, dbServerDelimiters); | ||
return new Document(schema, { | ||
record | ||
}); | ||
} | ||
/** Convert a multivalue string to an array */ | ||
static convertMvStringToArray(recordString, dbServerDelimiters) { | ||
const { | ||
am, | ||
vm, | ||
svm | ||
} = dbServerDelimiters; | ||
const record = recordString === '' ? [] : recordString.split(am).map(attribute => { | ||
if (attribute === '') { | ||
return null; | ||
} | ||
const attributeArray = attribute.split(vm); | ||
if (attributeArray.length === 1 && !attributeArray[0].includes(svm)) { | ||
return attribute; | ||
} | ||
return attributeArray.map(value => { | ||
if (value === '') { | ||
return null; | ||
} | ||
const valueArray = value.split(svm); | ||
if (valueArray.length === 1) { | ||
return value; | ||
} | ||
return valueArray.map(subvalue => subvalue === '' ? null : subvalue); | ||
}); | ||
}); | ||
return record; | ||
} | ||
/** Transform document structure to multivalue array structure */ | ||
@@ -156,5 +215,3 @@ | ||
#transformRecordToDocument(record) { | ||
// hold on to the original to use as the baseline when saving | ||
this.#record = record; | ||
#transformRecordToDocument() { | ||
const plainDocument = this.#schema === null ? { | ||
@@ -171,3 +228,4 @@ _raw: this.#record | ||
setValue = null; | ||
this.transformationErrors.push(err); | ||
this._transformationErrors.push(err); | ||
} else { | ||
@@ -174,0 +232,0 @@ // otherwise rethrow any other type of error |
{ | ||
"name": "mvom", | ||
"private": false, | ||
"version": "2.0.0-alpha.3", | ||
"version": "2.0.0-alpha.4", | ||
"description": "Multivalue Object Mapper", | ||
@@ -26,5 +26,5 @@ "main": "index.js", | ||
"lodash": "^4.17.21", | ||
"semver": "^7.3.5" | ||
"semver": "^7.3.6" | ||
}, | ||
"types": "index.d.ts" | ||
} |
20
Query.js
@@ -10,4 +10,2 @@ "use strict"; | ||
var _schemaType = require("./schemaType"); | ||
// #endregion | ||
@@ -233,5 +231,5 @@ | ||
const dictionaryId = (_this$Model$schema2 = this.Model.schema) === null || _this$Model$schema2 === void 0 ? void 0 : _this$Model$schema2.dictPaths.get(property); | ||
const dictionaryTypeDetail = (_this$Model$schema2 = this.Model.schema) === null || _this$Model$schema2 === void 0 ? void 0 : _this$Model$schema2.dictPaths.get(property); | ||
if (dictionaryId == null) { | ||
if (dictionaryTypeDetail == null) { | ||
throw new _errors.InvalidParameterError({ | ||
@@ -243,3 +241,3 @@ message: 'Nonexistent schema property or property does not have a dictionary specified', | ||
return dictionaryId; | ||
return dictionaryTypeDetail.dictionary; | ||
} | ||
@@ -252,9 +250,13 @@ /** Transform query constant to internal u2 format (if applicable) */ | ||
const schemaType = (_this$Model$schema3 = this.Model.schema) === null || _this$Model$schema3 === void 0 ? void 0 : _this$Model$schema3.paths.get(property); | ||
const dictionaryTypeDetail = (_this$Model$schema3 = this.Model.schema) === null || _this$Model$schema3 === void 0 ? void 0 : _this$Model$schema3.dictPaths.get(property); | ||
/* istanbul ignore if: Would have thrown previously in getDictionaryId */ | ||
if (schemaType == null) { | ||
return constant; | ||
if (dictionaryTypeDetail == null) { | ||
throw new _errors.InvalidParameterError({ | ||
message: 'Nonexistent schema property or property does not have a dictionary specified', | ||
parameterName: 'property' | ||
}); | ||
} | ||
return schemaType instanceof _schemaType.BaseScalarType || schemaType instanceof _schemaType.BaseScalarArrayType ? schemaType.transformToQuery(constant) : constant; | ||
return dictionaryTypeDetail.dataTransformer.transformToQuery(constant); | ||
} | ||
@@ -261,0 +263,0 @@ |
@@ -1,3 +0,3 @@ | ||
import type { BaseSchemaType, SchemaTypeDefinitionScalar } from './schemaType'; | ||
import type { DecryptFn, EncryptFn } from './types'; | ||
import type { BaseSchemaType, SchemaTypeDefinitionBoolean, SchemaTypeDefinitionISOCalendarDate, SchemaTypeDefinitionISOCalendarDateTime, SchemaTypeDefinitionISOTime, SchemaTypeDefinitionNumber, SchemaTypeDefinitionScalar, SchemaTypeDefinitionString } from './schemaType'; | ||
import type { DataTransformer, DecryptFn, EncryptFn, MarkRequired } from './types'; | ||
declare type SchemaTypeDefinition = Schema | SchemaTypeDefinitionScalar | SchemaDefinition | SchemaTypeDefinitionArray; | ||
@@ -17,4 +17,7 @@ declare type SchemaTypeDefinitionArray = Schema[] | SchemaTypeDefinitionScalar[] | SchemaTypeDefinitionScalar[][] | SchemaDefinition[] | SchemaDefinition[][]; | ||
} | ||
declare type PickAndMark<T extends SchemaTypeDefinitionScalar, K extends keyof T = never> = MarkRequired<Pick<T, 'dictionary' | 'type' | K>, 'dictionary'>; | ||
export declare type DictionaryTypeDefinition = PickAndMark<SchemaTypeDefinitionString> | PickAndMark<SchemaTypeDefinitionNumber> | PickAndMark<SchemaTypeDefinitionBoolean> | PickAndMark<SchemaTypeDefinitionISOCalendarDate> | PickAndMark<SchemaTypeDefinitionISOCalendarDateTime, 'dbFormat'> | PickAndMark<SchemaTypeDefinitionISOTime, 'dbFormat'>; | ||
export declare type DictionaryDefinition = string | DictionaryTypeDefinition; | ||
export interface SchemaConstructorOptions { | ||
dictionaries?: Record<string, string>; | ||
dictionaries?: Record<string, DictionaryDefinition>; | ||
idMatch?: RegExp; | ||
@@ -25,6 +28,10 @@ idForeignKey?: SchemaForeignKeyDefinition | SchemaCompoundForeignKeyDefinition; | ||
} | ||
interface DictionaryTypeDetail { | ||
dictionary: string; | ||
dataTransformer: DataTransformer; | ||
} | ||
/** Schema constructor */ | ||
declare class Schema { | ||
/** Key/value pairs of schema object path structure and associated multivalue dictionary ids */ | ||
dictPaths: Map<string, string>; | ||
dictPaths: Map<string, DictionaryTypeDetail>; | ||
/** The compiled schema object path structure */ | ||
@@ -50,3 +57,5 @@ readonly paths: Map<string, BaseSchemaType>; | ||
/** Transform the paths to positions */ | ||
transformPathsToDbPositions: (paths: string[]) => number[]; | ||
transformPathsToDbPositions(paths: string[]): number[]; | ||
/** Build the dictionary path map for additional dictionaries provided as schema options */ | ||
private buildDictionaryPaths; | ||
/** | ||
@@ -53,0 +62,0 @@ * Get all positionPaths with path as key and position array as value including children schemas |
151
Schema.js
@@ -8,2 +8,4 @@ "use strict"; | ||
var _dataTransformers = require("./dataTransformers"); | ||
var _errors = require("./errors"); | ||
@@ -41,3 +43,2 @@ | ||
} = {}) { | ||
this.dictPaths = new Map(Object.entries(dictionaries).concat([['_id', '@ID']])); | ||
this.idForeignKey = idForeignKey; | ||
@@ -50,2 +51,3 @@ this.idMatch = idMatch; | ||
this.decrypt = decrypt; | ||
this.dictPaths = this.buildDictionaryPaths(dictionaries); | ||
this.paths = this.buildPaths(this.definition); | ||
@@ -62,3 +64,3 @@ } | ||
transformPathsToDbPositions = paths => { | ||
transformPathsToDbPositions(paths) { | ||
if (paths.length === 0) { | ||
@@ -92,3 +94,69 @@ return []; | ||
return [...positions]; | ||
}; | ||
} | ||
/** Build the dictionary path map for additional dictionaries provided as schema options */ | ||
buildDictionaryPaths(dictionaries) { | ||
// Add reference for _id --> @ID by default | ||
const dictPaths = new Map([['_id', { | ||
dictionary: '@ID', | ||
dataTransformer: new _dataTransformers.StringDataTransformer() | ||
}]]); | ||
return Object.entries(dictionaries).reduce((acc, [queryProperty, dictionaryDefinition]) => { | ||
if (typeof dictionaryDefinition === 'string') { | ||
return acc.set(queryProperty, { | ||
dictionary: dictionaryDefinition, | ||
dataTransformer: new _dataTransformers.StringDataTransformer() | ||
}); | ||
} | ||
const { | ||
type, | ||
dictionary | ||
} = dictionaryDefinition; | ||
switch (type) { | ||
case 'string': | ||
return acc.set(queryProperty, { | ||
dictionary, | ||
dataTransformer: new _dataTransformers.StringDataTransformer() | ||
}); | ||
case 'number': | ||
return acc.set(queryProperty, { | ||
dictionary, | ||
dataTransformer: new _dataTransformers.NumberDataTransformer() | ||
}); | ||
case 'boolean': | ||
return acc.set(queryProperty, { | ||
dictionary, | ||
dataTransformer: new _dataTransformers.BooleanDataTransformer() | ||
}); | ||
case 'ISOCalendarDate': | ||
return acc.set(queryProperty, { | ||
dictionary, | ||
dataTransformer: new _dataTransformers.ISOCalendarDateDataTransformer() | ||
}); | ||
case 'ISOCalendarDateTime': | ||
return acc.set(queryProperty, { | ||
dictionary, | ||
dataTransformer: new _dataTransformers.ISOCalendarDateTimeDataTransformer(dictionaryDefinition.dbFormat) | ||
}); | ||
case 'ISOTime': | ||
return acc.set(queryProperty, { | ||
dictionary, | ||
dataTransformer: new _dataTransformers.ISOTimeDataTransformer(dictionaryDefinition.dbFormat) | ||
}); | ||
/* istanbul ignore next: cannot hit without violating types */ | ||
default: | ||
return acc; | ||
} | ||
}, dictPaths); | ||
} | ||
/** | ||
@@ -99,2 +167,3 @@ * Get all positionPaths with path as key and position array as value including children schemas | ||
getPositionPaths() { | ||
@@ -113,24 +182,26 @@ // merge the positionPaths from subdocumentSchemas with parentPath appended by the childPath recursively | ||
buildPaths = (definition, prev) => Object.entries(definition).reduce((acc, [key, value]) => { | ||
// construct flattened keypath | ||
const newKey = prev != null ? `${prev}.${key}` : key; | ||
buildPaths(definition, prev) { | ||
return Object.entries(definition).reduce((acc, [key, value]) => { | ||
// construct flattened keypath | ||
const newKey = prev != null ? `${prev}.${key}` : key; | ||
if (Array.isArray(value)) { | ||
return acc.set(newKey, this.castArray(value, newKey)); | ||
} | ||
if (Array.isArray(value)) { | ||
return acc.set(newKey, this.castArray(value, newKey)); | ||
} | ||
if (this.isScalarDefinition(value)) { | ||
// cast this value as a schemaType | ||
return acc.set(newKey, this.castScalar(value, newKey)); | ||
} | ||
if (this.isScalarDefinition(value)) { | ||
// cast this value as a schemaType | ||
return acc.set(newKey, this.castScalar(value, newKey)); | ||
} | ||
if (value instanceof Schema) { | ||
// value is an already compiled schema - cast as embedded document | ||
this.handleSubDocumentSchemas(value, newKey); | ||
return acc.set(newKey, new _schemaType.EmbeddedType(value)); | ||
} | ||
if (value instanceof Schema) { | ||
// value is an already compiled schema - cast as embedded document | ||
this.handleSubDocumentSchemas(value, newKey); | ||
return acc.set(newKey, new _schemaType.EmbeddedType(value)); | ||
} | ||
const nestedPaths = this.buildPaths(value, newKey); | ||
return new Map([...acc, ...nestedPaths]); | ||
}, new Map()); | ||
const nestedPaths = this.buildPaths(value, newKey); | ||
return new Map([...acc, ...nestedPaths]); | ||
}, new Map()); | ||
} | ||
/** | ||
@@ -141,3 +212,4 @@ * Cast an array to a schemaType | ||
castArray = (castee, keyPath) => { | ||
castArray(castee, keyPath) { | ||
if (castee.length !== 1) { | ||
@@ -189,3 +261,3 @@ // a schema array definition must contain exactly one value of language-type object (which includes arrays) | ||
return new _schemaType.DocumentArrayType(subdocumentSchema); | ||
}; | ||
} | ||
/** | ||
@@ -196,3 +268,4 @@ * Cast a scalar definition to a scalar schemaType | ||
castScalar = (castee, keyPath) => { | ||
castScalar(castee, keyPath) { | ||
const options = { | ||
@@ -206,7 +279,7 @@ encrypt: this.encrypt, | ||
case 'boolean': | ||
schemaTypeValue = new _schemaType.BooleanType(castee); | ||
schemaTypeValue = new _schemaType.BooleanType(castee, options); | ||
break; | ||
case 'ISOCalendarDateTime': | ||
schemaTypeValue = new _schemaType.ISOCalendarDateTimeType(castee); | ||
schemaTypeValue = new _schemaType.ISOCalendarDateTimeType(castee, options); | ||
break; | ||
@@ -219,7 +292,7 @@ | ||
case 'ISOTime': | ||
schemaTypeValue = new _schemaType.ISOTimeType(castee); | ||
schemaTypeValue = new _schemaType.ISOTimeType(castee, options); | ||
break; | ||
case 'number': | ||
schemaTypeValue = new _schemaType.NumberType(castee); | ||
schemaTypeValue = new _schemaType.NumberType(castee, options); | ||
break; | ||
@@ -250,15 +323,20 @@ | ||
if (schemaTypeValue.dictionary != null) { | ||
this.dictPaths.set(keyPath, schemaTypeValue.dictionary); | ||
this.dictPaths.set(keyPath, { | ||
dictionary: schemaTypeValue.dictionary, | ||
dataTransformer: schemaTypeValue | ||
}); | ||
} | ||
return schemaTypeValue; | ||
}; | ||
} | ||
/** Perform ancillary updates needed when a subdocument is in the Schema definition */ | ||
handleSubDocumentSchemas = (schema, keyPath) => { | ||
handleSubDocumentSchemas(schema, keyPath) { | ||
this.subdocumentSchemas.set(keyPath, schema); | ||
this.mergeSchemaDictionaries(schema, keyPath); | ||
}; | ||
} | ||
/** Determine if an object matches the structure of a scalar definition */ | ||
isScalarDefinition(schemaTypeDefinition) { | ||
@@ -270,8 +348,9 @@ return Object.prototype.hasOwnProperty.call(schemaTypeDefinition, 'type') && Object.prototype.hasOwnProperty.call(schemaTypeDefinition, 'path'); | ||
mergeSchemaDictionaries = (schema, keyPath) => { | ||
this.dictPaths = Array.from(schema.dictPaths).reduce((acc, [subDictPath, subDictId]) => { | ||
mergeSchemaDictionaries(schema, keyPath) { | ||
this.dictPaths = Array.from(schema.dictPaths).reduce((acc, [subDictPath, subDictTypeDetail]) => { | ||
const dictKey = `${keyPath}.${subDictPath}`; | ||
return acc.set(dictKey, subDictId); | ||
return acc.set(dictKey, subDictTypeDetail); | ||
}, this.dictPaths); | ||
}; | ||
} | ||
} | ||
@@ -278,0 +357,0 @@ |
@@ -10,5 +10,3 @@ import type BaseScalarType from './BaseScalarType'; | ||
cast(value: unknown): unknown[]; | ||
/** Transform query constants to the format defined by the array's schema */ | ||
transformToQuery(value: unknown): unknown; | ||
} | ||
export default BaseScalarArrayType; |
@@ -27,9 +27,3 @@ "use strict"; | ||
} | ||
/** Transform query constants to the format defined by the array's schema */ | ||
transformToQuery(value) { | ||
return this.valueSchemaType.transformToQuery(value); | ||
} | ||
} | ||
@@ -36,0 +30,0 @@ |
import type Document from '../Document'; | ||
import type { DecryptFn, EncryptFn, MvAttribute, MvRecord } from '../types'; | ||
import type { DataTransformer, DecryptFn, EncryptFn, MvAttribute, MvRecord } from '../types'; | ||
import BaseSchemaType from './BaseSchemaType'; | ||
@@ -17,3 +17,3 @@ import type { SchemaTypeDefinitionBoolean } from './BooleanType'; | ||
/** Abstract Scalar Schema Type */ | ||
declare abstract class BaseScalarType extends BaseSchemaType { | ||
declare abstract class BaseScalarType extends BaseSchemaType implements DataTransformer { | ||
/** Data definition which this schema type was constructed from */ | ||
@@ -33,2 +33,4 @@ readonly definition: SchemaTypeDefinitionScalar; | ||
private readonly decrypt?; | ||
/** Data transformer */ | ||
protected abstract readonly dataTransformer: DataTransformer; | ||
protected constructor(definition: SchemaTypeDefinitionScalar, { encrypt, decrypt }?: ScalarTypeConstructorOptions); | ||
@@ -39,4 +41,8 @@ /** Get value from mv data */ | ||
set(originalRecord: MvRecord, value: unknown): MvRecord; | ||
/** Transform from mv data to externally formatted data */ | ||
transformFromDb(value: unknown): unknown; | ||
/** Transform from externally formatted data to mv data */ | ||
transformToDb(value: unknown): string | null; | ||
/** Transform query constants to the format schema */ | ||
transformToQuery(value: unknown): unknown; | ||
transformToQuery(value: unknown): string; | ||
/** Validate the scalar type */ | ||
@@ -69,7 +75,3 @@ validate(value: unknown, document: Document): Promise<string[]>; | ||
private decryptSingle; | ||
/** Transform from mv data to externally formatted data */ | ||
abstract transformFromDb(value: unknown): unknown; | ||
/** Transform from externally formatted data to mv data */ | ||
abstract transformToDb(value: unknown): string | null; | ||
} | ||
export default BaseScalarType; |
@@ -34,2 +34,4 @@ "use strict"; | ||
/** Decrypt function to call on sensitive data encrypted in the database */ | ||
/** Data transformer */ | ||
constructor(definition, { | ||
@@ -84,2 +86,14 @@ encrypt, | ||
} | ||
/** Transform from mv data to externally formatted data */ | ||
transformFromDb(value) { | ||
return this.dataTransformer.transformFromDb(value); | ||
} | ||
/** Transform from externally formatted data to mv data */ | ||
transformToDb(value) { | ||
return this.dataTransformer.transformToDb(value); | ||
} | ||
/** Transform query constants to the format schema */ | ||
@@ -89,3 +103,3 @@ | ||
transformToQuery(value) { | ||
return value; | ||
return this.dataTransformer.transformToQuery(value); | ||
} | ||
@@ -223,5 +237,3 @@ /** Validate the scalar type */ | ||
} | ||
/** Transform from mv data to externally formatted data */ | ||
} | ||
@@ -228,0 +240,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { BooleanDataTransformer } from '../dataTransformers'; | ||
import type { ScalarTypeConstructorOptions } from './BaseScalarType'; | ||
@@ -9,12 +10,6 @@ import BaseScalarType from './BaseScalarType'; | ||
declare class BooleanType extends BaseScalarType { | ||
/** Data transformer */ | ||
protected readonly dataTransformer: BooleanDataTransformer; | ||
constructor(definition: SchemaTypeDefinitionBoolean, options?: ScalarTypeConstructorOptions); | ||
/** Transform mv style data to Boolean */ | ||
transformFromDb(value: unknown): boolean; | ||
/** Transform js style data to mv style data */ | ||
transformToDb(value: unknown): '1' | '0'; | ||
/** Transform query constants to u2 formatted Boolean */ | ||
transformToQuery(value: true | 'true' | 'TRUE'): '1'; | ||
transformToQuery(value: false | 'false' | 'FALSE'): '0'; | ||
transformToQuery(value: unknown): unknown; | ||
} | ||
export default BooleanType; |
@@ -10,2 +10,4 @@ "use strict"; | ||
var _dataTransformers = require("../dataTransformers"); | ||
var _BaseScalarType = _interopRequireDefault(require("./BaseScalarType")); | ||
@@ -15,33 +17,8 @@ | ||
class BooleanType extends _BaseScalarType.default { | ||
/** Data transformer */ | ||
constructor(definition, options = {}) { | ||
super(definition, options); | ||
this.dataTransformer = new _dataTransformers.BooleanDataTransformer(); | ||
} | ||
/** Transform mv style data to Boolean */ | ||
transformFromDb(value) { | ||
// this logic is intentionally trying to mimic the Boolean rules of the UniBasic interpreter | ||
return value != null && value !== '0' && value !== 0; | ||
} | ||
/** Transform js style data to mv style data */ | ||
transformToDb(value) { | ||
return value ? '1' : '0'; | ||
} | ||
/** Transform query constants to u2 formatted Boolean */ | ||
transformToQuery(value) { | ||
if (value === true || value === 'true' || value === 'TRUE') { | ||
return '1'; | ||
} | ||
if (value === false || value === 'false' || value === 'FALSE') { | ||
return '0'; | ||
} | ||
return value; | ||
} | ||
} | ||
@@ -48,0 +25,0 @@ |
@@ -44,6 +44,3 @@ "use strict"; | ||
return new _Document.default(this.valueSchema, { | ||
data: plainValue, | ||
isSubdocument: true | ||
}); | ||
return _Document.default.createSubdocumentFromData(this.valueSchema, plainValue); | ||
}); | ||
@@ -129,6 +126,4 @@ } | ||
const subdocument = new _Document.default(this.valueSchema, { | ||
isSubdocument: true, | ||
record: subRecord | ||
}); | ||
const subdocument = _Document.default.createSubdocumentFromRecord(this.valueSchema, subRecord); | ||
yield subdocument; | ||
@@ -135,0 +130,0 @@ iteration += 1; |
@@ -39,6 +39,3 @@ "use strict"; | ||
return new _Document.default(this.valueSchema, { | ||
data: plainValue, | ||
isSubdocument: true | ||
}); | ||
return _Document.default.createSubdocumentFromData(this.valueSchema, plainValue); | ||
} | ||
@@ -49,6 +46,4 @@ /** Get value from mv data */ | ||
get(record) { | ||
const embeddedDocument = new _Document.default(this.valueSchema, { | ||
isSubdocument: true, | ||
record | ||
}); | ||
const embeddedDocument = _Document.default.createSubdocumentFromRecord(this.valueSchema, record); | ||
return embeddedDocument; | ||
@@ -55,0 +50,0 @@ } |
export { default as ArrayType } from './ArrayType'; | ||
export { default as BaseDateType } from './BaseDateType'; | ||
export { default as BaseScalarArrayType } from './BaseScalarArrayType'; | ||
@@ -4,0 +3,0 @@ export { default as BaseScalarType, type SchemaTypeDefinitionScalar } from './BaseScalarType'; |
@@ -14,8 +14,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "BaseDateType", { | ||
enumerable: true, | ||
get: function () { | ||
return _BaseDateType.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "BaseScalarArrayType", { | ||
@@ -96,4 +90,2 @@ enumerable: true, | ||
var _BaseDateType = _interopRequireDefault(require("./BaseDateType")); | ||
var _BaseScalarArrayType = _interopRequireDefault(require("./BaseScalarArrayType")); | ||
@@ -100,0 +92,0 @@ |
@@ -0,4 +1,5 @@ | ||
import { ISOCalendarDateTimeDataTransformer } from '../dataTransformers'; | ||
import type Document from '../Document'; | ||
import BaseDateType from './BaseDateType'; | ||
import type { ScalarTypeConstructorOptions } from './BaseScalarType'; | ||
import BaseScalarType from './BaseScalarType'; | ||
import type { SchemaTypeDefinitionBase } from './BaseSchemaType'; | ||
@@ -10,5 +11,5 @@ export interface SchemaTypeDefinitionISOCalendarDateTime extends SchemaTypeDefinitionBase { | ||
/** An ISOCalendarDateTime Schema Type */ | ||
declare class ISOCalendarDateTimeType extends BaseDateType { | ||
/** Database time format is in milliseconds */ | ||
private readonly isDbInMs; | ||
declare class ISOCalendarDateTimeType extends BaseScalarType { | ||
/** Data transformer */ | ||
protected readonly dataTransformer: ISOCalendarDateTimeDataTransformer; | ||
/** ISOCalendarDateType instance to use for transformations and validations of the date part of the DateTime */ | ||
@@ -19,11 +20,2 @@ private readonly isoCalendarDateType; | ||
constructor(definition: SchemaTypeDefinitionISOCalendarDateTime, options?: ScalarTypeConstructorOptions); | ||
/** Transform mv style timestamp data (ddddd.sssss[SSS]) to ISO 8601 approved date/time format (yyyy-mm-ddTHH:mm:ss.SSS) */ | ||
transformFromDb(value: null): null; | ||
transformFromDb(value: unknown): string; | ||
/** | ||
* Transform ISO 8601 approved date/time format (yyyy-mm-ddTHH:mm:ss.SSS) to mv style timestamp data (ddddd.sssss[SSS]) | ||
* @throws {@link TransformDataError} Value could not be transformed to database format | ||
*/ | ||
transformToDb(value: null): null; | ||
transformToDb(value: unknown): string; | ||
/** ISOCalendarDateTime data type validator */ | ||
@@ -30,0 +22,0 @@ protected validateType: (value: unknown, document: Document) => Promise<boolean>; |
@@ -10,5 +10,5 @@ "use strict"; | ||
var _errors = require("../errors"); | ||
var _dataTransformers = require("../dataTransformers"); | ||
var _BaseDateType = _interopRequireDefault(require("./BaseDateType")); | ||
var _BaseScalarType = _interopRequireDefault(require("./BaseScalarType")); | ||
@@ -20,4 +20,4 @@ var _ISOCalendarDateType = _interopRequireDefault(require("./ISOCalendarDateType")); | ||
/** An ISOCalendarDateTime Schema Type */ | ||
class ISOCalendarDateTimeType extends _BaseDateType.default { | ||
/** Database time format is in milliseconds */ | ||
class ISOCalendarDateTimeType extends _BaseScalarType.default { | ||
/** Data transformer */ | ||
@@ -32,3 +32,2 @@ /** ISOCalendarDateType instance to use for transformations and validations of the date part of the DateTime */ | ||
} = definition; | ||
this.isDbInMs = dbFormat === 'ms'; | ||
this.isoCalendarDateType = new _ISOCalendarDateType.default({ ...definition, | ||
@@ -41,40 +40,4 @@ type: 'ISOCalendarDate' | ||
}, options); | ||
this.dataTransformer = new _dataTransformers.ISOCalendarDateTimeDataTransformer(dbFormat); | ||
} | ||
/** Transform mv style timestamp data (ddddd.sssss[SSS]) to ISO 8601 approved date/time format (yyyy-mm-ddTHH:mm:ss.SSS) */ | ||
transformFromDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
const valueParts = String(value).split('.'); | ||
const datePart = this.isoCalendarDateType.transformFromDb(+valueParts[0]); | ||
const timePart = this.isoTimeType.transformFromDb(+valueParts[1]); | ||
return `${datePart}T${timePart}`; | ||
} | ||
/** | ||
* Transform ISO 8601 approved date/time format (yyyy-mm-ddTHH:mm:ss.SSS) to mv style timestamp data (ddddd.sssss[SSS]) | ||
* @throws {@link TransformDataError} Value could not be transformed to database format | ||
*/ | ||
transformToDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
if (typeof value !== 'string') { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: value | ||
}); | ||
} | ||
const [datePart, timePart] = value.split('T'); | ||
const padLength = this.isDbInMs ? 8 : 5; | ||
const transformedDatePart = this.isoCalendarDateType.transformToDb(datePart); | ||
const transformedTimePart = this.isoTimeType.transformToDb(timePart).padStart(padLength, '0'); | ||
return `${transformedDatePart}.${transformedTimePart}`; | ||
} | ||
/** ISOCalendarDateTime data type validator */ | ||
@@ -81,0 +44,0 @@ |
@@ -1,3 +0,4 @@ | ||
import BaseDateType from './BaseDateType'; | ||
import { ISOCalendarDateDataTransformer } from '../dataTransformers'; | ||
import type { ScalarTypeConstructorOptions } from './BaseScalarType'; | ||
import BaseScalarType from './BaseScalarType'; | ||
import type { SchemaTypeDefinitionBase } from './BaseSchemaType'; | ||
@@ -8,16 +9,6 @@ export interface SchemaTypeDefinitionISOCalendarDate extends SchemaTypeDefinitionBase { | ||
/** ISOCalendarDate Schema Type */ | ||
declare class ISOCalendarDateType extends BaseDateType { | ||
declare class ISOCalendarDateType extends BaseScalarType { | ||
/** Data transformer */ | ||
protected readonly dataTransformer: ISOCalendarDateDataTransformer; | ||
constructor(definition: SchemaTypeDefinitionISOCalendarDate, options?: ScalarTypeConstructorOptions); | ||
/** | ||
* Transform mv date data to ISO 8601 approved date format (yyyy-mm-dd) | ||
* @throws {@link TransformDataError} Database value could not be transformed to external format | ||
*/ | ||
transformFromDb(value: null): null; | ||
transformFromDb(value: unknown): string; | ||
/** | ||
* Transform ISO 8601 approved date format (yyyy-mm-dd) to mv date data | ||
* @throws {@link TransformDataError} Value could not be transformed to database format | ||
*/ | ||
transformToDb(value: null): null; | ||
transformToDb(value: unknown): string; | ||
/** ISOCalendarDateType data type validator */ | ||
@@ -24,0 +15,0 @@ protected validateType: (value: unknown) => boolean; |
@@ -14,53 +14,13 @@ "use strict"; | ||
var _errors = require("../errors"); | ||
var _dataTransformers = require("../dataTransformers"); | ||
var _BaseDateType = _interopRequireDefault(require("./BaseDateType")); | ||
var _BaseScalarType = _interopRequireDefault(require("./BaseScalarType")); | ||
/** ISOCalendarDate Schema Type */ | ||
class ISOCalendarDateType extends _BaseDateType.default { | ||
class ISOCalendarDateType extends _BaseScalarType.default { | ||
/** Data transformer */ | ||
constructor(definition, options = {}) { | ||
super(definition, options); | ||
this.dataTransformer = new _dataTransformers.ISOCalendarDateDataTransformer(); | ||
} | ||
/** | ||
* Transform mv date data to ISO 8601 approved date format (yyyy-mm-dd) | ||
* @throws {@link TransformDataError} Database value could not be transformed to external format | ||
*/ | ||
transformFromDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
const castValue = Number(value); | ||
if (!Number.isInteger(castValue)) { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: castValue | ||
}); | ||
} | ||
return (0, _dateFns.format)((0, _dateFns.addDays)(_constants.mvEpoch, castValue), _constants.ISOCalendarDateFormat); | ||
} | ||
/** | ||
* Transform ISO 8601 approved date format (yyyy-mm-dd) to mv date data | ||
* @throws {@link TransformDataError} Value could not be transformed to database format | ||
*/ | ||
transformToDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
if (typeof value !== 'string') { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: value | ||
}); | ||
} | ||
return String((0, _dateFns.differenceInDays)(this.parseISOCalendarDate(value), _constants.mvEpoch)); | ||
} | ||
/** ISOCalendarDateType data type validator */ | ||
@@ -67,0 +27,0 @@ |
@@ -1,3 +0,4 @@ | ||
import BaseDateType from './BaseDateType'; | ||
import { ISOTimeDataTransformer } from '../dataTransformers'; | ||
import type { ScalarTypeConstructorOptions } from './BaseScalarType'; | ||
import BaseScalarType from './BaseScalarType'; | ||
import type { SchemaTypeDefinitionBase } from './BaseSchemaType'; | ||
@@ -9,24 +10,8 @@ export interface SchemaTypeDefinitionISOTime extends SchemaTypeDefinitionBase { | ||
/** ISOTime Schema Type */ | ||
declare class ISOTimeType extends BaseDateType { | ||
/** Database time format is in milliseconds */ | ||
private readonly isDbInMs; | ||
declare class ISOTimeType extends BaseScalarType { | ||
/** Data transformer */ | ||
protected readonly dataTransformer: ISOTimeDataTransformer; | ||
constructor(definition: SchemaTypeDefinitionISOTime, options?: ScalarTypeConstructorOptions); | ||
/** | ||
* Transform mv style time data to ISO 8601 approved time format (HH:mm:ss.SSS) | ||
* @throws {@link TransformDataError} Database value could not be transformed to external format | ||
*/ | ||
transformFromDb(value: null): null; | ||
transformFromDb(value: unknown): string; | ||
/** | ||
* Transform ISO 8601 approved time format (HH:mm:ss.SSS) to mv style time data | ||
* @throws {@link TransformDataError} Value could not be transformed to database format | ||
*/ | ||
transformToDb(value: null): null; | ||
transformToDb(value: unknown): string; | ||
/** ISOTimeType data type validator */ | ||
protected validateType: (value: unknown) => boolean; | ||
/** Convert internal time to ISOTime format */ | ||
private convertInternalTimeToISOTime; | ||
/** Convert hours, minutes, seconds, and milliseconds to multivalue internal time format */ | ||
private convertISOTimeToInternalTime; | ||
/** Parse ISOTime string into date */ | ||
@@ -33,0 +18,0 @@ private parseISOTime; |
@@ -14,77 +14,16 @@ "use strict"; | ||
var _errors = require("../errors"); | ||
var _dataTransformers = require("../dataTransformers"); | ||
var _BaseDateType = _interopRequireDefault(require("./BaseDateType")); | ||
var _BaseScalarType = _interopRequireDefault(require("./BaseScalarType")); | ||
/** ISOTime Schema Type */ | ||
class ISOTimeType extends _BaseDateType.default { | ||
/** Database time format is in milliseconds */ | ||
class ISOTimeType extends _BaseScalarType.default { | ||
/** Data transformer */ | ||
constructor(definition, options = {}) { | ||
super(definition, options); | ||
const { | ||
dbFormat = 's' | ||
dbFormat | ||
} = definition; | ||
this.isDbInMs = dbFormat === 'ms'; | ||
this.dataTransformer = new _dataTransformers.ISOTimeDataTransformer(dbFormat); | ||
} | ||
/** | ||
* Transform mv style time data to ISO 8601 approved time format (HH:mm:ss.SSS) | ||
* @throws {@link TransformDataError} Database value could not be transformed to external format | ||
*/ | ||
transformFromDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
const internalTime = Number(value); | ||
if (!Number.isInteger(internalTime) || internalTime < 0) { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: internalTime | ||
}); | ||
} | ||
if (internalTime > 86400000 || !this.isDbInMs && internalTime > 86400) { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: internalTime | ||
}); | ||
} | ||
return this.convertInternalTimeToISOTime(internalTime); | ||
} | ||
/** | ||
* Transform ISO 8601 approved time format (HH:mm:ss.SSS) to mv style time data | ||
* @throws {@link TransformDataError} Value could not be transformed to database format | ||
*/ | ||
transformToDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
if (typeof value !== 'string') { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: value | ||
}); | ||
} | ||
const isoTimeRegex = /(\d{2}):(\d{2}):(\d{2})\.(\d{3})/; // hh:mm:ss.SSS | ||
const match = isoTimeRegex.exec(value); | ||
if (match == null) { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: value | ||
}); | ||
} | ||
const [, hour, minute, second, millisecond] = match; | ||
return this.convertISOTimeToInternalTime(hour, minute, second, millisecond); | ||
} | ||
/** ISOTimeType data type validator */ | ||
@@ -104,33 +43,4 @@ | ||
}; | ||
/** Convert internal time to ISOTime format */ | ||
convertInternalTimeToISOTime(internalTime) { | ||
let workingValue = internalTime; | ||
const multiplier = this.isDbInMs ? 1000 : 1; | ||
const hours = String(Math.floor(workingValue / (3600 * multiplier))).padStart(2, '0'); | ||
workingValue %= 3600 * multiplier; | ||
const minutes = String(Math.floor(workingValue / (60 * multiplier))).padStart(2, '0'); | ||
workingValue %= 60 * multiplier; | ||
const seconds = String(Math.floor(workingValue / multiplier)).padStart(2, '0'); | ||
workingValue %= multiplier; | ||
const milliseconds = this.isDbInMs ? String(workingValue).padStart(3, '0') : '000'; | ||
return `${hours}:${minutes}:${seconds}.${milliseconds}`; | ||
} | ||
/** Convert hours, minutes, seconds, and milliseconds to multivalue internal time format */ | ||
convertISOTimeToInternalTime(hour, minute, second, millisecond) { | ||
let internalTime; | ||
if (this.isDbInMs) { | ||
internalTime = (0, _dateFns.hoursToMilliseconds)(Number(hour)) + (0, _dateFns.minutesToMilliseconds)(Number(minute)) + (0, _dateFns.secondsToMilliseconds)(Number(second)) + Number(millisecond); | ||
} else { | ||
internalTime = (0, _dateFns.hoursToSeconds)(Number(hour)) + (0, _dateFns.minutesToSeconds)(Number(minute)) + Number(second); | ||
} | ||
return String(internalTime); | ||
} | ||
/** Parse ISOTime string into date */ | ||
parseISOTime(value) { | ||
@@ -137,0 +47,0 @@ return (0, _dateFns.parse)(value, _constants.ISOTimeFormat, new Date()); |
@@ -0,1 +1,2 @@ | ||
import { NumberDataTransformer } from '../dataTransformers'; | ||
import type { ScalarTypeConstructorOptions } from './BaseScalarType'; | ||
@@ -8,19 +9,7 @@ import BaseScalarType from './BaseScalarType'; | ||
} | ||
/** | ||
* Number Schema Type | ||
* @throws {@link InvalidParameterError} An invalid parameter was passed to the function | ||
*/ | ||
/** Number Schema Type */ | ||
declare class NumberType extends BaseScalarType { | ||
/** Number of implied decimals in database storage */ | ||
private readonly dbDecimals; | ||
/** Data transformer */ | ||
protected readonly dataTransformer: NumberDataTransformer; | ||
constructor(definition: SchemaTypeDefinitionNumber, options?: ScalarTypeConstructorOptions); | ||
/** | ||
* Transform mv style internally formatted numeric data (nnnnn) to externally formatted numeric data (nnn.nn) | ||
* @throws {@link TransformDataError} Database value could not be transformed to external format | ||
*/ | ||
transformFromDb(value: null): null; | ||
transformFromDb(value: unknown): number; | ||
/** Transform externally formatted numeric data (nnn.nn) to mv style internally formatted numeric data */ | ||
transformToDb(value: null): null; | ||
transformToDb(value: unknown): string; | ||
/** NumberType data type validator */ | ||
@@ -27,0 +16,0 @@ protected validateType: (value: unknown) => boolean; |
@@ -10,54 +10,16 @@ "use strict"; | ||
var _errors = require("../errors"); | ||
var _dataTransformers = require("../dataTransformers"); | ||
var _BaseScalarType = _interopRequireDefault(require("./BaseScalarType")); | ||
/** | ||
* Number Schema Type | ||
* @throws {@link InvalidParameterError} An invalid parameter was passed to the function | ||
*/ | ||
/** Number Schema Type */ | ||
class NumberType extends _BaseScalarType.default { | ||
/** Number of implied decimals in database storage */ | ||
/** Data transformer */ | ||
constructor(definition, options = {}) { | ||
super(definition, options); | ||
const { | ||
dbDecimals = 0 | ||
dbDecimals | ||
} = definition; | ||
if (!Number.isInteger(dbDecimals)) { | ||
throw new _errors.InvalidParameterError({ | ||
parameterName: 'definition.dbDecimals' | ||
}); | ||
} | ||
this.dbDecimals = dbDecimals; | ||
this.dataTransformer = new _dataTransformers.NumberDataTransformer(dbDecimals); | ||
} | ||
/** | ||
* Transform mv style internally formatted numeric data (nnnnn) to externally formatted numeric data (nnn.nn) | ||
* @throws {@link TransformDataError} Database value could not be transformed to external format | ||
*/ | ||
transformFromDb(value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
const castValue = Number(value); | ||
if (!Number.isFinite(castValue)) { | ||
throw new _errors.TransformDataError({ | ||
transformClass: this.constructor.name, | ||
transformValue: castValue | ||
}); | ||
} | ||
return Number((Math.round(castValue) / 10 ** this.dbDecimals).toFixed(this.dbDecimals)); | ||
} | ||
/** Transform externally formatted numeric data (nnn.nn) to mv style internally formatted numeric data */ | ||
transformToDb(value) { | ||
return value == null ? null : (Number(value) * 10 ** this.dbDecimals).toFixed(0); | ||
} | ||
/** NumberType data type validator */ | ||
@@ -64,0 +26,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { StringDataTransformer } from '../dataTransformers'; | ||
import type { ForeignKeyDbDefinition } from '../ForeignKeyDbTransformer'; | ||
@@ -14,2 +15,4 @@ import type { SchemaCompoundForeignKeyDefinition, SchemaForeignKeyDefinition } from '../Schema'; | ||
declare class StringType extends BaseScalarType { | ||
/** Data transformer */ | ||
protected readonly dataTransformer: StringDataTransformer; | ||
/** Array of allowed enumerations */ | ||
@@ -20,8 +23,2 @@ private readonly enum; | ||
constructor(definition: SchemaTypeDefinitionString, options?: ScalarTypeConstructorOptions); | ||
/** Transform mv string to js string */ | ||
transformFromDb(value: null): null; | ||
transformFromDb(value: unknown): string; | ||
/** Transform js string to mv string */ | ||
transformToDb(value: null): null; | ||
transformToDb(value: unknown): string; | ||
/** Create an array of foreign key definitions that will be validated before save */ | ||
@@ -28,0 +25,0 @@ transformForeignKeyDefinitionsToDb(value: unknown): ForeignKeyDbDefinition[]; |
@@ -10,2 +10,4 @@ "use strict"; | ||
var _dataTransformers = require("../dataTransformers"); | ||
var _ForeignKeyDbTransformer = _interopRequireDefault(require("../ForeignKeyDbTransformer")); | ||
@@ -17,2 +19,4 @@ | ||
class StringType extends _BaseScalarType.default { | ||
/** Data transformer */ | ||
/** Array of allowed enumerations */ | ||
@@ -25,5 +29,11 @@ | ||
super(definition, options); | ||
this.enum = definition.enum ?? null; | ||
this.match = definition.match ?? null; | ||
this.foreignKeyDbTransformer = new _ForeignKeyDbTransformer.default(definition.foreignKey); // add validators for this type | ||
const { | ||
enum: definitionEnum, | ||
match, | ||
foreignKey | ||
} = definition; | ||
this.enum = definitionEnum ?? null; | ||
this.match = match ?? null; | ||
this.foreignKeyDbTransformer = new _ForeignKeyDbTransformer.default(foreignKey); | ||
this.dataTransformer = new _dataTransformers.StringDataTransformer(definitionEnum); // add validators for this type | ||
@@ -33,20 +43,2 @@ this.validators.unshift(this.createMatchValidator()); | ||
} | ||
/** Transform mv string to js string */ | ||
transformFromDb(value) { | ||
if (value == null) { | ||
// if this property has an enumeration constraint and one of those constraints is empty string then return empty string; | ||
// otherwise return null | ||
return this.enum != null && this.enum.includes('') ? '' : null; | ||
} | ||
return String(value); | ||
} | ||
/** Transform js string to mv string */ | ||
transformToDb(value) { | ||
return value == null ? null : String(value); | ||
} | ||
/** Create an array of foreign key definitions that will be validated before save */ | ||
@@ -53,0 +45,0 @@ |
import type { BuildForeignKeyDefinitionsResult } from '../Document'; | ||
import type { GenericObject, MvRecord } from '.'; | ||
import type { GenericObject } from '.'; | ||
export interface DbActionInputSubroutine<TSubroutineOptions extends GenericObject> { | ||
@@ -45,4 +45,3 @@ action: 'subroutine'; | ||
__v?: string | null; | ||
clearAttributes: boolean; | ||
record: MvRecord; | ||
record: string; | ||
foreignKeyDefinitions: BuildForeignKeyDefinitionsResult[]; | ||
@@ -49,0 +48,0 @@ } |
import type { DbActionResponse } from './DbFeature'; | ||
import type { MvRecord } from '.'; | ||
import type { DbServerDelimiters } from './Miscellaneous'; | ||
export interface DbDocument { | ||
_id: string; | ||
__v: string | null; | ||
record: MvRecord; | ||
record: string; | ||
} | ||
@@ -36,2 +36,3 @@ export interface DbSubroutineOutputDeleteById { | ||
time: number; | ||
delimiters: DbServerDelimiters; | ||
} | ||
@@ -38,0 +39,0 @@ export declare type DbActionResponseSubroutineGetServerInfo = DbActionResponse<DbSubroutineOutputGetServerInfo>; |
@@ -0,1 +1,2 @@ | ||
export * from './DataTransformation'; | ||
export * from './DbFeature'; | ||
@@ -6,1 +7,2 @@ export * from './DbSubroutineInput'; | ||
export * from './Miscellaneous'; | ||
export * from './Utility'; |
@@ -7,2 +7,15 @@ "use strict"; | ||
var _DataTransformation = require("./DataTransformation"); | ||
Object.keys(_DataTransformation).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _DataTransformation[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _DataTransformation[key]; | ||
} | ||
}); | ||
}); | ||
var _DbFeature = require("./DbFeature"); | ||
@@ -71,2 +84,15 @@ | ||
}); | ||
}); | ||
var _Utility = require("./Utility"); | ||
Object.keys(_Utility).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _Utility[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _Utility[key]; | ||
} | ||
}); | ||
}); |
export declare type GenericObject = Record<string, any>; | ||
export declare type MvDataType = string | number | null | undefined; | ||
export declare type MvDataType = string | null | undefined; | ||
export declare type MvAttribute = MvDataType | (MvDataType | MvDataType[])[]; | ||
export declare type MvRecord = MvAttribute[]; | ||
/** Characters which delimit strings on multivalue database server */ | ||
export interface DbServerDelimiters { | ||
/** Record mark */ | ||
rm: string; | ||
/** Attribute mark */ | ||
am: string; | ||
/** Value mark */ | ||
vm: string; | ||
/** Subvalue mark */ | ||
svm: string; | ||
} |
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
132
4559
269245
Updatedsemver@^7.3.6