@lakutata/orm 3.1.1 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCollectionStore.js +4 -4
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCollectionStore.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.d.ts +15 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.js +44 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.js.map +1 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedLog.js +2 -3
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedLog.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedWorkerCode.js +1 -1
- package/dist/vendor/typeorm/driver/mongodb/MongoDriver.js +4 -0
- package/dist/vendor/typeorm/driver/mongodb/MongoDriver.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongodb/MongoWebCrypto.d.ts +6 -0
- package/dist/vendor/typeorm/driver/mongodb/MongoWebCrypto.js +19 -0
- package/dist/vendor/typeorm/driver/mongodb/MongoWebCrypto.js.map +1 -0
- package/package.json +5 -5
|
@@ -11,6 +11,8 @@ const InstanceChecker_1 = require("../../util/InstanceChecker");
|
|
|
11
11
|
const ObjectUtils_1 = require("../../util/ObjectUtils");
|
|
12
12
|
const DriverUtils_1 = require("../DriverUtils");
|
|
13
13
|
const MongoQueryRunner_1 = require("./MongoQueryRunner");
|
|
14
|
+
// lakutata: the global crypto of the driver on Node.js 18
|
|
15
|
+
const MongoWebCrypto_1 = require("./MongoWebCrypto");
|
|
14
16
|
/**
|
|
15
17
|
* Organizes communication with MongoDB.
|
|
16
18
|
*/
|
|
@@ -396,6 +398,8 @@ class MongoDriver {
|
|
|
396
398
|
*/
|
|
397
399
|
loadDependencies() {
|
|
398
400
|
try {
|
|
401
|
+
// lakutata: the global crypto the driver uses, on Node.js 18
|
|
402
|
+
(0, MongoWebCrypto_1.provideWebCrypto)();
|
|
399
403
|
const mongodb = this.options.driver ?? PlatformTools_1.PlatformTools.load("mongodb");
|
|
400
404
|
this.mongodb = mongodb;
|
|
401
405
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoDriver.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongodb/MongoDriver.ts"],"names":[],"mappings":";;;AAGA,uCAA0C;AAC1C,iFAA6E;AAC7E,+FAA2F;AAG3F,gEAA4D;AAC5D,gFAA4E;AAK5E,8EAA0E;AAC1E,gEAA4D;AAC5D,wDAAoD;AAEpD,gDAA4C;AAS5C,yDAAqD;AAErD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;aACa,6BAAwB,GAAqB,EAAE,AAAvB,CAAuB;IAgL/D,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAlL5C,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAE5E;;WAEG;QACH,6BAAwB,GAAG,WAAW,CAAC,wBAAwB,CAAA;QA2B/D;;WAEG;QACH,iBAAY,GAAY,KAAK,CAAA;QAE7B;;WAEG;QACH,gBAAW,GAAG,KAAK,CAAA;QAEnB;;WAEG;QACH,uBAAkB,GAAG,MAAe,CAAA;QAEpC;;WAEG;QACH,uBAAkB,GAAiB,EAAE,CAAA;QAOrC;;WAEG;QACH,iBAAY,GAAiB,EAAE,CAAA;QAE/B;;WAEG;QACH,0BAAqB,GAAiB,EAAE,CAAA;QAExC;;WAEG;QACH,6BAAwB,GAAiB,EAAE,CAAA;QAE3C;;WAEG;QACH,yBAAoB,GAAiB,EAAE,CAAA;QAEvC;;WAEG;QACH,oBAAe,GAAsB;YACjC,UAAU,EAAE,KAAK;YACjB,iB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AAI,WAAW,GAAG,WAAW,EAChD,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAA;QAChC,CAAC;aAAM,CAAC;YACJ,gBAAgB,GAAG,GAAG,aAAa,MAAM,kBAAkB,GACvD,OAAO,CAAC,IAAI,IAAI,WACpB,GAAG,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAA;QAC9C,CAAC;QAED,OAAO,gBAAgB,CAAA;IAC3B,CAAC;IAED;;OAEG;IACO,sBAAsB,CAAC,OAA+B;QAC5D,MAAM,YAAY,GAAQ,EAAE,CAAA;QAE5B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC7C,IAAI,UAAU,IAAI,OAAO,EAAE,CAAC;gBACxB,YAAY,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;YAClD,CAAC;QACL,CAAC;QAED,YAAY,CAAC,UAAU,GAAG;YACtB,IAAI,EAAE,SAAS;SAClB,CAAA;QAED,IAAI,UAAU,IAAI,OAAO,EAAE,CAAC;YACxB,YAAY,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;QACrD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QAE1C,OAAO,YAAY,CAAA;IACvB,CAAC;;AAnkBL,kCAokBC","sourcesContent":["import type { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport type { DataSource } from \"../../data-source/DataSource\"\nimport type { DataSourceOptions } from \"../../data-source/DataSourceOptions\"\nimport { TypeORMError } from \"../../error\"\nimport { ConnectionIsNotSetError } from \"../../error/ConnectionIsNotSetError\"\nimport { DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport type { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport type { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { MongoSchemaBuilder } from \"../../schema-builder/MongoSchemaBuilder\"\nimport type { Table } from \"../../schema-builder/table/Table\"\nimport type { TableColumn } from \"../../schema-builder/table/TableColumn\"\nimport type { TableForeignKey } from \"../../schema-builder/table/TableForeignKey\"\nimport type { View } from \"../../schema-builder/view/View\"\nimport { ApplyValueTransformers } from \"../../util/ApplyValueTransformers\"\nimport { InstanceChecker } from \"../../util/InstanceChecker\"\nimport { ObjectUtils } from \"../../util/ObjectUtils\"\nimport type { Driver } from \"../Driver\"\nimport { DriverUtils } from \"../DriverUtils\"\nimport type { ColumnType } from \"../types/ColumnTypes\"\nimport type { CteCapabilities } from \"../types/CteCapabilities\"\nimport type { DataTypeDefaults } from \"../types/DataTypeDefaults\"\nimport type { MappedColumnTypes } from \"../types/MappedColumnTypes\"\nimport type { ReplicationMode } from \"../types/ReplicationMode\"\nimport type { IsolationLevel } from \"../types/IsolationLevel\"\nimport type { UpsertType } from \"../types/UpsertType\"\nimport type { MongoDataSourceOptions } from \"./MongoDataSourceOptions\"\nimport { MongoQueryRunner } from \"./MongoQueryRunner\"\n\n/**\n * Organizes communication with MongoDB.\n */\nexport class MongoDriver implements Driver {\n // -------------------------------------------------------------------------\n // Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * Transaction isolation levels supported by this driver.\n */\n static readonly supportedIsolationLevels: IsolationLevel[] = []\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Isolation levels supported by this driver.\n */\n supportedIsolationLevels = MongoDriver.supportedIsolationLevels\n\n /**\n * Underlying mongodb library.\n */\n mongodb: any\n\n /**\n * Mongodb does not require to dynamically create query runner each time,\n * because it does not have a regular connection pool as RDBMS systems have.\n */\n queryRunner?: MongoQueryRunner\n\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource options.\n */\n options: MongoDataSourceOptions\n\n /**\n * Master database used to perform all write queries.\n */\n database?: string\n\n /**\n * Indicates if replication is enabled.\n */\n isReplicated: boolean = false\n\n /**\n * Indicates if tree tables are supported by this driver.\n */\n treeSupport = false\n\n /**\n * Represent transaction support by this driver\n */\n transactionSupport = \"none\" as const\n\n /**\n * Mongodb does not need to have column types because they are not used in schema sync.\n */\n supportedDataTypes: ColumnType[] = []\n\n /**\n * Returns type of upsert supported by driver if any\n */\n supportedUpsertTypes: UpsertType[]\n\n /**\n * Gets list of spatial column data types.\n */\n spatialTypes: ColumnType[] = []\n\n /**\n * Gets list of column data types that support length by a driver.\n */\n withLengthColumnTypes: ColumnType[] = []\n\n /**\n * Gets list of column data types that support precision by a driver.\n */\n withPrecisionColumnTypes: ColumnType[] = []\n\n /**\n * Gets list of column data types that support scale by a driver.\n */\n withScaleColumnTypes: ColumnType[] = []\n\n /**\n * Mongodb does not need to have a strong defined mapped column types because they are not used in schema sync.\n */\n mappedDataTypes: MappedColumnTypes = {\n createDate: \"int\",\n createDateDefault: \"\",\n updateDate: \"int\",\n updateDateDefault: \"\",\n deleteDate: \"int\",\n deleteDateNullable: true,\n version: \"int\",\n treeLevel: \"int\",\n migrationId: \"int\",\n migrationName: \"int\",\n migrationTimestamp: \"int\",\n cacheId: \"int\",\n cacheIdentifier: \"int\",\n cacheTime: \"int\",\n cacheDuration: \"int\",\n cacheQuery: \"int\",\n cacheResult: \"int\",\n metadataType: \"int\",\n metadataDatabase: \"int\",\n metadataSchema: \"int\",\n metadataTable: \"int\",\n metadataName: \"int\",\n metadataValue: \"int\",\n }\n\n /**\n * Default values of length, precision and scale depends on column data type.\n * Used in the cases when length/precision/scale is not specified by user.\n */\n dataTypeDefaults: DataTypeDefaults\n\n /**\n * No documentation specifying a maximum length for identifiers could be found\n * for MongoDB.\n */\n maxAliasLength?: number\n\n cteCapabilities: CteCapabilities = {\n enabled: false,\n }\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Valid mongo connection options\n * NOTE: Keep in sync with MongoConnectionOptions\n */\n protected validOptionNames: string[] = [\n \"appName\",\n \"authMechanism\",\n \"authSource\",\n \"autoEncryption\",\n \"checkServerIdentity\",\n \"compressors\",\n \"connectTimeoutMS\",\n \"directConnection\",\n \"family\",\n \"forceServerObjectId\",\n \"ignoreUndefined\",\n \"localThresholdMS\",\n \"maxStalenessSeconds\",\n \"minPoolSize\",\n \"monitorCommands\",\n \"noDelay\",\n \"pkFactory\",\n \"promoteBuffers\",\n \"promoteLongs\",\n \"promoteValues\",\n \"raw\",\n \"readConcern\",\n \"readPreference\",\n \"readPreferenceTags\",\n \"replicaSet\",\n \"retryWrites\",\n \"serializeFunctions\",\n \"socketTimeoutMS\",\n \"tls\",\n \"tlsAllowInvalidCertificates\",\n \"tlsCAFile\",\n \"tlsCertificateKeyFile\",\n \"tlsCertificateKeyFilePassword\",\n \"writeConcern\",\n // Proxy configuration for Socks5\n \"proxyHost\",\n \"proxyPort\",\n \"proxyUsername\",\n \"proxyPassword\",\n ]\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected dataSource: DataSource) {\n this.options = dataSource.options as MongoDataSourceOptions\n\n // validate options to make sure everything is correct and driver will be able to establish connection\n this.validateOptions(dataSource.options)\n\n // load mongodb package\n this.loadDependencies()\n\n this.database = DriverUtils.buildMongoDBDriverOptions(\n this.options,\n ).database\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n const options = DriverUtils.buildMongoDBDriverOptions(this.options)\n\n const client = await this.mongodb.MongoClient.connect(\n this.buildConnectionUrl(options),\n this.buildConnectionOptions(options),\n )\n\n this.queryRunner = new MongoQueryRunner(this.dataSource, client)\n ObjectUtils.assign(this.queryRunner, {\n manager: this.dataSource.manager,\n })\n }\n\n afterConnect(): Promise<void> {\n return Promise.resolve()\n }\n\n /**\n * Closes connection with the database.\n */\n async disconnect(): Promise<void> {\n const queryRunner = this.queryRunner\n if (!queryRunner) {\n throw new ConnectionIsNotSetError(\"mongodb\")\n }\n\n this.queryRunner = undefined\n await queryRunner.databaseConnection.close()\n }\n\n /**\n * Creates a schema builder used to build and sync a schema.\n */\n createSchemaBuilder() {\n return new MongoSchemaBuilder(this.dataSource)\n }\n\n /**\n * Creates a query runner used to execute database queries.\n *\n * @param mode\n */\n createQueryRunner(mode: ReplicationMode) {\n return this.queryRunner!\n }\n\n /**\n * Replaces parameters in the given sql with special escaping character\n * and an array of parameter names to be passed to a query.\n *\n * @param sql\n * @param parameters\n */\n escapeQueryWithParameters(\n sql: string,\n parameters: ObjectLiteral,\n ): [string, any[]] {\n throw new TypeORMError(\n `This operation is not supported by Mongodb driver.`,\n )\n }\n\n /**\n * Escapes a column name.\n *\n * @param columnName\n */\n escape(columnName: string): string {\n return columnName\n }\n\n /**\n * Build full table name with database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n *\n * @param tableName\n * @param schema\n * @param database\n */\n buildTableName(\n tableName: string,\n schema?: string,\n database?: string,\n ): string {\n return tableName\n }\n\n /**\n * Parse a target table name or other types and return a normalized table definition.\n *\n * @param target\n */\n parseTableName(\n target: EntityMetadata | Table | View | TableForeignKey | string,\n ): { tableName: string; schema?: string; database?: string } {\n if (InstanceChecker.isEntityMetadata(target)) {\n return {\n tableName: target.tableName,\n }\n }\n\n if (InstanceChecker.isTable(target) || InstanceChecker.isView(target)) {\n return {\n tableName: target.name,\n }\n }\n\n if (InstanceChecker.isTableForeignKey(target)) {\n return {\n tableName: target.referencedTableName,\n }\n }\n\n return {\n tableName: target,\n }\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type and metadata.\n *\n * @param value\n * @param columnMetadata\n */\n preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any {\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformTo(\n columnMetadata.transformer,\n value,\n )\n return value\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type or metadata.\n *\n * @param value\n * @param columnMetadata\n */\n prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any {\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformFrom(\n columnMetadata.transformer,\n value,\n )\n return value\n }\n\n /**\n * Creates a database type from a given column metadata.\n *\n * @param column\n * @param column.type\n * @param column.length\n * @param column.precision\n * @param column.scale\n */\n normalizeType(column: {\n type?: ColumnType\n length?: number | string\n precision?: number | null\n scale?: number\n }): string {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Normalizes \"default\" value of the column.\n *\n * @param columnMetadata\n */\n normalizeDefault(columnMetadata: ColumnMetadata): string | undefined {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Normalizes \"isUnique\" value of the column.\n *\n * @param column\n */\n normalizeIsUnique(column: ColumnMetadata): boolean {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Calculates column length taking into account the default length values.\n *\n * @param column\n */\n getColumnLength(column: ColumnMetadata): string {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Normalizes \"default\" value of the column.\n *\n * @param column\n */\n createFullType(column: TableColumn): string {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Obtains a new database connection to a master server.\n * Used for replication.\n * If replication is not setup then returns default connection's database connection.\n */\n obtainMasterConnection(): Promise<any> {\n return Promise.resolve()\n }\n\n /**\n * Obtains a new database connection to a slave server.\n * Used for replication.\n * If replication is not setup then returns master (default) connection's database connection.\n */\n obtainSlaveConnection(): Promise<any> {\n return Promise.resolve()\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n *\n * @param metadata\n * @param insertedId\n */\n createGeneratedMap(metadata: EntityMetadata, insertedId: any) {\n return metadata.objectIdColumn!.createValueMap(insertedId)\n }\n\n /**\n * Differentiate columns of this table and columns from the given column metadatas columns\n * and returns only changed.\n *\n * @param tableColumns\n * @param columnMetadatas\n */\n findChangedColumns(\n tableColumns: TableColumn[],\n columnMetadatas: ColumnMetadata[],\n ): ColumnMetadata[] {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Returns true if driver supports RETURNING / OUTPUT statement.\n */\n isReturningSqlSupported(): boolean {\n return false\n }\n\n /**\n * Returns true if driver supports uuid values generation on its own.\n */\n isUUIDGenerationSupported(): boolean {\n return false\n }\n\n /**\n * Returns true if driver supports fulltext indices.\n */\n isFullTextColumnTypeSupported(): boolean {\n return false\n }\n\n /**\n * Creates an escaped parameter.\n *\n * @param parameterName\n * @param index\n */\n createParameter(parameterName: string, index: number): string {\n return \"\"\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Validate driver options to make sure everything is correct and driver will be able to establish connection.\n *\n * @param options\n */\n protected validateOptions(options: DataSourceOptions) {\n // todo: fix\n // if (!options.url) {\n // if (!options.database)\n // throw new DriverOptionNotSetError(\"database\");\n // }\n }\n\n /**\n * Loads all driver dependencies.\n */\n protected loadDependencies(): any {\n try {\n const mongodb = this.options.driver ?? PlatformTools.load(\"mongodb\")\n this.mongodb = mongodb\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"MongoDB\", \"mongodb\")\n }\n }\n\n /**\n * Builds connection url that is passed to underlying driver to perform connection to the mongodb database.\n */\n protected buildConnectionUrl(options: { [key: string]: any }): string {\n const schemaUrlPart = options.type.toLowerCase()\n const credentialsUrlPart =\n options.username && options.password\n ? `${encodeURIComponent(options.username)}:${encodeURIComponent(\n options.password,\n )}@`\n : \"\"\n\n const portUrlPart =\n schemaUrlPart === \"mongodb+srv\" ? \"\" : `:${options.port ?? \"27017\"}`\n\n let connectionString: string\n if (options.replicaSet) {\n connectionString = `${schemaUrlPart}://${credentialsUrlPart}${\n options.hostReplicaSet ??\n `${options.host ?? \"127.0.0.1\"}${portUrlPart}`\n }/${options.database ?? \"\"}`\n } else {\n connectionString = `${schemaUrlPart}://${credentialsUrlPart}${\n options.host ?? \"127.0.0.1\"\n }${portUrlPart}/${options.database ?? \"\"}`\n }\n\n return connectionString\n }\n\n /**\n * Build connection options from MongoConnectionOptions\n */\n protected buildConnectionOptions(options: { [key: string]: any }): any {\n const mongoOptions: any = {}\n\n for (const optionName of this.validOptionNames) {\n if (optionName in options) {\n mongoOptions[optionName] = options[optionName]\n }\n }\n\n mongoOptions.driverInfo = {\n name: \"TypeORM\",\n }\n\n if (\"poolSize\" in options) {\n mongoOptions[\"maxPoolSize\"] = options[\"poolSize\"]\n }\n\n Object.assign(mongoOptions, options.extra)\n\n return mongoOptions\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MongoDriver.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongodb/MongoDriver.ts"],"names":[],"mappings":";;;AAGA,uCAA0C;AAC1C,iFAA6E;AAC7E,+FAA2F;AAG3F,gEAA4D;AAC5D,gFAA4E;AAK5E,8EAA0E;AAC1E,gEAA4D;AAC5D,wDAAoD;AAEpD,gDAA4C;AAS5C,yDAAqD;AACrD,0DAA0D;AAC1D,qDAAmD;AAEnD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;aACa,6BAAwB,GAAqB,EAAE,AAAvB,CAAuB;IAgL/D,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAlL5C,4EAA4E;QAC5E,oBAAoB;QACpB,4EAA4E;QAE5E;;WAEG;QACH,6BAAwB,GAAG,WAAW,CAAC,wBAAwB,CAAA;QA2B/D;;WAEG;QACH,iBAAY,GAAY,KAAK,CAAA;QAE7B;;WAEG;QACH,gBAAW,GAAG,KAAK,CAAA;QAEnB;;WAEG;QACH,uBAAkB,GAAG,MAAe,CAAA;QAEpC;;WAEG;QACH,uBAAkB,GAAiB,EAAE,CAAA;QAOrC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} from \"../../data-source/DataSource\"\nimport type { DataSourceOptions } from \"../../data-source/DataSourceOptions\"\nimport { TypeORMError } from \"../../error\"\nimport { ConnectionIsNotSetError } from \"../../error/ConnectionIsNotSetError\"\nimport { DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport type { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport type { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { MongoSchemaBuilder } from \"../../schema-builder/MongoSchemaBuilder\"\nimport type { Table } from \"../../schema-builder/table/Table\"\nimport type { TableColumn } from \"../../schema-builder/table/TableColumn\"\nimport type { TableForeignKey } from \"../../schema-builder/table/TableForeignKey\"\nimport type { View } from \"../../schema-builder/view/View\"\nimport { ApplyValueTransformers } from \"../../util/ApplyValueTransformers\"\nimport { InstanceChecker } from \"../../util/InstanceChecker\"\nimport { ObjectUtils } from \"../../util/ObjectUtils\"\nimport type { Driver } from \"../Driver\"\nimport { DriverUtils } from \"../DriverUtils\"\nimport type { ColumnType } from \"../types/ColumnTypes\"\nimport type { CteCapabilities } from \"../types/CteCapabilities\"\nimport type { DataTypeDefaults } from \"../types/DataTypeDefaults\"\nimport type { MappedColumnTypes } from \"../types/MappedColumnTypes\"\nimport type { ReplicationMode } from \"../types/ReplicationMode\"\nimport type { IsolationLevel } from \"../types/IsolationLevel\"\nimport type { UpsertType } from \"../types/UpsertType\"\nimport type { MongoDataSourceOptions } from \"./MongoDataSourceOptions\"\nimport { MongoQueryRunner } from \"./MongoQueryRunner\"\n// lakutata: the global crypto of the driver on Node.js 18\nimport { provideWebCrypto } from \"./MongoWebCrypto\"\n\n/**\n * Organizes communication with MongoDB.\n */\nexport class MongoDriver implements Driver {\n // -------------------------------------------------------------------------\n // Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * Transaction isolation levels supported by this driver.\n */\n static readonly supportedIsolationLevels: IsolationLevel[] = []\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Isolation levels supported by this driver.\n */\n supportedIsolationLevels = MongoDriver.supportedIsolationLevels\n\n /**\n * Underlying mongodb library.\n */\n mongodb: any\n\n /**\n * Mongodb does not require to dynamically create query runner each time,\n * because it does not have a regular connection pool as RDBMS systems have.\n */\n queryRunner?: MongoQueryRunner\n\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource options.\n */\n options: MongoDataSourceOptions\n\n /**\n * Master database used to perform all write queries.\n */\n database?: string\n\n /**\n * Indicates if replication is enabled.\n */\n isReplicated: boolean = false\n\n /**\n * Indicates if tree tables are supported by this driver.\n */\n treeSupport = false\n\n /**\n * Represent transaction support by this driver\n */\n transactionSupport = \"none\" as const\n\n /**\n * Mongodb does not need to have column types because they are not used in schema sync.\n */\n supportedDataTypes: ColumnType[] = []\n\n /**\n * Returns type of upsert supported by driver if any\n */\n supportedUpsertTypes: UpsertType[]\n\n /**\n * Gets list of spatial column data types.\n */\n spatialTypes: ColumnType[] = []\n\n /**\n * Gets list of column data types that support length by a driver.\n */\n withLengthColumnTypes: ColumnType[] = []\n\n /**\n * Gets list of column data types that support precision by a driver.\n */\n withPrecisionColumnTypes: ColumnType[] = []\n\n /**\n * Gets list of column data types that support scale by a driver.\n */\n withScaleColumnTypes: ColumnType[] = []\n\n /**\n * Mongodb does not need to have a strong defined mapped column types because they are not used in schema sync.\n */\n mappedDataTypes: MappedColumnTypes = {\n createDate: \"int\",\n createDateDefault: \"\",\n updateDate: \"int\",\n updateDateDefault: \"\",\n deleteDate: \"int\",\n deleteDateNullable: true,\n version: \"int\",\n treeLevel: \"int\",\n migrationId: \"int\",\n migrationName: \"int\",\n migrationTimestamp: \"int\",\n cacheId: \"int\",\n cacheIdentifier: \"int\",\n cacheTime: \"int\",\n cacheDuration: \"int\",\n cacheQuery: \"int\",\n cacheResult: \"int\",\n metadataType: \"int\",\n metadataDatabase: \"int\",\n metadataSchema: \"int\",\n metadataTable: \"int\",\n metadataName: \"int\",\n metadataValue: \"int\",\n }\n\n /**\n * Default values of length, precision and scale depends on column data type.\n * Used in the cases when length/precision/scale is not specified by user.\n */\n dataTypeDefaults: DataTypeDefaults\n\n /**\n * No documentation specifying a maximum length for identifiers could be found\n * for MongoDB.\n */\n maxAliasLength?: number\n\n cteCapabilities: CteCapabilities = {\n enabled: false,\n }\n\n // -------------------------------------------------------------------------\n // Protected Properties\n // -------------------------------------------------------------------------\n\n /**\n * Valid mongo connection options\n * NOTE: Keep in sync with MongoConnectionOptions\n */\n protected validOptionNames: string[] = [\n \"appName\",\n \"authMechanism\",\n \"authSource\",\n \"autoEncryption\",\n \"checkServerIdentity\",\n \"compressors\",\n \"connectTimeoutMS\",\n \"directConnection\",\n \"family\",\n \"forceServerObjectId\",\n \"ignoreUndefined\",\n \"localThresholdMS\",\n \"maxStalenessSeconds\",\n \"minPoolSize\",\n \"monitorCommands\",\n \"noDelay\",\n \"pkFactory\",\n \"promoteBuffers\",\n \"promoteLongs\",\n \"promoteValues\",\n \"raw\",\n \"readConcern\",\n \"readPreference\",\n \"readPreferenceTags\",\n \"replicaSet\",\n \"retryWrites\",\n \"serializeFunctions\",\n \"socketTimeoutMS\",\n \"tls\",\n \"tlsAllowInvalidCertificates\",\n \"tlsCAFile\",\n \"tlsCertificateKeyFile\",\n \"tlsCertificateKeyFilePassword\",\n \"writeConcern\",\n // Proxy configuration for Socks5\n \"proxyHost\",\n \"proxyPort\",\n \"proxyUsername\",\n \"proxyPassword\",\n ]\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected dataSource: DataSource) {\n this.options = dataSource.options as MongoDataSourceOptions\n\n // validate options to make sure everything is correct and driver will be able to establish connection\n this.validateOptions(dataSource.options)\n\n // load mongodb package\n this.loadDependencies()\n\n this.database = DriverUtils.buildMongoDBDriverOptions(\n this.options,\n ).database\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n const options = DriverUtils.buildMongoDBDriverOptions(this.options)\n\n const client = await this.mongodb.MongoClient.connect(\n this.buildConnectionUrl(options),\n this.buildConnectionOptions(options),\n )\n\n this.queryRunner = new MongoQueryRunner(this.dataSource, client)\n ObjectUtils.assign(this.queryRunner, {\n manager: this.dataSource.manager,\n })\n }\n\n afterConnect(): Promise<void> {\n return Promise.resolve()\n }\n\n /**\n * Closes connection with the database.\n */\n async disconnect(): Promise<void> {\n const queryRunner = this.queryRunner\n if (!queryRunner) {\n throw new ConnectionIsNotSetError(\"mongodb\")\n }\n\n this.queryRunner = undefined\n await queryRunner.databaseConnection.close()\n }\n\n /**\n * Creates a schema builder used to build and sync a schema.\n */\n createSchemaBuilder() {\n return new MongoSchemaBuilder(this.dataSource)\n }\n\n /**\n * Creates a query runner used to execute database queries.\n *\n * @param mode\n */\n createQueryRunner(mode: ReplicationMode) {\n return this.queryRunner!\n }\n\n /**\n * Replaces parameters in the given sql with special escaping character\n * and an array of parameter names to be passed to a query.\n *\n * @param sql\n * @param parameters\n */\n escapeQueryWithParameters(\n sql: string,\n parameters: ObjectLiteral,\n ): [string, any[]] {\n throw new TypeORMError(\n `This operation is not supported by Mongodb driver.`,\n )\n }\n\n /**\n * Escapes a column name.\n *\n * @param columnName\n */\n escape(columnName: string): string {\n return columnName\n }\n\n /**\n * Build full table name with database name, schema name and table name.\n * E.g. myDB.mySchema.myTable\n *\n * @param tableName\n * @param schema\n * @param database\n */\n buildTableName(\n tableName: string,\n schema?: string,\n database?: string,\n ): string {\n return tableName\n }\n\n /**\n * Parse a target table name or other types and return a normalized table definition.\n *\n * @param target\n */\n parseTableName(\n target: EntityMetadata | Table | View | TableForeignKey | string,\n ): { tableName: string; schema?: string; database?: string } {\n if (InstanceChecker.isEntityMetadata(target)) {\n return {\n tableName: target.tableName,\n }\n }\n\n if (InstanceChecker.isTable(target) || InstanceChecker.isView(target)) {\n return {\n tableName: target.name,\n }\n }\n\n if (InstanceChecker.isTableForeignKey(target)) {\n return {\n tableName: target.referencedTableName,\n }\n }\n\n return {\n tableName: target,\n }\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type and metadata.\n *\n * @param value\n * @param columnMetadata\n */\n preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any {\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformTo(\n columnMetadata.transformer,\n value,\n )\n return value\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type or metadata.\n *\n * @param value\n * @param columnMetadata\n */\n prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any {\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformFrom(\n columnMetadata.transformer,\n value,\n )\n return value\n }\n\n /**\n * Creates a database type from a given column metadata.\n *\n * @param column\n * @param column.type\n * @param column.length\n * @param column.precision\n * @param column.scale\n */\n normalizeType(column: {\n type?: ColumnType\n length?: number | string\n precision?: number | null\n scale?: number\n }): string {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Normalizes \"default\" value of the column.\n *\n * @param columnMetadata\n */\n normalizeDefault(columnMetadata: ColumnMetadata): string | undefined {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Normalizes \"isUnique\" value of the column.\n *\n * @param column\n */\n normalizeIsUnique(column: ColumnMetadata): boolean {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Calculates column length taking into account the default length values.\n *\n * @param column\n */\n getColumnLength(column: ColumnMetadata): string {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Normalizes \"default\" value of the column.\n *\n * @param column\n */\n createFullType(column: TableColumn): string {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Obtains a new database connection to a master server.\n * Used for replication.\n * If replication is not setup then returns default connection's database connection.\n */\n obtainMasterConnection(): Promise<any> {\n return Promise.resolve()\n }\n\n /**\n * Obtains a new database connection to a slave server.\n * Used for replication.\n * If replication is not setup then returns master (default) connection's database connection.\n */\n obtainSlaveConnection(): Promise<any> {\n return Promise.resolve()\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n *\n * @param metadata\n * @param insertedId\n */\n createGeneratedMap(metadata: EntityMetadata, insertedId: any) {\n return metadata.objectIdColumn!.createValueMap(insertedId)\n }\n\n /**\n * Differentiate columns of this table and columns from the given column metadatas columns\n * and returns only changed.\n *\n * @param tableColumns\n * @param columnMetadatas\n */\n findChangedColumns(\n tableColumns: TableColumn[],\n columnMetadatas: ColumnMetadata[],\n ): ColumnMetadata[] {\n throw new TypeORMError(\n `MongoDB is schema-less, not supported by this driver.`,\n )\n }\n\n /**\n * Returns true if driver supports RETURNING / OUTPUT statement.\n */\n isReturningSqlSupported(): boolean {\n return false\n }\n\n /**\n * Returns true if driver supports uuid values generation on its own.\n */\n isUUIDGenerationSupported(): boolean {\n return false\n }\n\n /**\n * Returns true if driver supports fulltext indices.\n */\n isFullTextColumnTypeSupported(): boolean {\n return false\n }\n\n /**\n * Creates an escaped parameter.\n *\n * @param parameterName\n * @param index\n */\n createParameter(parameterName: string, index: number): string {\n return \"\"\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Validate driver options to make sure everything is correct and driver will be able to establish connection.\n *\n * @param options\n */\n protected validateOptions(options: DataSourceOptions) {\n // todo: fix\n // if (!options.url) {\n // if (!options.database)\n // throw new DriverOptionNotSetError(\"database\");\n // }\n }\n\n /**\n * Loads all driver dependencies.\n */\n protected loadDependencies(): any {\n try {\n // lakutata: the global crypto the driver uses, on Node.js 18\n provideWebCrypto()\n const mongodb = this.options.driver ?? PlatformTools.load(\"mongodb\")\n this.mongodb = mongodb\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"MongoDB\", \"mongodb\")\n }\n }\n\n /**\n * Builds connection url that is passed to underlying driver to perform connection to the mongodb database.\n */\n protected buildConnectionUrl(options: { [key: string]: any }): string {\n const schemaUrlPart = options.type.toLowerCase()\n const credentialsUrlPart =\n options.username && options.password\n ? `${encodeURIComponent(options.username)}:${encodeURIComponent(\n options.password,\n )}@`\n : \"\"\n\n const portUrlPart =\n schemaUrlPart === \"mongodb+srv\" ? \"\" : `:${options.port ?? \"27017\"}`\n\n let connectionString: string\n if (options.replicaSet) {\n connectionString = `${schemaUrlPart}://${credentialsUrlPart}${\n options.hostReplicaSet ??\n `${options.host ?? \"127.0.0.1\"}${portUrlPart}`\n }/${options.database ?? \"\"}`\n } else {\n connectionString = `${schemaUrlPart}://${credentialsUrlPart}${\n options.host ?? \"127.0.0.1\"\n }${portUrlPart}/${options.database ?? \"\"}`\n }\n\n return connectionString\n }\n\n /**\n * Build connection options from MongoConnectionOptions\n */\n protected buildConnectionOptions(options: { [key: string]: any }): any {\n const mongoOptions: any = {}\n\n for (const optionName of this.validOptionNames) {\n if (optionName in options) {\n mongoOptions[optionName] = options[optionName]\n }\n }\n\n mongoOptions.driverInfo = {\n name: \"TypeORM\",\n }\n\n if (\"poolSize\" in options) {\n mongoOptions[\"maxPoolSize\"] = options[\"poolSize\"]\n }\n\n Object.assign(mongoOptions, options.extra)\n\n return mongoOptions\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lakutata: gives the driver of MongoDB the global crypto it uses (the random bytes and the hashes of its SCRAM
|
|
3
|
+
* authentication), which comes in Node.js 19: on Node.js 18 it is the webcrypto of crypto, the one Node.js 19 and
|
|
4
|
+
* later make global.
|
|
5
|
+
*/
|
|
6
|
+
export declare function provideWebCrypto(): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.provideWebCrypto = provideWebCrypto;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
/**
|
|
6
|
+
* lakutata: gives the driver of MongoDB the global crypto it uses (the random bytes and the hashes of its SCRAM
|
|
7
|
+
* authentication), which comes in Node.js 19: on Node.js 18 it is the webcrypto of crypto, the one Node.js 19 and
|
|
8
|
+
* later make global.
|
|
9
|
+
*/
|
|
10
|
+
function provideWebCrypto() {
|
|
11
|
+
//node-compat: crypto (global)
|
|
12
|
+
if (!globalThis.crypto)
|
|
13
|
+
Object.defineProperty(globalThis, "crypto", {
|
|
14
|
+
value: crypto_1.webcrypto,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=MongoWebCrypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongoWebCrypto.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongodb/MongoWebCrypto.ts"],"names":[],"mappings":";;AAOA,4CAQC;AAfD,mCAAkC;AAElC;;;;GAIG;AACH,SAAgB,gBAAgB;IAC5B,8BAA8B;IAC9B,IAAI,CAAE,UAAmC,CAAC,MAAM;QAC5C,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE;YACxC,KAAK,EAAE,kBAAS;YAChB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAA;AACV,CAAC","sourcesContent":["import { webcrypto } from \"crypto\"\n\n/**\n * lakutata: gives the driver of MongoDB the global crypto it uses (the random bytes and the hashes of its SCRAM\n * authentication), which comes in Node.js 19: on Node.js 18 it is the webcrypto of crypto, the one Node.js 19 and\n * later make global.\n */\nexport function provideWebCrypto(): void {\n //node-compat: crypto (global)\n if (!(globalThis as { crypto?: unknown }).crypto)\n Object.defineProperty(globalThis, \"crypto\", {\n value: webcrypto,\n configurable: true,\n writable: true,\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/orm",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "The ORM of the lakutata framework, on TypeORM: the Database component and provider, the entity decorators and the generation of the migrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lakutata",
|
|
@@ -102,10 +102,10 @@
|
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@google-cloud/spanner": "^8.0.0",
|
|
105
|
-
"@lakutata/core": "3.1.
|
|
106
|
-
"@lakutata/utils": "3.1.
|
|
105
|
+
"@lakutata/core": "~3.1.5",
|
|
106
|
+
"@lakutata/utils": "~3.1.5",
|
|
107
107
|
"@sap/hana-client": "^2.14.22",
|
|
108
|
-
"better-sqlite3": "^12.0.0",
|
|
108
|
+
"better-sqlite3": "^11.0.0 || ^12.0.0",
|
|
109
109
|
"bson": "^7.0.0",
|
|
110
110
|
"ioredis": "^5.0.4",
|
|
111
111
|
"mingo": "^7.2.0",
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
}
|
|
172
172
|
},
|
|
173
173
|
"engines": {
|
|
174
|
-
"node": "
|
|
174
|
+
"node": ">=18.10.0"
|
|
175
175
|
},
|
|
176
176
|
"files": [
|
|
177
177
|
"dist",
|