every-plugin 0.6.2 → 0.7.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/dist/_virtual/rolldown_runtime.cjs +17 -7
- package/dist/_virtual/rolldown_runtime.mjs +17 -7
- package/dist/build/rspack/dev-server-middleware.cjs +1 -1
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
- package/dist/build/rspack/module-federation.cjs +0 -5
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +0 -5
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +2 -1
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.mjs +2 -1
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/errors.cjs +75 -51
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +8 -0
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +8 -0
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +75 -51
- package/dist/errors.mjs.map +1 -1
- package/dist/package.cjs +10 -10
- package/dist/package.cjs.map +1 -1
- package/dist/package.mjs +10 -10
- package/dist/package.mjs.map +1 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.d.mts +4 -4
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/services/module-federation.service.cjs +24 -33
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +2 -3
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts +2 -3
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +24 -33
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +1 -1
- package/dist/runtime/services/plugin.service.d.mts +1 -1
- package/dist/runtime/services/secrets.service.cjs +1 -1
- package/dist/runtime/services/secrets.service.mjs +1 -1
- package/dist/types.d.cts +10 -10
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -15
- package/dist/types.d.mts.map +1 -1
- package/package.json +22 -22
|
@@ -6,16 +6,26 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget
|
|
22
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
23
|
+
if (symbols) {
|
|
24
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
26
|
+
}
|
|
27
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
28
|
+
};
|
|
19
29
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
30
|
value: mod,
|
|
21
31
|
enumerable: true
|
|
@@ -6,16 +6,26 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget
|
|
22
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
23
|
+
if (symbols) {
|
|
24
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
26
|
+
}
|
|
27
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
28
|
+
};
|
|
19
29
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
30
|
|
|
21
31
|
//#endregion
|
|
@@ -33,10 +33,10 @@ function setupPluginMiddleware(devServer, pluginInfo, devConfig, port) {
|
|
|
33
33
|
try {
|
|
34
34
|
const { createPluginRuntime } = await Promise.resolve().then(() => require("../../index.cjs"));
|
|
35
35
|
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
36
|
-
const { onError } = await import("@orpc/server");
|
|
37
36
|
const { OpenAPIHandler } = await import("@orpc/openapi/fetch");
|
|
38
37
|
const { OpenAPIReferencePlugin } = await import("@orpc/openapi/plugins");
|
|
39
38
|
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
39
|
+
const { onError } = await Promise.resolve().then(() => require("../../orpc.cjs"));
|
|
40
40
|
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
41
41
|
const runtime = createPluginRuntime({ registry: { [pluginId]: { remote: `http://localhost:${port}/remoteEntry.js` } } });
|
|
42
42
|
const loaded = await runtime.usePlugin(pluginId, devConfig?.config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-middleware.cjs","names":["handlers: { rpc: any, api: any }","cleanup: (() => Promise<void>) | null","lines: string[]"],"sources":["../../../src/build/rspack/dev-server-middleware.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nconst corsHeaders = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'\n};\n\nconst applyCorsHeaders = (res: any) => {\n Object.entries(corsHeaders).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n};\n\nconst normalizePrefix = (prefix?: string): string => {\n if (!prefix) return '';\n const cleaned = prefix.replace(/^\\/+|\\/+$/g, '');\n return cleaned ? `/${cleaned}` : '';\n};\n\nexport function setupPluginMiddleware(devServer: any, pluginInfo: PluginInfo, devConfig: any, port: number) {\n const rpcPrefix = normalizePrefix(devConfig?.prefix);\n let handlers: { rpc: any, api: any } = { rpc: null, api: null };\n let cleanup: (() => Promise<void>) | null = null;\n\n const performCleanup = async () => {\n if (cleanup) {\n await cleanup();\n cleanup = null;\n }\n };\n\n (async () => {\n await performCleanup();\n\n try {\n const { createPluginRuntime } = await import('every-plugin');\n const { RPCHandler } = await import('@orpc/server/fetch');\n const { onError } = await import('@orpc/server');\n const { OpenAPIHandler } = await import('@orpc/openapi/fetch');\n const { OpenAPIReferencePlugin } = await import('@orpc/openapi/plugins');\n const { ZodToJsonSchemaConverter } = await import('@orpc/zod/zod4');\n\n const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;\n\n const runtime = createPluginRuntime({\n registry: {\n [pluginId]: {\n remote: `http://localhost:${port}/remoteEntry.js`\n }\n }\n });\n\n const loaded = await runtime.usePlugin(pluginId, devConfig?.config);\n\n cleanup = async () => {\n if (loaded && typeof (loaded as any).dispose === 'function') {\n await (loaded as any).dispose();\n }\n if (runtime && typeof (runtime as any).cleanup === 'function') {\n await (runtime as any).cleanup();\n }\n handlers.rpc = null;\n handlers.api = null;\n if (devServer.app.locals.handlers) {\n devServer.app.locals.handlers = null;\n }\n };\n\n const formatError = (error: any, context: string) => {\n const lines: string[] = [`\\n🔴 ${context} Error: ${error.message || 'Unknown error'}`];\n \n if (error.cause?.issues && Array.isArray(error.cause.issues)) {\n lines.push('\\n📋 Validation Issues:');\n error.cause.issues.forEach((issue: any, index: number) => {\n lines.push(` ${index + 1}. ${issue.path?.join('.') || 'root'}`);\n lines.push(` ├─ Code: ${issue.code || 'unknown'}`);\n lines.push(` ├─ Message: ${issue.message || 'No message'}`);\n if (issue.expected !== undefined) {\n lines.push(` ├─ Expected: ${JSON.stringify(issue.expected)}`);\n }\n if (issue.received !== undefined) {\n lines.push(` └─ Received: ${JSON.stringify(issue.received)}`);\n } else {\n lines.push(` └─ (end)`);\n }\n });\n }\n \n if (error.data && typeof error.data === 'object' && Object.keys(error.data).length > 0) {\n lines.push('\\n📊 Error Data:');\n try {\n const dataStr = JSON.stringify(error.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.data)}`);\n }\n }\n \n if (error.cause?.data) {\n lines.push('\\n📦 Request Data:');\n try {\n const dataStr = JSON.stringify(error.cause.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.cause.data)}`);\n }\n }\n \n if (error.code) {\n lines.push(`\\n⚠️ Error Code: ${error.code}`);\n }\n \n if (error.status) {\n lines.push(`📍 Status: ${error.status}`);\n }\n \n lines.push('');\n console.error(lines.join('\\n'));\n };\n\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n handlers.api = new OpenAPIHandler(loaded.router, {\n plugins: [\n new OpenAPIReferencePlugin({\n schemaConverters: [new ZodToJsonSchemaConverter()],\n }),\n ],\n interceptors: [\n onError((error: any) => {\n formatError(error, 'OpenAPI');\n }),\n ]\n });\n\n console.log(`╭─────────────────────────────────────────────`);\n console.log(`│ ✅ Plugin dev server ready: `);\n console.log(`├─────────────────────────────────────────────`);\n console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);\n console.log(`│ 📖 Docs: http://localhost:${port}/api`);\n console.log(`│ 💚 Health: http://localhost:${port}/`);\n console.log(`╰─────────────────────────────────────────────`);\n\n devServer.app.locals.handlers = handlers;\n\n if (devServer.server) {\n devServer.server.once('close', async () => {\n await performCleanup();\n });\n }\n } catch (error) {\n console.error('❌ Failed to load plugin:', error);\n await performCleanup();\n }\n })();\n\n process.once('SIGINT', async () => {\n await performCleanup();\n });\n process.once('SIGTERM', async () => {\n await performCleanup();\n });\n\n devServer.app.options('*', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.status(200).end();\n });\n\n devServer.app.get('/', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.json({\n ok: true,\n plugin: pluginInfo.normalizedName,\n version: pluginInfo.version,\n status: devServer.app.locals.handlers?.rpc ? 'ready' : 'loading',\n endpoints: {\n health: '/',\n docs: '/api',\n rpc: `/api/rpc${rpcPrefix}`\n }\n });\n });\n\n // OpenAPI documentation and REST endpoints at /api and /api/*\n const handleApiRequest = async (req: any, res: any) => {\n applyCorsHeaders(res);\n const apiHandler = devServer.app.locals.handlers?.api;\n if (!apiHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await apiHandler.handle(webRequest, {\n prefix: '/api',\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('OpenAPI error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n };\n\n devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req: any, res: any) => {\n applyCorsHeaders(res);\n const rpcHandler = devServer.app.locals.handlers?.rpc;\n if (!rpcHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await rpcHandler.handle(webRequest, {\n prefix: `/api/rpc${rpcPrefix}`,\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('RPC error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n });\n\n devServer.app.all('/api', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\n}\n"],"mappings":";;AAEA,MAAM,cAAc;CAClB,+BAA+B;CAC/B,gCAAgC;CAChC,gCAAgC;CACjC;AAED,MAAM,oBAAoB,QAAa;AACrC,QAAO,QAAQ,YAAY,CAAC,SAAS,CAAC,KAAK,WAAW;AACpD,MAAI,UAAU,KAAK,MAAM;GACzB;;AAGJ,MAAM,mBAAmB,WAA4B;AACnD,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,UAAU,OAAO,QAAQ,cAAc,GAAG;AAChD,QAAO,UAAU,IAAI,YAAY;;AAGnC,SAAgB,sBAAsB,WAAgB,YAAwB,WAAgB,MAAc;CAC1G,MAAM,YAAY,gBAAgB,WAAW,OAAO;CACpD,IAAIA,WAAmC;EAAE,KAAK;EAAM,KAAK;EAAM;CAC/D,IAAIC,UAAwC;CAE5C,MAAM,iBAAiB,YAAY;AACjC,MAAI,SAAS;AACX,SAAM,SAAS;AACf,aAAU;;;AAId,EAAC,YAAY;AACX,QAAM,gBAAgB;AAEtB,MAAI;GACF,MAAM,EAAE,wBAAwB,2CAAM;GACtC,MAAM,EAAE,eAAe,MAAM,OAAO;GACpC,MAAM,EAAE,YAAY,MAAM,OAAO;GACjC,MAAM,EAAE,mBAAmB,MAAM,OAAO;GACxC,MAAM,EAAE,2BAA2B,MAAM,OAAO;GAChD,MAAM,EAAE,6BAA6B,MAAM,OAAO;GAElD,MAAM,WAAW,WAAW,YAAY,WAAW;GAEnD,MAAM,UAAU,oBAAoB,EAClC,UAAU,GACP,WAAW,EACV,QAAQ,oBAAoB,KAAK,kBAClC,EACF,EACF,CAAC;GAEF,MAAM,SAAS,MAAM,QAAQ,UAAU,UAAU,WAAW,OAAO;AAEnE,aAAU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MAAgB,SAAS,CAAC;;;AAI7D,WAAU,IAAI,IAAI,WAAW,UAAU,KAAK,OAAO,KAAU,QAAa;AACxE,mBAAiB,IAAI;EACrB,MAAM,aAAa,UAAU,IAAI,OAAO,UAAU;AAClD,MAAI,CAAC,WACH,QAAO,IAAI,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,2BAA2B,CAAC;AAGnE,MAAI;GACF,MAAM,MAAM,UAAU,IAAI,QAAQ,OAAO,IAAI;GAC7C,MAAM,aAAa,IAAI,QAAQ,KAAK;IAClC,QAAQ,IAAI;IACZ,SAAS,IAAI;IACb,MAAM,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,MAAM;IAC5D,QAAQ,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,SAAS;IAClE,CAAgB;GAEjB,MAAM,SAAS,MAAM,WAAW,OAAO,YAAY;IACjD,QAAQ,WAAW;IACnB,SAAS,EAAE;IACZ,CAAC;AAEF,OAAI,OAAO,UAAU;AACnB,QAAI,OAAO,OAAO,SAAS,OAAO;AAClC,WAAO,SAAS,QAAQ,SAAS,OAAe,QAAgB;AAC9D,SAAI,UAAU,KAAK,MAAM;MACzB;IACF,MAAM,OAAO,MAAM,OAAO,SAAS,MAAM;AACzC,QAAI,KAAK,KAAK;SAEd,KAAI,OAAO,IAAI,CAAC,KAAK,YAAY;WAE5B,OAAO;AACd,WAAQ,MAAM,cAAc,MAAM;AAClC,OAAI,OAAO,IAAI,CAAC,KAAK,EAAE,OAAQ,MAAgB,SAAS,CAAC;;GAE3D;AAEF,WAAU,IAAI,IAAI,QAAQ,iBAAiB;AAC3C,WAAU,IAAI,IAAI,UAAU,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"dev-server-middleware.cjs","names":["handlers: { rpc: any, api: any }","cleanup: (() => Promise<void>) | null","lines: string[]"],"sources":["../../../src/build/rspack/dev-server-middleware.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nconst corsHeaders = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'\n};\n\nconst applyCorsHeaders = (res: any) => {\n Object.entries(corsHeaders).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n};\n\nconst normalizePrefix = (prefix?: string): string => {\n if (!prefix) return '';\n const cleaned = prefix.replace(/^\\/+|\\/+$/g, '');\n return cleaned ? `/${cleaned}` : '';\n};\n\nexport function setupPluginMiddleware(devServer: any, pluginInfo: PluginInfo, devConfig: any, port: number) {\n const rpcPrefix = normalizePrefix(devConfig?.prefix);\n let handlers: { rpc: any, api: any } = { rpc: null, api: null };\n let cleanup: (() => Promise<void>) | null = null;\n\n const performCleanup = async () => {\n if (cleanup) {\n await cleanup();\n cleanup = null;\n }\n };\n\n (async () => {\n await performCleanup();\n\n try {\n const { createPluginRuntime } = await import('every-plugin');\n const { RPCHandler } = await import('@orpc/server/fetch');\n const { OpenAPIHandler } = await import('@orpc/openapi/fetch');\n const { OpenAPIReferencePlugin } = await import('@orpc/openapi/plugins');\n const { ZodToJsonSchemaConverter } = await import('@orpc/zod/zod4');\n const { onError } = await import('every-plugin/orpc');\n\n\n const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;\n\n const runtime = createPluginRuntime({\n registry: {\n [pluginId]: {\n remote: `http://localhost:${port}/remoteEntry.js`\n }\n }\n });\n\n const loaded = await runtime.usePlugin(pluginId, devConfig?.config);\n\n cleanup = async () => {\n if (loaded && typeof (loaded as any).dispose === 'function') {\n await (loaded as any).dispose();\n }\n if (runtime && typeof (runtime as any).cleanup === 'function') {\n await (runtime as any).cleanup();\n }\n handlers.rpc = null;\n handlers.api = null;\n if (devServer.app.locals.handlers) {\n devServer.app.locals.handlers = null;\n }\n };\n\n const formatError = (error: any, context: string) => {\n const lines: string[] = [`\\n🔴 ${context} Error: ${error.message || 'Unknown error'}`];\n\n if (error.cause?.issues && Array.isArray(error.cause.issues)) {\n lines.push('\\n📋 Validation Issues:');\n error.cause.issues.forEach((issue: any, index: number) => {\n lines.push(` ${index + 1}. ${issue.path?.join('.') || 'root'}`);\n lines.push(` ├─ Code: ${issue.code || 'unknown'}`);\n lines.push(` ├─ Message: ${issue.message || 'No message'}`);\n if (issue.expected !== undefined) {\n lines.push(` ├─ Expected: ${JSON.stringify(issue.expected)}`);\n }\n if (issue.received !== undefined) {\n lines.push(` └─ Received: ${JSON.stringify(issue.received)}`);\n } else {\n lines.push(` └─ (end)`);\n }\n });\n }\n\n if (error.data && typeof error.data === 'object' && Object.keys(error.data).length > 0) {\n lines.push('\\n📊 Error Data:');\n try {\n const dataStr = JSON.stringify(error.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.data)}`);\n }\n }\n\n if (error.cause?.data) {\n lines.push('\\n📦 Request Data:');\n try {\n const dataStr = JSON.stringify(error.cause.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.cause.data)}`);\n }\n }\n\n if (error.code) {\n lines.push(`\\n⚠️ Error Code: ${error.code}`);\n }\n\n if (error.status) {\n lines.push(`📍 Status: ${error.status}`);\n }\n\n lines.push('');\n console.error(lines.join('\\n'));\n };\n\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n handlers.api = new OpenAPIHandler(loaded.router, {\n plugins: [\n new OpenAPIReferencePlugin({\n schemaConverters: [new ZodToJsonSchemaConverter()],\n }),\n ],\n interceptors: [\n onError((error: any) => {\n formatError(error, 'OpenAPI');\n }),\n ]\n });\n\n console.log(`╭─────────────────────────────────────────────`);\n console.log(`│ ✅ Plugin dev server ready: `);\n console.log(`├─────────────────────────────────────────────`);\n console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);\n console.log(`│ 📖 Docs: http://localhost:${port}/api`);\n console.log(`│ 💚 Health: http://localhost:${port}/`);\n console.log(`╰─────────────────────────────────────────────`);\n\n devServer.app.locals.handlers = handlers;\n\n if (devServer.server) {\n devServer.server.once('close', async () => {\n await performCleanup();\n });\n }\n } catch (error) {\n console.error('❌ Failed to load plugin:', error);\n await performCleanup();\n }\n })();\n\n process.once('SIGINT', async () => {\n await performCleanup();\n });\n process.once('SIGTERM', async () => {\n await performCleanup();\n });\n\n devServer.app.options('*', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.status(200).end();\n });\n\n devServer.app.get('/', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.json({\n ok: true,\n plugin: pluginInfo.normalizedName,\n version: pluginInfo.version,\n status: devServer.app.locals.handlers?.rpc ? 'ready' : 'loading',\n endpoints: {\n health: '/',\n docs: '/api',\n rpc: `/api/rpc${rpcPrefix}`\n }\n });\n });\n\n // OpenAPI documentation and REST endpoints at /api and /api/*\n const handleApiRequest = async (req: any, res: any) => {\n applyCorsHeaders(res);\n const apiHandler = devServer.app.locals.handlers?.api;\n if (!apiHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await apiHandler.handle(webRequest, {\n prefix: '/api',\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('OpenAPI error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n };\n\n devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req: any, res: any) => {\n applyCorsHeaders(res);\n const rpcHandler = devServer.app.locals.handlers?.rpc;\n if (!rpcHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await rpcHandler.handle(webRequest, {\n prefix: `/api/rpc${rpcPrefix}`,\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('RPC error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n });\n\n devServer.app.all('/api', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\n}\n"],"mappings":";;AAEA,MAAM,cAAc;CAClB,+BAA+B;CAC/B,gCAAgC;CAChC,gCAAgC;CACjC;AAED,MAAM,oBAAoB,QAAa;AACrC,QAAO,QAAQ,YAAY,CAAC,SAAS,CAAC,KAAK,WAAW;AACpD,MAAI,UAAU,KAAK,MAAM;GACzB;;AAGJ,MAAM,mBAAmB,WAA4B;AACnD,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,UAAU,OAAO,QAAQ,cAAc,GAAG;AAChD,QAAO,UAAU,IAAI,YAAY;;AAGnC,SAAgB,sBAAsB,WAAgB,YAAwB,WAAgB,MAAc;CAC1G,MAAM,YAAY,gBAAgB,WAAW,OAAO;CACpD,IAAIA,WAAmC;EAAE,KAAK;EAAM,KAAK;EAAM;CAC/D,IAAIC,UAAwC;CAE5C,MAAM,iBAAiB,YAAY;AACjC,MAAI,SAAS;AACX,SAAM,SAAS;AACf,aAAU;;;AAId,EAAC,YAAY;AACX,QAAM,gBAAgB;AAEtB,MAAI;GACF,MAAM,EAAE,wBAAwB,2CAAM;GACtC,MAAM,EAAE,eAAe,MAAM,OAAO;GACpC,MAAM,EAAE,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,CAAC,KAAK,EAAE,OAAQ,MAAgB,SAAS,CAAC;;GAE3D;AAEF,WAAU,IAAI,IAAI,QAAQ,iBAAiB;AAC3C,WAAU,IAAI,IAAI,UAAU,iBAAiB"}
|
|
@@ -32,10 +32,10 @@ function setupPluginMiddleware(devServer, pluginInfo, devConfig, port) {
|
|
|
32
32
|
try {
|
|
33
33
|
const { createPluginRuntime } = await import("../../index.mjs");
|
|
34
34
|
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
35
|
-
const { onError } = await import("@orpc/server");
|
|
36
35
|
const { OpenAPIHandler } = await import("@orpc/openapi/fetch");
|
|
37
36
|
const { OpenAPIReferencePlugin } = await import("@orpc/openapi/plugins");
|
|
38
37
|
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
38
|
+
const { onError } = await import("../../orpc.mjs");
|
|
39
39
|
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
40
40
|
const runtime = createPluginRuntime({ registry: { [pluginId]: { remote: `http://localhost:${port}/remoteEntry.js` } } });
|
|
41
41
|
const loaded = await runtime.usePlugin(pluginId, devConfig?.config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-middleware.mjs","names":["handlers: { rpc: any, api: any }","cleanup: (() => Promise<void>) | null","lines: string[]"],"sources":["../../../src/build/rspack/dev-server-middleware.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nconst corsHeaders = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'\n};\n\nconst applyCorsHeaders = (res: any) => {\n Object.entries(corsHeaders).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n};\n\nconst normalizePrefix = (prefix?: string): string => {\n if (!prefix) return '';\n const cleaned = prefix.replace(/^\\/+|\\/+$/g, '');\n return cleaned ? `/${cleaned}` : '';\n};\n\nexport function setupPluginMiddleware(devServer: any, pluginInfo: PluginInfo, devConfig: any, port: number) {\n const rpcPrefix = normalizePrefix(devConfig?.prefix);\n let handlers: { rpc: any, api: any } = { rpc: null, api: null };\n let cleanup: (() => Promise<void>) | null = null;\n\n const performCleanup = async () => {\n if (cleanup) {\n await cleanup();\n cleanup = null;\n }\n };\n\n (async () => {\n await performCleanup();\n\n try {\n const { createPluginRuntime } = await import('every-plugin');\n const { RPCHandler } = await import('@orpc/server/fetch');\n const { onError } = await import('@orpc/server');\n const { OpenAPIHandler } = await import('@orpc/openapi/fetch');\n const { OpenAPIReferencePlugin } = await import('@orpc/openapi/plugins');\n const { ZodToJsonSchemaConverter } = await import('@orpc/zod/zod4');\n\n const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;\n\n const runtime = createPluginRuntime({\n registry: {\n [pluginId]: {\n remote: `http://localhost:${port}/remoteEntry.js`\n }\n }\n });\n\n const loaded = await runtime.usePlugin(pluginId, devConfig?.config);\n\n cleanup = async () => {\n if (loaded && typeof (loaded as any).dispose === 'function') {\n await (loaded as any).dispose();\n }\n if (runtime && typeof (runtime as any).cleanup === 'function') {\n await (runtime as any).cleanup();\n }\n handlers.rpc = null;\n handlers.api = null;\n if (devServer.app.locals.handlers) {\n devServer.app.locals.handlers = null;\n }\n };\n\n const formatError = (error: any, context: string) => {\n const lines: string[] = [`\\n🔴 ${context} Error: ${error.message || 'Unknown error'}`];\n \n if (error.cause?.issues && Array.isArray(error.cause.issues)) {\n lines.push('\\n📋 Validation Issues:');\n error.cause.issues.forEach((issue: any, index: number) => {\n lines.push(` ${index + 1}. ${issue.path?.join('.') || 'root'}`);\n lines.push(` ├─ Code: ${issue.code || 'unknown'}`);\n lines.push(` ├─ Message: ${issue.message || 'No message'}`);\n if (issue.expected !== undefined) {\n lines.push(` ├─ Expected: ${JSON.stringify(issue.expected)}`);\n }\n if (issue.received !== undefined) {\n lines.push(` └─ Received: ${JSON.stringify(issue.received)}`);\n } else {\n lines.push(` └─ (end)`);\n }\n });\n }\n \n if (error.data && typeof error.data === 'object' && Object.keys(error.data).length > 0) {\n lines.push('\\n📊 Error Data:');\n try {\n const dataStr = JSON.stringify(error.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.data)}`);\n }\n }\n \n if (error.cause?.data) {\n lines.push('\\n📦 Request Data:');\n try {\n const dataStr = JSON.stringify(error.cause.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.cause.data)}`);\n }\n }\n \n if (error.code) {\n lines.push(`\\n⚠️ Error Code: ${error.code}`);\n }\n \n if (error.status) {\n lines.push(`📍 Status: ${error.status}`);\n }\n \n lines.push('');\n console.error(lines.join('\\n'));\n };\n\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n handlers.api = new OpenAPIHandler(loaded.router, {\n plugins: [\n new OpenAPIReferencePlugin({\n schemaConverters: [new ZodToJsonSchemaConverter()],\n }),\n ],\n interceptors: [\n onError((error: any) => {\n formatError(error, 'OpenAPI');\n }),\n ]\n });\n\n console.log(`╭─────────────────────────────────────────────`);\n console.log(`│ ✅ Plugin dev server ready: `);\n console.log(`├─────────────────────────────────────────────`);\n console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);\n console.log(`│ 📖 Docs: http://localhost:${port}/api`);\n console.log(`│ 💚 Health: http://localhost:${port}/`);\n console.log(`╰─────────────────────────────────────────────`);\n\n devServer.app.locals.handlers = handlers;\n\n if (devServer.server) {\n devServer.server.once('close', async () => {\n await performCleanup();\n });\n }\n } catch (error) {\n console.error('❌ Failed to load plugin:', error);\n await performCleanup();\n }\n })();\n\n process.once('SIGINT', async () => {\n await performCleanup();\n });\n process.once('SIGTERM', async () => {\n await performCleanup();\n });\n\n devServer.app.options('*', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.status(200).end();\n });\n\n devServer.app.get('/', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.json({\n ok: true,\n plugin: pluginInfo.normalizedName,\n version: pluginInfo.version,\n status: devServer.app.locals.handlers?.rpc ? 'ready' : 'loading',\n endpoints: {\n health: '/',\n docs: '/api',\n rpc: `/api/rpc${rpcPrefix}`\n }\n });\n });\n\n // OpenAPI documentation and REST endpoints at /api and /api/*\n const handleApiRequest = async (req: any, res: any) => {\n applyCorsHeaders(res);\n const apiHandler = devServer.app.locals.handlers?.api;\n if (!apiHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await apiHandler.handle(webRequest, {\n prefix: '/api',\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('OpenAPI error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n };\n\n devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req: any, res: any) => {\n applyCorsHeaders(res);\n const rpcHandler = devServer.app.locals.handlers?.rpc;\n if (!rpcHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await rpcHandler.handle(webRequest, {\n prefix: `/api/rpc${rpcPrefix}`,\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('RPC error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n });\n\n devServer.app.all('/api', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\n}\n"],"mappings":";AAEA,MAAM,cAAc;CAClB,+BAA+B;CAC/B,gCAAgC;CAChC,gCAAgC;CACjC;AAED,MAAM,oBAAoB,QAAa;AACrC,QAAO,QAAQ,YAAY,CAAC,SAAS,CAAC,KAAK,WAAW;AACpD,MAAI,UAAU,KAAK,MAAM;GACzB;;AAGJ,MAAM,mBAAmB,WAA4B;AACnD,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,UAAU,OAAO,QAAQ,cAAc,GAAG;AAChD,QAAO,UAAU,IAAI,YAAY;;AAGnC,SAAgB,sBAAsB,WAAgB,YAAwB,WAAgB,MAAc;CAC1G,MAAM,YAAY,gBAAgB,WAAW,OAAO;CACpD,IAAIA,WAAmC;EAAE,KAAK;EAAM,KAAK;EAAM;CAC/D,IAAIC,UAAwC;CAE5C,MAAM,iBAAiB,YAAY;AACjC,MAAI,SAAS;AACX,SAAM,SAAS;AACf,aAAU;;;AAId,EAAC,YAAY;AACX,QAAM,gBAAgB;AAEtB,MAAI;GACF,MAAM,EAAE,wBAAwB,MAAM,OAAO;GAC7C,MAAM,EAAE,eAAe,MAAM,OAAO;GACpC,MAAM,EAAE,YAAY,MAAM,OAAO;GACjC,MAAM,EAAE,mBAAmB,MAAM,OAAO;GACxC,MAAM,EAAE,2BAA2B,MAAM,OAAO;GAChD,MAAM,EAAE,6BAA6B,MAAM,OAAO;GAElD,MAAM,WAAW,WAAW,YAAY,WAAW;GAEnD,MAAM,UAAU,oBAAoB,EAClC,UAAU,GACP,WAAW,EACV,QAAQ,oBAAoB,KAAK,kBAClC,EACF,EACF,CAAC;GAEF,MAAM,SAAS,MAAM,QAAQ,UAAU,UAAU,WAAW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KAAK,EAAE,OAAQ,MAAgB,SAAS,CAAC;;;AAI7D,WAAU,IAAI,IAAI,WAAW,UAAU,KAAK,OAAO,KAAU,QAAa;AACxE,mBAAiB,IAAI;EACrB,MAAM,aAAa,UAAU,IAAI,OAAO,UAAU;AAClD,MAAI,CAAC,WACH,QAAO,IAAI,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,2BAA2B,CAAC;AAGnE,MAAI;GACF,MAAM,MAAM,UAAU,IAAI,QAAQ,OAAO,IAAI;GAC7C,MAAM,aAAa,IAAI,QAAQ,KAAK;IAClC,QAAQ,IAAI;IACZ,SAAS,IAAI;IACb,MAAM,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,MAAM;IAC5D,QAAQ,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,SAAS;IAClE,CAAgB;GAEjB,MAAM,SAAS,MAAM,WAAW,OAAO,YAAY;IACjD,QAAQ,WAAW;IACnB,SAAS,EAAE;IACZ,CAAC;AAEF,OAAI,OAAO,UAAU;AACnB,QAAI,OAAO,OAAO,SAAS,OAAO;AAClC,WAAO,SAAS,QAAQ,SAAS,OAAe,QAAgB;AAC9D,SAAI,UAAU,KAAK,MAAM;MACzB;IACF,MAAM,OAAO,MAAM,OAAO,SAAS,MAAM;AACzC,QAAI,KAAK,KAAK;SAEd,KAAI,OAAO,IAAI,CAAC,KAAK,YAAY;WAE5B,OAAO;AACd,WAAQ,MAAM,cAAc,MAAM;AAClC,OAAI,OAAO,IAAI,CAAC,KAAK,EAAE,OAAQ,MAAgB,SAAS,CAAC;;GAE3D;AAEF,WAAU,IAAI,IAAI,QAAQ,iBAAiB;AAC3C,WAAU,IAAI,IAAI,UAAU,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"dev-server-middleware.mjs","names":["handlers: { rpc: any, api: any }","cleanup: (() => Promise<void>) | null","lines: string[]"],"sources":["../../../src/build/rspack/dev-server-middleware.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nconst corsHeaders = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'\n};\n\nconst applyCorsHeaders = (res: any) => {\n Object.entries(corsHeaders).forEach(([key, value]) => {\n res.setHeader(key, value);\n });\n};\n\nconst normalizePrefix = (prefix?: string): string => {\n if (!prefix) return '';\n const cleaned = prefix.replace(/^\\/+|\\/+$/g, '');\n return cleaned ? `/${cleaned}` : '';\n};\n\nexport function setupPluginMiddleware(devServer: any, pluginInfo: PluginInfo, devConfig: any, port: number) {\n const rpcPrefix = normalizePrefix(devConfig?.prefix);\n let handlers: { rpc: any, api: any } = { rpc: null, api: null };\n let cleanup: (() => Promise<void>) | null = null;\n\n const performCleanup = async () => {\n if (cleanup) {\n await cleanup();\n cleanup = null;\n }\n };\n\n (async () => {\n await performCleanup();\n\n try {\n const { createPluginRuntime } = await import('every-plugin');\n const { RPCHandler } = await import('@orpc/server/fetch');\n const { OpenAPIHandler } = await import('@orpc/openapi/fetch');\n const { OpenAPIReferencePlugin } = await import('@orpc/openapi/plugins');\n const { ZodToJsonSchemaConverter } = await import('@orpc/zod/zod4');\n const { onError } = await import('every-plugin/orpc');\n\n\n const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;\n\n const runtime = createPluginRuntime({\n registry: {\n [pluginId]: {\n remote: `http://localhost:${port}/remoteEntry.js`\n }\n }\n });\n\n const loaded = await runtime.usePlugin(pluginId, devConfig?.config);\n\n cleanup = async () => {\n if (loaded && typeof (loaded as any).dispose === 'function') {\n await (loaded as any).dispose();\n }\n if (runtime && typeof (runtime as any).cleanup === 'function') {\n await (runtime as any).cleanup();\n }\n handlers.rpc = null;\n handlers.api = null;\n if (devServer.app.locals.handlers) {\n devServer.app.locals.handlers = null;\n }\n };\n\n const formatError = (error: any, context: string) => {\n const lines: string[] = [`\\n🔴 ${context} Error: ${error.message || 'Unknown error'}`];\n\n if (error.cause?.issues && Array.isArray(error.cause.issues)) {\n lines.push('\\n📋 Validation Issues:');\n error.cause.issues.forEach((issue: any, index: number) => {\n lines.push(` ${index + 1}. ${issue.path?.join('.') || 'root'}`);\n lines.push(` ├─ Code: ${issue.code || 'unknown'}`);\n lines.push(` ├─ Message: ${issue.message || 'No message'}`);\n if (issue.expected !== undefined) {\n lines.push(` ├─ Expected: ${JSON.stringify(issue.expected)}`);\n }\n if (issue.received !== undefined) {\n lines.push(` └─ Received: ${JSON.stringify(issue.received)}`);\n } else {\n lines.push(` └─ (end)`);\n }\n });\n }\n\n if (error.data && typeof error.data === 'object' && Object.keys(error.data).length > 0) {\n lines.push('\\n📊 Error Data:');\n try {\n const dataStr = JSON.stringify(error.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.data)}`);\n }\n }\n\n if (error.cause?.data) {\n lines.push('\\n📦 Request Data:');\n try {\n const dataStr = JSON.stringify(error.cause.data, null, 2);\n dataStr.split('\\n').forEach(line => {\n lines.push(` ${line}`);\n });\n } catch {\n lines.push(` ${String(error.cause.data)}`);\n }\n }\n\n if (error.code) {\n lines.push(`\\n⚠️ Error Code: ${error.code}`);\n }\n\n if (error.status) {\n lines.push(`📍 Status: ${error.status}`);\n }\n\n lines.push('');\n console.error(lines.join('\\n'));\n };\n\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n handlers.api = new OpenAPIHandler(loaded.router, {\n plugins: [\n new OpenAPIReferencePlugin({\n schemaConverters: [new ZodToJsonSchemaConverter()],\n }),\n ],\n interceptors: [\n onError((error: any) => {\n formatError(error, 'OpenAPI');\n }),\n ]\n });\n\n console.log(`╭─────────────────────────────────────────────`);\n console.log(`│ ✅ Plugin dev server ready: `);\n console.log(`├─────────────────────────────────────────────`);\n console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);\n console.log(`│ 📖 Docs: http://localhost:${port}/api`);\n console.log(`│ 💚 Health: http://localhost:${port}/`);\n console.log(`╰─────────────────────────────────────────────`);\n\n devServer.app.locals.handlers = handlers;\n\n if (devServer.server) {\n devServer.server.once('close', async () => {\n await performCleanup();\n });\n }\n } catch (error) {\n console.error('❌ Failed to load plugin:', error);\n await performCleanup();\n }\n })();\n\n process.once('SIGINT', async () => {\n await performCleanup();\n });\n process.once('SIGTERM', async () => {\n await performCleanup();\n });\n\n devServer.app.options('*', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.status(200).end();\n });\n\n devServer.app.get('/', (req: any, res: any) => {\n applyCorsHeaders(res);\n res.json({\n ok: true,\n plugin: pluginInfo.normalizedName,\n version: pluginInfo.version,\n status: devServer.app.locals.handlers?.rpc ? 'ready' : 'loading',\n endpoints: {\n health: '/',\n docs: '/api',\n rpc: `/api/rpc${rpcPrefix}`\n }\n });\n });\n\n // OpenAPI documentation and REST endpoints at /api and /api/*\n const handleApiRequest = async (req: any, res: any) => {\n applyCorsHeaders(res);\n const apiHandler = devServer.app.locals.handlers?.api;\n if (!apiHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await apiHandler.handle(webRequest, {\n prefix: '/api',\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('OpenAPI error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n };\n\n devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req: any, res: any) => {\n applyCorsHeaders(res);\n const rpcHandler = devServer.app.locals.handlers?.rpc;\n if (!rpcHandler) {\n return res.status(503).json({ error: 'Plugin still loading...' });\n }\n\n try {\n const url = `http://${req.headers.host}${req.url}`;\n const webRequest = new Request(url, {\n method: req.method,\n headers: req.headers,\n body: req.method !== 'GET' && req.method !== 'HEAD' ? req : undefined,\n duplex: req.method !== 'GET' && req.method !== 'HEAD' ? 'half' : undefined\n } as RequestInit);\n\n const result = await rpcHandler.handle(webRequest, {\n prefix: `/api/rpc${rpcPrefix}`,\n context: {}\n });\n\n if (result.response) {\n res.status(result.response.status);\n result.response.headers.forEach((value: string, key: string) => {\n res.setHeader(key, value);\n });\n const text = await result.response.text();\n res.send(text);\n } else {\n res.status(404).send('Not Found');\n }\n } catch (error) {\n console.error('RPC error:', error);\n res.status(500).json({ error: (error as Error).message });\n }\n });\n\n devServer.app.all('/api', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\n}\n"],"mappings":";AAEA,MAAM,cAAc;CAClB,+BAA+B;CAC/B,gCAAgC;CAChC,gCAAgC;CACjC;AAED,MAAM,oBAAoB,QAAa;AACrC,QAAO,QAAQ,YAAY,CAAC,SAAS,CAAC,KAAK,WAAW;AACpD,MAAI,UAAU,KAAK,MAAM;GACzB;;AAGJ,MAAM,mBAAmB,WAA4B;AACnD,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,UAAU,OAAO,QAAQ,cAAc,GAAG;AAChD,QAAO,UAAU,IAAI,YAAY;;AAGnC,SAAgB,sBAAsB,WAAgB,YAAwB,WAAgB,MAAc;CAC1G,MAAM,YAAY,gBAAgB,WAAW,OAAO;CACpD,IAAIA,WAAmC;EAAE,KAAK;EAAM,KAAK;EAAM;CAC/D,IAAIC,UAAwC;CAE5C,MAAM,iBAAiB,YAAY;AACjC,MAAI,SAAS;AACX,SAAM,SAAS;AACf,aAAU;;;AAId,EAAC,YAAY;AACX,QAAM,gBAAgB;AAEtB,MAAI;GACF,MAAM,EAAE,wBAAwB,MAAM,OAAO;GAC7C,MAAM,EAAE,eAAe,MAAM,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MAAM;AAClC,OAAI,OAAO,IAAI,CAAC,KAAK,EAAE,OAAQ,MAAgB,SAAS,CAAC;;GAE3D;AAEF,WAAU,IAAI,IAAI,QAAQ,iBAAiB;AAC3C,WAAU,IAAI,IAAI,UAAU,iBAAiB"}
|
|
@@ -6,35 +6,30 @@ function buildSharedDependencies(pluginInfo) {
|
|
|
6
6
|
"every-plugin": {
|
|
7
7
|
version: require_package.version,
|
|
8
8
|
singleton: true,
|
|
9
|
-
requiredVersion: `${require_package.version}`,
|
|
10
9
|
strictVersion: false,
|
|
11
10
|
eager: false
|
|
12
11
|
},
|
|
13
12
|
effect: {
|
|
14
13
|
version: require_package.dependencies.effect,
|
|
15
14
|
singleton: true,
|
|
16
|
-
requiredVersion: `${require_package.dependencies.effect}`,
|
|
17
15
|
strictVersion: false,
|
|
18
16
|
eager: false
|
|
19
17
|
},
|
|
20
18
|
zod: {
|
|
21
19
|
version: require_package.dependencies.zod,
|
|
22
20
|
singleton: true,
|
|
23
|
-
requiredVersion: `${require_package.dependencies.zod}`,
|
|
24
21
|
strictVersion: false,
|
|
25
22
|
eager: false
|
|
26
23
|
},
|
|
27
24
|
"@orpc/contract": {
|
|
28
25
|
version: require_package.dependencies["@orpc/contract"],
|
|
29
26
|
singleton: true,
|
|
30
|
-
requiredVersion: `${require_package.dependencies["@orpc/contract"]}`,
|
|
31
27
|
strictVersion: false,
|
|
32
28
|
eager: false
|
|
33
29
|
},
|
|
34
30
|
"@orpc/server": {
|
|
35
31
|
version: require_package.dependencies["@orpc/server"],
|
|
36
32
|
singleton: true,
|
|
37
|
-
requiredVersion: `${require_package.dependencies["@orpc/server"]}`,
|
|
38
33
|
strictVersion: false,
|
|
39
34
|
eager: false
|
|
40
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.cjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import everyPluginPkg from '../../../package.json';\nimport type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n
|
|
1
|
+
{"version":3,"file":"module-federation.cjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import everyPluginPkg from '../../../package.json';\nimport type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,wBAAwB,YAAwB;AAE9D,QAAO;EACL,gBAAgB;GACd;GACA,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,sCAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,sCAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sCAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sCAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACF"}
|
|
@@ -6,35 +6,30 @@ function buildSharedDependencies(pluginInfo) {
|
|
|
6
6
|
"every-plugin": {
|
|
7
7
|
version,
|
|
8
8
|
singleton: true,
|
|
9
|
-
requiredVersion: `${version}`,
|
|
10
9
|
strictVersion: false,
|
|
11
10
|
eager: false
|
|
12
11
|
},
|
|
13
12
|
effect: {
|
|
14
13
|
version: dependencies.effect,
|
|
15
14
|
singleton: true,
|
|
16
|
-
requiredVersion: `${dependencies.effect}`,
|
|
17
15
|
strictVersion: false,
|
|
18
16
|
eager: false
|
|
19
17
|
},
|
|
20
18
|
zod: {
|
|
21
19
|
version: dependencies.zod,
|
|
22
20
|
singleton: true,
|
|
23
|
-
requiredVersion: `${dependencies.zod}`,
|
|
24
21
|
strictVersion: false,
|
|
25
22
|
eager: false
|
|
26
23
|
},
|
|
27
24
|
"@orpc/contract": {
|
|
28
25
|
version: dependencies["@orpc/contract"],
|
|
29
26
|
singleton: true,
|
|
30
|
-
requiredVersion: `${dependencies["@orpc/contract"]}`,
|
|
31
27
|
strictVersion: false,
|
|
32
28
|
eager: false
|
|
33
29
|
},
|
|
34
30
|
"@orpc/server": {
|
|
35
31
|
version: dependencies["@orpc/server"],
|
|
36
32
|
singleton: true,
|
|
37
|
-
requiredVersion: `${dependencies["@orpc/server"]}`,
|
|
38
33
|
strictVersion: false,
|
|
39
34
|
eager: false
|
|
40
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.mjs","names":["everyPluginPkg.version"],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import everyPluginPkg from '../../../package.json';\nimport type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n
|
|
1
|
+
{"version":3,"file":"module-federation.mjs","names":["everyPluginPkg.version"],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import everyPluginPkg from '../../../package.json';\nimport type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,wBAAwB,YAAwB;AAE9D,QAAO;EACL,gBAAgB;GACLA;GACT,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,sBAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,sBAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sBAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sBAAqC;GACrC,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACF"}
|
|
@@ -26,7 +26,8 @@ var EveryPluginDevServer = class {
|
|
|
26
26
|
runtimePlugins: [require.resolve("@module-federation/node/runtimePlugin")],
|
|
27
27
|
library: { type: "commonjs-module" },
|
|
28
28
|
exposes: { "./plugin": "./src/index.ts" },
|
|
29
|
-
shared: require_module_federation.buildSharedDependencies(pluginInfo)
|
|
29
|
+
shared: require_module_federation.buildSharedDependencies(pluginInfo),
|
|
30
|
+
shareStrategy: "version-first"
|
|
30
31
|
}).apply(compiler);
|
|
31
32
|
}
|
|
32
33
|
configureDefaults(compiler, pluginInfo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["options: EveryPluginOptions","getPluginInfo","loadDevConfig","ModuleFederationPlugin","buildSharedDependencies","path"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\n library: { type: 'commonjs-module' },\n exposes: {\n './plugin': './src/index.ts',\n },\n shared: buildSharedDependencies(pluginInfo),\n }).apply(compiler);\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = 'auto';\n compiler.options.output.path = path.resolve(context, 'dist');\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: 'commonjs-module' };\n\n // Configure target and mode defaults\n if (!compiler.options.target) {\n compiler.options.target = 'async-node';\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === 'development' ? 'development' : 'production';\n }\n\n // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((rule: any) =>\n typeof rule === 'object' &&\n rule !== null &&\n 'test' in rule &&\n rule.test instanceof RegExp &&\n rule.test.test('.ts')\n );\n\n // Add TypeScript loader if not present\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: 'builtin:swc-loader',\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return; // Should never happen due to check in apply()\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, 'dist');\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n };\n\n // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;;AAcA,IAAa,uBAAb,MAAkE;CAChE,OAAO;CAEP,YAAY,AAAQA,UAA8B,EAAE,EAAE;EAAlC;;CAEpB,MAAM,UAAoB;EAExB,MAAM,aAAaC,4BAAc,SAAS,QAAQ,WAAW,QAAQ,KAAK,CAAC;EAC3E,MAAM,YAAYC,4BAAc,KAAK,QAAQ,iBAAiB,kBAAkB;EAChF,MAAM,OAAO,KAAK,QAAQ,QAAQ,WAAW,QAAQ;AAGrD,OAAK,kBAAkB,UAAU,WAAW;AAG5C,MAAI,CAAC,SAAS,QAAQ,UACpB,UAAS,QAAQ,YAAY,EAAE;AAIjC,OAAK,mBAAmB,UAAU,YAAY,WAAW,KAAK;AAG9D,MAAIC,2DAAuB;GACzB,MAAM,WAAW;GACjB,UAAU;GAEV,KAAK;GACL,gBAAgB,CACd,QAAQ,QAAQ,wCAAwC,CACzD;GACD,SAAS,EAAE,MAAM,mBAAmB;GACpC,SAAS,EACP,YAAY,kBACb;GACD,QAAQC,kDAAwB,WAAW;
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["options: EveryPluginOptions","getPluginInfo","loadDevConfig","ModuleFederationPlugin","buildSharedDependencies","path"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\n library: { type: 'commonjs-module' },\n exposes: {\n './plugin': './src/index.ts',\n },\n shared: buildSharedDependencies(pluginInfo),\n shareStrategy: 'version-first',\n }).apply(compiler);\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = 'auto';\n compiler.options.output.path = path.resolve(context, 'dist');\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: 'commonjs-module' };\n\n // Configure target and mode defaults\n if (!compiler.options.target) {\n compiler.options.target = 'async-node';\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === 'development' ? 'development' : 'production';\n }\n\n // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((rule: any) =>\n typeof rule === 'object' &&\n rule !== null &&\n 'test' in rule &&\n rule.test instanceof RegExp &&\n rule.test.test('.ts')\n );\n\n // Add TypeScript loader if not present\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: 'builtin:swc-loader',\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return; // Should never happen due to check in apply()\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, 'dist');\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n };\n\n // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;;AAcA,IAAa,uBAAb,MAAkE;CAChE,OAAO;CAEP,YAAY,AAAQA,UAA8B,EAAE,EAAE;EAAlC;;CAEpB,MAAM,UAAoB;EAExB,MAAM,aAAaC,4BAAc,SAAS,QAAQ,WAAW,QAAQ,KAAK,CAAC;EAC3E,MAAM,YAAYC,4BAAc,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" },
|
|
27
27
|
exposes: { "./plugin": "./src/index.ts" },
|
|
28
|
-
shared: buildSharedDependencies(pluginInfo)
|
|
28
|
+
shared: buildSharedDependencies(pluginInfo),
|
|
29
|
+
shareStrategy: "version-first"
|
|
29
30
|
}).apply(compiler);
|
|
30
31
|
}
|
|
31
32
|
configureDefaults(compiler, pluginInfo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":["options: EveryPluginOptions"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\n library: { type: 'commonjs-module' },\n exposes: {\n './plugin': './src/index.ts',\n },\n shared: buildSharedDependencies(pluginInfo),\n }).apply(compiler);\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = 'auto';\n compiler.options.output.path = path.resolve(context, 'dist');\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: 'commonjs-module' };\n\n // Configure target and mode defaults\n if (!compiler.options.target) {\n compiler.options.target = 'async-node';\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === 'development' ? 'development' : 'production';\n }\n\n // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((rule: any) =>\n typeof rule === 'object' &&\n rule !== null &&\n 'test' in rule &&\n rule.test instanceof RegExp &&\n rule.test.test('.ts')\n );\n\n // Add TypeScript loader if not present\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: 'builtin:swc-loader',\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return; // Should never happen due to check in apply()\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, 'dist');\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n };\n\n // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,uBAAb,MAAkE;CAChE,OAAO;CAEP,YAAY,AAAQA,UAA8B,EAAE,EAAE;EAAlC;;CAEpB,MAAM,UAAoB;EAExB,MAAM,aAAa,cAAc,SAAS,QAAQ,WAAW,QAAQ,KAAK,CAAC;EAC3E,MAAM,YAAY,cAAc,KAAK,QAAQ,iBAAiB,kBAAkB;EAChF,MAAM,OAAO,KAAK,QAAQ,QAAQ,WAAW,QAAQ;AAGrD,OAAK,kBAAkB,UAAU,WAAW;AAG5C,MAAI,CAAC,SAAS,QAAQ,UACpB,UAAS,QAAQ,YAAY,EAAE;AAIjC,OAAK,mBAAmB,UAAU,YAAY,WAAW,KAAK;AAG9D,MAAI,uBAAuB;GACzB,MAAM,WAAW;GACjB,UAAU;GAEV,KAAK;GACL,gBAAgB,WACN,QAAQ,wCAAwC,CACzD;GACD,SAAS,EAAE,MAAM,mBAAmB;GACpC,SAAS,EACP,YAAY,kBACb;GACD,QAAQ,wBAAwB,WAAW;
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":["options: EveryPluginOptions"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\n library: { type: 'commonjs-module' },\n exposes: {\n './plugin': './src/index.ts',\n },\n shared: buildSharedDependencies(pluginInfo),\n shareStrategy: 'version-first',\n }).apply(compiler);\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = 'auto';\n compiler.options.output.path = path.resolve(context, 'dist');\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: 'commonjs-module' };\n\n // Configure target and mode defaults\n if (!compiler.options.target) {\n compiler.options.target = 'async-node';\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === 'development' ? 'development' : 'production';\n }\n\n // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((rule: any) =>\n typeof rule === 'object' &&\n rule !== null &&\n 'test' in rule &&\n rule.test instanceof RegExp &&\n rule.test.test('.ts')\n );\n\n // Add TypeScript loader if not present\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: 'builtin:swc-loader',\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return; // Should never happen due to check in apply()\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, 'dist');\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',\n };\n\n // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,uBAAb,MAAkE;CAChE,OAAO;CAEP,YAAY,AAAQA,UAA8B,EAAE,EAAE;EAAlC;;CAEpB,MAAM,UAAoB;EAExB,MAAM,aAAa,cAAc,SAAS,QAAQ,WAAW,QAAQ,KAAK,CAAC;EAC3E,MAAM,YAAY,cAAc,KAAK,QAAQ,iBAAiB,kBAAkB;EAChF,MAAM,OAAO,KAAK,QAAQ,QAAQ,WAAW,QAAQ;AAGrD,OAAK,kBAAkB,UAAU,WAAW;AAG5C,MAAI,CAAC,SAAS,QAAQ,UACpB,UAAS,QAAQ,YAAY,EAAE;AAIjC,OAAK,mBAAmB,UAAU,YAAY,WAAW,KAAK;AAG9D,MAAI,uBAAuB;GACzB,MAAM,WAAW;GACjB,UAAU;GAEV,KAAK;GACL,gBAAgB,WACN,QAAQ,wCAAwC,CACzD;GACD,SAAS,EAAE,MAAM,mBAAmB;GACpC,SAAS,EACP,YAAY,kBACb;GACD,QAAQ,wBAAwB,WAAW;GAC3C,eAAe;GAChB,CAAC,CAAC,MAAM,SAAS;;CAGpB,AAAQ,kBAAkB,UAAoB,YAAiB;EAC7D,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;AAGzD,MAAI,CAAC,SAAS,QAAQ,OACpB,UAAS,QAAQ,SAAS,EAAE;AAE9B,WAAS,QAAQ,OAAO,aAAa,WAAW;AAChD,WAAS,QAAQ,OAAO,aAAa;AACrC,WAAS,QAAQ,OAAO,OAAO,KAAK,QAAQ,SAAS,OAAO;AAC5D,WAAS,QAAQ,OAAO,QAAQ;AAChC,WAAS,QAAQ,OAAO,UAAU,EAA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,QAAQ,UAAU,UAAU;GACnC,+BAA+B;GAC/B,gCAAgC;GAChC,gCAAgC;GACjC;AAGD,WAAS,QAAQ,UAAU,SAAS;GAClC,SAAS;GACT,SAAS;IACP,UAAU;IACV,QAAQ;IACT;GACF;AAED,WAAS,QAAQ,UAAU,oBAAoB,aAAa,cAAc;AACxE,yBAAsB,WAAW,YAAY,WAAW,KAAK;AAC7D,UAAO,gBAAgB,cAAc,aAAa,UAAU,GAAG"}
|
package/dist/errors.cjs
CHANGED
|
@@ -45,57 +45,81 @@ const ERROR_PATTERNS = {
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
const CommonPluginErrors = {
|
|
48
|
-
UNAUTHORIZED: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
48
|
+
UNAUTHORIZED: {
|
|
49
|
+
status: 401,
|
|
50
|
+
data: require_zod.zod_exports.z.object({
|
|
51
|
+
apiKeyProvided: require_zod.zod_exports.z.boolean(),
|
|
52
|
+
provider: require_zod.zod_exports.z.string().optional(),
|
|
53
|
+
authType: require_zod.zod_exports.z.enum([
|
|
54
|
+
"apiKey",
|
|
55
|
+
"oauth",
|
|
56
|
+
"token"
|
|
57
|
+
]).optional()
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
RATE_LIMITED: {
|
|
61
|
+
status: 429,
|
|
62
|
+
data: require_zod.zod_exports.z.object({
|
|
63
|
+
retryAfter: require_zod.zod_exports.z.number().int().min(1),
|
|
64
|
+
remainingRequests: require_zod.zod_exports.z.number().int().min(0).optional(),
|
|
65
|
+
resetTime: require_zod.zod_exports.z.string().datetime().optional(),
|
|
66
|
+
limitType: require_zod.zod_exports.z.enum([
|
|
67
|
+
"requests",
|
|
68
|
+
"tokens",
|
|
69
|
+
"bandwidth"
|
|
70
|
+
]).optional()
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
SERVICE_UNAVAILABLE: {
|
|
74
|
+
status: 503,
|
|
75
|
+
data: require_zod.zod_exports.z.object({
|
|
76
|
+
retryAfter: require_zod.zod_exports.z.number().int().optional(),
|
|
77
|
+
maintenanceWindow: require_zod.zod_exports.z.boolean().default(false),
|
|
78
|
+
estimatedUptime: require_zod.zod_exports.z.string().datetime().optional()
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
BAD_REQUEST: {
|
|
82
|
+
status: 400,
|
|
83
|
+
data: require_zod.zod_exports.z.object({
|
|
84
|
+
invalidFields: require_zod.zod_exports.z.array(require_zod.zod_exports.z.string()).optional(),
|
|
85
|
+
validationErrors: require_zod.zod_exports.z.array(require_zod.zod_exports.z.object({
|
|
86
|
+
field: require_zod.zod_exports.z.string(),
|
|
87
|
+
message: require_zod.zod_exports.z.string(),
|
|
88
|
+
code: require_zod.zod_exports.z.string().optional()
|
|
89
|
+
})).optional()
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
NOT_FOUND: {
|
|
93
|
+
status: 404,
|
|
94
|
+
data: require_zod.zod_exports.z.object({
|
|
95
|
+
resource: require_zod.zod_exports.z.string().optional(),
|
|
96
|
+
resourceId: require_zod.zod_exports.z.string().optional()
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
FORBIDDEN: {
|
|
100
|
+
status: 403,
|
|
101
|
+
data: require_zod.zod_exports.z.object({
|
|
102
|
+
requiredPermissions: require_zod.zod_exports.z.array(require_zod.zod_exports.z.string()).optional(),
|
|
103
|
+
action: require_zod.zod_exports.z.string().optional()
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
TIMEOUT: {
|
|
107
|
+
status: 504,
|
|
108
|
+
data: require_zod.zod_exports.z.object({
|
|
109
|
+
timeoutMs: require_zod.zod_exports.z.number().int().min(0).optional(),
|
|
110
|
+
operation: require_zod.zod_exports.z.string().optional(),
|
|
111
|
+
retryable: require_zod.zod_exports.z.boolean().default(true)
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
CONNECTION_ERROR: {
|
|
115
|
+
status: 502,
|
|
116
|
+
data: require_zod.zod_exports.z.object({
|
|
117
|
+
errorCode: require_zod.zod_exports.z.string().optional(),
|
|
118
|
+
host: require_zod.zod_exports.z.string().optional(),
|
|
119
|
+
port: require_zod.zod_exports.z.number().int().optional(),
|
|
120
|
+
suggestion: require_zod.zod_exports.z.string().optional()
|
|
121
|
+
})
|
|
122
|
+
}
|
|
99
123
|
};
|
|
100
124
|
|
|
101
125
|
//#endregion
|