houdini 1.2.13 → 1.2.14

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.
Files changed (45) hide show
  1. package/build/adapter/index.d.ts +3 -0
  2. package/build/adapter-cjs/index.js +33 -0
  3. package/build/adapter-cjs/package.json +1 -0
  4. package/build/adapter-esm/index.js +9 -0
  5. package/build/adapter-esm/package.json +1 -0
  6. package/build/cmd-cjs/index.js +19 -19
  7. package/build/cmd-esm/index.js +18 -18
  8. package/build/codegen-cjs/index.js +16 -17
  9. package/build/codegen-esm/index.js +16 -16
  10. package/build/lib/index.d.ts +2 -0
  11. package/build/lib/router/conventions.d.ts +2 -4
  12. package/build/lib/router/index.d.ts +1 -1
  13. package/build/lib/router/types.d.ts +1 -0
  14. package/build/lib-cjs/index.js +140 -24
  15. package/build/lib-esm/index.js +136 -23
  16. package/build/runtime/lib/types.d.ts +1 -1
  17. package/build/runtime/router/match.d.ts +38 -0
  18. package/build/runtime/router/server.d.ts +22 -25
  19. package/build/runtime/router/session.d.ts +22 -0
  20. package/build/runtime/router/types.d.ts +23 -0
  21. package/build/runtime-cjs/lib/types.d.ts +1 -1
  22. package/build/runtime-cjs/lib/types.js +2 -0
  23. package/build/runtime-cjs/router/match.d.ts +38 -0
  24. package/build/runtime-cjs/router/match.js +149 -0
  25. package/build/runtime-cjs/router/server.d.ts +22 -25
  26. package/build/runtime-cjs/router/server.js +71 -49
  27. package/build/runtime-cjs/router/session.d.ts +22 -0
  28. package/build/runtime-cjs/router/session.js +77 -0
  29. package/build/runtime-cjs/router/types.d.ts +23 -0
  30. package/build/runtime-cjs/router/types.js +16 -0
  31. package/build/runtime-esm/lib/types.d.ts +1 -1
  32. package/build/runtime-esm/lib/types.js +1 -0
  33. package/build/runtime-esm/router/match.d.ts +38 -0
  34. package/build/runtime-esm/router/match.js +122 -0
  35. package/build/runtime-esm/router/server.d.ts +22 -25
  36. package/build/runtime-esm/router/server.js +64 -47
  37. package/build/runtime-esm/router/session.d.ts +22 -0
  38. package/build/runtime-esm/router/session.js +52 -0
  39. package/build/runtime-esm/router/types.d.ts +23 -0
  40. package/build/runtime-esm/router/types.js +0 -0
  41. package/build/test-cjs/index.js +16 -17
  42. package/build/test-esm/index.js +16 -16
  43. package/build/vite-cjs/index.js +26 -34
  44. package/build/vite-esm/index.js +26 -33
  45. package/package.json +10 -1
@@ -1,4 +1,3 @@
1
- import { createRequire as conflict_free } from 'module'; const require = conflict_free(import.meta.url);
2
1
  "use strict";
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -58608,11 +58607,13 @@ __export(lib_exports, {
58608
58607
  detectTools: () => detectTools,
58609
58608
  ensureArtifactImport: () => ensureArtifactImport,
58610
58609
  ensureImports: () => ensureImports,
58610
+ exec: () => exec,
58611
58611
  extractHeaders: () => extractHeaders,
58612
58612
  extractHeadersStr: () => extractHeadersStr,
58613
58613
  extractQueries: () => extractQueries,
58614
58614
  fetch: () => fetch2,
58615
58615
  find_graphql: () => find_graphql,
58616
+ find_match: () => find_match,
58616
58617
  formatErrors: () => formatErrors,
58617
58618
  fragmentKey: () => fragmentKey,
58618
58619
  fs: () => fs_exports,
@@ -58620,6 +58621,7 @@ __export(lib_exports, {
58620
58621
  getCurrentConfig: () => getCurrentConfig,
58621
58622
  getMockConfig: () => getMockConfig,
58622
58623
  getRootType: () => getRootType,
58624
+ get_route_segments: () => get_route_segments,
58623
58625
  get_session: () => get_session,
58624
58626
  handle_request: () => handle_request,
58625
58627
  hashOriginal: () => hashOriginal,
@@ -58639,6 +58641,7 @@ __export(lib_exports, {
58639
58641
  parentTypeFromAncestors: () => parentTypeFromAncestors,
58640
58642
  parseJS: () => parseJS,
58641
58643
  parseJSON: () => parseJSON,
58644
+ parse_page_pattern: () => parse_page_pattern,
58642
58645
  path: () => path_exports,
58643
58646
  plugin: () => plugin,
58644
58647
  printJS: () => printJS,
@@ -66882,7 +66885,7 @@ var LogLevel = {
66882
66885
 
66883
66886
  // src/lib/config.ts
66884
66887
  var import_meta = {};
66885
- var currentDir = global.__dirname || dirname((0, import_node_url2.fileURLToPath)(import_meta.url));
66888
+ var currentDir = dirname((0, import_node_url2.fileURLToPath)(import_meta.url));
66886
66889
  var Config = class {
66887
66890
  filepath;
66888
66891
  rootDir;
@@ -68048,6 +68051,124 @@ async function detectTools(cwd) {
68048
68051
  };
68049
68052
  }
68050
68053
 
68054
+ // src/runtime/router/match.ts
68055
+ var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
68056
+ function find_match(manifest, current, allowNull = true) {
68057
+ let match = null;
68058
+ let matchVariables = null;
68059
+ for (const page of Object.values(manifest.pages)) {
68060
+ const urlMatch = current.match(page.pattern);
68061
+ if (!urlMatch) {
68062
+ continue;
68063
+ }
68064
+ match = page;
68065
+ matchVariables = exec(urlMatch, page.params) || {};
68066
+ break;
68067
+ }
68068
+ if (!match && !allowNull) {
68069
+ throw new Error("404");
68070
+ }
68071
+ return [match, matchVariables];
68072
+ }
68073
+ function parse_page_pattern(id) {
68074
+ const params = [];
68075
+ const pattern = id === "/" ? /^\/$/ : new RegExp(
68076
+ `^${get_route_segments(id).map((segment) => {
68077
+ const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
68078
+ if (rest_match) {
68079
+ params.push({
68080
+ name: rest_match[1],
68081
+ matcher: rest_match[2],
68082
+ optional: false,
68083
+ rest: true,
68084
+ chained: true
68085
+ });
68086
+ return "(?:/(.*))?";
68087
+ }
68088
+ const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
68089
+ if (optional_match) {
68090
+ params.push({
68091
+ name: optional_match[1],
68092
+ matcher: optional_match[2],
68093
+ optional: true,
68094
+ rest: false,
68095
+ chained: true
68096
+ });
68097
+ return "(?:/([^/]+))?";
68098
+ }
68099
+ if (!segment) {
68100
+ return;
68101
+ }
68102
+ const parts = segment.split(/\[(.+?)\](?!\])/);
68103
+ const result = parts.map((content, i2) => {
68104
+ if (i2 % 2) {
68105
+ if (content.startsWith("x+")) {
68106
+ return escape2(
68107
+ String.fromCharCode(parseInt(content.slice(2), 16))
68108
+ );
68109
+ }
68110
+ if (content.startsWith("u+")) {
68111
+ return escape2(
68112
+ String.fromCharCode(
68113
+ ...content.slice(2).split("-").map((code) => parseInt(code, 16))
68114
+ )
68115
+ );
68116
+ }
68117
+ const match = param_pattern.exec(content);
68118
+ if (!match) {
68119
+ throw new Error(
68120
+ `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
68121
+ );
68122
+ }
68123
+ const [, is_optional, is_rest, name, matcher] = match;
68124
+ params.push({
68125
+ name,
68126
+ matcher,
68127
+ optional: !!is_optional,
68128
+ rest: !!is_rest,
68129
+ chained: is_rest ? i2 === 1 && parts[0] === "" : false
68130
+ });
68131
+ return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
68132
+ }
68133
+ return escape2(content);
68134
+ }).join("");
68135
+ return "/" + result;
68136
+ }).join("")}/?$`
68137
+ );
68138
+ return { pattern, params, page_id: id };
68139
+ }
68140
+ function affects_path(segment) {
68141
+ return !/^\([^)]+\)$/.test(segment);
68142
+ }
68143
+ function get_route_segments(route) {
68144
+ return route.slice(1).split("/").filter(affects_path);
68145
+ }
68146
+ function exec(match, params) {
68147
+ const result = {};
68148
+ const values = match.slice(1);
68149
+ let buffered = "";
68150
+ for (let i2 = 0; i2 < params.length; i2 += 1) {
68151
+ const param = params[i2];
68152
+ let value = values[i2];
68153
+ if (param.chained && param.rest && buffered) {
68154
+ value = value ? buffered + "/" + value : buffered;
68155
+ }
68156
+ buffered = "";
68157
+ if (value === void 0) {
68158
+ if (param.rest)
68159
+ result[param.name] = "";
68160
+ } else {
68161
+ result[param.name] = value;
68162
+ }
68163
+ }
68164
+ if (buffered)
68165
+ return;
68166
+ return result;
68167
+ }
68168
+ function escape2(str) {
68169
+ return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
68170
+ }
68171
+
68051
68172
  // ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
68052
68173
  var WalkerBase = class {
68053
68174
  constructor() {
@@ -68235,6 +68356,7 @@ async function find_graphql(config2, parsedScript, walker) {
68235
68356
  // src/lib/router/conventions.ts
68236
68357
  var conventions_exports = {};
68237
68358
  __export(conventions_exports, {
68359
+ adapter_config_path: () => adapter_config_path,
68238
68360
  fallback_unit_path: () => fallback_unit_path,
68239
68361
  is_layout: () => is_layout,
68240
68362
  layout_unit_path: () => layout_unit_path,
@@ -68246,13 +68368,10 @@ __export(conventions_exports, {
68246
68368
  read_layoutView: () => read_layoutView,
68247
68369
  read_pageQuery: () => read_pageQuery,
68248
68370
  read_pageView: () => read_pageView,
68249
- render_app_path: () => render_app_path,
68250
- render_client_path: () => render_client_path,
68251
- render_server_path: () => render_server_path,
68252
- render_yoga_path: () => render_yoga_path,
68253
68371
  router_index_path: () => router_index_path,
68254
68372
  router_path: () => router_path,
68255
- serialized_manifest_path: () => serialized_manifest_path
68373
+ serialized_manifest_path: () => serialized_manifest_path,
68374
+ server_adapter_path: () => server_adapter_path
68256
68375
  });
68257
68376
  function router_path(config2) {
68258
68377
  return path_exports.join(base_dir(config2), "Router.jsx");
@@ -68260,17 +68379,11 @@ function router_path(config2) {
68260
68379
  function page_entry_path(config2, id, base) {
68261
68380
  return path_exports.join(page_entries_dir(config2, base), `${id}.jsx`);
68262
68381
  }
68263
- function render_client_path(config2, base) {
68264
- return path_exports.join(units_dir(config2, base), "render", "client.jsx");
68265
- }
68266
- function render_server_path(config2, base) {
68382
+ function server_adapter_path(config2, base) {
68267
68383
  return path_exports.join(units_dir(config2, base), "render", "server.js");
68268
68384
  }
68269
- function render_yoga_path(config2, base) {
68270
- return path_exports.join(units_dir(config2, base), "render", "yoga.js");
68271
- }
68272
- function render_app_path(config2, base) {
68273
- return path_exports.join(units_dir(config2, base), "render", "App.jsx");
68385
+ function adapter_config_path(config2, base) {
68386
+ return path_exports.join(units_dir(config2, base), "render", "config.js");
68274
68387
  }
68275
68388
  function page_unit_path(config2, id, base) {
68276
68389
  return path_exports.join(page_units_dir(config2, base), `${id}.jsx`);
@@ -68807,29 +68920,28 @@ function decode2(token) {
68807
68920
  };
68808
68921
  }
68809
68922
 
68810
- // src/runtime/router/server.ts
68923
+ // src/runtime/router/session.ts
68811
68924
  async function handle_request(args) {
68812
68925
  const plugin_config = args.config.router ?? {};
68813
68926
  if (plugin_config.auth && "redirect" in plugin_config.auth && args.url.startsWith(plugin_config.auth.redirect)) {
68814
68927
  return await redirect_auth(args);
68815
68928
  }
68816
- args.next();
68817
68929
  }
68818
68930
  async function redirect_auth(args) {
68819
- const { searchParams } = new URL(args.url, `http://${args.get_header("host")}`);
68931
+ const { searchParams } = new URL(args.url, `http://${args.headers.get("host")}`);
68820
68932
  const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
68821
- await set_session(args, session);
68822
68933
  if (redirectTo) {
68823
- return args.redirect(302, redirectTo);
68934
+ const response = Response.redirect(redirectTo, 302);
68935
+ await set_session(args, response, session);
68936
+ return response;
68824
68937
  }
68825
- args.next();
68826
68938
  }
68827
68939
  var session_cookie_name = "__houdini__";
68828
- async function set_session(req, value) {
68940
+ async function set_session(req, response, value) {
68829
68941
  const today = new Date();
68830
68942
  const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
68831
68943
  const serialized = await encode(value, req.session_keys[0]);
68832
- req.set_header(
68944
+ response.headers.set(
68833
68945
  "Set-Cookie",
68834
68946
  `${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
68835
68947
  );
@@ -68884,11 +68996,13 @@ async function get_session(req, secrets) {
68884
68996
  detectTools,
68885
68997
  ensureArtifactImport,
68886
68998
  ensureImports,
68999
+ exec,
68887
69000
  extractHeaders,
68888
69001
  extractHeadersStr,
68889
69002
  extractQueries,
68890
69003
  fetch,
68891
69004
  find_graphql,
69005
+ find_match,
68892
69006
  formatErrors,
68893
69007
  fragmentKey,
68894
69008
  fs,
@@ -68896,6 +69010,7 @@ async function get_session(req, secrets) {
68896
69010
  getCurrentConfig,
68897
69011
  getMockConfig,
68898
69012
  getRootType,
69013
+ get_route_segments,
68899
69014
  get_session,
68900
69015
  handle_request,
68901
69016
  hashOriginal,
@@ -68915,6 +69030,7 @@ async function get_session(req, secrets) {
68915
69030
  parentTypeFromAncestors,
68916
69031
  parseJS,
68917
69032
  parseJSON,
69033
+ parse_page_pattern,
68918
69034
  path,
68919
69035
  plugin,
68920
69036
  printJS,
@@ -66809,7 +66809,7 @@ var LogLevel = {
66809
66809
  };
66810
66810
 
66811
66811
  // src/lib/config.ts
66812
- var currentDir = global.__dirname || dirname(fileURLToPath(import.meta.url));
66812
+ var currentDir = dirname(fileURLToPath(import.meta.url));
66813
66813
  var Config = class {
66814
66814
  filepath;
66815
66815
  rootDir;
@@ -67975,6 +67975,124 @@ async function detectTools(cwd) {
67975
67975
  };
67976
67976
  }
67977
67977
 
67978
+ // src/runtime/router/match.ts
67979
+ var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
67980
+ function find_match(manifest, current, allowNull = true) {
67981
+ let match = null;
67982
+ let matchVariables = null;
67983
+ for (const page of Object.values(manifest.pages)) {
67984
+ const urlMatch = current.match(page.pattern);
67985
+ if (!urlMatch) {
67986
+ continue;
67987
+ }
67988
+ match = page;
67989
+ matchVariables = exec(urlMatch, page.params) || {};
67990
+ break;
67991
+ }
67992
+ if (!match && !allowNull) {
67993
+ throw new Error("404");
67994
+ }
67995
+ return [match, matchVariables];
67996
+ }
67997
+ function parse_page_pattern(id) {
67998
+ const params = [];
67999
+ const pattern = id === "/" ? /^\/$/ : new RegExp(
68000
+ `^${get_route_segments(id).map((segment) => {
68001
+ const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
68002
+ if (rest_match) {
68003
+ params.push({
68004
+ name: rest_match[1],
68005
+ matcher: rest_match[2],
68006
+ optional: false,
68007
+ rest: true,
68008
+ chained: true
68009
+ });
68010
+ return "(?:/(.*))?";
68011
+ }
68012
+ const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
68013
+ if (optional_match) {
68014
+ params.push({
68015
+ name: optional_match[1],
68016
+ matcher: optional_match[2],
68017
+ optional: true,
68018
+ rest: false,
68019
+ chained: true
68020
+ });
68021
+ return "(?:/([^/]+))?";
68022
+ }
68023
+ if (!segment) {
68024
+ return;
68025
+ }
68026
+ const parts = segment.split(/\[(.+?)\](?!\])/);
68027
+ const result = parts.map((content, i2) => {
68028
+ if (i2 % 2) {
68029
+ if (content.startsWith("x+")) {
68030
+ return escape2(
68031
+ String.fromCharCode(parseInt(content.slice(2), 16))
68032
+ );
68033
+ }
68034
+ if (content.startsWith("u+")) {
68035
+ return escape2(
68036
+ String.fromCharCode(
68037
+ ...content.slice(2).split("-").map((code) => parseInt(code, 16))
68038
+ )
68039
+ );
68040
+ }
68041
+ const match = param_pattern.exec(content);
68042
+ if (!match) {
68043
+ throw new Error(
68044
+ `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
68045
+ );
68046
+ }
68047
+ const [, is_optional, is_rest, name, matcher] = match;
68048
+ params.push({
68049
+ name,
68050
+ matcher,
68051
+ optional: !!is_optional,
68052
+ rest: !!is_rest,
68053
+ chained: is_rest ? i2 === 1 && parts[0] === "" : false
68054
+ });
68055
+ return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
68056
+ }
68057
+ return escape2(content);
68058
+ }).join("");
68059
+ return "/" + result;
68060
+ }).join("")}/?$`
68061
+ );
68062
+ return { pattern, params, page_id: id };
68063
+ }
68064
+ function affects_path(segment) {
68065
+ return !/^\([^)]+\)$/.test(segment);
68066
+ }
68067
+ function get_route_segments(route) {
68068
+ return route.slice(1).split("/").filter(affects_path);
68069
+ }
68070
+ function exec(match, params) {
68071
+ const result = {};
68072
+ const values = match.slice(1);
68073
+ let buffered = "";
68074
+ for (let i2 = 0; i2 < params.length; i2 += 1) {
68075
+ const param = params[i2];
68076
+ let value = values[i2];
68077
+ if (param.chained && param.rest && buffered) {
68078
+ value = value ? buffered + "/" + value : buffered;
68079
+ }
68080
+ buffered = "";
68081
+ if (value === void 0) {
68082
+ if (param.rest)
68083
+ result[param.name] = "";
68084
+ } else {
68085
+ result[param.name] = value;
68086
+ }
68087
+ }
68088
+ if (buffered)
68089
+ return;
68090
+ return result;
68091
+ }
68092
+ function escape2(str) {
68093
+ return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
68094
+ }
68095
+
67978
68096
  // ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
67979
68097
  var WalkerBase = class {
67980
68098
  constructor() {
@@ -68162,6 +68280,7 @@ async function find_graphql(config2, parsedScript, walker) {
68162
68280
  // src/lib/router/conventions.ts
68163
68281
  var conventions_exports = {};
68164
68282
  __export(conventions_exports, {
68283
+ adapter_config_path: () => adapter_config_path,
68165
68284
  fallback_unit_path: () => fallback_unit_path,
68166
68285
  is_layout: () => is_layout,
68167
68286
  layout_unit_path: () => layout_unit_path,
@@ -68173,13 +68292,10 @@ __export(conventions_exports, {
68173
68292
  read_layoutView: () => read_layoutView,
68174
68293
  read_pageQuery: () => read_pageQuery,
68175
68294
  read_pageView: () => read_pageView,
68176
- render_app_path: () => render_app_path,
68177
- render_client_path: () => render_client_path,
68178
- render_server_path: () => render_server_path,
68179
- render_yoga_path: () => render_yoga_path,
68180
68295
  router_index_path: () => router_index_path,
68181
68296
  router_path: () => router_path,
68182
- serialized_manifest_path: () => serialized_manifest_path
68297
+ serialized_manifest_path: () => serialized_manifest_path,
68298
+ server_adapter_path: () => server_adapter_path
68183
68299
  });
68184
68300
  function router_path(config2) {
68185
68301
  return path_exports.join(base_dir(config2), "Router.jsx");
@@ -68187,17 +68303,11 @@ function router_path(config2) {
68187
68303
  function page_entry_path(config2, id, base) {
68188
68304
  return path_exports.join(page_entries_dir(config2, base), `${id}.jsx`);
68189
68305
  }
68190
- function render_client_path(config2, base) {
68191
- return path_exports.join(units_dir(config2, base), "render", "client.jsx");
68192
- }
68193
- function render_server_path(config2, base) {
68306
+ function server_adapter_path(config2, base) {
68194
68307
  return path_exports.join(units_dir(config2, base), "render", "server.js");
68195
68308
  }
68196
- function render_yoga_path(config2, base) {
68197
- return path_exports.join(units_dir(config2, base), "render", "yoga.js");
68198
- }
68199
- function render_app_path(config2, base) {
68200
- return path_exports.join(units_dir(config2, base), "render", "App.jsx");
68309
+ function adapter_config_path(config2, base) {
68310
+ return path_exports.join(units_dir(config2, base), "render", "config.js");
68201
68311
  }
68202
68312
  function page_unit_path(config2, id, base) {
68203
68313
  return path_exports.join(page_units_dir(config2, base), `${id}.jsx`);
@@ -68734,29 +68844,28 @@ function decode2(token) {
68734
68844
  };
68735
68845
  }
68736
68846
 
68737
- // src/runtime/router/server.ts
68847
+ // src/runtime/router/session.ts
68738
68848
  async function handle_request(args) {
68739
68849
  const plugin_config = args.config.router ?? {};
68740
68850
  if (plugin_config.auth && "redirect" in plugin_config.auth && args.url.startsWith(plugin_config.auth.redirect)) {
68741
68851
  return await redirect_auth(args);
68742
68852
  }
68743
- args.next();
68744
68853
  }
68745
68854
  async function redirect_auth(args) {
68746
- const { searchParams } = new URL(args.url, `http://${args.get_header("host")}`);
68855
+ const { searchParams } = new URL(args.url, `http://${args.headers.get("host")}`);
68747
68856
  const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
68748
- await set_session(args, session);
68749
68857
  if (redirectTo) {
68750
- return args.redirect(302, redirectTo);
68858
+ const response = Response.redirect(redirectTo, 302);
68859
+ await set_session(args, response, session);
68860
+ return response;
68751
68861
  }
68752
- args.next();
68753
68862
  }
68754
68863
  var session_cookie_name = "__houdini__";
68755
- async function set_session(req, value) {
68864
+ async function set_session(req, response, value) {
68756
68865
  const today = new Date();
68757
68866
  const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
68758
68867
  const serialized = await encode(value, req.session_keys[0]);
68759
- req.set_header(
68868
+ response.headers.set(
68760
68869
  "Set-Cookie",
68761
68870
  `${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
68762
68871
  );
@@ -68810,11 +68919,13 @@ export {
68810
68919
  detectTools,
68811
68920
  ensureArtifactImport,
68812
68921
  ensureImports,
68922
+ exec,
68813
68923
  extractHeaders,
68814
68924
  extractHeadersStr,
68815
68925
  extractQueries,
68816
68926
  fetch2 as fetch,
68817
68927
  find_graphql,
68928
+ find_match,
68818
68929
  formatErrors,
68819
68930
  fragmentKey,
68820
68931
  fs_exports as fs,
@@ -68822,6 +68933,7 @@ export {
68822
68933
  getCurrentConfig,
68823
68934
  getMockConfig,
68824
68935
  getRootType,
68936
+ get_route_segments,
68825
68937
  get_session,
68826
68938
  handle_request,
68827
68939
  hashOriginal,
@@ -68841,6 +68953,7 @@ export {
68841
68953
  parentTypeFromAncestors,
68842
68954
  parseJS,
68843
68955
  parseJSON,
68956
+ parse_page_pattern,
68844
68957
  path_exports as path,
68845
68958
  plugin,
68846
68959
  printJS,
@@ -11,6 +11,7 @@ export declare const PaginateMode: {
11
11
  readonly SinglePage: "SinglePage";
12
12
  };
13
13
  export type PaginateModes = ValuesOf<typeof PaginateMode>;
14
+ export * from '../router/types';
14
15
  declare global {
15
16
  namespace App {
16
17
  interface Session {
@@ -356,4 +357,3 @@ export type QueryManifest = {
356
357
  /** The filepath of the unit */
357
358
  path: string;
358
359
  };
359
- export {};
@@ -0,0 +1,38 @@
1
+ import type { GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ import type { RouterManifest, RouterPageManifest } from './types';
3
+ export type RouteParam = {
4
+ name: string;
5
+ matcher: string;
6
+ optional: boolean;
7
+ rest: boolean;
8
+ chained: boolean;
9
+ };
10
+ export interface ParamMatcher {
11
+ (param: string): boolean;
12
+ }
13
+ export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
14
+ export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
15
+ /**
16
+ * Creates the regex pattern, extracts parameter names, and generates types for a route
17
+ */
18
+ export declare function parse_page_pattern(id: string): {
19
+ pattern: RegExp;
20
+ params: RouteParam[];
21
+ page_id: string;
22
+ };
23
+ /**
24
+ * Splits a route id into its segments, removing segments that
25
+ * don't affect the path (i.e. groups). The root route is represented by `/`
26
+ * and will be returned as `['']`.
27
+ */
28
+ export declare function get_route_segments(route: string): string[];
29
+ export declare function exec(match: RegExpMatchArray, params: RouteParam[]): Record<string, string> | undefined;
30
+ /**
31
+ Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
+ */
@@ -1,25 +1,22 @@
1
- import type { ConfigFile } from '../lib';
2
- type ServerHandlerArgs = {
3
- url: string;
4
- config: ConfigFile;
5
- session_keys: string[];
6
- set_header: (key: string, value: string | number | string[]) => void;
7
- get_header: (key: string) => string | number | string[] | undefined;
8
- redirect: (code: number, url: string) => void;
9
- next: () => void;
10
- };
11
- export declare function handle_request(args: ServerHandlerArgs): Promise<void>;
12
- export type Server = {
13
- use(fn: ServerMiddleware): void;
14
- };
15
- export type ServerMiddleware = (req: IncomingRequest, res: ServerResponse, next: () => void) => void;
16
- export type IncomingRequest = {
17
- url?: string;
18
- headers: Headers;
19
- };
20
- export type ServerResponse = {
21
- redirect(url: string, status?: number): void;
22
- set_header(name: string, value: string): void;
23
- };
24
- export declare function get_session(req: Headers, secrets: string[]): Promise<App.Session>;
25
- export {};
1
+ /// <reference types="node" />
2
+ import { createServerAdapter as createAdapter } from '@whatwg-node/server';
3
+ import { type GraphQLSchema } from 'graphql';
4
+ import { createYoga } from 'graphql-yoga';
5
+ import type { IncomingMessage, ServerResponse } from 'node:http';
6
+ import type { RouterManifest, RouterPageManifest, YogaServerOptions } from './types';
7
+ export declare const serverAdapterFactory: <ComponentType>({ schema, yoga, production, manifest, on_render, pipe, assetPrefix, }: {
8
+ schema?: GraphQLSchema | null | undefined;
9
+ yoga?: import("graphql-yoga").YogaServerInstance<Record<string, any>, Record<string, any>> | null | undefined;
10
+ assetPrefix: string;
11
+ production?: boolean | undefined;
12
+ pipe?: ServerResponse<IncomingMessage> | undefined;
13
+ on_render: (args: {
14
+ url: string;
15
+ match: RouterPageManifest<ComponentType> | null;
16
+ manifest: RouterManifest<unknown>;
17
+ session: App.Session;
18
+ pipe?: ServerResponse<IncomingMessage> | undefined;
19
+ }) => Response | Promise<Response>;
20
+ manifest: RouterManifest<ComponentType> | null;
21
+ } & Omit<import("graphql-yoga").YogaServerOptions<Record<string, any>, Record<string, any>>, "schema">) => ReturnType<typeof createAdapter>;
22
+ export type ServerAdapterFactory = typeof serverAdapterFactory;
@@ -0,0 +1,22 @@
1
+ import type { ConfigFile } from '../lib';
2
+ type ServerHandlerArgs = {
3
+ url: string;
4
+ config: ConfigFile;
5
+ session_keys: string[];
6
+ headers: Headers;
7
+ };
8
+ export declare function handle_request(args: ServerHandlerArgs): Promise<Response | undefined>;
9
+ export type Server = {
10
+ use(fn: ServerMiddleware): void;
11
+ };
12
+ export type ServerMiddleware = (req: IncomingRequest, res: ServerResponse, next: () => void) => void;
13
+ export type IncomingRequest = {
14
+ url?: string;
15
+ headers: Headers;
16
+ };
17
+ export type ServerResponse = {
18
+ redirect(url: string, status?: number): void;
19
+ set_header(name: string, value: string): void;
20
+ };
21
+ export declare function get_session(req: Headers, secrets: string[]): Promise<App.Session>;
22
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { QueryArtifact } from '$houdini/runtime/lib/types';
2
+ import type { createYoga } from 'graphql-yoga';
3
+ import type { RouteParam } from './match';
4
+ export type YogaServer = ReturnType<typeof createYoga>;
5
+ export type YogaServerOptions = Parameters<typeof createYoga>[0];
6
+ export type RouterManifest<_ComponentType> = {
7
+ pages: Record<string, RouterPageManifest<_ComponentType>>;
8
+ };
9
+ export type { ServerAdapterFactory } from './server';
10
+ export type RouterPageManifest<_ComponentType> = {
11
+ id: string;
12
+ pattern: RegExp;
13
+ params: RouteParam[];
14
+ documents: Record<string, {
15
+ artifact: () => Promise<{
16
+ default: QueryArtifact;
17
+ }>;
18
+ loading: boolean;
19
+ }>;
20
+ component: () => Promise<{
21
+ default: (props: any) => _ComponentType;
22
+ }>;
23
+ };
@@ -11,6 +11,7 @@ export declare const PaginateMode: {
11
11
  readonly SinglePage: "SinglePage";
12
12
  };
13
13
  export type PaginateModes = ValuesOf<typeof PaginateMode>;
14
+ export * from '../router/types';
14
15
  declare global {
15
16
  namespace App {
16
17
  interface Session {
@@ -356,4 +357,3 @@ export type QueryManifest = {
356
357
  /** The filepath of the unit */
357
358
  path: string;
358
359
  };
359
- export {};