houdini 1.2.10 → 1.2.12

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 (59) hide show
  1. package/build/cmd-cjs/index.js +1539 -16157
  2. package/build/cmd-esm/index.js +1541 -16159
  3. package/build/codegen/transforms/collectDefinitions.d.ts +1 -1
  4. package/build/codegen/utils/flattenSelections.d.ts +1 -1
  5. package/build/codegen-cjs/index.js +301 -14970
  6. package/build/codegen-esm/index.js +305 -14974
  7. package/build/lib/config.d.ts +4 -0
  8. package/build/lib/index.d.ts +1 -1
  9. package/build/lib/types.d.ts +2 -2
  10. package/build/lib-cjs/index.js +1600 -15892
  11. package/build/lib-esm/index.js +1596 -15894
  12. package/build/{lib/router → router}/conventions.d.ts +2 -1
  13. package/build/{lib/router → router}/index.d.ts +2 -0
  14. package/build/router/manifest.d.ts +12 -0
  15. package/build/router/server.d.ts +4 -0
  16. package/build/{lib/router → router}/types.d.ts +3 -2
  17. package/build/router-cjs/index.js +57736 -0
  18. package/build/router-cjs/package.json +1 -0
  19. package/build/router-esm/index.js +57726 -0
  20. package/build/router-esm/package.json +1 -0
  21. package/build/runtime/client/documentStore.d.ts +1 -0
  22. package/build/runtime/client/index.d.ts +14 -2
  23. package/build/runtime/lib/config.d.ts +19 -0
  24. package/build/runtime/lib/types.d.ts +39 -0
  25. package/build/runtime/router/cookies.d.ts +41 -0
  26. package/build/runtime/router/jwt.d.ts +117 -0
  27. package/build/runtime/router/server.d.ts +25 -0
  28. package/build/runtime-cjs/client/documentStore.d.ts +1 -0
  29. package/build/runtime-cjs/client/documentStore.js +42 -2
  30. package/build/runtime-cjs/client/index.d.ts +14 -2
  31. package/build/runtime-cjs/client/index.js +8 -2
  32. package/build/runtime-cjs/lib/config.d.ts +19 -0
  33. package/build/runtime-cjs/lib/config.js +10 -0
  34. package/build/runtime-cjs/lib/types.d.ts +39 -0
  35. package/build/runtime-cjs/router/cookies.d.ts +41 -0
  36. package/build/runtime-cjs/router/cookies.js +168 -0
  37. package/build/runtime-cjs/router/jwt.d.ts +117 -0
  38. package/build/runtime-cjs/router/jwt.js +181 -0
  39. package/build/runtime-cjs/router/server.d.ts +25 -0
  40. package/build/runtime-cjs/router/server.js +78 -0
  41. package/build/runtime-esm/client/documentStore.d.ts +1 -0
  42. package/build/runtime-esm/client/documentStore.js +42 -2
  43. package/build/runtime-esm/client/index.d.ts +14 -2
  44. package/build/runtime-esm/client/index.js +8 -2
  45. package/build/runtime-esm/lib/config.d.ts +19 -0
  46. package/build/runtime-esm/lib/config.js +8 -0
  47. package/build/runtime-esm/lib/types.d.ts +39 -0
  48. package/build/runtime-esm/router/cookies.d.ts +41 -0
  49. package/build/runtime-esm/router/cookies.js +143 -0
  50. package/build/runtime-esm/router/jwt.d.ts +117 -0
  51. package/build/runtime-esm/router/jwt.js +155 -0
  52. package/build/runtime-esm/router/server.d.ts +25 -0
  53. package/build/runtime-esm/router/server.js +53 -0
  54. package/build/test-cjs/index.js +324 -14973
  55. package/build/test-esm/index.js +328 -14977
  56. package/build/vite-cjs/index.js +1826 -16184
  57. package/build/vite-esm/index.js +1828 -16186
  58. package/package.json +10 -1
  59. package/build/lib/router/manifest.d.ts +0 -45
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -25,6 +25,7 @@ export declare class DocumentStore<_Data extends GraphQLObject, _Input extends G
25
25
  });
26
26
  send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
27
27
  cleanup(): Promise<void>;
28
+ getFetch(getSession: () => App.Session | null | undefined): (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>;
28
29
  }
29
30
  declare function marshalVariables<_Data extends GraphQLObject, _Input extends GraphQLVariables>(ctx: ClientPluginContext): Record<string, any>;
30
31
  export type ClientPlugin = () => ClientHooks | null | (ClientHooks | ClientPlugin | null)[];
@@ -7,7 +7,7 @@ import type { FetchParamFn, ThrowOnErrorOperations, ThrowOnErrorParams } from '.
7
7
  export { DocumentStore, type ClientPlugin, type SendParams } from './documentStore';
8
8
  export { fetch, mutation, query, subscription } from './plugins';
9
9
  export type HoudiniClientConstructorArgs = {
10
- url: string;
10
+ url?: string;
11
11
  fetchParams?: FetchParamFn;
12
12
  plugins?: NestedList<ClientPlugin>;
13
13
  pipeline?: NestedList<ClientPlugin>;
@@ -25,7 +25,19 @@ export declare class HoudiniClient {
25
25
  url: string;
26
26
  readonly plugins: ClientPlugin[];
27
27
  readonly throwOnError_operations: ThrowOnErrorOperations[];
28
- constructor({ url, fetchParams, plugins, pipeline, throwOnError, }: HoudiniClientConstructorArgs);
28
+ proxies: Record<string, (operation: {
29
+ query: string;
30
+ variables: any;
31
+ operationName: string;
32
+ session: App.Session | null | undefined;
33
+ }) => Promise<any>>;
34
+ constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
29
35
  observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
36
+ registerProxy(url: string, handler: (operation: {
37
+ query: string;
38
+ variables: any;
39
+ operationName: string;
40
+ session: App.Session | null | undefined;
41
+ }) => Promise<any>): void;
30
42
  }
31
43
  export declare function createPluginHooks(plugins: ClientPlugin[]): ClientHooks[];
@@ -5,6 +5,8 @@ export declare function setMockConfig(config: ConfigFile | null): void;
5
5
  export declare function defaultConfigValues(file: ConfigFile): ConfigFile;
6
6
  export declare function keyFieldsForType(configFile: ConfigFile, type: string): string[];
7
7
  export declare function computeID(configFile: ConfigFile, type: string, data: any): string;
8
+ export declare function localApiEndpoint(configFile: ConfigFile): string;
9
+ export declare function localApiSessionKeys(configFile: ConfigFile): string[];
8
10
  export declare function getCurrentConfig(): ConfigFile;
9
11
  export type ConfigFile = {
10
12
  /**
@@ -110,6 +112,23 @@ export type ConfigFile = {
110
112
  * you must enable this flag.
111
113
  */
112
114
  acceptImperativeInstability?: boolean;
115
+ /**
116
+ * Configure the router
117
+ */
118
+ router?: RouterConfig;
119
+ };
120
+ type RouterConfig = {
121
+ auth?: AuthStrategy;
122
+ apiEndpoint?: string;
123
+ };
124
+ type AuthStrategy = {
125
+ redirect: string;
126
+ sessionKeys: string[];
127
+ url: string;
128
+ } | {
129
+ mutation: string;
130
+ sessionKeys: string[];
131
+ url: string;
113
132
  };
114
133
  type ScalarMap = {
115
134
  [typeName: string]: ScalarSpec;
@@ -317,4 +317,43 @@ interface VariableNode {
317
317
  export declare const PendingValue: unique symbol;
318
318
  export type LoadingType = typeof PendingValue;
319
319
  export declare function isPending(value: any): value is LoadingType;
320
+ export type ProjectManifest = {
321
+ /** All of the pages in the project */
322
+ pages: Record<string, PageManifest>;
323
+ /** All of the layouts in the project */
324
+ layouts: Record<string, PageManifest>;
325
+ /** All of the page queries in the project */
326
+ page_queries: Record<string, QueryManifest>;
327
+ /** All of the layout queries in the project */
328
+ layout_queries: Record<string, QueryManifest>;
329
+ /** All of the artifacts in the project */
330
+ artifacts: string[];
331
+ /** Whether or not there is a local schema defined */
332
+ local_schema: boolean;
333
+ /** Whether or not there is a custom instance of yoga defined */
334
+ local_yoga: boolean;
335
+ };
336
+ export type PageManifest = {
337
+ id: string;
338
+ /** the name of every query that the page depends on */
339
+ queries: string[];
340
+ /** the list of queries that this page could potentially ask for */
341
+ query_options: string[];
342
+ /** the full url pattern of the page */
343
+ url: string;
344
+ /** the ids of layouts that wrap this page */
345
+ layouts: string[];
346
+ /** The filepath of the unit */
347
+ path: string;
348
+ };
349
+ export type QueryManifest = {
350
+ /** the name of the query */
351
+ name: string;
352
+ /** the url tied with the query */
353
+ url: string;
354
+ /** wether the query uses the loading directive (ie, wants a fallback) */
355
+ loading: boolean;
356
+ /** The filepath of the unit */
357
+ path: string;
358
+ };
320
359
  export {};
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * cookie
3
+ * Copyright(c) 2012-2014 Roman Shtylman
4
+ * Copyright(c) 2015 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+ /**
8
+ * Parse a cookie header.
9
+ *
10
+ * Parse the given cookie header string into an object
11
+ * The object has the various cookies as keys(names) => values
12
+ *
13
+ * @param {string} str
14
+ * @param {object} [options]
15
+ * @return {object}
16
+ * @public
17
+ */
18
+ export declare function parse(str: string, options?: {
19
+ decode?: (val: string) => string;
20
+ }): Record<string, string>;
21
+ /**
22
+ * Serialize data into a cookie header.
23
+ *
24
+ * Serialize the a name value pair into a cookie string suitable for
25
+ * http headers. An optional options object specified cookie parameters.
26
+ *
27
+ * serialize('foo', 'bar', { httpOnly: true })
28
+ * => "foo=bar; httpOnly"
29
+ *
30
+ */
31
+ export declare function serialize(name: string, val: string, options: {
32
+ encode: boolean;
33
+ maxAge: number;
34
+ domain: string;
35
+ path: string;
36
+ expires: Date;
37
+ httpOnly: boolean;
38
+ priority: string | number;
39
+ secure: boolean;
40
+ sameSite: string | boolean;
41
+ }): string;
@@ -0,0 +1,117 @@
1
+ type SubtleCryptoImportKeyAlgorithm = any;
2
+ /**
3
+ * @typedef JwtAlgorithm
4
+ * @type {'ES256'|'ES384'|'ES512'|'HS256'|'HS384'|'HS512'|'RS256'|'RS384'|'RS512'}
5
+ */
6
+ export type JwtAlgorithm = 'ES256' | 'ES384' | 'ES512' | 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512';
7
+ /**
8
+ * @typedef JwtAlgorithms
9
+ */
10
+ export interface JwtAlgorithms {
11
+ [key: string]: SubtleCryptoImportKeyAlgorithm;
12
+ }
13
+ /**
14
+ * @typedef JwtHeader
15
+ * @prop {string} [typ] Type
16
+ */
17
+ export interface JwtHeader {
18
+ /**
19
+ * Type (default: `"JWT"`)
20
+ *
21
+ * @default "JWT"
22
+ */
23
+ typ?: string;
24
+ [key: string]: any;
25
+ }
26
+ /**
27
+ * @typedef JwtPayload
28
+ * @prop {string} [iss] Issuer
29
+ * @prop {string} [sub] Subject
30
+ * @prop {string | string[]} [aud] Audience
31
+ * @prop {string} [exp] Expiration Time
32
+ * @prop {string} [nbf] Not Before
33
+ * @prop {string} [iat] Issued At
34
+ * @prop {string} [jti] JWT ID
35
+ */
36
+ export interface JwtPayload {
37
+ /** Issuer */
38
+ iss?: string;
39
+ /** Subject */
40
+ sub?: string;
41
+ /** Audience */
42
+ aud?: string | string[];
43
+ /** Expiration Time */
44
+ exp?: number;
45
+ /** Not Before */
46
+ nbf?: number;
47
+ /** Issued At */
48
+ iat?: number;
49
+ /** JWT ID */
50
+ jti?: string;
51
+ [key: string]: any;
52
+ }
53
+ /**
54
+ * @typedef JwtOptions
55
+ * @prop {JwtAlgorithm | string} algorithm
56
+ */
57
+ export interface JwtOptions {
58
+ algorithm?: JwtAlgorithm | string;
59
+ }
60
+ /**
61
+ * @typedef JwtSignOptions
62
+ * @extends JwtOptions
63
+ * @prop {JwtHeader} [header]
64
+ */
65
+ export interface JwtSignOptions extends JwtOptions {
66
+ header?: JwtHeader;
67
+ }
68
+ /**
69
+ * @typedef JwtVerifyOptions
70
+ * @extends JwtOptions
71
+ * @prop {boolean} [throwError=false] If `true` throw error if checks fail. (default: `false`)
72
+ */
73
+ export interface JwtVerifyOptions extends JwtOptions {
74
+ /**
75
+ * If `true` throw error if checks fail. (default: `false`)
76
+ *
77
+ * @default false
78
+ */
79
+ throwError?: boolean;
80
+ }
81
+ /**
82
+ * @typedef JwtData
83
+ * @prop {JwtHeader} header
84
+ * @prop {JwtPayload} payload
85
+ */
86
+ export interface JwtData {
87
+ header: JwtHeader;
88
+ payload: JwtPayload;
89
+ }
90
+ /**
91
+ * Signs a payload and returns the token
92
+ *
93
+ * @param {JwtPayload} payload The payload object. To use `nbf` (Not Before) and/or `exp` (Expiration Time) add `nbf` and/or `exp` to the payload.
94
+ * @param {string | JsonWebKey} secret A string which is used to sign the payload.
95
+ * @param {JwtSignOptions | JwtAlgorithm | string} [options={ algorithm: 'HS256', header: { typ: 'JWT' } }] The options object or the algorithm.
96
+ * @throws {Error} If there's a validation issue.
97
+ * @returns {Promise<string>} Returns token as a `string`.
98
+ */
99
+ export declare function encode(payload: JwtPayload, secret: string | JsonWebKey, options?: JwtSignOptions | JwtAlgorithm): Promise<string>;
100
+ /**
101
+ * Verifies the integrity of the token and returns a boolean value.
102
+ *
103
+ * @param {string} token The token string generated by `jwt.sign()`.
104
+ * @param {string | JsonWebKey} secret The string which was used to sign the payload.
105
+ * @param {JWTVerifyOptions | JWTAlgorithm} options The options object or the algorithm.
106
+ * @throws {Error | string} Throws an error `string` if the token is invalid or an `Error-Object` if there's a validation issue.
107
+ * @returns {Promise<boolean>} Returns `true` if signature, `nbf` (if set) and `exp` (if set) are valid, otherwise returns `false`.
108
+ */
109
+ export declare function verify(token: string, secret: string | JsonWebKey, options?: JwtVerifyOptions | JwtAlgorithm): Promise<boolean>;
110
+ /**
111
+ * Returns the payload **without** verifying the integrity of the token. Please use `jwt.verify()` first to keep your application secure!
112
+ *
113
+ * @param {string} token The token string generated by `jwt.sign()`.
114
+ * @returns {JwtData} Returns an `object` containing `header` and `payload`.
115
+ */
116
+ export declare function decode(token: string): JwtData;
117
+ export {};
@@ -0,0 +1,25 @@
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 {};
@@ -25,6 +25,7 @@ export declare class DocumentStore<_Data extends GraphQLObject, _Input extends G
25
25
  });
26
26
  send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
27
27
  cleanup(): Promise<void>;
28
+ getFetch(getSession: () => App.Session | null | undefined): (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>;
28
29
  }
29
30
  declare function marshalVariables<_Data extends GraphQLObject, _Input extends GraphQLVariables>(ctx: ClientPluginContext): Record<string, any>;
30
31
  export type ClientPlugin = () => ClientHooks | null | (ClientHooks | ClientPlugin | null)[];
@@ -91,7 +91,7 @@ class DocumentStore extends import_store.Writable {
91
91
  async send({
92
92
  metadata,
93
93
  session,
94
- fetch = globalThis.fetch,
94
+ fetch,
95
95
  variables,
96
96
  policy,
97
97
  stuff,
@@ -108,7 +108,7 @@ class DocumentStore extends import_store.Writable {
108
108
  variables: null,
109
109
  metadata,
110
110
  session,
111
- fetch,
111
+ fetch: fetch ?? this.getFetch(() => session),
112
112
  stuff: {
113
113
  inputs: {
114
114
  changed: false,
@@ -150,6 +150,46 @@ class DocumentStore extends import_store.Writable {
150
150
  plugin.cleanup?.(this.#lastContext);
151
151
  }
152
152
  }
153
+ getFetch(getSession) {
154
+ return async (input, init) => {
155
+ let url = "";
156
+ let queries = [];
157
+ if (typeof input === "string") {
158
+ url = input.startsWith("http") ? new URL(input).pathname : input;
159
+ }
160
+ if (input instanceof URL) {
161
+ url = input.pathname;
162
+ } else if (input instanceof Request) {
163
+ url = new URL(input.url).pathname;
164
+ }
165
+ if (input instanceof Request) {
166
+ const body = await input.json();
167
+ if (!Array.isArray(body)) {
168
+ queries = [body];
169
+ }
170
+ } else {
171
+ const body = JSON.parse(init?.body);
172
+ if (!Array.isArray(body)) {
173
+ queries = [body];
174
+ }
175
+ }
176
+ if (!url || queries.length === 0) {
177
+ return await globalThis.fetch(input, init);
178
+ }
179
+ if (this.#client?.proxies[url]) {
180
+ const result = await Promise.all(
181
+ queries.map(
182
+ (q) => this.#client?.proxies[url]({
183
+ ...q,
184
+ session: getSession()
185
+ })
186
+ )
187
+ );
188
+ return new Response(JSON.stringify(result.length === 1 ? result[0] : result));
189
+ }
190
+ return await globalThis.fetch(input, init);
191
+ };
192
+ }
153
193
  #step(direction, ctx, value) {
154
194
  const hook = direction === "error" ? "catch" : steps[direction][ctx.currentStep];
155
195
  let valid = (i) => i <= this.#plugins.length;
@@ -7,7 +7,7 @@ import type { FetchParamFn, ThrowOnErrorOperations, ThrowOnErrorParams } from '.
7
7
  export { DocumentStore, type ClientPlugin, type SendParams } from './documentStore';
8
8
  export { fetch, mutation, query, subscription } from './plugins';
9
9
  export type HoudiniClientConstructorArgs = {
10
- url: string;
10
+ url?: string;
11
11
  fetchParams?: FetchParamFn;
12
12
  plugins?: NestedList<ClientPlugin>;
13
13
  pipeline?: NestedList<ClientPlugin>;
@@ -25,7 +25,19 @@ export declare class HoudiniClient {
25
25
  url: string;
26
26
  readonly plugins: ClientPlugin[];
27
27
  readonly throwOnError_operations: ThrowOnErrorOperations[];
28
- constructor({ url, fetchParams, plugins, pipeline, throwOnError, }: HoudiniClientConstructorArgs);
28
+ proxies: Record<string, (operation: {
29
+ query: string;
30
+ variables: any;
31
+ operationName: string;
32
+ session: App.Session | null | undefined;
33
+ }) => Promise<any>>;
34
+ constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
29
35
  observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
36
+ registerProxy(url: string, handler: (operation: {
37
+ query: string;
38
+ variables: any;
39
+ operationName: string;
40
+ session: App.Session | null | undefined;
41
+ }) => Promise<any>): void;
30
42
  }
31
43
  export declare function createPluginHooks(plugins: ClientPlugin[]): ClientHooks[];
@@ -33,6 +33,7 @@ __export(client_exports, {
33
33
  subscription: () => import_plugins2.subscription
34
34
  });
35
35
  module.exports = __toCommonJS(client_exports);
36
+ var import_lib = require("../lib");
36
37
  var import_flatten = require("../lib/flatten");
37
38
  var import_documentStore = require("./documentStore");
38
39
  var import_plugins = require("./plugins");
@@ -43,13 +44,14 @@ class HoudiniClient {
43
44
  url;
44
45
  plugins;
45
46
  throwOnError_operations;
47
+ proxies = {};
46
48
  constructor({
47
49
  url,
48
50
  fetchParams,
49
51
  plugins,
50
52
  pipeline,
51
53
  throwOnError
52
- }) {
54
+ } = {}) {
53
55
  if (plugins && pipeline) {
54
56
  throw new Error(
55
57
  "A client cannot be given a pipeline and a list of plugins at the same time."
@@ -71,7 +73,8 @@ class HoudiniClient {
71
73
  )
72
74
  )
73
75
  );
74
- this.url = url;
76
+ let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
77
+ this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
75
78
  }
76
79
  observe({
77
80
  enableCache = true,
@@ -86,6 +89,9 @@ class HoudiniClient {
86
89
  ...rest
87
90
  });
88
91
  }
92
+ registerProxy(url, handler) {
93
+ this.proxies[url] = handler;
94
+ }
89
95
  }
90
96
  function createPluginHooks(plugins) {
91
97
  return plugins.reduce((hooks, plugin) => {
@@ -5,6 +5,8 @@ export declare function setMockConfig(config: ConfigFile | null): void;
5
5
  export declare function defaultConfigValues(file: ConfigFile): ConfigFile;
6
6
  export declare function keyFieldsForType(configFile: ConfigFile, type: string): string[];
7
7
  export declare function computeID(configFile: ConfigFile, type: string, data: any): string;
8
+ export declare function localApiEndpoint(configFile: ConfigFile): string;
9
+ export declare function localApiSessionKeys(configFile: ConfigFile): string[];
8
10
  export declare function getCurrentConfig(): ConfigFile;
9
11
  export type ConfigFile = {
10
12
  /**
@@ -110,6 +112,23 @@ export type ConfigFile = {
110
112
  * you must enable this flag.
111
113
  */
112
114
  acceptImperativeInstability?: boolean;
115
+ /**
116
+ * Configure the router
117
+ */
118
+ router?: RouterConfig;
119
+ };
120
+ type RouterConfig = {
121
+ auth?: AuthStrategy;
122
+ apiEndpoint?: string;
123
+ };
124
+ type AuthStrategy = {
125
+ redirect: string;
126
+ sessionKeys: string[];
127
+ url: string;
128
+ } | {
129
+ mutation: string;
130
+ sessionKeys: string[];
131
+ url: string;
113
132
  };
114
133
  type ScalarMap = {
115
134
  [typeName: string]: ScalarSpec;
@@ -29,6 +29,8 @@ __export(config_exports, {
29
29
  getCurrentConfig: () => getCurrentConfig,
30
30
  getMockConfig: () => getMockConfig,
31
31
  keyFieldsForType: () => keyFieldsForType,
32
+ localApiEndpoint: () => localApiEndpoint,
33
+ localApiSessionKeys: () => localApiSessionKeys,
32
34
  setMockConfig: () => setMockConfig
33
35
  });
34
36
  module.exports = __toCommonJS(config_exports);
@@ -70,6 +72,12 @@ function computeID(configFile, type, data) {
70
72
  return id.slice(0, -2);
71
73
  }
72
74
  let _configFile = null;
75
+ function localApiEndpoint(configFile) {
76
+ return configFile.router?.apiEndpoint ?? "/_api";
77
+ }
78
+ function localApiSessionKeys(configFile) {
79
+ return configFile.router?.auth?.sessionKeys ?? [];
80
+ }
73
81
  function getCurrentConfig() {
74
82
  const mockConfig2 = getMockConfig();
75
83
  if (mockConfig2) {
@@ -92,5 +100,7 @@ function getCurrentConfig() {
92
100
  getCurrentConfig,
93
101
  getMockConfig,
94
102
  keyFieldsForType,
103
+ localApiEndpoint,
104
+ localApiSessionKeys,
95
105
  setMockConfig
96
106
  });
@@ -317,4 +317,43 @@ interface VariableNode {
317
317
  export declare const PendingValue: unique symbol;
318
318
  export type LoadingType = typeof PendingValue;
319
319
  export declare function isPending(value: any): value is LoadingType;
320
+ export type ProjectManifest = {
321
+ /** All of the pages in the project */
322
+ pages: Record<string, PageManifest>;
323
+ /** All of the layouts in the project */
324
+ layouts: Record<string, PageManifest>;
325
+ /** All of the page queries in the project */
326
+ page_queries: Record<string, QueryManifest>;
327
+ /** All of the layout queries in the project */
328
+ layout_queries: Record<string, QueryManifest>;
329
+ /** All of the artifacts in the project */
330
+ artifacts: string[];
331
+ /** Whether or not there is a local schema defined */
332
+ local_schema: boolean;
333
+ /** Whether or not there is a custom instance of yoga defined */
334
+ local_yoga: boolean;
335
+ };
336
+ export type PageManifest = {
337
+ id: string;
338
+ /** the name of every query that the page depends on */
339
+ queries: string[];
340
+ /** the list of queries that this page could potentially ask for */
341
+ query_options: string[];
342
+ /** the full url pattern of the page */
343
+ url: string;
344
+ /** the ids of layouts that wrap this page */
345
+ layouts: string[];
346
+ /** The filepath of the unit */
347
+ path: string;
348
+ };
349
+ export type QueryManifest = {
350
+ /** the name of the query */
351
+ name: string;
352
+ /** the url tied with the query */
353
+ url: string;
354
+ /** wether the query uses the loading directive (ie, wants a fallback) */
355
+ loading: boolean;
356
+ /** The filepath of the unit */
357
+ path: string;
358
+ };
320
359
  export {};
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * cookie
3
+ * Copyright(c) 2012-2014 Roman Shtylman
4
+ * Copyright(c) 2015 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+ /**
8
+ * Parse a cookie header.
9
+ *
10
+ * Parse the given cookie header string into an object
11
+ * The object has the various cookies as keys(names) => values
12
+ *
13
+ * @param {string} str
14
+ * @param {object} [options]
15
+ * @return {object}
16
+ * @public
17
+ */
18
+ export declare function parse(str: string, options?: {
19
+ decode?: (val: string) => string;
20
+ }): Record<string, string>;
21
+ /**
22
+ * Serialize data into a cookie header.
23
+ *
24
+ * Serialize the a name value pair into a cookie string suitable for
25
+ * http headers. An optional options object specified cookie parameters.
26
+ *
27
+ * serialize('foo', 'bar', { httpOnly: true })
28
+ * => "foo=bar; httpOnly"
29
+ *
30
+ */
31
+ export declare function serialize(name: string, val: string, options: {
32
+ encode: boolean;
33
+ maxAge: number;
34
+ domain: string;
35
+ path: string;
36
+ expires: Date;
37
+ httpOnly: boolean;
38
+ priority: string | number;
39
+ secure: boolean;
40
+ sameSite: string | boolean;
41
+ }): string;