houdini 1.2.12 → 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.
- package/build/adapter/index.d.ts +3 -0
- package/build/adapter-cjs/index.js +33 -0
- package/build/adapter-esm/index.js +9 -0
- package/build/cmd/init.d.ts +1 -0
- package/build/cmd-cjs/index.js +53 -48
- package/build/cmd-esm/index.js +51 -46
- package/build/codegen-cjs/index.js +23 -25
- package/build/codegen-esm/index.js +23 -24
- package/build/lib/index.d.ts +3 -1
- package/build/{router → lib/router}/conventions.d.ts +3 -5
- package/build/{router → lib/router}/index.d.ts +1 -1
- package/build/{router → lib/router}/manifest.d.ts +2 -2
- package/build/{router → lib/router}/server.d.ts +2 -2
- package/build/{router → lib/router}/types.d.ts +2 -1
- package/build/lib/types.d.ts +1 -1
- package/build/lib-cjs/index.js +148 -32
- package/build/lib-esm/index.js +142 -29
- package/build/runtime/lib/types.d.ts +1 -1
- package/build/runtime/router/match.d.ts +38 -0
- package/build/runtime/router/server.d.ts +22 -25
- package/build/runtime/router/session.d.ts +22 -0
- package/build/runtime/router/types.d.ts +23 -0
- package/build/runtime-cjs/lib/types.d.ts +1 -1
- package/build/runtime-cjs/lib/types.js +2 -0
- package/build/runtime-cjs/router/match.d.ts +38 -0
- package/build/runtime-cjs/router/match.js +149 -0
- package/build/runtime-cjs/router/server.d.ts +22 -25
- package/build/runtime-cjs/router/server.js +71 -49
- package/build/runtime-cjs/router/session.d.ts +22 -0
- package/build/runtime-cjs/router/session.js +77 -0
- package/build/runtime-cjs/router/types.d.ts +23 -0
- package/build/runtime-cjs/router/types.js +16 -0
- package/build/runtime-esm/lib/types.d.ts +1 -1
- package/build/runtime-esm/lib/types.js +1 -0
- package/build/runtime-esm/router/match.d.ts +38 -0
- package/build/runtime-esm/router/match.js +122 -0
- package/build/runtime-esm/router/server.d.ts +22 -25
- package/build/runtime-esm/router/server.js +64 -47
- package/build/runtime-esm/router/session.d.ts +22 -0
- package/build/runtime-esm/router/session.js +52 -0
- package/build/runtime-esm/router/types.d.ts +23 -0
- package/build/runtime-esm/router/types.js +0 -0
- package/build/test-cjs/index.js +27 -25
- package/build/test-esm/index.js +27 -24
- package/build/vite-cjs/index.js +40 -46
- package/build/vite-esm/index.js +39 -44
- package/package.json +10 -9
- package/build/router-cjs/index.js +0 -57736
- package/build/router-esm/index.js +0 -57726
- /package/build/{router-cjs → adapter-cjs}/package.json +0 -0
- /package/build/{router-esm → adapter-esm}/package.json +0 -0
|
@@ -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
|
+
*/
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
2
|
+
function find_match(manifest, current, allowNull = true) {
|
|
3
|
+
let match = null;
|
|
4
|
+
let matchVariables = null;
|
|
5
|
+
for (const page of Object.values(manifest.pages)) {
|
|
6
|
+
const urlMatch = current.match(page.pattern);
|
|
7
|
+
if (!urlMatch) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
match = page;
|
|
11
|
+
matchVariables = exec(urlMatch, page.params) || {};
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
if (!match && !allowNull) {
|
|
15
|
+
throw new Error("404");
|
|
16
|
+
}
|
|
17
|
+
return [match, matchVariables];
|
|
18
|
+
}
|
|
19
|
+
function parse_page_pattern(id) {
|
|
20
|
+
const params = [];
|
|
21
|
+
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
22
|
+
`^${get_route_segments(id).map((segment) => {
|
|
23
|
+
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
24
|
+
if (rest_match) {
|
|
25
|
+
params.push({
|
|
26
|
+
name: rest_match[1],
|
|
27
|
+
matcher: rest_match[2],
|
|
28
|
+
optional: false,
|
|
29
|
+
rest: true,
|
|
30
|
+
chained: true
|
|
31
|
+
});
|
|
32
|
+
return "(?:/(.*))?";
|
|
33
|
+
}
|
|
34
|
+
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
35
|
+
if (optional_match) {
|
|
36
|
+
params.push({
|
|
37
|
+
name: optional_match[1],
|
|
38
|
+
matcher: optional_match[2],
|
|
39
|
+
optional: true,
|
|
40
|
+
rest: false,
|
|
41
|
+
chained: true
|
|
42
|
+
});
|
|
43
|
+
return "(?:/([^/]+))?";
|
|
44
|
+
}
|
|
45
|
+
if (!segment) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
49
|
+
const result = parts.map((content, i) => {
|
|
50
|
+
if (i % 2) {
|
|
51
|
+
if (content.startsWith("x+")) {
|
|
52
|
+
return escape(
|
|
53
|
+
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (content.startsWith("u+")) {
|
|
57
|
+
return escape(
|
|
58
|
+
String.fromCharCode(
|
|
59
|
+
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const match = param_pattern.exec(content);
|
|
64
|
+
if (!match) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const [, is_optional, is_rest, name, matcher] = match;
|
|
70
|
+
params.push({
|
|
71
|
+
name,
|
|
72
|
+
matcher,
|
|
73
|
+
optional: !!is_optional,
|
|
74
|
+
rest: !!is_rest,
|
|
75
|
+
chained: is_rest ? i === 1 && parts[0] === "" : false
|
|
76
|
+
});
|
|
77
|
+
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
78
|
+
}
|
|
79
|
+
return escape(content);
|
|
80
|
+
}).join("");
|
|
81
|
+
return "/" + result;
|
|
82
|
+
}).join("")}/?$`
|
|
83
|
+
);
|
|
84
|
+
return { pattern, params, page_id: id };
|
|
85
|
+
}
|
|
86
|
+
function affects_path(segment) {
|
|
87
|
+
return !/^\([^)]+\)$/.test(segment);
|
|
88
|
+
}
|
|
89
|
+
function get_route_segments(route) {
|
|
90
|
+
return route.slice(1).split("/").filter(affects_path);
|
|
91
|
+
}
|
|
92
|
+
function exec(match, params) {
|
|
93
|
+
const result = {};
|
|
94
|
+
const values = match.slice(1);
|
|
95
|
+
let buffered = "";
|
|
96
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
97
|
+
const param = params[i];
|
|
98
|
+
let value = values[i];
|
|
99
|
+
if (param.chained && param.rest && buffered) {
|
|
100
|
+
value = value ? buffered + "/" + value : buffered;
|
|
101
|
+
}
|
|
102
|
+
buffered = "";
|
|
103
|
+
if (value === void 0) {
|
|
104
|
+
if (param.rest)
|
|
105
|
+
result[param.name] = "";
|
|
106
|
+
} else {
|
|
107
|
+
result[param.name] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (buffered)
|
|
111
|
+
return;
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
function escape(str) {
|
|
115
|
+
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
exec,
|
|
119
|
+
find_match,
|
|
120
|
+
get_route_segments,
|
|
121
|
+
parse_page_pattern
|
|
122
|
+
};
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
|
@@ -1,53 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { createServerAdapter as createAdapter } from "@whatwg-node/server";
|
|
2
|
+
import { parse, execute } from "graphql";
|
|
3
|
+
import { createYoga } from "graphql-yoga";
|
|
4
|
+
import client from "../../../src/+client";
|
|
5
|
+
import { localApiSessionKeys, localApiEndpoint, getCurrentConfig } from "../lib/config";
|
|
6
|
+
import { find_match } from "./match";
|
|
7
|
+
import { get_session, handle_request } from "./session";
|
|
8
|
+
const config_file = getCurrentConfig();
|
|
9
|
+
const session_keys = localApiSessionKeys(config_file);
|
|
10
|
+
const graphqlEndpoint = localApiEndpoint(config_file);
|
|
11
|
+
const serverAdapterFactory = ({
|
|
12
|
+
schema,
|
|
13
|
+
yoga,
|
|
14
|
+
production,
|
|
15
|
+
manifest,
|
|
16
|
+
on_render,
|
|
17
|
+
pipe,
|
|
18
|
+
assetPrefix
|
|
19
|
+
}) => {
|
|
20
|
+
if (schema && !yoga) {
|
|
21
|
+
yoga = createYoga({
|
|
22
|
+
schema,
|
|
23
|
+
landingPage: !production,
|
|
24
|
+
graphqlEndpoint
|
|
25
|
+
});
|
|
7
26
|
}
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
await set_session(args, session);
|
|
14
|
-
if (redirectTo) {
|
|
15
|
-
return args.redirect(302, redirectTo);
|
|
27
|
+
if (schema) {
|
|
28
|
+
client.registerProxy(graphqlEndpoint, async ({ query, variables, session }) => {
|
|
29
|
+
const parsed = parse(query);
|
|
30
|
+
return await execute(schema, parsed, null, session, variables);
|
|
31
|
+
});
|
|
16
32
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const serialized = await encode(value, req.session_keys[0]);
|
|
24
|
-
req.set_header(
|
|
25
|
-
"Set-Cookie",
|
|
26
|
-
`${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
async function get_session(req, secrets) {
|
|
30
|
-
const cookies = req.get("cookie");
|
|
31
|
-
if (!cookies) {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
const cookie = parse(cookies)[session_cookie_name];
|
|
35
|
-
if (!cookie) {
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
for (const secret of secrets) {
|
|
39
|
-
if (!await verify(cookie, secret)) {
|
|
40
|
-
continue;
|
|
33
|
+
return createAdapter(async (request) => {
|
|
34
|
+
if (!manifest) {
|
|
35
|
+
return new Response(
|
|
36
|
+
"Adapter did not provide the project's manifest. Please open an issue on github.",
|
|
37
|
+
{ status: 500 }
|
|
38
|
+
);
|
|
41
39
|
}
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
40
|
+
const url = new URL(request.url).pathname;
|
|
41
|
+
if (yoga && url === localApiEndpoint(config_file)) {
|
|
42
|
+
return yoga(request);
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const authResponse = await handle_request({
|
|
45
|
+
url,
|
|
46
|
+
config: config_file,
|
|
47
|
+
session_keys,
|
|
48
|
+
headers: request.headers
|
|
49
|
+
});
|
|
50
|
+
if (authResponse) {
|
|
51
|
+
return authResponse;
|
|
52
|
+
}
|
|
53
|
+
const [match] = find_match(manifest, url);
|
|
54
|
+
const rendered = await on_render({
|
|
55
|
+
url,
|
|
56
|
+
match,
|
|
57
|
+
session: await get_session(request.headers, session_keys),
|
|
58
|
+
manifest,
|
|
59
|
+
pipe
|
|
60
|
+
});
|
|
61
|
+
if (rendered) {
|
|
62
|
+
console.log(url, rendered);
|
|
63
|
+
return rendered;
|
|
64
|
+
}
|
|
65
|
+
return new Response("404", { status: 404 });
|
|
66
|
+
});
|
|
67
|
+
};
|
|
50
68
|
export {
|
|
51
|
-
|
|
52
|
-
handle_request
|
|
69
|
+
serverAdapterFactory
|
|
53
70
|
};
|
|
@@ -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,52 @@
|
|
|
1
|
+
import { parse } from "./cookies";
|
|
2
|
+
import { decode, encode, verify } from "./jwt";
|
|
3
|
+
async function handle_request(args) {
|
|
4
|
+
const plugin_config = args.config.router ?? {};
|
|
5
|
+
if (plugin_config.auth && "redirect" in plugin_config.auth && args.url.startsWith(plugin_config.auth.redirect)) {
|
|
6
|
+
return await redirect_auth(args);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
async function redirect_auth(args) {
|
|
10
|
+
const { searchParams } = new URL(args.url, `http://${args.headers.get("host")}`);
|
|
11
|
+
const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
|
|
12
|
+
if (redirectTo) {
|
|
13
|
+
const response = Response.redirect(redirectTo, 302);
|
|
14
|
+
await set_session(args, response, session);
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const session_cookie_name = "__houdini__";
|
|
19
|
+
async function set_session(req, response, value) {
|
|
20
|
+
const today = new Date();
|
|
21
|
+
const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
|
|
22
|
+
const serialized = await encode(value, req.session_keys[0]);
|
|
23
|
+
response.headers.set(
|
|
24
|
+
"Set-Cookie",
|
|
25
|
+
`${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
async function get_session(req, secrets) {
|
|
29
|
+
const cookies = req.get("cookie");
|
|
30
|
+
if (!cookies) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
const cookie = parse(cookies)[session_cookie_name];
|
|
34
|
+
if (!cookie) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
for (const secret of secrets) {
|
|
38
|
+
if (!await verify(cookie, secret)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const parsed = decode(cookie);
|
|
42
|
+
if (!parsed) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
return parsed.payload;
|
|
46
|
+
}
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
get_session,
|
|
51
|
+
handle_request
|
|
52
|
+
};
|
|
@@ -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
|
+
};
|
|
File without changes
|
package/build/test-cjs/index.js
CHANGED
|
@@ -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;
|
|
@@ -57118,7 +57117,7 @@ var LogLevel = {
|
|
|
57118
57117
|
|
|
57119
57118
|
// src/lib/config.ts
|
|
57120
57119
|
var import_meta = {};
|
|
57121
|
-
var currentDir =
|
|
57120
|
+
var currentDir = dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
57122
57121
|
var Config = class {
|
|
57123
57122
|
filepath;
|
|
57124
57123
|
rootDir;
|
|
@@ -57977,13 +57976,10 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
57977
57976
|
// src/lib/walk.ts
|
|
57978
57977
|
var graphql4 = __toESM(require("graphql"), 1);
|
|
57979
57978
|
|
|
57980
|
-
// src/router/manifest.ts
|
|
57979
|
+
// src/lib/router/manifest.ts
|
|
57981
57980
|
var t = __toESM(require_lib6(), 1);
|
|
57982
57981
|
var graphql5 = __toESM(require("graphql"), 1);
|
|
57983
57982
|
|
|
57984
|
-
// src/router/server.ts
|
|
57985
|
-
var import_vite = require("vite");
|
|
57986
|
-
|
|
57987
57983
|
// src/codegen/generators/artifacts/index.ts
|
|
57988
57984
|
var graphql15 = __toESM(require("graphql"), 1);
|
|
57989
57985
|
var recast5 = __toESM(require_main2(), 1);
|
|
@@ -58990,9 +58986,11 @@ function serializeValue(value) {
|
|
|
58990
58986
|
}
|
|
58991
58987
|
if (typeof value === "object" && value !== null) {
|
|
58992
58988
|
return AST4.objectExpression(
|
|
58993
|
-
Object.entries(value).filter(
|
|
58994
|
-
([key, value2]) =>
|
|
58995
|
-
)
|
|
58989
|
+
Object.entries(value).filter(
|
|
58990
|
+
([key, value2]) => typeof value2 !== "undefined" && key !== "prev" && key !== "next"
|
|
58991
|
+
).map(([key, val]) => {
|
|
58992
|
+
return AST4.objectProperty(AST4.stringLiteral(key), serializeValue(val));
|
|
58993
|
+
})
|
|
58996
58994
|
);
|
|
58997
58995
|
}
|
|
58998
58996
|
if (typeof value === "string") {
|
|
@@ -59539,7 +59537,7 @@ async function paginate(config2, documents) {
|
|
|
59539
59537
|
value: "__typename"
|
|
59540
59538
|
}
|
|
59541
59539
|
},
|
|
59542
|
-
...(typeConfig?.keys || [
|
|
59540
|
+
...(typeConfig?.keys || [config2.defaultKeys[0]]).map((key) => ({
|
|
59543
59541
|
kind: graphql11.Kind.FIELD,
|
|
59544
59542
|
name: {
|
|
59545
59543
|
kind: graphql11.Kind.NAME,
|
|
@@ -63223,7 +63221,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
63223
63221
|
if (missing.length > 0) {
|
|
63224
63222
|
ctx.reportError(
|
|
63225
63223
|
new graphql26.GraphQLError(
|
|
63226
|
-
|
|
63224
|
+
`The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
|
|
63227
63225
|
)
|
|
63228
63226
|
);
|
|
63229
63227
|
return;
|
|
@@ -63459,7 +63457,7 @@ function nodeDirectives(config2, directives) {
|
|
|
63459
63457
|
}
|
|
63460
63458
|
if (!possibleNodes.includes(definitionType)) {
|
|
63461
63459
|
ctx.reportError(
|
|
63462
|
-
new graphql26.GraphQLError(paginateOnNonNodeMessage(
|
|
63460
|
+
new graphql26.GraphQLError(paginateOnNonNodeMessage(node.name.value))
|
|
63463
63461
|
);
|
|
63464
63462
|
}
|
|
63465
63463
|
}
|
|
@@ -63594,45 +63592,45 @@ function getAndVerifyNodeInterface(config2) {
|
|
|
63594
63592
|
return null;
|
|
63595
63593
|
}
|
|
63596
63594
|
if (!graphql26.isInterfaceType(nodeInterface)) {
|
|
63597
|
-
displayInvalidNodeFieldMessage(config2
|
|
63595
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63598
63596
|
return null;
|
|
63599
63597
|
}
|
|
63600
63598
|
const queryType = schema.getQueryType();
|
|
63601
63599
|
if (!queryType) {
|
|
63602
|
-
displayInvalidNodeFieldMessage(config2
|
|
63600
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63603
63601
|
return null;
|
|
63604
63602
|
}
|
|
63605
63603
|
const nodeField = queryType.getFields()["node"];
|
|
63606
63604
|
if (!nodeField) {
|
|
63607
|
-
displayInvalidNodeFieldMessage(config2
|
|
63605
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63608
63606
|
return null;
|
|
63609
63607
|
}
|
|
63610
63608
|
const args = nodeField.args;
|
|
63611
63609
|
if (args.length === 0) {
|
|
63612
|
-
displayInvalidNodeFieldMessage(config2
|
|
63610
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63613
63611
|
return null;
|
|
63614
63612
|
}
|
|
63615
|
-
const idArg = args.find((arg) => arg.name ===
|
|
63613
|
+
const idArg = args.find((arg) => arg.name === config2.defaultKeys[0]);
|
|
63616
63614
|
if (!idArg) {
|
|
63617
|
-
displayInvalidNodeFieldMessage(config2
|
|
63615
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63618
63616
|
return null;
|
|
63619
63617
|
}
|
|
63620
63618
|
const idType = unwrapType(config2, idArg.type);
|
|
63621
63619
|
if (idType.type.name !== "ID") {
|
|
63622
|
-
displayInvalidNodeFieldMessage(config2
|
|
63620
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63623
63621
|
return null;
|
|
63624
63622
|
}
|
|
63625
63623
|
const fieldReturnType = unwrapType(config2, nodeField.type);
|
|
63626
63624
|
if (fieldReturnType.type.name !== "Node") {
|
|
63627
|
-
displayInvalidNodeFieldMessage(config2
|
|
63625
|
+
displayInvalidNodeFieldMessage(config2);
|
|
63628
63626
|
return null;
|
|
63629
63627
|
}
|
|
63630
63628
|
return nodeInterface;
|
|
63631
63629
|
}
|
|
63632
63630
|
var nbInvalidNodeFieldMessageDisplayed = 0;
|
|
63633
|
-
function displayInvalidNodeFieldMessage(
|
|
63631
|
+
function displayInvalidNodeFieldMessage(config2) {
|
|
63634
63632
|
if (nbInvalidNodeFieldMessageDisplayed === 0) {
|
|
63635
|
-
if (logLevel === LogLevel.Full) {
|
|
63633
|
+
if (config2.logLevel === LogLevel.Full) {
|
|
63636
63634
|
console.warn(invalidNodeFieldMessage);
|
|
63637
63635
|
} else {
|
|
63638
63636
|
console.warn(invalidNodeFieldMessageLight);
|
|
@@ -63646,18 +63644,18 @@ var invalidNodeFieldMessage = `\u26A0\uFE0F Your project defines a Node interfa
|
|
|
63646
63644
|
If you are trying to provide the Node interface and its field, they must look like the following:
|
|
63647
63645
|
|
|
63648
63646
|
interface Node {
|
|
63649
|
-
|
|
63647
|
+
id: ID!
|
|
63650
63648
|
}
|
|
63651
63649
|
|
|
63652
63650
|
extend type Query {
|
|
63653
|
-
|
|
63651
|
+
node(id: ID!): Node
|
|
63654
63652
|
}
|
|
63655
63653
|
|
|
63656
63654
|
For more information, please visit these links:
|
|
63657
63655
|
- https://graphql.org/learn/global-object-identification/
|
|
63658
63656
|
- ${siteURL}/guides/caching-data#custom-ids
|
|
63659
63657
|
`;
|
|
63660
|
-
var paginateOnNonNodeMessage = (
|
|
63658
|
+
var paginateOnNonNodeMessage = (directiveName) => `It looks like you are trying to use @${directiveName} on a document that does not have a valid type resolver.
|
|
63661
63659
|
If this is happening inside of a fragment, make sure that the fragment either implements the Node interface or you
|
|
63662
63660
|
have defined a resolver entry for the fragment type.
|
|
63663
63661
|
|
|
@@ -63887,6 +63885,10 @@ function testConfigFile({ plugins, ...config2 } = {}) {
|
|
|
63887
63885
|
|
|
63888
63886
|
directive @live on QUERY
|
|
63889
63887
|
|
|
63888
|
+
input MyInput {
|
|
63889
|
+
string: String
|
|
63890
|
+
}
|
|
63891
|
+
|
|
63890
63892
|
type User implements Node & Friend & CatOwner {
|
|
63891
63893
|
id: ID!
|
|
63892
63894
|
name: String!
|