eddev 0.2.0-beta.36 → 0.2.0-beta.39
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/get-webpack-config.js +1 -0
- package/build/serverless/create-next-app.js +0 -1
- package/build/workers/codegen-worker-script.js +31 -0
- package/entry/entry.serverless.dev.d.ts +0 -0
- package/entry/entry.serverless.dev.js +2 -0
- package/package.json +2 -2
- package/serverless/create-rpc-client.d.ts +18 -5
- package/serverless/define-rpc-router.d.ts +3 -1
- package/serverless/define-rpc-router.js +2 -0
- package/serverless-template/package.json +1 -1
- package/serverless-template/pages/api/trpc/[...trpc].ts +4 -4
- package/hooks/rpc-client.d.ts +0 -3
- package/hooks/rpc-client.js +0 -15
- package/serverless/rpc-client.d.ts +0 -3
- package/serverless/rpc-client.js +0 -15
|
@@ -130,6 +130,7 @@ function getWebpackConfig(opts) {
|
|
|
130
130
|
ALIAS["@views"] = path_1.default.join(opts.baseDirectory, "views");
|
|
131
131
|
ALIAS["@hooks"] = path_1.default.join(opts.baseDirectory, "hooks");
|
|
132
132
|
ALIAS["@queries"] = path_1.default.join(opts.baseDirectory, "hooks/queries");
|
|
133
|
+
ALIAS["@utils"] = path_1.default.join(opts.baseDirectory, "utils");
|
|
133
134
|
RULES.push({
|
|
134
135
|
test: /\.[jt]sx?$/,
|
|
135
136
|
exclude: /node_modules/,
|
|
@@ -339,7 +339,6 @@ function writeAPIProxies(sourceFolder, targetFolder) {
|
|
|
339
339
|
function syncAPIProxies(sourceFolder, targetFolder) {
|
|
340
340
|
return __awaiter(this, void 0, void 0, function () {
|
|
341
341
|
return __generator(this, function (_a) {
|
|
342
|
-
console.log("Syncing files", sourceFolder, targetFolder);
|
|
343
342
|
return [2 /*return*/, syncFiles(sourceFolder, targetFolder, ["**/*"], function (inputPath) {
|
|
344
343
|
if (inputPath.includes("_rpc"))
|
|
345
344
|
return null;
|
|
@@ -150,6 +150,7 @@ function beginWork(opts) {
|
|
|
150
150
|
schemaDescription: false,
|
|
151
151
|
specifiedByUrl: true,
|
|
152
152
|
});
|
|
153
|
+
processSchema(schema);
|
|
153
154
|
hash = JSON.stringify(schema);
|
|
154
155
|
if (hash !== lastSchemaHash) {
|
|
155
156
|
lastSchemaHash = hash;
|
|
@@ -577,4 +578,34 @@ function debounce(wait, fn) {
|
|
|
577
578
|
};
|
|
578
579
|
return debounced;
|
|
579
580
|
}
|
|
581
|
+
function processSchema(schema) {
|
|
582
|
+
var walkFields = function (fields) { };
|
|
583
|
+
var updateFieldType = function (fieldType) {
|
|
584
|
+
var _a;
|
|
585
|
+
if (fieldType.kind === "LIST") {
|
|
586
|
+
if (((_a = fieldType.ofType) === null || _a === void 0 ? void 0 : _a.kind) !== "NON_NULL") {
|
|
587
|
+
fieldType.ofType = {
|
|
588
|
+
kind: "NON_NULL",
|
|
589
|
+
name: null,
|
|
590
|
+
ofType: fieldType.ofType,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
var updateType = function (type) {
|
|
596
|
+
if (typeof type.type === "object" && type.type) {
|
|
597
|
+
updateFieldType(type.type);
|
|
598
|
+
}
|
|
599
|
+
if (type.fields) {
|
|
600
|
+
for (var _i = 0, _a = type.fields; _i < _a.length; _i++) {
|
|
601
|
+
var field = _a[_i];
|
|
602
|
+
updateType(field);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
for (var _i = 0, _a = schema.__schema.types; _i < _a.length; _i++) {
|
|
607
|
+
var type = _a[_i];
|
|
608
|
+
updateType(type);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
580
611
|
beginWork(worker_threads_1.workerData);
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eddev",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.39",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@types/url-parse": "^1.4.4",
|
|
28
28
|
"@types/webpack-dev-server": "^3.11.2",
|
|
29
29
|
"csstype": "^3.0.9",
|
|
30
|
-
"next": "12.0
|
|
30
|
+
"next": "^12.1.0",
|
|
31
31
|
"react-html-props": "^1.0.32"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare function createRPCClient(): {
|
|
2
3
|
Provider: ({ client, queryClient, children, isPrepass, ssrContext, }: {
|
|
3
|
-
queryClient:
|
|
4
|
+
queryClient: QueryClient;
|
|
4
5
|
client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>;
|
|
5
6
|
children: import("react").ReactNode;
|
|
6
7
|
isPrepass?: boolean | undefined;
|
|
@@ -8,13 +9,25 @@ export declare function createRPCClient(): {
|
|
|
8
9
|
}) => JSX.Element;
|
|
9
10
|
createClient: (opts: import("@trpc/react").CreateTRPCClientOptions<import("@trpc/server").AnyRouter<any>>) => import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>;
|
|
10
11
|
useContext: () => import("@trpc/react/dist/declarations/src/internals/context").TRPCContextState<import("@trpc/server").AnyRouter<any>, unknown>;
|
|
11
|
-
useQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, unknown, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) =>
|
|
12
|
-
|
|
12
|
+
useQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, unknown, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) => UseQueryResult<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
13
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
14
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
15
|
+
}; }[TPath_2]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
16
|
+
useMutation: <TPath_1 extends string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<unknown, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>, any> | undefined) => UseMutationResult<{ [TPath_3 in keyof TRouter["_def"]["mutations"]]: {
|
|
17
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_3]>;
|
|
18
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_3]["call"]>>;
|
|
19
|
+
}; }[TPath_1_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_3 in keyof TRouter["_def"]["mutations"]]: {
|
|
20
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_3]>;
|
|
21
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_3]["call"]>>;
|
|
22
|
+
}; }[TPath_1_1]["input"], unknown>;
|
|
13
23
|
useSubscription: <TPath_2 extends string, TOutput extends any>(pathAndInput: [TPath_2, (null | undefined)?], opts: {
|
|
14
24
|
enabled?: boolean | undefined;
|
|
15
25
|
onError?: ((err: import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>) => void) | undefined;
|
|
16
26
|
onNext: (data: TOutput) => void;
|
|
17
27
|
}) => void;
|
|
18
|
-
useDehydratedState: (client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>, trpcState:
|
|
19
|
-
useInfiniteQuery: <TPath_3 extends never>(pathAndInput: [path: TPath_3, input: Omit<unknown, "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<unknown, "cursor">, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) =>
|
|
28
|
+
useDehydratedState: (client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>, trpcState: any) => any;
|
|
29
|
+
useInfiniteQuery: <TPath_3 extends never>(pathAndInput: [path: TPath_3, input: Omit<unknown, "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<unknown, "cursor">, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) => UseInfiniteQueryResult<{ [TPath_1 in keyof TRouter["_def"]["queries"]]: {
|
|
30
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
31
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
32
|
+
}; }[TPath_3_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
20
33
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as trpc from "@trpc/server";
|
|
2
2
|
import * as trpcNext from "@trpc/server/adapters/next";
|
|
3
|
-
|
|
3
|
+
declare const createRouter: () => import("@trpc/server/dist/declarations/src/router").Router<RPCContextType, RPCContextType, {}, {}, {}, trpc.DefaultErrorShape>;
|
|
4
|
+
export declare function defineRPC<TCreator extends (base: ReturnType<typeof createRouter>, z: typeof import("zod")) => any>(creator: TCreator): ReturnType<TCreator>;
|
|
4
5
|
export declare function defineRPCContextCreator<TCreator extends (opts: trpcNext.CreateNextContextOptions) => any>(creator: TCreator): TCreator;
|
|
6
|
+
export {};
|
|
@@ -23,6 +23,8 @@ exports.defineRPCContextCreator = exports.defineRPC = void 0;
|
|
|
23
23
|
var trpc = __importStar(require("@trpc/server"));
|
|
24
24
|
var z = __importStar(require("zod"));
|
|
25
25
|
// @ts-ignore
|
|
26
|
+
var createRouter = function () { return trpc.router(); };
|
|
27
|
+
// @ts-ignore
|
|
26
28
|
function defineRPC(creator) {
|
|
27
29
|
return creator(trpc.router(), z);
|
|
28
30
|
}
|
|
@@ -12,11 +12,11 @@ export default function (req: NextApiRequest, res: NextApiResponse) {
|
|
|
12
12
|
// TODO: Use an origin whitelist
|
|
13
13
|
const origin = req.headers.origin
|
|
14
14
|
if (origin) {
|
|
15
|
+
res.setHeader("Access-Control-Allow-Origin", "*")
|
|
16
|
+
res.setHeader("Access-Control-Request-Method", "*")
|
|
17
|
+
res.setHeader("Access-Control-Request-Method", "OPTIONS, GET, POST")
|
|
18
|
+
res.setHeader("Access-Control-Allow-Headers", "*")
|
|
15
19
|
if (req.method === "OPTIONS") {
|
|
16
|
-
res.setHeader("Access-Control-Allow-Origin", "*")
|
|
17
|
-
res.setHeader("Access-Control-Request-Method", "*")
|
|
18
|
-
res.setHeader("Access-Control-Request-Method", "OPTIONS, GET, POST")
|
|
19
|
-
res.setHeader("Access-Control-Allow-Headers", "*")
|
|
20
20
|
res.writeHead(200)
|
|
21
21
|
res.end()
|
|
22
22
|
return
|
package/hooks/rpc-client.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const useRPCQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, RPCRouter, RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>> | undefined) => import("react-query").UseQueryResult<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>>;
|
|
2
|
-
export declare const useRPCMutation: <TPath_1 extends string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>, RPCRouter> | undefined) => import("react-query").UseMutationResult<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>, RPCRouter, unknown>;
|
|
3
|
-
export declare const rpcClient: import("@trpc/react").TRPCClient<RPCRouter>;
|
package/hooks/rpc-client.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rpcClient = exports.useRPCMutation = exports.useRPCQuery = void 0;
|
|
4
|
-
var react_1 = require("@trpc/react");
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
var _a = (0, react_1.createReactQueryHooks)({
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
url: process.serverlessEndpoint + "/api/trpc",
|
|
9
|
-
}), useQuery = _a.useQuery, useMutation = _a.useMutation, createClient = _a.createClient;
|
|
10
|
-
exports.useRPCQuery = useQuery;
|
|
11
|
-
exports.useRPCMutation = useMutation;
|
|
12
|
-
exports.rpcClient = createClient({
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
url: process.serverlessEndpoint + "/api/trpc",
|
|
15
|
-
});
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const useRPCQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, RPCRouter, RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>> | undefined) => import("react-query").UseQueryResult<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>>;
|
|
2
|
-
export declare const useRPCMutation: <TPath_1 extends string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>, RPCRouter> | undefined) => import("react-query").UseMutationResult<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>, RPCRouter, unknown>;
|
|
3
|
-
export declare const rpcClient: import("@trpc/react").TRPCClient<RPCRouter>;
|
package/serverless/rpc-client.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rpcClient = exports.useRPCMutation = exports.useRPCQuery = void 0;
|
|
4
|
-
var react_1 = require("@trpc/react");
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
var _a = (0, react_1.createReactQueryHooks)({
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
url: process.serverlessEndpoint + "/api/trpc",
|
|
9
|
-
}), useQuery = _a.useQuery, useMutation = _a.useMutation, createClient = _a.createClient;
|
|
10
|
-
exports.useRPCQuery = useQuery;
|
|
11
|
-
exports.useRPCMutation = useMutation;
|
|
12
|
-
exports.rpcClient = createClient({
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
url: process.serverlessEndpoint + "/api/trpc",
|
|
15
|
-
});
|