CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
cache.cjs58 linesDownload Raw Back to core
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var cache_exports = {};20__export(cache_exports, {21  Cache: () => Cache,22  NoopCache: () => NoopCache,23  hashQuery: () => hashQuery24});25module.exports = __toCommonJS(cache_exports);26var import_entity = require("../../entity.cjs");27class Cache {28  static [import_entity.entityKind] = "Cache";29}30class NoopCache extends Cache {31  strategy() {32    return "all";33  }34  static [import_entity.entityKind] = "NoopCache";35  async get(_key) {36    return void 0;37  }38  async put(_hashedQuery, _response, _tables, _config) {39  }40  async onMutate(_params) {41  }42}43async function hashQuery(sql, params) {44  const dataToHash = `${sql}-${JSON.stringify(params)}`;45  const encoder = new TextEncoder();46  const data = encoder.encode(dataToHash);47  const hashBuffer = await crypto.subtle.digest("SHA-256", data);48  const hashArray = [...new Uint8Array(hashBuffer)];49  const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");50  return hashHex;51}52// Annotate the CommonJS export names for ESM import in node:530 && (module.exports = {54  Cache,55  NoopCache,56  hashQuery57});58//# sourceMappingURL=cache.cjs.map