????

Your IP : 3.17.57.190


Current Path : C:/inetpub/vhost/invest.gdtsolutions.vn/api/node_modules/typeorm/cache/
Upload File :
Current File : C:/inetpub/vhost/invest.gdtsolutions.vn/api/node_modules/typeorm/cache/DbQueryResultCache.js.map

{"version":3,"sources":["../../src/cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,uEAAmE;AAEnE,yDAAqD;AAGrD,+BAAmC;AAEnC;;GAEG;AACH,MAAa,kBAAkB;IAW3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACxC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,CAAA;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;QAChD,MAAM,YAAY,GACd,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ;YAC7C,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK;YAC/B,CAAC,CAAC,EAAE,CAAA;QACZ,MAAM,cAAc,GAAG,YAAY,CAAC,SAAS,IAAI,oBAAoB,CAAA;QAErE,IAAI,CAAC,wBAAwB,GAAG,QAAQ,CAAA;QACxC,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAA;QACpC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAC9D,cAAc,EACd,MAAM,EACN,QAAQ,CACX,CAAA;IACL,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,OAAO,KAAmB,CAAC;IAEjC;;OAEG;IACH,KAAK,CAAC,UAAU,KAAmB,CAAC;IAEpC;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,WAAyB;QACvC,WAAW,GAAG,IAAI,CAAC,cAA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AC;YAC1B,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;QAC/B,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,WAAwB;QAChC,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,UAAU,CAC9C,IAAI,CAAC,qBAAqB,CAC7B,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACR,WAAqB,EACrB,WAAyB;QAEzB,IAAI,YAAY,GAAgB,WAAW,IAAI,IAAI,CAAC,cAAc,EAAE,CAAA;QACpE,MAAM,OAAO,CAAC,GAAG,CACb,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAC3B,MAAM,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAA;YACpD,OAAO,EAAE;iBACJ,MAAM,EAAE;iBACR,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC;iBAChC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;gBAC/C,UAAU;aACb,CAAC;iBACD,OAAO,EAAE,CAAA;QAClB,CAAC,CAAC,CACL,CAAA;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;QAChC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,cAAc,CAAC,WAAyB;QAC9C,IAAI,WAAW;YAAE,OAAO,WAAW,CAAA;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;IAC9C,CAAC;CACJ;AAlUD,gDAkUC","file":"DbQueryResultCache.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { QueryResultCache } from \"./QueryResultCache\"\nimport { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\nimport { v4 as uuidv4 } from \"uuid\"\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n    // -------------------------------------------------------------------------\n    // Private properties\n    // -------------------------------------------------------------------------\n\n    private queryResultCacheTable: string\n\n    private queryResultCacheDatabase?: string\n\n    private queryResultCacheSchema?: string\n\n    // -------------------------------------------------------------------------\n    // Constructor\n    // -------------------------------------------------------------------------\n\n    constructor(protected connection: DataSource) {\n        const { schema } = this.connection.driver.options as any\n        const database = this.connection.driver.database\n        const cacheOptions =\n            typeof this.connection.options.cache === \"object\"\n                ? this.connection.options.cache\n                : {}\n        const cacheTableName = cacheOptions.tableName || \"query-result-cache\"\n\n        this.queryResultCacheDatabase = database\n        this.queryResultCacheSchema = schema\n        this.queryResultCacheTable = this.connection.driver.buildTableName(\n            cacheTableName,\n            schema,\n            database,\n        )\n    }\n\n    // -------------------------------------------------------------------------\n    // Public Methods\n    // -------------------------------------------------------------------------\n\n    /**\n     * Creates a connection with given cache provider.\n     */\n    async connect(): Promise<void> {}\n\n    /**\n     * Disconnects with given cache provider.\n     */\n    async disconnect(): Promise<void> {}\n\n    /**\n     * Creates table for storing cache if it does not exist yet.\n     */\n    async synchronize(queryRunner?: QueryRunner): Promise<void> {\n        queryRunner = this.getQueryRunner(queryRunner)\n        const driver = this.connection.driver\n        const tableExist = await queryRunner.hasTable(\n            this.queryResultCacheTable,\n        ) // todo: table name should be configurable\n        if (tableExist) return\n\n        await queryRunner.createTable(\n            new Table({\n                database: this.queryResultCacheDatabase,\n                schema: this.queryResultCacheSchema,\n                name: this.queryResultCacheTable,\n                columns: [\n                    {\n                        name: \"id\",\n                        isPrimary: true,\n                        isNullable: false,\n                        type: driver.normalizeType({\n                            type: driver.mappedDataTypes.cacheId,\n                        }),\n                        generationStrategy:\n                            driver.options.type === \"spanner\"\n                                ? \"uuid\"\n                                : \"increment\",\n                        isGenerated: true,\n                    },\n                    {\n                        name: \"identifier\",\n                        type: driver.normalizeType({\n                            type: driver.mappedDataTypes.cacheIdentifier,\n                        }),\n                        isNullable: true,\n                    },\n                    {\n                        name: \"time\",\n                        type: driver.normalizeType({\n                            type: driver.mappedDataTypes.cacheTime,\n                        }),\n                        isPrimary: false,\n                        isNullable: false,\n                    },\n                    {\n                        name: \"duration\",\n                        type: driver.normalizeType({\n                            type: driver.mappedDataTypes.cacheDuration,\n                        }),\n                        isPrimary: false,\n                        isNullable: false,\n                    },\n                    {\n                        name: \"query\",\n                        type: driver.normalizeType({\n                            type: driver.mappedDataTypes.cacheQuery,\n                        }),\n                        isPrimary: false,\n                        isNullable: false,\n                    },\n                    {\n                        name: \"result\",\n                        type: driver.normalizeType({\n                            type: driver.mappedDataTypes.cacheResult,\n                        }),\n                        isNullable: false,\n                    },\n                ],\n            }),\n        )\n    }\n\n    /**\n     * Get data from cache.\n     * Returns cache result if found.\n     * Returns undefined if result is not cached.\n     */\n    getFromCache(\n        options: QueryResultCacheOptions,\n        queryRunner?: QueryRunner,\n    ): Promise<QueryResultCacheOptions | undefined> {\n        queryRunner = this.getQueryRunner(queryRunner)\n        const qb = this.connection\n            .createQueryBuilder(queryRunner)\n            .select()\n            .from(this.queryResultCacheTable, \"cache\")\n\n        if (options.identifier) {\n            return qb\n                .where(\n                    `${qb.escape(\"cache\")}.${qb.escape(\n                        \"identifier\",\n                    )} = :identifier`,\n                )\n                .setParameters({\n                    identifier:\n                        this.connection.driver.options.type === \"mssql\"\n                            ? new MssqlParameter(options.identifier, \"nvarchar\")\n                            : options.identifier,\n                })\n                .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n                .getRawOne()\n        } else if (options.query) {\n            if (this.connection.driver.options.type === \"oracle\") {\n                return qb\n                    .where(\n                        `dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\n                            \"query\",\n                        )}, :query) = 0`,\n                        { query: options.query },\n                    )\n                    .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n                    .getRawOne()\n            }\n\n            return qb\n                .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n                .setParameters({\n                    query:\n                        this.connection.driver.options.type === \"mssql\"\n                            ? new MssqlParameter(options.query, \"nvarchar\")\n                            : options.query,\n                })\n                .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n                .getRawOne()\n        }\n\n        return Promise.resolve(undefined)\n    }\n\n    /**\n     * Checks if cache is expired or not.\n     */\n    isExpired(savedCache: QueryResultCacheOptions): boolean {\n        const duration =\n            typeof savedCache.duration === \"string\"\n                ? parseInt(savedCache.duration)\n                : savedCache.duration\n        return (\n            (typeof savedCache.time === \"string\"\n                ? parseInt(savedCache.time as any)\n                : savedCache.time)! +\n                duration <\n            new Date().getTime()\n        )\n    }\n\n    /**\n     * Stores given query result in the cache.\n     */\n    async storeInCache(\n        options: QueryResultCacheOptions,\n        savedCache: QueryResultCacheOptions | undefined,\n        queryRunner?: QueryRunner,\n    ): Promise<void> {\n        const shouldCreateQueryRunner =\n            queryRunner === undefined ||\n            queryRunner?.getReplicationMode() === \"slave\"\n\n        if (queryRunner === undefined || shouldCreateQueryRunner) {\n            queryRunner = this.connection.createQueryRunner(\"master\")\n        }\n\n        let insertedValues: ObjectLiteral = options\n        if (this.connection.driver.options.type === \"mssql\") {\n            // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n            insertedValues = {\n                identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n                time: new MssqlParameter(options.time, \"bigint\"),\n                duration: new MssqlParameter(options.duration, \"int\"),\n                query: new MssqlParameter(options.query, \"nvarchar\"),\n                result: new MssqlParameter(options.result, \"nvarchar\"),\n            }\n        }\n\n        if (savedCache && savedCache.identifier) {\n            // if exist then update\n            const qb = queryRunner.manager\n                .createQueryBuilder()\n                .update(this.queryResultCacheTable)\n                .set(insertedValues)\n\n            qb.where(`${qb.escape(\"identifier\")} = :condition`, {\n                condition: insertedValues.identifier,\n            })\n            await qb.execute()\n        } else if (savedCache && savedCache.query) {\n            // if exist then update\n            const qb = queryRunner.manager\n                .createQueryBuilder()\n                .update(this.queryResultCacheTable)\n                .set(insertedValues)\n\n            if (this.connection.driver.options.type === \"oracle\") {\n                qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, {\n                    condition: insertedValues.query,\n                })\n            } else {\n                qb.where(`${qb.escape(\"query\")} = :condition`, {\n                    condition: insertedValues.query,\n                })\n            }\n\n            await qb.execute()\n        } else {\n            // Spanner does not support auto-generated columns\n            if (\n                this.connection.driver.options.type === \"spanner\" &&\n                !insertedValues.id\n            ) {\n                insertedValues.id = uuidv4()\n            }\n\n            // otherwise insert\n            await queryRunner.manager\n                .createQueryBuilder()\n                .insert()\n                .into(this.queryResultCacheTable)\n                .values(insertedValues)\n                .execute()\n        }\n\n        if (shouldCreateQueryRunner) {\n            await queryRunner.release()\n        }\n    }\n\n    /**\n     * Clears everything stored in the cache.\n     */\n    async clear(queryRunner: QueryRunner): Promise<void> {\n        return this.getQueryRunner(queryRunner).clearTable(\n            this.queryResultCacheTable,\n        )\n    }\n\n    /**\n     * Removes all cached results by given identifiers from cache.\n     */\n    async remove(\n        identifiers: string[],\n        queryRunner?: QueryRunner,\n    ): Promise<void> {\n        let _queryRunner: QueryRunner = queryRunner || this.getQueryRunner()\n        await Promise.all(\n            identifiers.map((identifier) => {\n                const qb = _queryRunner.manager.createQueryBuilder()\n                return qb\n                    .delete()\n                    .from(this.queryResultCacheTable)\n                    .where(`${qb.escape(\"identifier\")} = :identifier`, {\n                        identifier,\n                    })\n                    .execute()\n            }),\n        )\n\n        if (!queryRunner) {\n            await _queryRunner.release()\n        }\n    }\n\n    // -------------------------------------------------------------------------\n    // Protected Methods\n    // -------------------------------------------------------------------------\n\n    /**\n     * Gets a query runner to work with.\n     */\n    protected getQueryRunner(queryRunner?: QueryRunner): QueryRunner {\n        if (queryRunner) return queryRunner\n\n        return this.connection.createQueryRunner()\n    }\n}\n"],"sourceRoot":".."}