@query-farm/vgi 0.26.0 → 0.27.0

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.
@@ -2646,6 +2646,8 @@ function deserializeBindRequest(params) {
2646
2646
  functionType = "scalar" /* SCALAR */;
2647
2647
  } else if (ftStr === "table" || ftStr === "TABLE") {
2648
2648
  functionType = "table" /* TABLE */;
2649
+ } else if (ftStr === "table_buffering" || ftStr === "TABLE_BUFFERING") {
2650
+ functionType = "table_buffering" /* TABLE_BUFFERING */;
2649
2651
  } else if (ftStr === "aggregate" || ftStr === "AGGREGATE") {
2650
2652
  functionType = "aggregate" /* AGGREGATE */;
2651
2653
  } else {
@@ -5882,6 +5884,29 @@ var CLIENT_BUNDLE_BYTES = decodeBase642(CLIENT_BUNDLE_B64);
5882
5884
 
5883
5885
  // src/http/landing.ts
5884
5886
  var DEFAULT_CUPOLA_BASE = "https://cupola.query-farm.services";
5887
+ var REVALIDATE = "public, no-cache";
5888
+ function etagFor(bytes) {
5889
+ let hash = 2166136261;
5890
+ for (let i = 0;i < bytes.length; i++) {
5891
+ hash ^= bytes[i];
5892
+ hash = Math.imul(hash, 16777619) >>> 0;
5893
+ }
5894
+ return `"${hash.toString(16)}-${bytes.length.toString(16)}"`;
5895
+ }
5896
+ var landingEtag = null;
5897
+ var bundleEtag = null;
5898
+ function notModified(request, etag, extra) {
5899
+ const ifNoneMatch = request.headers.get("If-None-Match");
5900
+ if (!ifNoneMatch)
5901
+ return null;
5902
+ const matches = ifNoneMatch.split(",").map((c) => c.trim().replace(/^W\//, "")).includes(etag);
5903
+ if (!matches)
5904
+ return null;
5905
+ const headers = new Headers(extra);
5906
+ headers.set("ETag", etag);
5907
+ headers.set("Cache-Control", REVALIDATE);
5908
+ return new Response(null, { status: 304, headers });
5909
+ }
5885
5910
  function createLandingRoutes(info) {
5886
5911
  return (request, ctx) => {
5887
5912
  const path2 = ctx.url.pathname;
@@ -5905,14 +5930,31 @@ function createLandingRoutes(info) {
5905
5930
  ctx.addCorsHeaders(headers2);
5906
5931
  return new Response(body, { status: 200, headers: headers2 });
5907
5932
  }
5908
- const headers = new Headers({ "Content-Type": "text/html; charset=utf-8" });
5933
+ landingEtag ??= etagFor(LANDING_HTML_BYTES);
5934
+ const conditional = notModified(request, landingEtag);
5935
+ if (conditional) {
5936
+ ctx.addCorsHeaders(conditional.headers);
5937
+ return conditional;
5938
+ }
5939
+ const headers = new Headers({
5940
+ "Content-Type": "text/html; charset=utf-8",
5941
+ "Cache-Control": REVALIDATE,
5942
+ ETag: landingEtag
5943
+ });
5909
5944
  ctx.addCorsHeaders(headers);
5910
5945
  return new Response(LANDING_HTML_BYTES, { status: 200, headers });
5911
5946
  }
5912
5947
  if (path2 === `${prefix}/vgi-client.js`) {
5948
+ bundleEtag ??= etagFor(CLIENT_BUNDLE_BYTES);
5949
+ const conditional = notModified(request, bundleEtag);
5950
+ if (conditional) {
5951
+ ctx.addCorsHeaders(conditional.headers);
5952
+ return conditional;
5953
+ }
5913
5954
  const headers = new Headers({
5914
5955
  "Content-Type": "text/javascript; charset=utf-8",
5915
- "Cache-Control": "public, max-age=3600"
5956
+ "Cache-Control": REVALIDATE,
5957
+ ETag: bundleEtag
5916
5958
  });
5917
5959
  ctx.addCorsHeaders(headers);
5918
5960
  return new Response(CLIENT_BUNDLE_BYTES, { status: 200, headers });
@@ -5944,7 +5986,7 @@ function createVgiFetch(opts) {
5944
5986
  tokenKey: opts.signingKey,
5945
5987
  tokenTtl,
5946
5988
  stateSerializer: arrowStateSerializer,
5947
- corsOrigins: opts.corsOrigins,
5989
+ corsOrigins: opts.corsOrigins === null ? undefined : opts.corsOrigins ?? "*",
5948
5990
  repositoryUrl: opts.repositoryUrl,
5949
5991
  extraRoutes: createLandingRoutes(opts.landingInfo),
5950
5992
  enableLandingPage: false
@@ -6012,7 +6054,7 @@ function createVgiWorkerFetch(opts) {
6012
6054
  const env = opts.env ?? process.env;
6013
6055
  const signingKey = resolveSigningKey(opts.signingKey, env);
6014
6056
  const tokenTtl = resolveTokenTtl(opts.tokenTtl, env);
6015
- const corsOrigins = opts.corsOrigins === null ? undefined : opts.corsOrigins ?? env.CORS_ORIGINS ?? "*";
6057
+ const corsOrigins = opts.corsOrigins === null ? null : opts.corsOrigins ?? env.CORS_ORIGINS;
6016
6058
  return createVgiFetch({
6017
6059
  protocol: { registry: opts.registry, catalogInterface: opts.catalogInterface },
6018
6060
  signingKey,
@@ -6053,4 +6095,4 @@ export {
6053
6095
  DEFAULT_PORT
6054
6096
  };
6055
6097
 
6056
- //# debugId=785B2206E2F38BBD64756E2164756E21
6098
+ //# debugId=AF152B2CA425E9C164756E2164756E21