every-plugin 0.5.1 ā 0.6.1
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 +0 -4
- package/dist/_virtual/rolldown_runtime.mjs +1 -10
- 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 +11 -12
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +11 -12
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/errors.cjs +41 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +29 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +29 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +41 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/package.cjs +20 -161
- package/dist/package.cjs.map +1 -1
- package/dist/package.mjs +13 -163
- package/dist/package.mjs.map +1 -1
- package/dist/runtime/errors.cjs +54 -2
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.mjs +54 -2
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +7 -8
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +7 -9
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +11 -4
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.mjs +11 -4
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
8
|
var __copyProps = (to, from, except, desc) => {
|
|
12
9
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
10
|
key = keys[i];
|
|
@@ -26,6 +23,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
23
|
|
|
27
24
|
//#endregion
|
|
28
25
|
|
|
29
|
-
exports.__commonJS = __commonJS;
|
|
30
26
|
exports.__reExport = __reExport;
|
|
31
27
|
exports.__toESM = __toESM;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
|
|
3
3
|
//#region rolldown:runtime
|
|
4
|
-
var __create = Object.create;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __commonJS = (cb, mod) => function() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
8
|
var __copyProps = (to, from, except, desc) => {
|
|
14
9
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
10
|
key = keys[i];
|
|
@@ -21,11 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
16
|
return to;
|
|
22
17
|
};
|
|
23
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
-
value: mod,
|
|
26
|
-
enumerable: true
|
|
27
|
-
}) : target, mod));
|
|
28
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
29
20
|
|
|
30
21
|
//#endregion
|
|
31
|
-
export {
|
|
22
|
+
export { __reExport, __require };
|
|
@@ -38,7 +38,7 @@ function setupPluginMiddleware(devServer, pluginInfo, devConfig, port) {
|
|
|
38
38
|
const { OpenAPIReferencePlugin } = await import("@orpc/openapi/plugins");
|
|
39
39
|
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
40
40
|
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
41
|
-
const runtime = createPluginRuntime({ registry: { [pluginId]: {
|
|
41
|
+
const runtime = createPluginRuntime({ registry: { [pluginId]: { remote: `http://localhost:${port}/remoteEntry.js` } } });
|
|
42
42
|
const loaded = await runtime.usePlugin(pluginId, devConfig?.config);
|
|
43
43
|
cleanup = async () => {
|
|
44
44
|
if (loaded && typeof loaded.dispose === "function") await loaded.dispose();
|
|
@@ -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 remoteUrl: `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 // @ts-expect-error no type\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n // @ts-expect-error no type\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', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\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"],"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,EAA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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"}
|
|
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 // @ts-expect-error no type\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n // @ts-expect-error no type\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', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\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"],"mappings":";;AAEA,MAAM,cAAc;CAClB,+BAA+B;CAC/B,gCAAgC;CAChC,gCAAgC;CACjC;AAED,MAAM,oBAAoB,QAAa;AACrC,QAAO,QAAQ,YAA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E,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"}
|
|
@@ -37,7 +37,7 @@ function setupPluginMiddleware(devServer, pluginInfo, devConfig, port) {
|
|
|
37
37
|
const { OpenAPIReferencePlugin } = await import("@orpc/openapi/plugins");
|
|
38
38
|
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
39
39
|
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
40
|
-
const runtime = createPluginRuntime({ registry: { [pluginId]: {
|
|
40
|
+
const runtime = createPluginRuntime({ registry: { [pluginId]: { remote: `http://localhost:${port}/remoteEntry.js` } } });
|
|
41
41
|
const loaded = await runtime.usePlugin(pluginId, devConfig?.config);
|
|
42
42
|
cleanup = async () => {
|
|
43
43
|
if (loaded && typeof loaded.dispose === "function") await loaded.dispose();
|
|
@@ -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 remoteUrl: `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 // @ts-expect-error no type\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n // @ts-expect-error no type\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', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\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"],"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,OA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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"}
|
|
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 // @ts-expect-error no type\n handlers.rpc = new RPCHandler(loaded.router, {\n interceptors: [\n onError((error: any) => {\n formatError(error, 'RPC');\n }),\n ]\n });\n\n // @ts-expect-error no type\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', handleApiRequest);\n devServer.app.all('/api/*', handleApiRequest);\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);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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"}
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
const require_package
|
|
1
|
+
const require_package = require('../../package.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/build/rspack/module-federation.ts
|
|
4
4
|
function buildSharedDependencies(pluginInfo) {
|
|
5
|
-
const everyPluginPkg = require_package$1.default();
|
|
6
5
|
return {
|
|
7
6
|
"every-plugin": {
|
|
8
|
-
version:
|
|
7
|
+
version: require_package.version,
|
|
9
8
|
singleton: true,
|
|
10
|
-
requiredVersion: `${
|
|
9
|
+
requiredVersion: `${require_package.version}`,
|
|
11
10
|
strictVersion: false,
|
|
12
11
|
eager: false
|
|
13
12
|
},
|
|
14
13
|
effect: {
|
|
15
|
-
version:
|
|
14
|
+
version: require_package.dependencies.effect,
|
|
16
15
|
singleton: true,
|
|
17
|
-
requiredVersion: `${
|
|
16
|
+
requiredVersion: `${require_package.dependencies.effect}`,
|
|
18
17
|
strictVersion: false,
|
|
19
18
|
eager: false
|
|
20
19
|
},
|
|
21
20
|
zod: {
|
|
22
|
-
version:
|
|
21
|
+
version: require_package.dependencies.zod,
|
|
23
22
|
singleton: true,
|
|
24
|
-
requiredVersion: `${
|
|
23
|
+
requiredVersion: `${require_package.dependencies.zod}`,
|
|
25
24
|
strictVersion: false,
|
|
26
25
|
eager: false
|
|
27
26
|
},
|
|
28
27
|
"@orpc/contract": {
|
|
29
|
-
version:
|
|
28
|
+
version: require_package.dependencies["@orpc/contract"],
|
|
30
29
|
singleton: true,
|
|
31
|
-
requiredVersion: `${
|
|
30
|
+
requiredVersion: `${require_package.dependencies["@orpc/contract"]}`,
|
|
32
31
|
strictVersion: false,
|
|
33
32
|
eager: false
|
|
34
33
|
},
|
|
35
34
|
"@orpc/server": {
|
|
36
|
-
version:
|
|
35
|
+
version: require_package.dependencies["@orpc/server"],
|
|
37
36
|
singleton: true,
|
|
38
|
-
requiredVersion: `${
|
|
37
|
+
requiredVersion: `${require_package.dependencies["@orpc/server"]}`,
|
|
39
38
|
strictVersion: false,
|
|
40
39
|
eager: false
|
|
41
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.cjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\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 requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,wBAAwB,YAAwB;AAE9D,QAAO;EACL,gBAAgB;GACd;GACA,WAAW;GACX,iBAAiB;GACjB,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dependencies, version } from "../../package.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/build/rspack/module-federation.ts
|
|
4
4
|
function buildSharedDependencies(pluginInfo) {
|
|
5
|
-
const everyPluginPkg = require_package();
|
|
6
5
|
return {
|
|
7
6
|
"every-plugin": {
|
|
8
|
-
version
|
|
7
|
+
version,
|
|
9
8
|
singleton: true,
|
|
10
|
-
requiredVersion: `${
|
|
9
|
+
requiredVersion: `${version}`,
|
|
11
10
|
strictVersion: false,
|
|
12
11
|
eager: false
|
|
13
12
|
},
|
|
14
13
|
effect: {
|
|
15
|
-
version:
|
|
14
|
+
version: dependencies.effect,
|
|
16
15
|
singleton: true,
|
|
17
|
-
requiredVersion: `${
|
|
16
|
+
requiredVersion: `${dependencies.effect}`,
|
|
18
17
|
strictVersion: false,
|
|
19
18
|
eager: false
|
|
20
19
|
},
|
|
21
20
|
zod: {
|
|
22
|
-
version:
|
|
21
|
+
version: dependencies.zod,
|
|
23
22
|
singleton: true,
|
|
24
|
-
requiredVersion: `${
|
|
23
|
+
requiredVersion: `${dependencies.zod}`,
|
|
25
24
|
strictVersion: false,
|
|
26
25
|
eager: false
|
|
27
26
|
},
|
|
28
27
|
"@orpc/contract": {
|
|
29
|
-
version:
|
|
28
|
+
version: dependencies["@orpc/contract"],
|
|
30
29
|
singleton: true,
|
|
31
|
-
requiredVersion: `${
|
|
30
|
+
requiredVersion: `${dependencies["@orpc/contract"]}`,
|
|
32
31
|
strictVersion: false,
|
|
33
32
|
eager: false
|
|
34
33
|
},
|
|
35
34
|
"@orpc/server": {
|
|
36
|
-
version:
|
|
35
|
+
version: dependencies["@orpc/server"],
|
|
37
36
|
singleton: true,
|
|
38
|
-
requiredVersion: `${
|
|
37
|
+
requiredVersion: `${dependencies["@orpc/server"]}`,
|
|
39
38
|
strictVersion: false,
|
|
40
39
|
eager: false
|
|
41
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.mjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\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 requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,wBAAwB,YAAwB;AAE9D,QAAO;EACL,gBAAgB;GACLA;GACT,WAAW;GACX,iBAAiB,GAAGA;GACpB,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
|
package/dist/errors.cjs
CHANGED
|
@@ -2,6 +2,35 @@ const require_zod = require('./zod.cjs');
|
|
|
2
2
|
|
|
3
3
|
//#region src/errors.ts
|
|
4
4
|
/**
|
|
5
|
+
* Error pattern constants for categorizing infrastructure errors
|
|
6
|
+
*/
|
|
7
|
+
const ERROR_PATTERNS = {
|
|
8
|
+
CONNECTION_REFUSED: ["ECONNREFUSED"],
|
|
9
|
+
HOST_NOT_FOUND: ["ENOTFOUND", "EHOSTUNREACH"],
|
|
10
|
+
TIMEOUT: [
|
|
11
|
+
"ETIMEDOUT",
|
|
12
|
+
"ESOCKETTIMEDOUT",
|
|
13
|
+
"timeout"
|
|
14
|
+
],
|
|
15
|
+
CONNECTION_RESET: ["ECONNRESET", "EPIPE"],
|
|
16
|
+
PERMISSION: [
|
|
17
|
+
"EACCES",
|
|
18
|
+
"EPERM",
|
|
19
|
+
"permission denied"
|
|
20
|
+
],
|
|
21
|
+
AUTH: [
|
|
22
|
+
"401",
|
|
23
|
+
"unauthorized",
|
|
24
|
+
"authentication failed"
|
|
25
|
+
],
|
|
26
|
+
RATE_LIMITED: [
|
|
27
|
+
"429",
|
|
28
|
+
"too many requests",
|
|
29
|
+
"rate limit"
|
|
30
|
+
],
|
|
31
|
+
SERVICE_UNAVAILABLE: ["503", "service unavailable"]
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
5
34
|
* Common error schemas for plugin contracts.
|
|
6
35
|
* Import these to ensure consistent error handling across plugins.
|
|
7
36
|
*
|
|
@@ -55,9 +84,21 @@ const CommonPluginErrors = {
|
|
|
55
84
|
FORBIDDEN: { data: require_zod.zod_exports.z.object({
|
|
56
85
|
requiredPermissions: require_zod.zod_exports.z.array(require_zod.zod_exports.z.string()).optional(),
|
|
57
86
|
action: require_zod.zod_exports.z.string().optional()
|
|
87
|
+
}) },
|
|
88
|
+
TIMEOUT: { data: require_zod.zod_exports.z.object({
|
|
89
|
+
timeoutMs: require_zod.zod_exports.z.number().int().min(0).optional(),
|
|
90
|
+
operation: require_zod.zod_exports.z.string().optional(),
|
|
91
|
+
retryable: require_zod.zod_exports.z.boolean().default(true)
|
|
92
|
+
}) },
|
|
93
|
+
CONNECTION_ERROR: { data: require_zod.zod_exports.z.object({
|
|
94
|
+
errorCode: require_zod.zod_exports.z.string().optional(),
|
|
95
|
+
host: require_zod.zod_exports.z.string().optional(),
|
|
96
|
+
port: require_zod.zod_exports.z.number().int().optional(),
|
|
97
|
+
suggestion: require_zod.zod_exports.z.string().optional()
|
|
58
98
|
}) }
|
|
59
99
|
};
|
|
60
100
|
|
|
61
101
|
//#endregion
|
|
62
102
|
exports.CommonPluginErrors = CommonPluginErrors;
|
|
103
|
+
exports.ERROR_PATTERNS = ERROR_PATTERNS;
|
|
63
104
|
//# sourceMappingURL=errors.cjs.map
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n\tCONNECTION_REFUSED: ['ECONNREFUSED'],\n\tHOST_NOT_FOUND: ['ENOTFOUND', 'EHOSTUNREACH'],\n\tTIMEOUT: ['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'timeout'],\n\tCONNECTION_RESET: ['ECONNRESET', 'EPIPE'],\n\tPERMISSION: ['EACCES', 'EPERM', 'permission denied'],\n\tAUTH: ['401', 'unauthorized', 'authentication failed'],\n\tRATE_LIMITED: ['429', 'too many requests', 'rate limit'],\n\tSERVICE_UNAVAILABLE: ['503', 'service unavailable'],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t},\n\tTIMEOUT: {\n\t\tdata: z.object({\n\t\t\ttimeoutMs: z.number().int().min(0).optional(),\n\t\t\toperation: z.string().optional(),\n\t\t\tretryable: z.boolean().default(true),\n\t\t})\n\t},\n\tCONNECTION_ERROR: {\n\t\tdata: z.object({\n\t\t\terrorCode: z.string().optional(),\n\t\t\thost: z.string().optional(),\n\t\t\tport: z.number().int().optional(),\n\t\t\tsuggestion: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":";;;;;;AAKA,MAAa,iBAAiB;CAC7B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ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,oCAAY,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,EACF;CACD,WAAW,EACV,8BAAM,EAAE,OAAO;EACd,6CAAqB,EAAE,8BAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,gCAAQ,EAAE,QAAQ,CAAC,UAAU;EAC7B,CAAC,EACF;CACD,SAAS,EACR,8BAAM,EAAE,OAAO;EACd,mCAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,mCAAW,EAAE,SAAS,CAAC,QAAQ,KAAK;EACpC,CAAC,EACF;CACD,kBAAkB,EACjB,8BAAM,EAAE,OAAO;EACd,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,8BAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,8BAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,oCAAY,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,EACF;CACD"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -2,6 +2,19 @@ import { zod_d_exports } from "./zod.cjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Error pattern constants for categorizing infrastructure errors
|
|
7
|
+
*/
|
|
8
|
+
declare const ERROR_PATTERNS: {
|
|
9
|
+
readonly CONNECTION_REFUSED: readonly ["ECONNREFUSED"];
|
|
10
|
+
readonly HOST_NOT_FOUND: readonly ["ENOTFOUND", "EHOSTUNREACH"];
|
|
11
|
+
readonly TIMEOUT: readonly ["ETIMEDOUT", "ESOCKETTIMEDOUT", "timeout"];
|
|
12
|
+
readonly CONNECTION_RESET: readonly ["ECONNRESET", "EPIPE"];
|
|
13
|
+
readonly PERMISSION: readonly ["EACCES", "EPERM", "permission denied"];
|
|
14
|
+
readonly AUTH: readonly ["401", "unauthorized", "authentication failed"];
|
|
15
|
+
readonly RATE_LIMITED: readonly ["429", "too many requests", "rate limit"];
|
|
16
|
+
readonly SERVICE_UNAVAILABLE: readonly ["503", "service unavailable"];
|
|
17
|
+
};
|
|
5
18
|
/**
|
|
6
19
|
* Common error schemas for plugin contracts.
|
|
7
20
|
* Import these to ensure consistent error handling across plugins.
|
|
@@ -69,7 +82,22 @@ declare const CommonPluginErrors: {
|
|
|
69
82
|
action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
70
83
|
}, zod_d_exports.z.core.$strip>;
|
|
71
84
|
};
|
|
85
|
+
readonly TIMEOUT: {
|
|
86
|
+
readonly data: zod_d_exports.z.ZodObject<{
|
|
87
|
+
timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
|
|
88
|
+
operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
89
|
+
retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
|
|
90
|
+
}, zod_d_exports.z.core.$strip>;
|
|
91
|
+
};
|
|
92
|
+
readonly CONNECTION_ERROR: {
|
|
93
|
+
readonly data: zod_d_exports.z.ZodObject<{
|
|
94
|
+
errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
95
|
+
host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
96
|
+
port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
|
|
97
|
+
suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
98
|
+
}, zod_d_exports.z.core.$strip>;
|
|
99
|
+
};
|
|
72
100
|
};
|
|
73
101
|
//#endregion
|
|
74
|
-
export { CommonPluginErrors };
|
|
102
|
+
export { CommonPluginErrors, ERROR_PATTERNS };
|
|
75
103
|
//# sourceMappingURL=errors.d.cts.map
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAyBa,cAzBA,cAqFH,EAAA;;;;;;;;;;;;;;;;;;;;;;;;cA5DG"}
|
package/dist/errors.d.mts
CHANGED
|
@@ -2,6 +2,19 @@ import { zod_d_exports } from "./zod.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Error pattern constants for categorizing infrastructure errors
|
|
7
|
+
*/
|
|
8
|
+
declare const ERROR_PATTERNS: {
|
|
9
|
+
readonly CONNECTION_REFUSED: readonly ["ECONNREFUSED"];
|
|
10
|
+
readonly HOST_NOT_FOUND: readonly ["ENOTFOUND", "EHOSTUNREACH"];
|
|
11
|
+
readonly TIMEOUT: readonly ["ETIMEDOUT", "ESOCKETTIMEDOUT", "timeout"];
|
|
12
|
+
readonly CONNECTION_RESET: readonly ["ECONNRESET", "EPIPE"];
|
|
13
|
+
readonly PERMISSION: readonly ["EACCES", "EPERM", "permission denied"];
|
|
14
|
+
readonly AUTH: readonly ["401", "unauthorized", "authentication failed"];
|
|
15
|
+
readonly RATE_LIMITED: readonly ["429", "too many requests", "rate limit"];
|
|
16
|
+
readonly SERVICE_UNAVAILABLE: readonly ["503", "service unavailable"];
|
|
17
|
+
};
|
|
5
18
|
/**
|
|
6
19
|
* Common error schemas for plugin contracts.
|
|
7
20
|
* Import these to ensure consistent error handling across plugins.
|
|
@@ -69,7 +82,22 @@ declare const CommonPluginErrors: {
|
|
|
69
82
|
action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
70
83
|
}, zod_d_exports.z.core.$strip>;
|
|
71
84
|
};
|
|
85
|
+
readonly TIMEOUT: {
|
|
86
|
+
readonly data: zod_d_exports.z.ZodObject<{
|
|
87
|
+
timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
|
|
88
|
+
operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
89
|
+
retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
|
|
90
|
+
}, zod_d_exports.z.core.$strip>;
|
|
91
|
+
};
|
|
92
|
+
readonly CONNECTION_ERROR: {
|
|
93
|
+
readonly data: zod_d_exports.z.ZodObject<{
|
|
94
|
+
errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
95
|
+
host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
96
|
+
port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
|
|
97
|
+
suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
|
|
98
|
+
}, zod_d_exports.z.core.$strip>;
|
|
99
|
+
};
|
|
72
100
|
};
|
|
73
101
|
//#endregion
|
|
74
|
-
export { CommonPluginErrors };
|
|
102
|
+
export { CommonPluginErrors, ERROR_PATTERNS };
|
|
75
103
|
//# sourceMappingURL=errors.d.mts.map
|
package/dist/errors.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAyBa,cAzBA,cAqFH,EAAA;;;;;;;;;;;;;;;;;;;;;;;;cA5DG"}
|
package/dist/errors.mjs
CHANGED
|
@@ -2,6 +2,35 @@ import { zod_exports } from "./zod.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/errors.ts
|
|
4
4
|
/**
|
|
5
|
+
* Error pattern constants for categorizing infrastructure errors
|
|
6
|
+
*/
|
|
7
|
+
const ERROR_PATTERNS = {
|
|
8
|
+
CONNECTION_REFUSED: ["ECONNREFUSED"],
|
|
9
|
+
HOST_NOT_FOUND: ["ENOTFOUND", "EHOSTUNREACH"],
|
|
10
|
+
TIMEOUT: [
|
|
11
|
+
"ETIMEDOUT",
|
|
12
|
+
"ESOCKETTIMEDOUT",
|
|
13
|
+
"timeout"
|
|
14
|
+
],
|
|
15
|
+
CONNECTION_RESET: ["ECONNRESET", "EPIPE"],
|
|
16
|
+
PERMISSION: [
|
|
17
|
+
"EACCES",
|
|
18
|
+
"EPERM",
|
|
19
|
+
"permission denied"
|
|
20
|
+
],
|
|
21
|
+
AUTH: [
|
|
22
|
+
"401",
|
|
23
|
+
"unauthorized",
|
|
24
|
+
"authentication failed"
|
|
25
|
+
],
|
|
26
|
+
RATE_LIMITED: [
|
|
27
|
+
"429",
|
|
28
|
+
"too many requests",
|
|
29
|
+
"rate limit"
|
|
30
|
+
],
|
|
31
|
+
SERVICE_UNAVAILABLE: ["503", "service unavailable"]
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
5
34
|
* Common error schemas for plugin contracts.
|
|
6
35
|
* Import these to ensure consistent error handling across plugins.
|
|
7
36
|
*
|
|
@@ -55,9 +84,20 @@ const CommonPluginErrors = {
|
|
|
55
84
|
FORBIDDEN: { data: zod_exports.z.object({
|
|
56
85
|
requiredPermissions: zod_exports.z.array(zod_exports.z.string()).optional(),
|
|
57
86
|
action: zod_exports.z.string().optional()
|
|
87
|
+
}) },
|
|
88
|
+
TIMEOUT: { data: zod_exports.z.object({
|
|
89
|
+
timeoutMs: zod_exports.z.number().int().min(0).optional(),
|
|
90
|
+
operation: zod_exports.z.string().optional(),
|
|
91
|
+
retryable: zod_exports.z.boolean().default(true)
|
|
92
|
+
}) },
|
|
93
|
+
CONNECTION_ERROR: { data: zod_exports.z.object({
|
|
94
|
+
errorCode: zod_exports.z.string().optional(),
|
|
95
|
+
host: zod_exports.z.string().optional(),
|
|
96
|
+
port: zod_exports.z.number().int().optional(),
|
|
97
|
+
suggestion: zod_exports.z.string().optional()
|
|
58
98
|
}) }
|
|
59
99
|
};
|
|
60
100
|
|
|
61
101
|
//#endregion
|
|
62
|
-
export { CommonPluginErrors };
|
|
102
|
+
export { CommonPluginErrors, ERROR_PATTERNS };
|
|
63
103
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n\tCONNECTION_REFUSED: ['ECONNREFUSED'],\n\tHOST_NOT_FOUND: ['ENOTFOUND', 'EHOSTUNREACH'],\n\tTIMEOUT: ['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'timeout'],\n\tCONNECTION_RESET: ['ECONNRESET', 'EPIPE'],\n\tPERMISSION: ['EACCES', 'EPERM', 'permission denied'],\n\tAUTH: ['401', 'unauthorized', 'authentication failed'],\n\tRATE_LIMITED: ['429', 'too many requests', 'rate limit'],\n\tSERVICE_UNAVAILABLE: ['503', 'service unavailable'],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t},\n\tTIMEOUT: {\n\t\tdata: z.object({\n\t\t\ttimeoutMs: z.number().int().min(0).optional(),\n\t\t\toperation: z.string().optional(),\n\t\t\tretryable: z.boolean().default(true),\n\t\t})\n\t},\n\tCONNECTION_ERROR: {\n\t\tdata: z.object({\n\t\t\terrorCode: z.string().optional(),\n\t\t\thost: z.string().optional(),\n\t\t\tport: z.number().int().optional(),\n\t\t\tsuggestion: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":";;;;;;AAKA,MAAa,iBAAiB;CAC7B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACnD;;;;;;;;;;;;;;;AAgBD,MAAa,qBAAqB;CACjC,cAAc,EACb,MAAMA,cAAE,OAAO;EACd,gBAAgBA,cAAE,SAAS;EAC3B,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,UAAUA,cAAE,KAAK;GAAC;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AAQ,CAAC,UAAU;EAChC,WAAWA,cAAE,SAAS,CAAC,QAAQ,KAAK;EACpC,CAAC,EACF;CACD,kBAAkB,EACjB,MAAMA,cAAE,OAAO;EACd,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,MAAMA,cAAE,QAAQ,CAAC,UAAU;EAC3B,MAAMA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,YAAYA,cAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,EACF;CACD"}
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const require_runtime_services_normalize = require('./runtime/services/normalize
|
|
|
4
4
|
const require_runtime_index = require('./runtime/index.cjs');
|
|
5
5
|
|
|
6
6
|
exports.CommonPluginErrors = require_errors.CommonPluginErrors;
|
|
7
|
+
exports.ERROR_PATTERNS = require_errors.ERROR_PATTERNS;
|
|
7
8
|
exports.PluginRuntime = require_runtime_index.PluginRuntime;
|
|
8
9
|
exports.createPlugin = require_plugin.createPlugin;
|
|
9
10
|
exports.createPluginRuntime = require_runtime_index.createPluginRuntime;
|