wexts 3.0.2 → 4.0.0
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 -346
- package/bin/wexts.cjs +2 -0
- package/dist/chunk-2KAQYLVN.js +0 -0
- package/dist/chunk-2KAQYLVN.js.map +1 -1
- package/dist/{chunk-O42L6HOX.js → chunk-2LJVUMXW.js} +79 -93
- package/dist/chunk-2LJVUMXW.js.map +1 -0
- package/dist/chunk-7QKLIVRF.js +94 -0
- package/dist/chunk-7QKLIVRF.js.map +1 -0
- package/dist/{chunk-FCEZDH42.mjs → chunk-7WULUGLH.mjs} +5 -3
- package/dist/chunk-7WULUGLH.mjs.map +1 -0
- package/dist/{chunk-WF65EDRZ.js → chunk-BG56B4DE.js} +20 -2
- package/dist/chunk-BG56B4DE.js.map +1 -0
- package/dist/chunk-CLM5PNSG.mjs +496 -0
- package/dist/chunk-CLM5PNSG.mjs.map +1 -0
- package/dist/chunk-DNLGCKTT.js +31 -0
- package/dist/chunk-DNLGCKTT.js.map +1 -0
- package/dist/{chunk-VNNVLQLJ.mjs → chunk-JHOVXH3X.mjs} +2 -2
- package/dist/chunk-JHOVXH3X.mjs.map +1 -0
- package/dist/chunk-MXINIFPC.js +105 -0
- package/dist/chunk-MXINIFPC.js.map +1 -0
- package/dist/chunk-SE32ZPOZ.js +496 -0
- package/dist/chunk-SE32ZPOZ.js.map +1 -0
- package/dist/{chunk-STTOPUZ2.mjs → chunk-UAL54DVV.mjs} +21 -3
- package/dist/chunk-UAL54DVV.mjs.map +1 -0
- package/dist/{chunk-3OM7CHCA.js → chunk-WCKSKU3C.js} +1 -1
- package/dist/chunk-WCKSKU3C.js.map +1 -0
- package/dist/chunk-WU6FW77M.mjs +105 -0
- package/dist/chunk-WU6FW77M.mjs.map +1 -0
- package/dist/chunk-XE4OXN2W.js +0 -0
- package/dist/chunk-XE4OXN2W.js.map +1 -1
- package/dist/chunk-YBM3IJEA.mjs +94 -0
- package/dist/chunk-YBM3IJEA.mjs.map +1 -0
- package/dist/{chunk-KXYLEUSW.mjs → chunk-YN6WIWNQ.mjs} +69 -83
- package/dist/chunk-YN6WIWNQ.mjs.map +1 -0
- package/dist/chunk-YSLEF5C5.mjs +0 -0
- package/dist/chunk-YSLEF5C5.mjs.map +0 -0
- package/dist/chunk-ZX7QIN24.mjs +31 -0
- package/dist/chunk-ZX7QIN24.mjs.map +1 -0
- package/dist/cli/index.d.mts +10 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.js +292 -292
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +294 -293
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.d.mts +10 -1
- package/dist/client/index.d.ts +10 -1
- package/dist/client/index.js +4 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +6 -4
- package/dist/client/index.mjs.map +0 -0
- package/dist/codegen/index.d.mts +2 -1
- package/dist/codegen/index.d.ts +2 -1
- package/dist/codegen/index.js +5 -3
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/index.mjs +7 -5
- package/dist/codegen/index.mjs.map +0 -0
- package/dist/decorators-BT1FFqN0.d.mts +29 -0
- package/dist/decorators-DvS58PqC.d.ts +29 -0
- package/dist/dev-server/index.d.mts +1 -1
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/index.js +3 -3
- package/dist/dev-server/index.js.map +1 -1
- package/dist/dev-server/index.mjs +3 -3
- package/dist/dev-server/index.mjs.map +0 -0
- package/dist/{index-SjUaHgFr.d.ts → index-7QeQEf37.d.ts} +27 -10
- package/dist/{index-tFGPFVfQ.d.mts → index-7RvU-jGE.d.mts} +0 -1
- package/dist/{index-tFGPFVfQ.d.ts → index-7RvU-jGE.d.ts} +0 -1
- package/dist/{index-SjUaHgFr.d.mts → index-8nzxy0NN.d.mts} +27 -10
- package/dist/index-Co5ZsLqq.d.ts +58 -0
- package/dist/index-D94W1__r.d.mts +58 -0
- package/dist/index-DQmyVp6F.d.mts +27 -0
- package/dist/index-KL_1BrQb.d.ts +27 -0
- package/dist/index.d.mts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +57 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -21
- package/dist/index.mjs.map +1 -1
- package/dist/nest/index.d.mts +3 -1
- package/dist/nest/index.d.ts +3 -1
- package/dist/nest/index.js +20 -2
- package/dist/nest/index.js.map +1 -1
- package/dist/nest/index.mjs +21 -3
- package/dist/nest/index.mjs.map +0 -0
- package/dist/next/index.d.mts +7 -2
- package/dist/next/index.d.ts +7 -2
- package/dist/next/index.js +72 -5
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +70 -4
- package/dist/next/index.mjs.map +1 -1
- package/dist/rpc/index.d.mts +2 -0
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.js +23 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/index.mjs +23 -0
- package/dist/{chunk-7NSRDJ5C.mjs.map → rpc/index.mjs.map} +0 -0
- package/dist/runtime/index.d.mts +55 -0
- package/dist/runtime/index.d.ts +55 -0
- package/dist/runtime/index.js +213 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +213 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/types/index.d.mts +0 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.js +0 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/index.mjs.map +0 -0
- package/dist/types-7d_fC-C3.d.mts +32 -0
- package/dist/types-7d_fC-C3.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 +37 -16
- package/templates/.dockerignore +43 -43
- package/templates/.env.example +0 -0
- package/templates/Dockerfile +60 -60
- package/templates/Procfile +1 -1
- package/templates/README.md +67 -58
- package/templates/api-sdk.ts +115 -115
- package/templates/docker-compose.yml +34 -34
- package/templates/nestjs-api/.env.example +0 -0
- package/templates/nestjs-api/README.md +87 -79
- package/templates/nestjs-api/nest-cli.json +6 -6
- package/templates/nestjs-api/package-lock.json +5623 -5623
- package/templates/nestjs-api/package.json +40 -40
- package/templates/nestjs-api/prisma/dev.db +0 -0
- package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +0 -0
- package/templates/nestjs-api/prisma/migrations/migration_lock.toml +0 -0
- package/templates/nestjs-api/prisma/schema.prisma +29 -29
- package/templates/nestjs-api/src/app.module.ts +17 -17
- package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
- package/templates/nestjs-api/src/auth/auth.module.ts +37 -29
- 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 -19
- 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 -68
- 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 +28 -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-lock.json +3254 -3254
- 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 +1 -1
- 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
- package/dist/chunk-2MCBBWEA.js +0 -1
- package/dist/chunk-2MCBBWEA.js.map +0 -1
- package/dist/chunk-3OM7CHCA.js.map +0 -1
- package/dist/chunk-63MTCWU2.mjs +0 -361
- package/dist/chunk-63MTCWU2.mjs.map +0 -1
- package/dist/chunk-667BQCEM.js +0 -375
- package/dist/chunk-667BQCEM.js.map +0 -1
- package/dist/chunk-67IJ6H4J.mjs +0 -44
- package/dist/chunk-67IJ6H4J.mjs.map +0 -1
- package/dist/chunk-6SVQEGEX.mjs +0 -44
- package/dist/chunk-6SVQEGEX.mjs.map +0 -1
- package/dist/chunk-7NSRDJ5C.mjs +0 -1
- package/dist/chunk-ASDXAK6G.js +0 -44
- package/dist/chunk-ASDXAK6G.js.map +0 -1
- package/dist/chunk-CKZ4VSCB.mjs +0 -18
- package/dist/chunk-CKZ4VSCB.mjs.map +0 -1
- package/dist/chunk-DW6GOKMF.js +0 -57
- package/dist/chunk-DW6GOKMF.js.map +0 -1
- package/dist/chunk-EFZPSZWO.mjs +0 -1
- package/dist/chunk-EFZPSZWO.mjs.map +0 -1
- package/dist/chunk-FCEZDH42.mjs.map +0 -1
- package/dist/chunk-FYGXL4V7.js +0 -361
- package/dist/chunk-FYGXL4V7.js.map +0 -1
- package/dist/chunk-GKVPGKAH.js +0 -66
- package/dist/chunk-GKVPGKAH.js.map +0 -1
- package/dist/chunk-GWP6PNSP.js +0 -225
- package/dist/chunk-GWP6PNSP.js.map +0 -1
- package/dist/chunk-HQKTXE7E.mjs +0 -225
- package/dist/chunk-HQKTXE7E.mjs.map +0 -1
- package/dist/chunk-HSFLZUJN.mjs +0 -57
- package/dist/chunk-HSFLZUJN.mjs.map +0 -1
- package/dist/chunk-HU63F22V.js +0 -361
- package/dist/chunk-HU63F22V.js.map +0 -1
- package/dist/chunk-J5LGTIGS.mjs +0 -10
- package/dist/chunk-J5LGTIGS.mjs.map +0 -1
- package/dist/chunk-JMBD6DOP.js +0 -225
- package/dist/chunk-JMBD6DOP.js.map +0 -1
- package/dist/chunk-K7EIJSYQ.js +0 -1
- package/dist/chunk-K7EIJSYQ.js.map +0 -1
- package/dist/chunk-KXYLEUSW.mjs.map +0 -1
- package/dist/chunk-MTHKZO55.js +0 -44
- package/dist/chunk-MTHKZO55.js.map +0 -1
- package/dist/chunk-NNQFLD7O.mjs +0 -361
- package/dist/chunk-NNQFLD7O.mjs.map +0 -1
- package/dist/chunk-NU2UB242.js +0 -82
- package/dist/chunk-NU2UB242.js.map +0 -1
- package/dist/chunk-NULGSZFE.mjs +0 -57
- package/dist/chunk-NULGSZFE.mjs.map +0 -1
- package/dist/chunk-O42L6HOX.js.map +0 -1
- package/dist/chunk-ONXNE2A6.mjs +0 -375
- package/dist/chunk-ONXNE2A6.mjs.map +0 -1
- package/dist/chunk-OTBYRUBE.mjs +0 -225
- package/dist/chunk-OTBYRUBE.mjs.map +0 -1
- package/dist/chunk-OTSAVKLY.mjs +0 -66
- package/dist/chunk-OTSAVKLY.mjs.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-QP2TMRLG.js +0 -57
- package/dist/chunk-QP2TMRLG.js.map +0 -1
- package/dist/chunk-RS23R3ZQ.mjs +0 -82
- package/dist/chunk-RS23R3ZQ.mjs.map +0 -1
- package/dist/chunk-STTOPUZ2.mjs.map +0 -1
- package/dist/chunk-VMT3LALB.mjs +0 -51
- package/dist/chunk-VMT3LALB.mjs.map +0 -1
- package/dist/chunk-VNNVLQLJ.mjs.map +0 -1
- package/dist/chunk-W3YRVEFQ.js +0 -66
- package/dist/chunk-W3YRVEFQ.js.map +0 -1
- package/dist/chunk-WF65EDRZ.js.map +0 -1
- package/dist/chunk-WMHVXEYQ.mjs +0 -66
- package/dist/chunk-WMHVXEYQ.mjs.map +0 -1
- package/dist/chunk-XVKTIYHY.js +0 -51
- package/dist/chunk-XVKTIYHY.js.map +0 -1
- package/dist/codegen-MRZDLCYI.js +0 -13
- package/dist/codegen-MRZDLCYI.js.map +0 -1
- package/dist/codegen-UI5HTMXE.mjs +0 -13
- package/dist/codegen-UI5HTMXE.mjs.map +0 -1
- package/dist/dev-server-JKRVBWPY.mjs +0 -13
- package/dist/dev-server-JKRVBWPY.mjs.map +0 -1
- package/dist/dev-server-TLL7UQMR.js +0 -13
- package/dist/dev-server-TLL7UQMR.js.map +0 -1
- package/dist/index-BsNaOUtH.d.mts +0 -44
- package/dist/index-BsNaOUtH.d.ts +0 -44
- package/dist/index-CrbXnXsO.d.ts +0 -62
- package/dist/index-kEbGExWM.d.mts +0 -62
- package/templates/nestjs-api/.env +0 -4
- package/templates/nextjs-web/.env +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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/rpc/decorators.ts
|
|
6
|
+
require('reflect-metadata');
|
|
7
|
+
var RPC_SERVICE_KEY = "wexts:rpc:service";
|
|
8
|
+
var RPC_METHODS_KEY = "wexts:rpc:methods";
|
|
9
|
+
function RpcService(nameOrOptions) {
|
|
10
|
+
const options = normalizeServiceOptions(nameOrOptions);
|
|
11
|
+
return (target) => {
|
|
12
|
+
Reflect.defineMetadata(RPC_SERVICE_KEY, options, target);
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, RpcService, "RpcService");
|
|
17
|
+
function RpcMethod(nameOrOptions) {
|
|
18
|
+
const options = normalizeMethodOptions(nameOrOptions);
|
|
19
|
+
return (target, propertyKey) => {
|
|
20
|
+
const constructor = target.constructor;
|
|
21
|
+
const methods = Reflect.getMetadata(RPC_METHODS_KEY, constructor) || [];
|
|
22
|
+
const nextMethods = methods.filter((method) => method.propertyKey !== propertyKey);
|
|
23
|
+
nextMethods.push({
|
|
24
|
+
propertyKey,
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
Reflect.defineMetadata(RPC_METHODS_KEY, nextMethods, constructor);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, RpcMethod, "RpcMethod");
|
|
31
|
+
function RequireAuth() {
|
|
32
|
+
return (target, propertyKey) => {
|
|
33
|
+
if (propertyKey) {
|
|
34
|
+
RpcMethod({
|
|
35
|
+
requireAuth: true
|
|
36
|
+
})(target, propertyKey, Object.getOwnPropertyDescriptor(target, propertyKey));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const existing = getRuntimeRpcServiceMetadata(target);
|
|
40
|
+
Reflect.defineMetadata(RPC_SERVICE_KEY, {
|
|
41
|
+
...existing,
|
|
42
|
+
requireAuth: true
|
|
43
|
+
}, target);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, RequireAuth, "RequireAuth");
|
|
47
|
+
function getRuntimeRpcServiceMetadata(target) {
|
|
48
|
+
return Reflect.getMetadata(RPC_SERVICE_KEY, target);
|
|
49
|
+
}
|
|
50
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, getRuntimeRpcServiceMetadata, "getRuntimeRpcServiceMetadata");
|
|
51
|
+
function getRuntimeRpcMethodsMetadata(target) {
|
|
52
|
+
return Reflect.getMetadata(RPC_METHODS_KEY, target) || [];
|
|
53
|
+
}
|
|
54
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, getRuntimeRpcMethodsMetadata, "getRuntimeRpcMethodsMetadata");
|
|
55
|
+
function getRpcAuthPolicy(requireAuth) {
|
|
56
|
+
return requireAuth ? "required" : "public";
|
|
57
|
+
}
|
|
58
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, getRpcAuthPolicy, "getRpcAuthPolicy");
|
|
59
|
+
var WextsRpcService = RpcService;
|
|
60
|
+
var WextsRpc = RpcMethod;
|
|
61
|
+
function normalizeServiceOptions(input) {
|
|
62
|
+
if (typeof input === "string") {
|
|
63
|
+
return {
|
|
64
|
+
name: input,
|
|
65
|
+
requireAuth: false
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
name: _optionalChain([input, 'optionalAccess', _ => _.name]),
|
|
70
|
+
requireAuth: _nullishCoalesce(_optionalChain([input, 'optionalAccess', _2 => _2.requireAuth]), () => ( true))
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, normalizeServiceOptions, "normalizeServiceOptions");
|
|
74
|
+
function normalizeMethodOptions(input) {
|
|
75
|
+
if (typeof input === "string") {
|
|
76
|
+
return {
|
|
77
|
+
name: input
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return _nullishCoalesce(input, () => ( {}));
|
|
81
|
+
}
|
|
82
|
+
_chunkXE4OXN2Wjs.__name.call(void 0, normalizeMethodOptions, "normalizeMethodOptions");
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
exports.RpcService = RpcService; exports.RpcMethod = RpcMethod; exports.RequireAuth = RequireAuth; exports.getRuntimeRpcServiceMetadata = getRuntimeRpcServiceMetadata; exports.getRuntimeRpcMethodsMetadata = getRuntimeRpcMethodsMetadata; exports.getRpcAuthPolicy = getRpcAuthPolicy; exports.WextsRpcService = WextsRpcService; exports.WextsRpc = WextsRpc;
|
|
94
|
+
//# sourceMappingURL=chunk-7QKLIVRF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Volumes/Projects/wexts/packages/dist/chunk-7QKLIVRF.js","../src/rpc/decorators.ts"],"names":["RPC_SERVICE_KEY","RPC_METHODS_KEY","RpcService","nameOrOptions","options","normalizeServiceOptions","target","Reflect","defineMetadata","RpcMethod","normalizeMethodOptions","propertyKey","constructor","methods","getMetadata","nextMethods","filter","method","push","RequireAuth","requireAuth","Object","getOwnPropertyDescriptor","existing","getRuntimeRpcServiceMetadata","getRuntimeRpcMethodsMetadata","getRpcAuthPolicy","WextsRpcService","WextsRpc","input","name"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACJA,4BAAO;AAGP,IAAMA,gBAAAA,EAAkB,mBAAA;AACxB,IAAMC,gBAAAA,EAAkB,mBAAA;AAuBjB,SAASC,UAAAA,CAAWC,aAAAA,EAA0C;AACjE,EAAA,MAAMC,QAAAA,EAAUC,uBAAAA,CAAwBF,aAAAA,CAAAA;AAExC,EAAA,OAAO,CAACG,MAAAA,EAAAA,GAAAA;AACJC,IAAAA,OAAAA,CAAQC,cAAAA,CAAeR,eAAAA,EAAiBI,OAAAA,EAASE,MAAAA,CAAAA;AACjD,IAAA,OAAOA,MAAAA;ADnBf,ECoBI,CAAA;AACJ;AAPgBJ,qCAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAST,SAASO,SAAAA,CAAUN,aAAAA,EAAyC;AAC/D,EAAA,MAAMC,QAAAA,EAAUM,sBAAAA,CAAuBP,aAAAA,CAAAA;AAEvC,EAAA,OAAO,CAACG,MAAAA,EAAQK,WAAAA,EAAAA,GAAAA;AACZ,IAAA,MAAMC,YAAAA,EAAcN,MAAAA,CAAO,WAAA;AAC3B,IAAA,MAAMO,QAAAA,EAAsCN,OAAAA,CAAQO,WAAAA,CAAYb,eAAAA,EAAiBW,WAAAA,EAAAA,GAAgB,CAAA,CAAA;AACjG,IAAA,MAAMG,YAAAA,EAAcF,OAAAA,CAAQG,M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port type { RpcAuthPolicy } from './types';\n\nconst RPC_SERVICE_KEY = 'wexts:rpc:service';\nconst RPC_METHODS_KEY = 'wexts:rpc:methods';\n\nexport interface RpcServiceOptions {\n name?: string;\n requireAuth?: boolean;\n}\n\nexport interface RpcMethodOptions {\n name?: string;\n requireAuth?: boolean;\n}\n\nexport interface RuntimeRpcServiceMetadata {\n name?: string;\n requireAuth: boolean;\n}\n\nexport interface RuntimeRpcMethodMetadata {\n propertyKey: string | symbol;\n name?: string;\n requireAuth?: boolean;\n}\n\nexport function RpcService(nameOrOptions?: string | RpcServiceOptions): ClassDecorator {\n const options = normalizeServiceOptions(nameOrOptions);\n\n return (target) => {\n Reflect.defineMetadata(RPC_SERVICE_KEY, options, target);\n return target;\n };\n}\n\nexport function RpcMethod(nameOrOptions?: string | RpcMethodOptions): MethodDecorator {\n const options = normalizeMethodOptions(nameOrOptions);\n\n return (target, propertyKey) => {\n const constructor = target.constructor;\n const methods: RuntimeRpcMethodMetadata[] = Reflect.getMetadata(RPC_METHODS_KEY, constructor) || [];\n const nextMethods = methods.filter((method) => method.propertyKey !== propertyKey);\n nextMethods.push({ propertyKey, ...options });\n Reflect.defineMetadata(RPC_METHODS_KEY, nextMethods, constructor);\n };\n}\n\nexport function RequireAuth(): MethodDecorator & ClassDecorator {\n return (target: object, propertyKey?: string | symbol) => {\n if (propertyKey) {\n RpcMethod({ requireAuth: true })(target, propertyKey, Object.getOwnPropertyDescriptor(target, propertyKey)!);\n return;\n }\n\n const existing = getRuntimeRpcServiceMetadata(target as Function);\n Reflect.defineMetadata(RPC_SERVICE_KEY, { ...existing, requireAuth: true }, target);\n };\n}\n\nexport function getRuntimeRpcServiceMetadata(target: Function): RuntimeRpcServiceMetadata | undefined {\n return Reflect.getMetadata(RPC_SERVICE_KEY, target);\n}\n\nexport function getRuntimeRpcMethodsMetadata(target: Function): RuntimeRpcMethodMetadata[] {\n return Reflect.getMetadata(RPC_METHODS_KEY, target) || [];\n}\n\nexport function getRpcAuthPolicy(requireAuth?: boolean): RpcAuthPolicy {\n return requireAuth ? 'required' : 'public';\n}\n\nexport const WextsRpcService = RpcService;\nexport const WextsRpc = RpcMethod;\n\nfunction normalizeServiceOptions(input?: string | RpcServiceOptions): RuntimeRpcServiceMetadata {\n if (typeof input === 'string') {\n return { name: input, requireAuth: false };\n }\n\n return {\n name: input?.name,\n requireAuth: input?.requireAuth ?? true,\n };\n}\n\nfunction normalizeMethodOptions(input?: string | RpcMethodOptions): RpcMethodOptions {\n if (typeof input === 'string') {\n return { name: input };\n }\n\n return input ?? {};\n}\n"]}
|
|
@@ -5,16 +5,18 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
// ../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.
|
|
8
|
+
// ../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.32_jiti@1.21.7_postcss@8.5.12_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
9
9
|
import path from "path";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
var getFilename = /* @__PURE__ */ __name(() => fileURLToPath(import.meta.url), "getFilename");
|
|
12
12
|
var getDirname = /* @__PURE__ */ __name(() => path.dirname(getFilename()), "getDirname");
|
|
13
13
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
14
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
14
15
|
|
|
15
16
|
export {
|
|
16
17
|
__name,
|
|
17
18
|
__export,
|
|
18
|
-
__dirname
|
|
19
|
+
__dirname,
|
|
20
|
+
__filename
|
|
19
21
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-7WULUGLH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.32_jiti@1.21.7_postcss@8.5.12_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;AACA,OAAOA,UAAU;AACjB,SAASC,qBAAqB;AAE9B,IAAMC,cAAc,6BAAMC,cAAc,YAAYC,GAAG,GAAnC;AACpB,IAAMC,aAAa,6BAAMC,KAAKC,QAAQL,YAAAA,CAAAA,GAAnB;AAEZ,IAAMM,YAA4BH,2BAAAA;AAClC,IAAMI,aAA6BP,4BAAAA;","names":["path","fileURLToPath","getFilename","fileURLToPath","url","getDirname","path","dirname","__dirname","__filename"]}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk7QKLIVRFjs = require('./chunk-7QKLIVRF.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
4
14
|
var _chunkXE4OXN2Wjs = require('./chunk-XE4OXN2W.js');
|
|
5
15
|
|
|
6
16
|
// src/nest/index.ts
|
|
@@ -12,7 +22,15 @@ _chunkXE4OXN2Wjs.__export.call(void 0, nest_exports, {
|
|
|
12
22
|
FusionPost: () => FusionPost,
|
|
13
23
|
FusionPut: () => FusionPut,
|
|
14
24
|
FusionRoute: () => FusionRoute,
|
|
15
|
-
|
|
25
|
+
RequireAuth: () => _chunk7QKLIVRFjs.RequireAuth,
|
|
26
|
+
RpcMethod: () => _chunk7QKLIVRFjs.RpcMethod,
|
|
27
|
+
RpcService: () => _chunk7QKLIVRFjs.RpcService,
|
|
28
|
+
WextsRpc: () => _chunk7QKLIVRFjs.WextsRpc,
|
|
29
|
+
WextsRpcService: () => _chunk7QKLIVRFjs.WextsRpcService,
|
|
30
|
+
getFusionMetadata: () => getFusionMetadata,
|
|
31
|
+
getRpcAuthPolicy: () => _chunk7QKLIVRFjs.getRpcAuthPolicy,
|
|
32
|
+
getRuntimeRpcMethodsMetadata: () => _chunk7QKLIVRFjs.getRuntimeRpcMethodsMetadata,
|
|
33
|
+
getRuntimeRpcServiceMetadata: () => _chunk7QKLIVRFjs.getRuntimeRpcServiceMetadata
|
|
16
34
|
});
|
|
17
35
|
|
|
18
36
|
// src/nest/decorators.ts
|
|
@@ -85,4 +103,4 @@ _chunkXE4OXN2Wjs.__name.call(void 0, getFusionMetadata, "getFusionMetadata");
|
|
|
85
103
|
|
|
86
104
|
|
|
87
105
|
exports.FusionController = FusionController; exports.FusionRoute = FusionRoute; exports.FusionGet = FusionGet; exports.FusionPost = FusionPost; exports.FusionPut = FusionPut; exports.FusionDelete = FusionDelete; exports.getFusionMetadata = getFusionMetadata; exports.nest_exports = nest_exports;
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-BG56B4DE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Volumes/Projects/wexts/packages/dist/chunk-BG56B4DE.js","../src/nest/index.ts","../src/nest/decorators.ts"],"names":["FUSION_METADATA_KEY","FusionController","prefix","target","Reflect","defineMetadata","FusionRoute","metadata","propertyKey","descriptor","routes","getMetadata","push","handler","FusionGet","path","method","FusionPost","FusionPut","FusionDelete","getFusionMetadata","controller"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACA;ACfA,IAAA,aAAA,EAAA,CAAA,CAAA;ADiBA,uCAAQ,YAAa,EAAE;AACvB,EAAE,gBAAgB,EAAE,CAAC,EAAE,GAAG,gBAAgB;AAC1C,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG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I,qCAAAA,YAAAA,EAAAA,cAAAA,CAAAA;AAOT,SAASC,iBAAAA,CAAkBC,UAAAA,EAAe;AAI7C,EAAA,OAAO;AFsBX,IErBQA,UAAAA,EAAYjB,OAAAA,CAAQO,WAAAA,CAAY,mBAAA,EAAqBU,UAAAA,CAAAA;AFsB7D,IErBQX,MAAAA,EAAQN,OAAAA,CAAQO,WAAAA,CAAYX,mBAAAA,EAAqBqB,UAAAA,EAAAA,GAAe,CAAA;AFsBxE,EErBI,CAAA;AACJ;AARgBD,qCAAAA,iBAAAA,EAAAA,mBAAAA,CAAAA;AF+BhB;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uSAAC","file":"/Volumes/Projects/wexts/packages/dist/chunk-BG56B4DE.js","sourcesContent":[null,"export * from './decorators';\nexport * from '../rpc/decorators';\n","// NestJS Integration - Decorators for wexts\n// These decorators add metadata for auto API client generation\n\nimport 'reflect-metadata';\n\nexport interface FusionRouteMetadata {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n path: string;\n responseType?: string;\n requestType?: string;\n}\n\nconst FUSION_METADATA_KEY = 'fusion:routes';\n\n/**\n * Mark a NestJS controller for Fusion codegen\n * Usage: @FusionController('users')\n */\nexport function FusionController(prefix: string = ''): ClassDecorator {\n return function (target: any) {\n Reflect.defineMetadata('fusion:controller', { prefix }, target);\n return target;\n };\n}\n\n/**\n * Mark a route for API client generation\n * Usage: @FusionRoute({ method: 'GET', path: '/:id' })\n */\nexport function FusionRoute(metadata: FusionRouteMetadata): MethodDecorator {\n return function (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) {\n const routes = Reflect.getMetadata(FUSION_METADATA_KEY, target.constructor) || [];\n routes.push({\n ...metadata,\n handler: propertyKey,\n });\n Reflect.defineMetadata(FUSION_METADATA_KEY, routes, target.constructor);\n return descriptor;\n };\n}\n\n/**\n * Helper decorators for common HTTP methods\n */\nexport function FusionGet(path: string = ''): MethodDecorator {\n return FusionRoute({ method: 'GET', path });\n}\n\nexport function FusionPost(path: string = ''): MethodDecorator {\n return FusionRoute({ method: 'POST', path });\n}\n\nexport function FusionPut(path: string = ''): MethodDecorator {\n return FusionRoute({ method: 'PUT', path });\n}\n\nexport function FusionDelete(path: string = ''): MethodDecorator {\n return FusionRoute({ method: 'DELETE', path });\n}\n\n/**\n * Get Fusion metadata from a controller\n */\nexport function getFusionMetadata(controller: any): {\n controller: any;\n routes: any[];\n} {\n return {\n controller: Reflect.getMetadata('fusion:controller', controller),\n routes: Reflect.getMetadata(FUSION_METADATA_KEY, controller) || [],\n };\n}\n"]}
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-JHOVXH3X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export,
|
|
6
|
+
__name
|
|
7
|
+
} from "./chunk-7WULUGLH.mjs";
|
|
8
|
+
|
|
9
|
+
// src/codegen/index.ts
|
|
10
|
+
var codegen_exports = {};
|
|
11
|
+
__export(codegen_exports, {
|
|
12
|
+
ClientGenerator: () => ClientGenerator,
|
|
13
|
+
CodegenWatcher: () => CodegenWatcher,
|
|
14
|
+
NestJSParser: () => NestJSParser,
|
|
15
|
+
generateRpcClient: () => generateRpcClient
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/codegen/parser.ts
|
|
19
|
+
import * as path from "path";
|
|
20
|
+
import * as ts from "typescript";
|
|
21
|
+
var RPC_SERVICE_DECORATORS = /* @__PURE__ */ new Set([
|
|
22
|
+
"RpcService",
|
|
23
|
+
"WextsRpcService"
|
|
24
|
+
]);
|
|
25
|
+
var RPC_METHOD_DECORATORS = /* @__PURE__ */ new Set([
|
|
26
|
+
"RpcMethod",
|
|
27
|
+
"WextsRpc"
|
|
28
|
+
]);
|
|
29
|
+
var REQUIRE_AUTH_DECORATORS = /* @__PURE__ */ new Set([
|
|
30
|
+
"RequireAuth"
|
|
31
|
+
]);
|
|
32
|
+
var NestJSParser = class {
|
|
33
|
+
static {
|
|
34
|
+
__name(this, "NestJSParser");
|
|
35
|
+
}
|
|
36
|
+
projectPath;
|
|
37
|
+
program;
|
|
38
|
+
constructor(projectPath) {
|
|
39
|
+
this.projectPath = projectPath;
|
|
40
|
+
const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, "tsconfig.json");
|
|
41
|
+
if (!configPath) {
|
|
42
|
+
throw new Error("tsconfig.json not found");
|
|
43
|
+
}
|
|
44
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
45
|
+
const parsedConfig = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
|
|
46
|
+
this.program = ts.createProgram(parsedConfig.fileNames, parsedConfig.options);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Find all controllers with @FusionController decorator
|
|
50
|
+
*/
|
|
51
|
+
findFusionControllers() {
|
|
52
|
+
const controllers = [];
|
|
53
|
+
const sourceFiles = this.program.getSourceFiles();
|
|
54
|
+
for (const sourceFile of sourceFiles) {
|
|
55
|
+
if (sourceFile.fileName.includes("node_modules")) continue;
|
|
56
|
+
if (!sourceFile.fileName.includes(".controller.ts")) continue;
|
|
57
|
+
const fileControllers = this.parseSourceFile(sourceFile);
|
|
58
|
+
controllers.push(...fileControllers);
|
|
59
|
+
}
|
|
60
|
+
return controllers;
|
|
61
|
+
}
|
|
62
|
+
findRpcManifest() {
|
|
63
|
+
const services = [];
|
|
64
|
+
for (const sourceFile of this.program.getSourceFiles()) {
|
|
65
|
+
if (sourceFile.fileName.includes("node_modules")) continue;
|
|
66
|
+
if (!sourceFile.fileName.endsWith(".ts")) continue;
|
|
67
|
+
if (sourceFile.fileName.endsWith(".d.ts")) continue;
|
|
68
|
+
services.push(...this.parseRpcServices(sourceFile));
|
|
69
|
+
}
|
|
70
|
+
services.sort((a, b) => a.name.localeCompare(b.name));
|
|
71
|
+
for (const service of services) {
|
|
72
|
+
service.methods.sort((a, b) => a.name.localeCompare(b.name));
|
|
73
|
+
}
|
|
74
|
+
if (services.length === 0) {
|
|
75
|
+
return {
|
|
76
|
+
schemaVersion: 1,
|
|
77
|
+
services
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
schemaVersion: 1,
|
|
82
|
+
services
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
parseSourceFile(sourceFile) {
|
|
86
|
+
const controllers = [];
|
|
87
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
88
|
+
if (ts.isClassDeclaration(node) && node.name) {
|
|
89
|
+
const controllerInfo = this.parseController(node);
|
|
90
|
+
if (controllerInfo) {
|
|
91
|
+
controllers.push(controllerInfo);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return controllers;
|
|
96
|
+
}
|
|
97
|
+
parseController(classNode) {
|
|
98
|
+
const decorators = ts.getDecorators(classNode);
|
|
99
|
+
if (!decorators) return null;
|
|
100
|
+
let controllerPrefix = "";
|
|
101
|
+
let isFusionController = false;
|
|
102
|
+
for (const decorator of decorators) {
|
|
103
|
+
const expr = decorator.expression;
|
|
104
|
+
if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {
|
|
105
|
+
const decoratorName = expr.expression.text;
|
|
106
|
+
if (decoratorName === "FusionController") {
|
|
107
|
+
isFusionController = true;
|
|
108
|
+
if (expr.arguments.length > 0) {
|
|
109
|
+
const arg = expr.arguments[0];
|
|
110
|
+
if (ts.isStringLiteral(arg)) {
|
|
111
|
+
controllerPrefix = arg.text;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!isFusionController) return null;
|
|
118
|
+
const routes = this.parseRoutes(classNode);
|
|
119
|
+
const className = classNode.name?.text || "Unknown";
|
|
120
|
+
return {
|
|
121
|
+
name: className,
|
|
122
|
+
prefix: controllerPrefix,
|
|
123
|
+
routes: routes.map((r) => ({
|
|
124
|
+
...r,
|
|
125
|
+
controllerName: className
|
|
126
|
+
}))
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
parseRoutes(classNode) {
|
|
130
|
+
const routes = [];
|
|
131
|
+
classNode.members.forEach((member) => {
|
|
132
|
+
if (ts.isMethodDeclaration(member)) {
|
|
133
|
+
const decorators = ts.getDecorators(member);
|
|
134
|
+
if (!decorators) return;
|
|
135
|
+
for (const decorator of decorators) {
|
|
136
|
+
const expr = decorator.expression;
|
|
137
|
+
if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {
|
|
138
|
+
const decoratorName = expr.expression.text;
|
|
139
|
+
let method = null;
|
|
140
|
+
let routePath = "";
|
|
141
|
+
if (decoratorName === "FusionGet") method = "GET";
|
|
142
|
+
else if (decoratorName === "FusionPost") method = "POST";
|
|
143
|
+
else if (decoratorName === "FusionPut") method = "PUT";
|
|
144
|
+
else if (decoratorName === "FusionDelete") method = "DELETE";
|
|
145
|
+
if (method) {
|
|
146
|
+
if (expr.arguments.length > 0) {
|
|
147
|
+
const arg = expr.arguments[0];
|
|
148
|
+
if (ts.isStringLiteral(arg)) {
|
|
149
|
+
routePath = arg.text;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const handlerName = member.name.text;
|
|
153
|
+
routes.push({
|
|
154
|
+
method,
|
|
155
|
+
path: routePath,
|
|
156
|
+
handler: handlerName,
|
|
157
|
+
controllerName: ""
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return routes;
|
|
165
|
+
}
|
|
166
|
+
parseRpcServices(sourceFile) {
|
|
167
|
+
const services = [];
|
|
168
|
+
const rootDir = path.resolve(this.projectPath);
|
|
169
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
170
|
+
if (!ts.isClassDeclaration(node) || !node.name) return;
|
|
171
|
+
const serviceDecorator = this.findDecorator(node, RPC_SERVICE_DECORATORS);
|
|
172
|
+
if (!serviceDecorator) return;
|
|
173
|
+
const className = node.name.text;
|
|
174
|
+
const serviceOptions = this.readDecoratorOptions(serviceDecorator);
|
|
175
|
+
const classRequiresAuth = serviceOptions.requireAuth || this.hasDecorator(node, REQUIRE_AUTH_DECORATORS);
|
|
176
|
+
const serviceName = serviceOptions.name || toStableServiceName(className);
|
|
177
|
+
const methods = this.parseRpcMethods(node, classRequiresAuth, sourceFile);
|
|
178
|
+
if (methods.length === 0) return;
|
|
179
|
+
services.push({
|
|
180
|
+
name: serviceName,
|
|
181
|
+
className,
|
|
182
|
+
importPath: toPosixPath(path.relative(rootDir, sourceFile.fileName).replace(/\.ts$/, "")),
|
|
183
|
+
requireAuth: classRequiresAuth,
|
|
184
|
+
methods
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
return services;
|
|
188
|
+
}
|
|
189
|
+
parseRpcMethods(classNode, classRequiresAuth, sourceFile) {
|
|
190
|
+
const methods = [];
|
|
191
|
+
for (const member of classNode.members) {
|
|
192
|
+
if (!ts.isMethodDeclaration(member)) continue;
|
|
193
|
+
if (!ts.isIdentifier(member.name)) continue;
|
|
194
|
+
const methodDecorator = this.findDecorator(member, RPC_METHOD_DECORATORS);
|
|
195
|
+
if (!methodDecorator) continue;
|
|
196
|
+
const handlerName = member.name.text;
|
|
197
|
+
const methodOptions = this.readDecoratorOptions(methodDecorator);
|
|
198
|
+
const requireAuth = classRequiresAuth || methodOptions.requireAuth || this.hasDecorator(member, REQUIRE_AUTH_DECORATORS);
|
|
199
|
+
methods.push({
|
|
200
|
+
name: methodOptions.name || handlerName,
|
|
201
|
+
handlerName,
|
|
202
|
+
requireAuth,
|
|
203
|
+
parameters: member.parameters.map((parameter) => this.parseParameter(parameter, sourceFile)),
|
|
204
|
+
returnType: member.type ? getNodeText(member.type, sourceFile) : "unknown"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return methods;
|
|
208
|
+
}
|
|
209
|
+
parseParameter(parameter, sourceFile) {
|
|
210
|
+
return {
|
|
211
|
+
name: ts.isIdentifier(parameter.name) ? parameter.name.text : parameter.name.getText(),
|
|
212
|
+
type: parameter.type ? getNodeText(parameter.type, sourceFile) : "unknown",
|
|
213
|
+
optional: Boolean(parameter.questionToken || parameter.initializer)
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
findDecorator(node, names) {
|
|
217
|
+
const decorators = ts.getDecorators(node);
|
|
218
|
+
if (!decorators) return void 0;
|
|
219
|
+
return decorators.find((decorator) => {
|
|
220
|
+
const name = getDecoratorName(decorator);
|
|
221
|
+
return Boolean(name && names.has(name));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
hasDecorator(node, names) {
|
|
225
|
+
return Boolean(this.findDecorator(node, names));
|
|
226
|
+
}
|
|
227
|
+
readDecoratorOptions(decorator) {
|
|
228
|
+
const expression = decorator.expression;
|
|
229
|
+
if (!ts.isCallExpression(expression)) return {};
|
|
230
|
+
const firstArg = expression.arguments[0];
|
|
231
|
+
if (!firstArg) return {};
|
|
232
|
+
if (ts.isStringLiteral(firstArg)) {
|
|
233
|
+
return {
|
|
234
|
+
name: firstArg.text
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
if (!ts.isObjectLiteralExpression(firstArg)) return {};
|
|
238
|
+
const result = {};
|
|
239
|
+
for (const property of firstArg.properties) {
|
|
240
|
+
if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) continue;
|
|
241
|
+
if (property.name.text === "name" && ts.isStringLiteral(property.initializer)) {
|
|
242
|
+
result.name = property.initializer.text;
|
|
243
|
+
}
|
|
244
|
+
if (property.name.text === "requireAuth") {
|
|
245
|
+
if (property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
246
|
+
result.requireAuth = true;
|
|
247
|
+
} else if (property.initializer.kind === ts.SyntaxKind.FalseKeyword) {
|
|
248
|
+
result.requireAuth = false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
function getDecoratorName(decorator) {
|
|
256
|
+
const expression = decorator.expression;
|
|
257
|
+
if (ts.isIdentifier(expression)) return expression.text;
|
|
258
|
+
if (ts.isCallExpression(expression) && ts.isIdentifier(expression.expression)) {
|
|
259
|
+
return expression.expression.text;
|
|
260
|
+
}
|
|
261
|
+
return void 0;
|
|
262
|
+
}
|
|
263
|
+
__name(getDecoratorName, "getDecoratorName");
|
|
264
|
+
function toStableServiceName(className) {
|
|
265
|
+
const withoutSuffix = className.replace(/(Service|Controller)$/, "");
|
|
266
|
+
return withoutSuffix.charAt(0).toLowerCase() + withoutSuffix.slice(1);
|
|
267
|
+
}
|
|
268
|
+
__name(toStableServiceName, "toStableServiceName");
|
|
269
|
+
function toPosixPath(filePath) {
|
|
270
|
+
return filePath.split(path.sep).join(path.posix.sep);
|
|
271
|
+
}
|
|
272
|
+
__name(toPosixPath, "toPosixPath");
|
|
273
|
+
function getNodeText(node, sourceFile) {
|
|
274
|
+
return sourceFile.text.slice(node.getStart(sourceFile), node.getEnd());
|
|
275
|
+
}
|
|
276
|
+
__name(getNodeText, "getNodeText");
|
|
277
|
+
|
|
278
|
+
// src/core/filesystem.ts
|
|
279
|
+
import * as fs from "fs";
|
|
280
|
+
import * as path2 from "path";
|
|
281
|
+
import { promisify } from "util";
|
|
282
|
+
var readFile2 = promisify(fs.readFile);
|
|
283
|
+
var writeFile2 = promisify(fs.writeFile);
|
|
284
|
+
var mkdir2 = promisify(fs.mkdir);
|
|
285
|
+
var access2 = promisify(fs.access);
|
|
286
|
+
var FileSystem = class {
|
|
287
|
+
static {
|
|
288
|
+
__name(this, "FileSystem");
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Read file as string
|
|
292
|
+
*/
|
|
293
|
+
async readFile(filePath, encoding = "utf-8") {
|
|
294
|
+
return readFile2(filePath, encoding);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Write file
|
|
298
|
+
*/
|
|
299
|
+
async writeFile(filePath, content) {
|
|
300
|
+
await this.ensureDir(path2.dirname(filePath));
|
|
301
|
+
return writeFile2(filePath, content, "utf-8");
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Read JSON file
|
|
305
|
+
*/
|
|
306
|
+
async readJSON(filePath) {
|
|
307
|
+
const content = await this.readFile(filePath);
|
|
308
|
+
return JSON.parse(content);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Write JSON file
|
|
312
|
+
*/
|
|
313
|
+
async writeJSON(filePath, data, pretty = true) {
|
|
314
|
+
const content = pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
315
|
+
return this.writeFile(filePath, content);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Check if file/directory exists
|
|
319
|
+
*/
|
|
320
|
+
async exists(filePath) {
|
|
321
|
+
try {
|
|
322
|
+
await access2(filePath, fs.constants.F_OK);
|
|
323
|
+
return true;
|
|
324
|
+
} catch {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Ensure directory exists (create if not)
|
|
330
|
+
*/
|
|
331
|
+
async ensureDir(dirPath) {
|
|
332
|
+
if (!await this.exists(dirPath)) {
|
|
333
|
+
await mkdir2(dirPath, {
|
|
334
|
+
recursive: true
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Copy file
|
|
340
|
+
*/
|
|
341
|
+
async copyFile(src, dest) {
|
|
342
|
+
const content = await this.readFile(src);
|
|
343
|
+
await this.writeFile(dest, content);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Read directory
|
|
347
|
+
*/
|
|
348
|
+
readDir(dirPath) {
|
|
349
|
+
return promisify(fs.readdir)(dirPath);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var filesystem = new FileSystem();
|
|
353
|
+
|
|
354
|
+
// src/codegen/generator.ts
|
|
355
|
+
import * as path3 from "path";
|
|
356
|
+
var ClientGenerator = class {
|
|
357
|
+
static {
|
|
358
|
+
__name(this, "ClientGenerator");
|
|
359
|
+
}
|
|
360
|
+
async generate(options) {
|
|
361
|
+
const { manifest, outputPath, manifestFileName = "wexts.rpc.manifest.json", clientFileName = "client.ts" } = options;
|
|
362
|
+
if (manifest.services.length === 0) {
|
|
363
|
+
throw new Error("No Wexts RPC services found. Add @RpcService() to a Nest provider and @RpcMethod() to at least one method.");
|
|
364
|
+
}
|
|
365
|
+
const sortedManifest = sortManifest(manifest);
|
|
366
|
+
const clientCode = this.generateRpcClientCode(sortedManifest);
|
|
367
|
+
await filesystem.writeJSON(path3.join(outputPath, manifestFileName), sortedManifest, true);
|
|
368
|
+
await filesystem.writeFile(path3.join(outputPath, clientFileName), clientCode);
|
|
369
|
+
const indexCode = `export * from './client';
|
|
370
|
+
`;
|
|
371
|
+
await filesystem.writeFile(path3.join(outputPath, "index.ts"), indexCode);
|
|
372
|
+
}
|
|
373
|
+
generateRpcClientCode(manifest) {
|
|
374
|
+
const manifestJson = JSON.stringify(manifest, null, 2);
|
|
375
|
+
return `import { createWextsRpcClient, type WextsRpcClientOptions } from 'wexts/client';
|
|
376
|
+
import type { RpcManifest } from 'wexts/rpc';
|
|
377
|
+
|
|
378
|
+
const manifest = ${manifestJson} satisfies RpcManifest;
|
|
379
|
+
|
|
380
|
+
${this.generateClientInterface(manifest)}
|
|
381
|
+
|
|
382
|
+
export function createWextsClient(options?: WextsRpcClientOptions): WextsClient {
|
|
383
|
+
return createWextsRpcClient(manifest, options) as unknown as WextsClient;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export const wexts = createWextsClient();
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
389
|
+
generateClientInterface(manifest) {
|
|
390
|
+
const services = manifest.services.map((service) => this.generateServiceInterface(service)).join("\n");
|
|
391
|
+
return `export interface WextsClient {
|
|
392
|
+
${services}}
|
|
393
|
+
`;
|
|
394
|
+
}
|
|
395
|
+
generateServiceInterface(service) {
|
|
396
|
+
const methods = service.methods.map((method) => ` ${method.name}: (${this.parametersToSignature(method)}) => Promise<${normalizeReturnType(method.returnType)}>;`).join("\n");
|
|
397
|
+
return ` ${service.name}: {
|
|
398
|
+
${methods}
|
|
399
|
+
};
|
|
400
|
+
`;
|
|
401
|
+
}
|
|
402
|
+
parametersToSignature(method) {
|
|
403
|
+
return method.parameters.map((parameter) => `${parameter.name}${parameter.optional ? "?" : ""}: ${parameter.type}`).join(", ");
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
async function generateRpcClient(options) {
|
|
407
|
+
const parser = new NestJSParser(options.projectPath);
|
|
408
|
+
const manifest = parser.findRpcManifest();
|
|
409
|
+
const generator = new ClientGenerator();
|
|
410
|
+
await generator.generate({
|
|
411
|
+
manifest,
|
|
412
|
+
outputPath: options.outputPath,
|
|
413
|
+
manifestFileName: options.manifestFileName,
|
|
414
|
+
clientFileName: options.clientFileName
|
|
415
|
+
});
|
|
416
|
+
return sortManifest(manifest);
|
|
417
|
+
}
|
|
418
|
+
__name(generateRpcClient, "generateRpcClient");
|
|
419
|
+
function sortManifest(manifest) {
|
|
420
|
+
return {
|
|
421
|
+
schemaVersion: 1,
|
|
422
|
+
services: [
|
|
423
|
+
...manifest.services
|
|
424
|
+
].sort((a, b) => a.name.localeCompare(b.name)).map((service) => ({
|
|
425
|
+
...service,
|
|
426
|
+
methods: [
|
|
427
|
+
...service.methods
|
|
428
|
+
].sort((a, b) => a.name.localeCompare(b.name))
|
|
429
|
+
}))
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
__name(sortManifest, "sortManifest");
|
|
433
|
+
function normalizeReturnType(returnType) {
|
|
434
|
+
const match = returnType.match(/^Promise<(.+)>$/);
|
|
435
|
+
return match?.[1] ?? returnType;
|
|
436
|
+
}
|
|
437
|
+
__name(normalizeReturnType, "normalizeReturnType");
|
|
438
|
+
|
|
439
|
+
// src/codegen/watcher.ts
|
|
440
|
+
import * as chokidar from "chokidar";
|
|
441
|
+
var CodegenWatcher = class {
|
|
442
|
+
static {
|
|
443
|
+
__name(this, "CodegenWatcher");
|
|
444
|
+
}
|
|
445
|
+
watcher = null;
|
|
446
|
+
async watch(options) {
|
|
447
|
+
const { projectPath, outputPath, pattern = "**/*.controller.ts" } = options;
|
|
448
|
+
logger.info("\u{1F440} Watching for controller changes...");
|
|
449
|
+
await this.generateClient(projectPath, outputPath);
|
|
450
|
+
this.watcher = chokidar.watch(pattern, {
|
|
451
|
+
cwd: projectPath,
|
|
452
|
+
ignored: /node_modules/,
|
|
453
|
+
persistent: true
|
|
454
|
+
});
|
|
455
|
+
this.watcher.on("change", async (path4) => {
|
|
456
|
+
logger.info(`\u{1F4DD} Controller changed: ${path4}`);
|
|
457
|
+
await this.generateClient(projectPath, outputPath);
|
|
458
|
+
});
|
|
459
|
+
this.watcher.on("add", async (path4) => {
|
|
460
|
+
logger.info(`\u2795 New controller: ${path4}`);
|
|
461
|
+
await this.generateClient(projectPath, outputPath);
|
|
462
|
+
});
|
|
463
|
+
this.watcher.on("unlink", async (path4) => {
|
|
464
|
+
logger.info(`\u2796 Controller removed: ${path4}`);
|
|
465
|
+
await this.generateClient(projectPath, outputPath);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
async stop() {
|
|
469
|
+
if (this.watcher) {
|
|
470
|
+
await this.watcher.close();
|
|
471
|
+
this.watcher = null;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
async generateClient(projectPath, outputPath) {
|
|
475
|
+
try {
|
|
476
|
+
const manifest = await generateRpcClient({
|
|
477
|
+
projectPath,
|
|
478
|
+
outputPath
|
|
479
|
+
});
|
|
480
|
+
logger.success(`Generated client for ${manifest.services.length} RPC service(s)`);
|
|
481
|
+
} catch (error) {
|
|
482
|
+
logger.error("Failed to generate client:", error.message);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
export {
|
|
488
|
+
FileSystem,
|
|
489
|
+
filesystem,
|
|
490
|
+
NestJSParser,
|
|
491
|
+
ClientGenerator,
|
|
492
|
+
generateRpcClient,
|
|
493
|
+
CodegenWatcher,
|
|
494
|
+
codegen_exports
|
|
495
|
+
};
|
|
496
|
+
//# sourceMappingURL=chunk-CLM5PNSG.mjs.map
|