wexts 4.1.5 → 4.1.7
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/README.md +49 -49
- package/bin/wexts.cjs +2 -2
- package/dist/chunk-27NEYQD2.mjs +222 -0
- package/dist/chunk-27NEYQD2.mjs.map +1 -0
- package/dist/chunk-2LJVUMXW.js +228 -0
- package/dist/chunk-2LJVUMXW.js.map +1 -0
- package/dist/chunk-5DBFN65W.mjs +183 -0
- package/dist/chunk-5DBFN65W.mjs.map +1 -0
- package/dist/chunk-75HBI2XG.js +504 -0
- package/dist/chunk-75HBI2XG.js.map +1 -0
- package/dist/chunk-AVMQJWYD.js +95 -0
- package/dist/chunk-AVMQJWYD.js.map +1 -0
- package/dist/chunk-C2AG7Q3C.mjs +65 -0
- package/dist/chunk-C2AG7Q3C.mjs.map +1 -0
- package/dist/chunk-DS5KVVWJ.mjs +95 -0
- package/dist/chunk-DS5KVVWJ.mjs.map +1 -0
- package/dist/chunk-FUPLZMSR.mjs +228 -0
- package/dist/chunk-FUPLZMSR.mjs.map +1 -0
- package/dist/chunk-HLT3IHJY.js +183 -0
- package/dist/chunk-HLT3IHJY.js.map +1 -0
- package/dist/chunk-IRRJJ7KL.js +273 -0
- package/dist/chunk-IRRJJ7KL.js.map +1 -0
- package/dist/chunk-L77ANWWT.mjs +22 -0
- package/dist/chunk-L77ANWWT.mjs.map +1 -0
- package/dist/chunk-P3Q4I5FD.js +222 -0
- package/dist/chunk-P3Q4I5FD.js.map +1 -0
- package/dist/chunk-VBIQGUDI.mjs +504 -0
- package/dist/chunk-VBIQGUDI.mjs.map +1 -0
- package/dist/chunk-VJY6PHYF.mjs +273 -0
- package/dist/chunk-VJY6PHYF.mjs.map +1 -0
- package/dist/chunk-WCKSKU3C.js +65 -0
- package/dist/chunk-WCKSKU3C.js.map +1 -0
- package/dist/chunk-XE4OXN2W.js +12 -0
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/cli/index.d.mts +23 -0
- package/dist/cli/index.d.ts +23 -0
- package/dist/cli/index.js +634 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +636 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client/index.d.mts +43 -0
- package/dist/client/index.d.ts +43 -0
- package/dist/client/index.js +187 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +166 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/codegen/index.d.mts +2 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +16 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/index.mjs +16 -0
- package/dist/codegen/index.mjs.map +1 -0
- package/dist/decorators-BiQtOHuF.d.ts +60 -0
- package/dist/decorators-vBopODtr.d.mts +60 -0
- package/dist/dev-server/index.d.mts +1 -0
- package/dist/dev-server/index.d.ts +1 -0
- package/dist/dev-server/index.js +13 -0
- package/dist/dev-server/index.js.map +1 -0
- package/dist/dev-server/index.mjs +13 -0
- package/dist/dev-server/index.mjs.map +1 -0
- package/dist/errors-D545UvXf.d.mts +37 -0
- package/dist/errors-D545UvXf.d.ts +37 -0
- package/dist/index-7RvU-jGE.d.mts +66 -0
- package/dist/index-7RvU-jGE.d.ts +66 -0
- package/dist/index-BsafLP-a.d.mts +70 -0
- package/dist/index-BsafLP-a.d.ts +70 -0
- package/dist/index-CJKs4wtN.d.ts +92 -0
- package/dist/index-CUR6CnLk.d.ts +27 -0
- package/dist/index-h66Vq9dK.d.mts +92 -0
- package/dist/index-tqmYsTUn.d.mts +27 -0
- package/dist/index.d.mts +289 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +544 -0
- package/dist/index.mjs.map +1 -0
- package/dist/nest/index.d.mts +2 -0
- package/dist/nest/index.d.ts +2 -0
- package/dist/nest/index.js +36 -0
- package/dist/nest/index.js.map +1 -0
- package/dist/nest/index.mjs +36 -0
- package/dist/nest/index.mjs.map +1 -0
- package/dist/next/index.d.mts +66 -0
- package/dist/next/index.d.ts +66 -0
- package/dist/next/index.js +282 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/index.mjs +251 -0
- package/dist/next/index.mjs.map +1 -0
- package/dist/rpc/index.d.mts +32 -0
- package/dist/rpc/index.d.ts +32 -0
- package/dist/rpc/index.js +19 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/index.mjs +1 -0
- package/dist/rpc/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +55 -0
- package/dist/runtime/index.d.ts +55 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +15 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/server/index.d.mts +7 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +58 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +58 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/types/index.d.mts +12 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types-CQ_aexOX.d.mts +32 -0
- package/dist/types-CQ_aexOX.d.ts +32 -0
- package/dist/vercel-builder/index.d.mts +58 -0
- package/dist/vercel-builder/index.d.ts +58 -0
- package/dist/vercel-builder/index.js +330 -0
- package/dist/vercel-builder/index.js.map +1 -0
- package/dist/vercel-builder/index.mjs +330 -0
- package/dist/vercel-builder/index.mjs.map +1 -0
- package/package.json +153 -153
- package/templates/.dockerignore +43 -43
- package/templates/.env.example +17 -17
- package/templates/Dockerfile +60 -60
- package/templates/Procfile +1 -1
- package/templates/README.md +67 -67
- package/templates/api-sdk.ts +115 -115
- package/templates/docker-compose.yml +34 -34
- package/templates/nestjs-api/.env.example +3 -3
- package/templates/nestjs-api/README.md +87 -87
- package/templates/nestjs-api/nest-cli.json +6 -6
- package/templates/nestjs-api/package.json +40 -40
- package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +24 -24
- package/templates/nestjs-api/prisma/migrations/migration_lock.toml +3 -3
- package/templates/nestjs-api/prisma/schema.prisma +29 -29
- package/templates/nestjs-api/src/app.module.ts +19 -17
- package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
- package/templates/nestjs-api/src/auth/auth.module.ts +37 -37
- package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
- package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
- package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
- package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -27
- package/templates/nestjs-api/src/hello.service.ts +11 -0
- package/templates/nestjs-api/src/main.ts +32 -32
- package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
- package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
- package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
- package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
- package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
- package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
- package/templates/nestjs-api/src/users/users.controller.ts +14 -14
- package/templates/nestjs-api/src/users/users.module.ts +12 -12
- package/templates/nestjs-api/src/users/users.service.ts +19 -19
- package/templates/nestjs-api/tsconfig.json +39 -39
- package/templates/nextjs-web/README.md +76 -76
- package/templates/nextjs-web/app/actions/auth.ts +108 -108
- package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
- package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
- package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
- package/templates/nextjs-web/app/globals.css +93 -93
- package/templates/nextjs-web/app/layout.tsx +29 -29
- package/templates/nextjs-web/app/login/page.tsx +5 -5
- package/templates/nextjs-web/app/page.tsx +138 -28
- package/templates/nextjs-web/app/register/page.tsx +5 -5
- package/templates/nextjs-web/components/ui/button.tsx +56 -56
- package/templates/nextjs-web/components/ui/card.tsx +79 -79
- package/templates/nextjs-web/components/ui/input.tsx +25 -25
- package/templates/nextjs-web/components/ui/label.tsx +24 -24
- package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
- package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
- package/templates/nextjs-web/features/auth/api.ts +35 -35
- package/templates/nextjs-web/features/auth/index.ts +3 -3
- package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
- package/templates/nextjs-web/features/dashboard/api.ts +9 -9
- package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
- package/templates/nextjs-web/features/dashboard/index.ts +3 -3
- package/templates/nextjs-web/hooks/index.ts +4 -4
- package/templates/nextjs-web/lib/api-client.ts +89 -89
- package/templates/nextjs-web/lib/api.ts +115 -115
- package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
- package/templates/nextjs-web/lib/utils.ts +6 -6
- package/templates/nextjs-web/lib/wexts-client.ts +4 -4
- package/templates/nextjs-web/next-env.d.ts +6 -6
- package/templates/nextjs-web/next.config.ts +20 -20
- package/templates/nextjs-web/package.json +37 -37
- package/templates/nextjs-web/postcss.config.js +6 -6
- package/templates/nextjs-web/tailwind.config.ts +69 -69
- package/templates/nextjs-web/tsconfig.json +41 -41
- package/templates/nixpacks.toml +11 -11
- package/templates/root-package.json +31 -31
- package/templates/server.ts +66 -66
- package/templates/tsconfig.json +30 -30
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FusionController,
|
|
3
|
+
FusionDelete,
|
|
4
|
+
FusionGet,
|
|
5
|
+
FusionPost,
|
|
6
|
+
FusionPut,
|
|
7
|
+
FusionRoute,
|
|
8
|
+
RequireAuth,
|
|
9
|
+
RpcMethod,
|
|
10
|
+
RpcService,
|
|
11
|
+
WextsRpc,
|
|
12
|
+
WextsRpcService,
|
|
13
|
+
getFusionMetadata,
|
|
14
|
+
getRpcAuthPolicy,
|
|
15
|
+
getRuntimeRpcMethodsMetadata,
|
|
16
|
+
getRuntimeRpcServiceMetadata
|
|
17
|
+
} from "../chunk-5DBFN65W.mjs";
|
|
18
|
+
import {
|
|
19
|
+
createWextsHandler,
|
|
20
|
+
createWextsRuntimeServer,
|
|
21
|
+
registerRpcRoutes,
|
|
22
|
+
startWextsRuntime
|
|
23
|
+
} from "../chunk-27NEYQD2.mjs";
|
|
24
|
+
import {
|
|
25
|
+
WextsError,
|
|
26
|
+
WextsRpcError,
|
|
27
|
+
WextsRuntimeError,
|
|
28
|
+
WextsSecurityError,
|
|
29
|
+
formatWextsError
|
|
30
|
+
} from "../chunk-DS5KVVWJ.mjs";
|
|
31
|
+
import "../chunk-L77ANWWT.mjs";
|
|
32
|
+
export {
|
|
33
|
+
FusionController,
|
|
34
|
+
FusionDelete,
|
|
35
|
+
FusionGet,
|
|
36
|
+
FusionPost,
|
|
37
|
+
FusionPut,
|
|
38
|
+
FusionRoute,
|
|
39
|
+
RequireAuth,
|
|
40
|
+
RpcMethod,
|
|
41
|
+
RpcService,
|
|
42
|
+
WextsError,
|
|
43
|
+
WextsRpc,
|
|
44
|
+
WextsRpcError,
|
|
45
|
+
WextsRpcService,
|
|
46
|
+
WextsRuntimeError,
|
|
47
|
+
WextsSecurityError,
|
|
48
|
+
createWextsHandler,
|
|
49
|
+
createWextsRuntimeServer,
|
|
50
|
+
formatWextsError,
|
|
51
|
+
getFusionMetadata,
|
|
52
|
+
getRpcAuthPolicy,
|
|
53
|
+
getRuntimeRpcMethodsMetadata,
|
|
54
|
+
getRuntimeRpcServiceMetadata,
|
|
55
|
+
registerRpcRoutes,
|
|
56
|
+
startWextsRuntime
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types/index.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export interface User {\n id: string;\n email: string;\n name?: string;\n}\n\nexport interface Todo {\n id: string;\n title: string;\n completed: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA;;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type RpcAuthPolicy = 'public' | 'required';
|
|
2
|
+
interface RpcParameterManifest {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
optional: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface RpcMethodManifest {
|
|
8
|
+
name: string;
|
|
9
|
+
handlerName: string;
|
|
10
|
+
requireAuth: boolean;
|
|
11
|
+
parameters: RpcParameterManifest[];
|
|
12
|
+
returnType: string;
|
|
13
|
+
}
|
|
14
|
+
interface RpcServiceManifest {
|
|
15
|
+
name: string;
|
|
16
|
+
className: string;
|
|
17
|
+
importPath: string;
|
|
18
|
+
requireAuth: boolean;
|
|
19
|
+
methods: RpcMethodManifest[];
|
|
20
|
+
}
|
|
21
|
+
interface RpcManifest {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
services: RpcServiceManifest[];
|
|
24
|
+
}
|
|
25
|
+
interface RpcInvocationRequest {
|
|
26
|
+
args: unknown[];
|
|
27
|
+
}
|
|
28
|
+
interface RpcInvocationResponse<T = unknown> {
|
|
29
|
+
data: T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { RpcAuthPolicy as R, RpcManifest as a, RpcInvocationRequest as b, RpcInvocationResponse as c, RpcMethodManifest as d, RpcParameterManifest as e, RpcServiceManifest as f };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type RpcAuthPolicy = 'public' | 'required';
|
|
2
|
+
interface RpcParameterManifest {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
optional: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface RpcMethodManifest {
|
|
8
|
+
name: string;
|
|
9
|
+
handlerName: string;
|
|
10
|
+
requireAuth: boolean;
|
|
11
|
+
parameters: RpcParameterManifest[];
|
|
12
|
+
returnType: string;
|
|
13
|
+
}
|
|
14
|
+
interface RpcServiceManifest {
|
|
15
|
+
name: string;
|
|
16
|
+
className: string;
|
|
17
|
+
importPath: string;
|
|
18
|
+
requireAuth: boolean;
|
|
19
|
+
methods: RpcMethodManifest[];
|
|
20
|
+
}
|
|
21
|
+
interface RpcManifest {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
services: RpcServiceManifest[];
|
|
24
|
+
}
|
|
25
|
+
interface RpcInvocationRequest {
|
|
26
|
+
args: unknown[];
|
|
27
|
+
}
|
|
28
|
+
interface RpcInvocationResponse<T = unknown> {
|
|
29
|
+
data: T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { RpcAuthPolicy as R, RpcManifest as a, RpcInvocationRequest as b, RpcInvocationResponse as c, RpcMethodManifest as d, RpcParameterManifest as e, RpcServiceManifest as f };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wexts Vercel Build Output API builder.
|
|
3
|
+
*
|
|
4
|
+
* Produces the `.vercel/output` tree (Build Output API v3) that Vercel
|
|
5
|
+
* uses for deployment. This module is invoked by `wexts vercel-build`.
|
|
6
|
+
*
|
|
7
|
+
* Layout produced:
|
|
8
|
+
* .vercel/output/
|
|
9
|
+
* config.json – { version: 3 }
|
|
10
|
+
* static/ – public / static assets copied here
|
|
11
|
+
* functions/
|
|
12
|
+
* index.func/
|
|
13
|
+
* index.js – serverless entry point
|
|
14
|
+
* package.json – { type: "module" } or cjs
|
|
15
|
+
* .vc-config.json – Vercel function config
|
|
16
|
+
* ...copied runtime files
|
|
17
|
+
*/
|
|
18
|
+
interface VercelBuildOptions {
|
|
19
|
+
/** Project root (cwd). Defaults to process.cwd(). */
|
|
20
|
+
rootDir?: string;
|
|
21
|
+
/** Path to NestJS/API project for codegen. */
|
|
22
|
+
apiProjectPath?: string;
|
|
23
|
+
/** Output directory for generated RPC client. */
|
|
24
|
+
rpcOutputPath?: string;
|
|
25
|
+
/** Path to wexts.runtime.js config. */
|
|
26
|
+
runtimeConfigPath?: string;
|
|
27
|
+
/** Node.js runtime version for the Vercel function. */
|
|
28
|
+
nodeVersion?: string;
|
|
29
|
+
/** Max duration in seconds for the serverless function. */
|
|
30
|
+
maxDuration?: number;
|
|
31
|
+
/** Memory size in MB for the serverless function. */
|
|
32
|
+
memory?: number;
|
|
33
|
+
/** Regions to deploy to. */
|
|
34
|
+
regions?: string[];
|
|
35
|
+
/** Skip the RPC codegen step. */
|
|
36
|
+
skipCodegen?: boolean;
|
|
37
|
+
/** Skip the Next.js / project build step. */
|
|
38
|
+
skipBuild?: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface VercelBuildResult {
|
|
41
|
+
outputDir: string;
|
|
42
|
+
configPath: string;
|
|
43
|
+
functionDir: string;
|
|
44
|
+
staticDir: string;
|
|
45
|
+
errors: string[];
|
|
46
|
+
warnings: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the `.vercel/output` directory from a Wexts project.
|
|
50
|
+
*/
|
|
51
|
+
declare function buildVercelOutput(options?: VercelBuildOptions): Promise<VercelBuildResult>;
|
|
52
|
+
interface ValidationResult {
|
|
53
|
+
errors: string[];
|
|
54
|
+
warnings: string[];
|
|
55
|
+
}
|
|
56
|
+
declare function validateOutput(outputDir: string): ValidationResult;
|
|
57
|
+
|
|
58
|
+
export { type ValidationResult, type VercelBuildOptions, type VercelBuildResult, buildVercelOutput, validateOutput };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wexts Vercel Build Output API builder.
|
|
3
|
+
*
|
|
4
|
+
* Produces the `.vercel/output` tree (Build Output API v3) that Vercel
|
|
5
|
+
* uses for deployment. This module is invoked by `wexts vercel-build`.
|
|
6
|
+
*
|
|
7
|
+
* Layout produced:
|
|
8
|
+
* .vercel/output/
|
|
9
|
+
* config.json – { version: 3 }
|
|
10
|
+
* static/ – public / static assets copied here
|
|
11
|
+
* functions/
|
|
12
|
+
* index.func/
|
|
13
|
+
* index.js – serverless entry point
|
|
14
|
+
* package.json – { type: "module" } or cjs
|
|
15
|
+
* .vc-config.json – Vercel function config
|
|
16
|
+
* ...copied runtime files
|
|
17
|
+
*/
|
|
18
|
+
interface VercelBuildOptions {
|
|
19
|
+
/** Project root (cwd). Defaults to process.cwd(). */
|
|
20
|
+
rootDir?: string;
|
|
21
|
+
/** Path to NestJS/API project for codegen. */
|
|
22
|
+
apiProjectPath?: string;
|
|
23
|
+
/** Output directory for generated RPC client. */
|
|
24
|
+
rpcOutputPath?: string;
|
|
25
|
+
/** Path to wexts.runtime.js config. */
|
|
26
|
+
runtimeConfigPath?: string;
|
|
27
|
+
/** Node.js runtime version for the Vercel function. */
|
|
28
|
+
nodeVersion?: string;
|
|
29
|
+
/** Max duration in seconds for the serverless function. */
|
|
30
|
+
maxDuration?: number;
|
|
31
|
+
/** Memory size in MB for the serverless function. */
|
|
32
|
+
memory?: number;
|
|
33
|
+
/** Regions to deploy to. */
|
|
34
|
+
regions?: string[];
|
|
35
|
+
/** Skip the RPC codegen step. */
|
|
36
|
+
skipCodegen?: boolean;
|
|
37
|
+
/** Skip the Next.js / project build step. */
|
|
38
|
+
skipBuild?: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface VercelBuildResult {
|
|
41
|
+
outputDir: string;
|
|
42
|
+
configPath: string;
|
|
43
|
+
functionDir: string;
|
|
44
|
+
staticDir: string;
|
|
45
|
+
errors: string[];
|
|
46
|
+
warnings: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the `.vercel/output` directory from a Wexts project.
|
|
50
|
+
*/
|
|
51
|
+
declare function buildVercelOutput(options?: VercelBuildOptions): Promise<VercelBuildResult>;
|
|
52
|
+
interface ValidationResult {
|
|
53
|
+
errors: string[];
|
|
54
|
+
warnings: string[];
|
|
55
|
+
}
|
|
56
|
+
declare function validateOutput(outputDir: string): ValidationResult;
|
|
57
|
+
|
|
58
|
+
export { type ValidationResult, type VercelBuildOptions, type VercelBuildResult, buildVercelOutput, validateOutput };
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkXE4OXN2Wjs = require('../chunk-XE4OXN2W.js');
|
|
4
|
+
|
|
5
|
+
// src/vercel-builder/index.ts
|
|
6
|
+
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
7
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
8
|
+
var _child_process = require('child_process');
|
|
9
|
+
async function buildVercelOutput(options = {}) {
|
|
10
|
+
const rootDir = path.resolve(_nullishCoalesce(options.rootDir, () => ( process.cwd())));
|
|
11
|
+
const outputDir = path.join(rootDir, ".vercel", "output");
|
|
12
|
+
const staticDir = path.join(outputDir, "static");
|
|
13
|
+
const functionDir = path.join(outputDir, "functions", "index.func");
|
|
14
|
+
const configPath = path.join(outputDir, "config.json");
|
|
15
|
+
const errors = [];
|
|
16
|
+
const warnings = [];
|
|
17
|
+
if (fs.existsSync(outputDir)) {
|
|
18
|
+
fs.rmSync(outputDir, {
|
|
19
|
+
recursive: true,
|
|
20
|
+
force: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (!options.skipCodegen) {
|
|
24
|
+
const apiDir = path.resolve(rootDir, _nullishCoalesce(options.apiProjectPath, () => ( "apps/api")));
|
|
25
|
+
const rpcOut = path.resolve(rootDir, _nullishCoalesce(options.rpcOutputPath, () => ( "apps/web/lib/wexts")));
|
|
26
|
+
if (fs.existsSync(apiDir)) {
|
|
27
|
+
console.log("\u{1F527} Running RPC codegen...");
|
|
28
|
+
const result = _child_process.spawnSync.call(void 0, "npx", [
|
|
29
|
+
"wexts",
|
|
30
|
+
"generate",
|
|
31
|
+
"-p",
|
|
32
|
+
apiDir,
|
|
33
|
+
"-o",
|
|
34
|
+
rpcOut
|
|
35
|
+
], {
|
|
36
|
+
cwd: rootDir,
|
|
37
|
+
stdio: "inherit",
|
|
38
|
+
shell: process.platform === "win32"
|
|
39
|
+
});
|
|
40
|
+
if (result.status !== 0) {
|
|
41
|
+
errors.push("RPC codegen failed.");
|
|
42
|
+
return {
|
|
43
|
+
outputDir,
|
|
44
|
+
configPath,
|
|
45
|
+
functionDir,
|
|
46
|
+
staticDir,
|
|
47
|
+
errors,
|
|
48
|
+
warnings
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
warnings.push(`API directory not found at ${apiDir}; skipping codegen.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!options.skipBuild) {
|
|
56
|
+
console.log("\u{1F3D7}\uFE0F Building project...");
|
|
57
|
+
const apiDir = path.resolve(rootDir, _nullishCoalesce(options.apiProjectPath, () => ( "apps/api")));
|
|
58
|
+
if (fs.existsSync(path.join(apiDir, "tsconfig.json"))) {
|
|
59
|
+
const tscResult = _child_process.spawnSync.call(void 0, "npx", [
|
|
60
|
+
"tsc",
|
|
61
|
+
"-p",
|
|
62
|
+
path.join(apiDir, "tsconfig.json")
|
|
63
|
+
], {
|
|
64
|
+
cwd: rootDir,
|
|
65
|
+
stdio: "inherit",
|
|
66
|
+
shell: process.platform === "win32"
|
|
67
|
+
});
|
|
68
|
+
if (tscResult.status !== 0) {
|
|
69
|
+
errors.push("API TypeScript compilation failed.");
|
|
70
|
+
return {
|
|
71
|
+
outputDir,
|
|
72
|
+
configPath,
|
|
73
|
+
functionDir,
|
|
74
|
+
staticDir,
|
|
75
|
+
errors,
|
|
76
|
+
warnings
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const webDir = path.resolve(rootDir, "apps/web");
|
|
81
|
+
if (fs.existsSync(webDir)) {
|
|
82
|
+
const nextResult = _child_process.spawnSync.call(void 0, "npx", [
|
|
83
|
+
"next",
|
|
84
|
+
"build",
|
|
85
|
+
webDir
|
|
86
|
+
], {
|
|
87
|
+
cwd: rootDir,
|
|
88
|
+
stdio: "inherit",
|
|
89
|
+
shell: process.platform === "win32",
|
|
90
|
+
env: {
|
|
91
|
+
...process.env,
|
|
92
|
+
NODE_ENV: "production"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
if (nextResult.status !== 0) {
|
|
96
|
+
errors.push("Next.js build failed.");
|
|
97
|
+
return {
|
|
98
|
+
outputDir,
|
|
99
|
+
configPath,
|
|
100
|
+
functionDir,
|
|
101
|
+
staticDir,
|
|
102
|
+
errors,
|
|
103
|
+
warnings
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
console.log("\u{1F4E6} Creating .vercel/output...");
|
|
109
|
+
fs.mkdirSync(functionDir, {
|
|
110
|
+
recursive: true
|
|
111
|
+
});
|
|
112
|
+
fs.mkdirSync(staticDir, {
|
|
113
|
+
recursive: true
|
|
114
|
+
});
|
|
115
|
+
const config = {
|
|
116
|
+
version: 3
|
|
117
|
+
};
|
|
118
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
119
|
+
const vcConfig = {
|
|
120
|
+
runtime: `nodejs${_nullishCoalesce(options.nodeVersion, () => ( "20"))}.x`,
|
|
121
|
+
handler: "index.js",
|
|
122
|
+
launcherType: "Nodejs",
|
|
123
|
+
maxDuration: _nullishCoalesce(options.maxDuration, () => ( 30)),
|
|
124
|
+
...options.memory ? {
|
|
125
|
+
memory: options.memory
|
|
126
|
+
} : {},
|
|
127
|
+
..._optionalChain([options, 'access', _ => _.regions, 'optionalAccess', _2 => _2.length]) ? {
|
|
128
|
+
regions: options.regions
|
|
129
|
+
} : {}
|
|
130
|
+
};
|
|
131
|
+
fs.writeFileSync(path.join(functionDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
|
|
132
|
+
const runtimeConfigSrc = path.resolve(rootDir, _nullishCoalesce(options.runtimeConfigPath, () => ( "wexts.runtime.js")));
|
|
133
|
+
const apiDistDir = path.resolve(rootDir, _nullishCoalesce(options.apiProjectPath, () => ( "apps/api")), "dist");
|
|
134
|
+
if (fs.existsSync(apiDistDir)) {
|
|
135
|
+
const targetApiDist = path.join(functionDir, "apps", "api", "dist");
|
|
136
|
+
fs.mkdirSync(path.dirname(targetApiDist), {
|
|
137
|
+
recursive: true
|
|
138
|
+
});
|
|
139
|
+
fs.cpSync(apiDistDir, targetApiDist, {
|
|
140
|
+
recursive: true
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
warnings.push("API dist not found; function may not have service implementations.");
|
|
144
|
+
}
|
|
145
|
+
const manifestCandidates = [
|
|
146
|
+
path.resolve(rootDir, _nullishCoalesce(options.rpcOutputPath, () => ( "apps/web/lib/wexts")), "wexts.rpc.manifest.json")
|
|
147
|
+
];
|
|
148
|
+
for (const manifestPath of manifestCandidates) {
|
|
149
|
+
if (fs.existsSync(manifestPath)) {
|
|
150
|
+
const relPath = path.relative(rootDir, manifestPath);
|
|
151
|
+
const dest = path.join(functionDir, relPath);
|
|
152
|
+
fs.mkdirSync(path.dirname(dest), {
|
|
153
|
+
recursive: true
|
|
154
|
+
});
|
|
155
|
+
fs.copyFileSync(manifestPath, dest);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (fs.existsSync(runtimeConfigSrc)) {
|
|
160
|
+
fs.copyFileSync(runtimeConfigSrc, path.join(functionDir, "wexts.runtime.js"));
|
|
161
|
+
} else {
|
|
162
|
+
warnings.push(`Runtime config not found at ${runtimeConfigSrc}.`);
|
|
163
|
+
}
|
|
164
|
+
const entryJs = generateServerlessEntry();
|
|
165
|
+
fs.writeFileSync(path.join(functionDir, "index.js"), entryJs);
|
|
166
|
+
const funcPkg = generateFunctionPackageJson(rootDir);
|
|
167
|
+
fs.writeFileSync(path.join(functionDir, "package.json"), JSON.stringify(funcPkg, null, 2));
|
|
168
|
+
const publicDir = path.join(rootDir, "apps/web/public");
|
|
169
|
+
if (fs.existsSync(publicDir)) {
|
|
170
|
+
fs.cpSync(publicDir, staticDir, {
|
|
171
|
+
recursive: true
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const nextStaticDir = path.join(rootDir, "apps/web/.next/static");
|
|
175
|
+
if (fs.existsSync(nextStaticDir)) {
|
|
176
|
+
const dest = path.join(staticDir, "_next", "static");
|
|
177
|
+
fs.mkdirSync(path.dirname(dest), {
|
|
178
|
+
recursive: true
|
|
179
|
+
});
|
|
180
|
+
fs.cpSync(nextStaticDir, dest, {
|
|
181
|
+
recursive: true
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const validation = validateOutput(outputDir);
|
|
185
|
+
errors.push(...validation.errors);
|
|
186
|
+
warnings.push(...validation.warnings);
|
|
187
|
+
if (errors.length === 0) {
|
|
188
|
+
console.log("\u2705 Vercel Build Output created successfully.");
|
|
189
|
+
console.log(` Output: ${outputDir}`);
|
|
190
|
+
} else {
|
|
191
|
+
console.error("\u274C Vercel build completed with errors:");
|
|
192
|
+
for (const err of errors) {
|
|
193
|
+
console.error(` \u2022 ${err}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
outputDir,
|
|
198
|
+
configPath,
|
|
199
|
+
functionDir,
|
|
200
|
+
staticDir,
|
|
201
|
+
errors,
|
|
202
|
+
warnings
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, buildVercelOutput, "buildVercelOutput");
|
|
206
|
+
function generateServerlessEntry() {
|
|
207
|
+
return `// Wexts serverless entry for Vercel
|
|
208
|
+
// Auto-generated by wexts vercel-build \u2014 do not edit.
|
|
209
|
+
const path = require('path');
|
|
210
|
+
|
|
211
|
+
let handlerPromise;
|
|
212
|
+
|
|
213
|
+
function getHandler() {
|
|
214
|
+
if (!handlerPromise) {
|
|
215
|
+
handlerPromise = (async () => {
|
|
216
|
+
const { createWextsHandler } = require('wexts/runtime');
|
|
217
|
+
const runtimeConfigPath = path.join(__dirname, 'wexts.runtime.js');
|
|
218
|
+
let runtimeConfig = {};
|
|
219
|
+
try {
|
|
220
|
+
runtimeConfig = require(runtimeConfigPath);
|
|
221
|
+
runtimeConfig = runtimeConfig.default || runtimeConfig;
|
|
222
|
+
} catch (_e) {
|
|
223
|
+
// No runtime config \u2014 use defaults
|
|
224
|
+
}
|
|
225
|
+
return createWextsHandler({
|
|
226
|
+
...runtimeConfig,
|
|
227
|
+
dev: false,
|
|
228
|
+
});
|
|
229
|
+
})();
|
|
230
|
+
}
|
|
231
|
+
return handlerPromise;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
module.exports = async (req, res) => {
|
|
235
|
+
const handler = await getHandler();
|
|
236
|
+
return handler(req, res);
|
|
237
|
+
};
|
|
238
|
+
`;
|
|
239
|
+
}
|
|
240
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, generateServerlessEntry, "generateServerlessEntry");
|
|
241
|
+
function generateFunctionPackageJson(rootDir) {
|
|
242
|
+
const projectPkgPath = path.join(rootDir, "package.json");
|
|
243
|
+
let projectPkg = {};
|
|
244
|
+
if (fs.existsSync(projectPkgPath)) {
|
|
245
|
+
projectPkg = JSON.parse(fs.readFileSync(projectPkgPath, "utf8"));
|
|
246
|
+
}
|
|
247
|
+
const deps = {};
|
|
248
|
+
const rawDeps = _nullishCoalesce(projectPkg.dependencies, () => ( {}));
|
|
249
|
+
for (const [name, version] of Object.entries(rawDeps)) {
|
|
250
|
+
if (version.startsWith("workspace:")) {
|
|
251
|
+
const resolved = resolveWorkspaceDependencyVersion(rootDir, name);
|
|
252
|
+
if (resolved) {
|
|
253
|
+
deps[name] = resolved;
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
deps[name] = version;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
name: "wexts-vercel-function",
|
|
261
|
+
version: "0.0.0",
|
|
262
|
+
private: true,
|
|
263
|
+
main: "index.js",
|
|
264
|
+
dependencies: deps
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, generateFunctionPackageJson, "generateFunctionPackageJson");
|
|
268
|
+
function resolveWorkspaceDependencyVersion(rootDir, name) {
|
|
269
|
+
const candidates = [
|
|
270
|
+
path.join(rootDir, "packages", "package.json"),
|
|
271
|
+
path.join(rootDir, "packages", name, "package.json"),
|
|
272
|
+
path.join(rootDir, "node_modules", name, "package.json")
|
|
273
|
+
];
|
|
274
|
+
for (const candidate of candidates) {
|
|
275
|
+
if (fs.existsSync(candidate)) {
|
|
276
|
+
try {
|
|
277
|
+
const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
|
|
278
|
+
if (pkg.name === name && pkg.version) {
|
|
279
|
+
return `^${pkg.version}`;
|
|
280
|
+
}
|
|
281
|
+
} catch (e) {
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return void 0;
|
|
286
|
+
}
|
|
287
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, resolveWorkspaceDependencyVersion, "resolveWorkspaceDependencyVersion");
|
|
288
|
+
function validateOutput(outputDir) {
|
|
289
|
+
const errors = [];
|
|
290
|
+
const warnings = [];
|
|
291
|
+
const configPath = path.join(outputDir, "config.json");
|
|
292
|
+
if (!fs.existsSync(configPath)) {
|
|
293
|
+
errors.push("Missing .vercel/output/config.json");
|
|
294
|
+
} else {
|
|
295
|
+
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
296
|
+
if (config.version !== 3) {
|
|
297
|
+
errors.push(`config.json version must be 3, got ${config.version}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const funcDir = path.join(outputDir, "functions", "index.func");
|
|
301
|
+
if (!fs.existsSync(funcDir)) {
|
|
302
|
+
errors.push("Missing .vercel/output/functions/index.func");
|
|
303
|
+
} else {
|
|
304
|
+
if (!fs.existsSync(path.join(funcDir, "index.js"))) {
|
|
305
|
+
errors.push("Missing index.js in function directory");
|
|
306
|
+
}
|
|
307
|
+
if (!fs.existsSync(path.join(funcDir, ".vc-config.json"))) {
|
|
308
|
+
errors.push("Missing .vc-config.json in function directory");
|
|
309
|
+
}
|
|
310
|
+
const funcPkgPath = path.join(funcDir, "package.json");
|
|
311
|
+
if (!fs.existsSync(funcPkgPath)) {
|
|
312
|
+
errors.push("Missing package.json in function directory");
|
|
313
|
+
} else {
|
|
314
|
+
const funcPkgContent = fs.readFileSync(funcPkgPath, "utf8");
|
|
315
|
+
if (funcPkgContent.includes("workspace:")) {
|
|
316
|
+
errors.push("Function package.json contains workspace:* protocol \u2014 not deployable.");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
errors,
|
|
322
|
+
warnings
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, validateOutput, "validateOutput");
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
exports.buildVercelOutput = buildVercelOutput; exports.validateOutput = validateOutput;
|
|
330
|
+
//# sourceMappingURL=index.js.map
|