every-plugin 2.9.6 → 2.10.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.mjs +1 -1
- package/dist/build/rspack/dev-server-middleware.cjs +57 -3
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs +57 -3
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +0 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +0 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +2 -0
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +1 -2
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +1 -2
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +2 -0
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/shared-deps.cjs +0 -1
- package/dist/build/shared-deps.cjs.map +1 -1
- package/dist/build/shared-deps.d.cts.map +1 -1
- package/dist/build/shared-deps.d.mts.map +1 -1
- package/dist/build/shared-deps.mjs.map +1 -1
- package/dist/errors.cjs +0 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +0 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +0 -1
- package/dist/errors.d.mts.map +1 -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/orpc.cjs +0 -1
- package/dist/plugin.cjs +2 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +3 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +3 -2
- package/dist/plugin.mjs.map +1 -1
- package/dist/runtime/errors.cjs +0 -1
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +3 -5
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +3 -5
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +4 -2
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +0 -1
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +0 -1
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +4 -1
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +1 -2
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +1 -1
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +0 -1
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +0 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts +0 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs.map +1 -1
- package/dist/runtime/services/normalize.d.cts.map +1 -1
- package/dist/runtime/services/normalize.d.mts.map +1 -1
- package/dist/runtime/services/normalize.mjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +2 -2
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +1 -2
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts +1 -2
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.mjs +2 -1
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +0 -1
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +5 -6
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +5 -6
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts +1 -2
- package/dist/runtime/services/secrets.service.d.cts.map +1 -1
- package/dist/runtime/services/secrets.service.d.mts +1 -2
- package/dist/runtime/services/secrets.service.d.mts.map +1 -1
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/validation.cjs +0 -1
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -1
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.mts +2 -1
- package/dist/testing/index.d.mts.map +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/dist/types.d.cts +1 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +1 -2
- package/dist/types.d.mts.map +1 -1
- package/package.json +6 -6
- package/src/build/rspack/dev-server-middleware.ts +81 -7
- package/src/plugin.ts +3 -1
- package/src/runtime/services/plugin-loader.service.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleFederationPlugin } from \"@module-federation/enhanced/rspack\";\nimport type { Compiler, RspackPluginInstance } from \"@rspack/core\";\nimport { setupPluginMiddleware } from \"./dev-server-middleware\";\nimport { buildSharedDependencies } from \"./module-federation\";\nimport { getPluginInfo, loadDevConfig } from \"./utils\";\n\nexport interface EveryPluginOptions {\n devConfigPath?: string;\n port?: number;\n pluginId?: string;\n dts?: boolean;\n}\n\nexport interface AdditionalExport {\n srcPath: string;\n exportNames: string[];\n}\n\nexport interface PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\n additionalExports?: AdditionalExport[];\n}\n\nexport class EmitPluginManifest implements RspackPluginInstance {\n name = \"EmitPluginManifest\";\n\n constructor(private options: PluginManifestEmitterOptions = {}) {}\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(this.name, (compilation) => {\n const webpack = (compiler as Compiler & { webpack?: any }).webpack;\n const rawSource = webpack?.sources?.RawSource;\n const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1000;\n\n compilation.hooks.processAssets.tapPromise({ name: this.name, stage }, async () => {\n const context = compiler.options.context || process.cwd();\n const pluginInfo = getPluginInfo(context);\n const contractFileName = this.options.contractFileName ?? \"contract.d.ts\";\n const manifestFileName = this.options.manifestFileName ?? \"plugin.manifest.json\";\n\n const sourceContractPath = path.join(context, \"types\", contractFileName);\n\n let contractTypes: string;\n\n const tryReadFile = async (filePath: string): Promise<string | null> => {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n const stats = fs.statSync(filePath);\n if (!stats.isFile()) {\n return null;\n }\n try {\n return await fs.promises.readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n };\n\n contractTypes = (await tryReadFile(sourceContractPath)) ?? \"\";\n\n if (!contractTypes) {\n const packageDir = context.split(\"/\").pop();\n const nestedPath = path.join(context, \"types\", packageDir ?? \"\", \"src\", contractFileName);\n\n contractTypes = (await tryReadFile(nestedPath)) ?? \"\";\n\n if (!contractTypes) {\n console.warn(\n `[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. ` +\n `Skipping manifest generation.`,\n );\n return;\n }\n }\n\n const contractSha256 = crypto.createHash(\"sha256\").update(contractTypes).digest(\"hex\");\n const manifest: Record<string, unknown> = {\n schemaVersion: 1,\n kind: \"every-plugin/manifest\",\n plugin: {\n name: pluginInfo.name,\n version: pluginInfo.version,\n },\n runtime: {\n remoteEntry: \"./remoteEntry.js\",\n },\n contract: {\n kind: \"orpc\",\n types: {\n path: `./types/${contractFileName}`,\n exportName: \"contract\",\n typeName: \"ContractType\",\n sha256: contractSha256,\n },\n },\n };\n\n const additionalExportsEntries: Array<{ path: string; exports: string[]; sha256: string }> =\n [];\n\n if (this.options.additionalExports?.length) {\n for (const additional of this.options.additionalExports) {\n const sourcePath = path.join(context, \"types\", additional.srcPath);\n const content = await tryReadFile(sourcePath);\n if (!content) {\n console.warn(\n `[EmitPluginManifest] Additional export file not found at ${sourcePath}. Skipping.`,\n );\n continue;\n }\n const sha256 = crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n const distPath = `./types/${additional.srcPath}`;\n additionalExportsEntries.push({\n path: distPath,\n exports: additional.exportNames,\n sha256,\n });\n\n if (rawSource) {\n compilation.emitAsset(`types/${additional.srcPath}`, new rawSource(content));\n }\n }\n\n if (additionalExportsEntries.length > 0) {\n manifest.additionalExports = additionalExportsEntries;\n }\n }\n\n if (rawSource) {\n compilation.emitAsset(\n manifestFileName,\n new rawSource(`${JSON.stringify(manifest, null, 2)}\\n`),\n );\n compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));\n }\n });\n });\n }\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = \"EveryPluginDevServer\";\n\n constructor(private options: EveryPluginOptions = {}) {}\n\n apply(compiler: Compiler) {\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || \"./plugin.dev.ts\");\n const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;\n\n this.configureDefaults(compiler, pluginInfo);\n\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: \"remoteEntry.js\",\n dts: this.options.dts !== false,\n manifest: {},\n runtimePlugins: [require.resolve(\"@module-federation/node/runtimePlugin\")],\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 if (this.options.dts === false) {\n compiler.options.plugins = (compiler.options.plugins ?? []).filter(\n (p) =>\n !p ||\n typeof p !== \"object\" ||\n ((p as any).name !== \"MFDevPlugin\" && (p as any).name !== \"ModuleFederationDtsPlugin\"),\n );\n }\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\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 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 if (compiler.options.devtool === undefined) {\n compiler.options.devtool = \"source-map\";\n }\n\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: \"warn\",\n };\n }\n\n this.ensureTypeScriptLoader(compiler);\n\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = [\"...\", \".tsx\", \".ts\"];\n compiler.options.resolve.conditionNames = [\n \"webpack\",\n \"import\",\n \"module\",\n \"require\",\n \"node\",\n \"default\",\n ];\n if (compiler.options.resolve.byDependency) {\n for (const depType of Object.keys(compiler.options.resolve.byDependency)) {\n const depConfig = (\n compiler.options.resolve.byDependency as Record<string, { conditionNames?: string[] }>\n )[depType];\n if (depConfig?.conditionNames) {\n depConfig.conditionNames = depConfig.conditionNames.filter((c) => c !== \"development\");\n }\n }\n }\n compiler.options.resolve.fallback = {\n ...compiler.options.resolve.fallback,\n bufferutil: false,\n \"utf-8-validate\": false,\n };\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 const hasTsLoader = compiler.options.module.rules.some(\n (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 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;\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 compiler.options.devServer.client = {\n logging: \"warn\",\n overlay: {\n warnings: false,\n errors: true,\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":";;;;;;;;;;AA2BA,IAAa,qBAAb,MAAgE;CAC9D,OAAO;CAEP,YAAY,AAAQ,UAAwC,EAAE,EAAE;EAA5C;;CAEpB,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAAI,KAAK,OAAO,gBAAgB;GAC7D,MAAM,UAAW,SAA0C;GAC3D,MAAM,YAAY,SAAS,SAAS;GACpC,MAAM,QAAQ,SAAS,aAAa,kCAAkC;AAEtE,eAAY,MAAM,cAAc,WAAW;IAAE,MAAM,KAAK;IAAM;IAAO,EAAE,YAAY;IACjF,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;IACzD,MAAM,aAAa,cAAc,QAAQ;IACzC,MAAM,mBAAmB,KAAK,QAAQ,oBAAoB;IAC1D,MAAM,mBAAmB,KAAK,QAAQ,oBAAoB;IAE1D,MAAM,qBAAqB,KAAK,KAAK,SAAS,SAAS,iBAAiB;IAExE,IAAI;IAEJ,MAAM,cAAc,OAAO,aAA6C;AACtE,SAAI,CAAC,GAAG,WAAW,SAAS,CAC1B,QAAO;AAGT,SAAI,CADU,GAAG,SAAS,SAChB,CAAC,QAAQ,CACjB,QAAO;AAET,SAAI;AACF,aAAO,MA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;AAYpC,MAAI,CATgB,SAAS,QAAQ,OAAO,MAAM,MAC/C,SACC,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,KAAK,gBAAgB,UACrB,KAAK,KAAK,KAAK,MAAM,CAGT,CACd,UAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,KAAK;GACL,SAAS;GACV,CAAC;;CAIN,AAAQ,mBAAmB,UAAoB,YAAiB,WAAgB,MAAc;AAC5F,MAAI,CAAC,SAAS,QAAQ,UACpB;EAGF,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;EACzD,MAAM,gBAAgB,SAAS,QAAQ,UAAU;AAEjD,WAAS,QAAQ,UAAU,OAAO;AAClC,WAAS,QAAQ,UAAU,SAAS,KAAK,KAAK,SAAS,OAAO;AAC9D,WAAS,QAAQ,UAAU,MAAM;AACjC,WAAS,QAAQ,UAAU,gBAAgB,EAAE,aAAa,MAAM;AAChE,WAAS,QAAQ,UAAU,UAAU;GACnC,+BAA+B;GAC/B,gCAAgC;GAChC,gCAAgC;GACjC;AAED,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"}
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleFederationPlugin } from \"@module-federation/enhanced/rspack\";\nimport type { Compiler, RspackPluginInstance } from \"@rspack/core\";\nimport { setupPluginMiddleware } from \"./dev-server-middleware\";\nimport { buildSharedDependencies } from \"./module-federation\";\nimport { getPluginInfo, loadDevConfig } from \"./utils\";\n\nexport interface EveryPluginOptions {\n devConfigPath?: string;\n port?: number;\n pluginId?: string;\n dts?: boolean;\n}\n\nexport interface AdditionalExport {\n srcPath: string;\n exportNames: string[];\n}\n\nexport interface PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\n additionalExports?: AdditionalExport[];\n}\n\nexport class EmitPluginManifest implements RspackPluginInstance {\n name = \"EmitPluginManifest\";\n\n constructor(private options: PluginManifestEmitterOptions = {}) {}\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(this.name, (compilation) => {\n const webpack = (compiler as Compiler & { webpack?: any }).webpack;\n const rawSource = webpack?.sources?.RawSource;\n const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1000;\n\n compilation.hooks.processAssets.tapPromise({ name: this.name, stage }, async () => {\n const context = compiler.options.context || process.cwd();\n const pluginInfo = getPluginInfo(context);\n const contractFileName = this.options.contractFileName ?? \"contract.d.ts\";\n const manifestFileName = this.options.manifestFileName ?? \"plugin.manifest.json\";\n\n const sourceContractPath = path.join(context, \"types\", contractFileName);\n\n let contractTypes: string;\n\n const tryReadFile = async (filePath: string): Promise<string | null> => {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n const stats = fs.statSync(filePath);\n if (!stats.isFile()) {\n return null;\n }\n try {\n return await fs.promises.readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n };\n\n contractTypes = (await tryReadFile(sourceContractPath)) ?? \"\";\n\n if (!contractTypes) {\n const packageDir = context.split(\"/\").pop();\n const nestedPath = path.join(context, \"types\", packageDir ?? \"\", \"src\", contractFileName);\n\n contractTypes = (await tryReadFile(nestedPath)) ?? \"\";\n\n if (!contractTypes) {\n console.warn(\n `[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. ` +\n `Skipping manifest generation.`,\n );\n return;\n }\n }\n\n const contractSha256 = crypto.createHash(\"sha256\").update(contractTypes).digest(\"hex\");\n const manifest: Record<string, unknown> = {\n schemaVersion: 1,\n kind: \"every-plugin/manifest\",\n plugin: {\n name: pluginInfo.name,\n version: pluginInfo.version,\n },\n runtime: {\n remoteEntry: \"./remoteEntry.js\",\n },\n contract: {\n kind: \"orpc\",\n types: {\n path: `./types/${contractFileName}`,\n exportName: \"contract\",\n typeName: \"ContractType\",\n sha256: contractSha256,\n },\n },\n };\n\n const additionalExportsEntries: Array<{ path: string; exports: string[]; sha256: string }> =\n [];\n\n if (this.options.additionalExports?.length) {\n for (const additional of this.options.additionalExports) {\n const sourcePath = path.join(context, \"types\", additional.srcPath);\n const content = await tryReadFile(sourcePath);\n if (!content) {\n console.warn(\n `[EmitPluginManifest] Additional export file not found at ${sourcePath}. Skipping.`,\n );\n continue;\n }\n const sha256 = crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n const distPath = `./types/${additional.srcPath}`;\n additionalExportsEntries.push({\n path: distPath,\n exports: additional.exportNames,\n sha256,\n });\n\n if (rawSource) {\n compilation.emitAsset(`types/${additional.srcPath}`, new rawSource(content));\n }\n }\n\n if (additionalExportsEntries.length > 0) {\n manifest.additionalExports = additionalExportsEntries;\n }\n }\n\n if (rawSource) {\n compilation.emitAsset(\n manifestFileName,\n new rawSource(`${JSON.stringify(manifest, null, 2)}\\n`),\n );\n compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));\n }\n });\n });\n }\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = \"EveryPluginDevServer\";\n\n constructor(private options: EveryPluginOptions = {}) {}\n\n apply(compiler: Compiler) {\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || \"./plugin.dev.ts\");\n const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;\n\n this.configureDefaults(compiler, pluginInfo);\n\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: \"remoteEntry.js\",\n dts: this.options.dts !== false,\n manifest: {},\n runtimePlugins: [require.resolve(\"@module-federation/node/runtimePlugin\")],\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 if (this.options.dts === false) {\n compiler.options.plugins = (compiler.options.plugins ?? []).filter(\n (p) =>\n !p ||\n typeof p !== \"object\" ||\n ((p as any).name !== \"MFDevPlugin\" && (p as any).name !== \"ModuleFederationDtsPlugin\"),\n );\n }\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\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 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 if (compiler.options.devtool === undefined) {\n compiler.options.devtool = \"source-map\";\n }\n\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: \"warn\",\n };\n }\n\n this.ensureTypeScriptLoader(compiler);\n\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = [\"...\", \".tsx\", \".ts\"];\n compiler.options.resolve.conditionNames = [\n \"webpack\",\n \"import\",\n \"module\",\n \"require\",\n \"node\",\n \"default\",\n ];\n if (compiler.options.resolve.byDependency) {\n for (const depType of Object.keys(compiler.options.resolve.byDependency)) {\n const depConfig = (\n compiler.options.resolve.byDependency as Record<string, { conditionNames?: string[] }>\n )[depType];\n if (depConfig?.conditionNames) {\n depConfig.conditionNames = depConfig.conditionNames.filter((c) => c !== \"development\");\n }\n }\n }\n compiler.options.resolve.fallback = {\n ...compiler.options.resolve.fallback,\n bufferutil: false,\n \"utf-8-validate\": false,\n };\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 const hasTsLoader = compiler.options.module.rules.some(\n (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 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;\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 compiler.options.devServer.client = {\n logging: \"warn\",\n overlay: {\n warnings: false,\n errors: true,\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":";;;;;;;;;;AA2BA,IAAa,qBAAb,MAAgE;CAG1C;CAFpB,OAAO;CAEP,YAAY,AAAQ,UAAwC,CAAC,GAAG;EAA5C;CAA6C;CAEjE,MAAM,UAAoB;EACxB,SAAS,MAAM,gBAAgB,IAAI,KAAK,OAAO,gBAAgB;GAC7D,MAAM,UAAW,SAA0C;GAC3D,MAAM,YA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KAAK;EAC/D,SAAS,QAAQ,UAAU,UAAU;GACnC,+BAA+B;GAC/B,gCAAgC;GAChC,gCAAgC;EAClC;EAEA,SAAS,QAAQ,UAAU,SAAS;GAClC,SAAS;GACT,SAAS;IACP,UAAU;IACV,QAAQ;GACV;EACF;EAEA,SAAS,QAAQ,UAAU,oBAAoB,aAAa,cAAc;GACxE,sBAAsB,WAAW,YAAY,WAAW,IAAI;GAC5D,OAAO,gBAAgB,cAAc,aAAa,SAAS,IAAI;EACjE;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["path","fs","getNormalizedRemoteName"],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getNormalizedRemoteName } from \"every-plugin/normalize\";\n\nexport interface PluginInfo {\n name: string;\n version: string;\n normalizedName: string;\n dependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n}\n\nexport function getPluginInfo(context: string): PluginInfo {\n const pkgPath = path.join(context, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\n return {\n name: pkg.name,\n version: pkg.version,\n normalizedName: getNormalizedRemoteName(pkg.name),\n dependencies: pkg.dependencies || {},\n peerDependencies: pkg.peerDependencies || {},\n };\n}\n\nconst loadedModules = new Set<string>();\n\nexport function loadDevConfig(devConfigPath: string) {\n if (process.env.DEPLOY === \"true\") {\n return null;\n }\n\n try {\n const fullPath = path.resolve(devConfigPath);\n\n if (loadedModules.has(fullPath)) {\n delete require.cache[fullPath];\n const dirPath = path.dirname(fullPath);\n for (const key of Object.keys(require.cache)) {\n if (key.startsWith(dirPath) && key !== fullPath) {\n delete require.cache[key];\n }\n }\n }\n\n const module = require(fullPath).default;\n loadedModules.add(fullPath);\n return module;\n } catch (error) {\n console.warn(`Could not load dev config from ${devConfigPath}:`, (error as Error).message);\n return null;\n }\n}\n\nexport function cleanupDevConfig() {\n for (const modulePath of loadedModules) {\n delete require.cache[modulePath];\n }\n loadedModules.clear();\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,cAAc,SAA6B;CACzD,MAAM,UAAUA,kBAAK,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["path","fs","getNormalizedRemoteName"],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getNormalizedRemoteName } from \"every-plugin/normalize\";\n\nexport interface PluginInfo {\n name: string;\n version: string;\n normalizedName: string;\n dependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n}\n\nexport function getPluginInfo(context: string): PluginInfo {\n const pkgPath = path.join(context, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\n return {\n name: pkg.name,\n version: pkg.version,\n normalizedName: getNormalizedRemoteName(pkg.name),\n dependencies: pkg.dependencies || {},\n peerDependencies: pkg.peerDependencies || {},\n };\n}\n\nconst loadedModules = new Set<string>();\n\nexport function loadDevConfig(devConfigPath: string) {\n if (process.env.DEPLOY === \"true\") {\n return null;\n }\n\n try {\n const fullPath = path.resolve(devConfigPath);\n\n if (loadedModules.has(fullPath)) {\n delete require.cache[fullPath];\n const dirPath = path.dirname(fullPath);\n for (const key of Object.keys(require.cache)) {\n if (key.startsWith(dirPath) && key !== fullPath) {\n delete require.cache[key];\n }\n }\n }\n\n const module = require(fullPath).default;\n loadedModules.add(fullPath);\n return module;\n } catch (error) {\n console.warn(`Could not load dev config from ${devConfigPath}:`, (error as Error).message);\n return null;\n }\n}\n\nexport function cleanupDevConfig() {\n for (const modulePath of loadedModules) {\n delete require.cache[modulePath];\n }\n loadedModules.clear();\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,cAAc,SAA6B;CACzD,MAAM,UAAUA,kBAAK,KAAK,SAAS,cAAc;CACjD,MAAM,MAAM,KAAK,MAAMC,gBAAG,aAAa,SAAS,OAAO,CAAC;CAExD,OAAO;EACL,MAAM,IAAI;EACV,SAAS,IAAI;EACb,gBAAgBC,2DAAwB,IAAI,IAAI;EAChD,cAAc,IAAI,gBAAgB,CAAC;EACnC,kBAAkB,IAAI,oBAAoB,CAAC;CAC7C;AACF;AAEA,MAAM,gCAAgB,IAAI,IAAY;AAEtC,SAAgB,cAAc,eAAuB;CACnD,IAAI,QAAQ,IAAI,WAAW,QACzB,OAAO;CAGT,IAAI;EACF,MAAM,WAAWF,kBAAK,QAAQ,aAAa;EAE3C,IAAI,cAAc,IAAI,QAAQ,GAAG;GAC/B,OAAO,QAAQ,MAAM;GACrB,MAAM,UAAUA,kBAAK,QAAQ,QAAQ;GACrC,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,KAAK,GACzC,IAAI,IAAI,WAAW,OAAO,KAAK,QAAQ,UACrC,OAAO,QAAQ,MAAM;EAG3B;EAEA,MAAM,SAAS,QAAQ,QAAQ,CAAC,CAAC;EACjC,cAAc,IAAI,QAAQ;EAC1B,OAAO;CACT,SAAS,OAAO;EACd,QAAQ,KAAK,kCAAkC,cAAc,IAAK,MAAgB,OAAO;EACzF,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getNormalizedRemoteName } from \"every-plugin/normalize\";\n\nexport interface PluginInfo {\n name: string;\n version: string;\n normalizedName: string;\n dependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n}\n\nexport function getPluginInfo(context: string): PluginInfo {\n const pkgPath = path.join(context, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\n return {\n name: pkg.name,\n version: pkg.version,\n normalizedName: getNormalizedRemoteName(pkg.name),\n dependencies: pkg.dependencies || {},\n peerDependencies: pkg.peerDependencies || {},\n };\n}\n\nconst loadedModules = new Set<string>();\n\nexport function loadDevConfig(devConfigPath: string) {\n if (process.env.DEPLOY === \"true\") {\n return null;\n }\n\n try {\n const fullPath = path.resolve(devConfigPath);\n\n if (loadedModules.has(fullPath)) {\n delete require.cache[fullPath];\n const dirPath = path.dirname(fullPath);\n for (const key of Object.keys(require.cache)) {\n if (key.startsWith(dirPath) && key !== fullPath) {\n delete require.cache[key];\n }\n }\n }\n\n const module = require(fullPath).default;\n loadedModules.add(fullPath);\n return module;\n } catch (error) {\n console.warn(`Could not load dev config from ${devConfigPath}:`, (error as Error).message);\n return null;\n }\n}\n\nexport function cleanupDevConfig() {\n for (const modulePath of loadedModules) {\n delete require.cache[modulePath];\n }\n loadedModules.clear();\n}\n"],"mappings":";;;;;;AAYA,SAAgB,cAAc,SAA6B;CACzD,MAAM,UAAU,KAAK,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getNormalizedRemoteName } from \"every-plugin/normalize\";\n\nexport interface PluginInfo {\n name: string;\n version: string;\n normalizedName: string;\n dependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n}\n\nexport function getPluginInfo(context: string): PluginInfo {\n const pkgPath = path.join(context, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\n return {\n name: pkg.name,\n version: pkg.version,\n normalizedName: getNormalizedRemoteName(pkg.name),\n dependencies: pkg.dependencies || {},\n peerDependencies: pkg.peerDependencies || {},\n };\n}\n\nconst loadedModules = new Set<string>();\n\nexport function loadDevConfig(devConfigPath: string) {\n if (process.env.DEPLOY === \"true\") {\n return null;\n }\n\n try {\n const fullPath = path.resolve(devConfigPath);\n\n if (loadedModules.has(fullPath)) {\n delete require.cache[fullPath];\n const dirPath = path.dirname(fullPath);\n for (const key of Object.keys(require.cache)) {\n if (key.startsWith(dirPath) && key !== fullPath) {\n delete require.cache[key];\n }\n }\n }\n\n const module = require(fullPath).default;\n loadedModules.add(fullPath);\n return module;\n } catch (error) {\n console.warn(`Could not load dev config from ${devConfigPath}:`, (error as Error).message);\n return null;\n }\n}\n\nexport function cleanupDevConfig() {\n for (const modulePath of loadedModules) {\n delete require.cache[modulePath];\n }\n loadedModules.clear();\n}\n"],"mappings":";;;;;;AAYA,SAAgB,cAAc,SAA6B;CACzD,MAAM,UAAU,KAAK,KAAK,SAAS,cAAc;CACjD,MAAM,MAAM,KAAK,MAAM,GAAG,aAAa,SAAS,OAAO,CAAC;CAExD,OAAO;EACL,MAAM,IAAI;EACV,SAAS,IAAI;EACb,gBAAgB,wBAAwB,IAAI,IAAI;EAChD,cAAc,IAAI,gBAAgB,CAAC;EACnC,kBAAkB,IAAI,oBAAoB,CAAC;CAC7C;AACF;AAEA,MAAM,gCAAgB,IAAI,IAAY;AAEtC,SAAgB,cAAc,eAAuB;CACnD,IAAI,QAAQ,IAAI,WAAW,QACzB,OAAO;CAGT,IAAI;EACF,MAAM,WAAW,KAAK,QAAQ,aAAa;EAE3C,IAAI,cAAc,IAAI,QAAQ,GAAG;GAC/B,iBAAe,MAAM;GACrB,MAAM,UAAU,KAAK,QAAQ,QAAQ;GACrC,KAAK,MAAM,OAAO,OAAO,eAAa,KAAK,GACzC,IAAI,IAAI,WAAW,OAAO,KAAK,QAAQ,UACrC,iBAAe,MAAM;EAG3B;EAEA,MAAM,mBAAiB,QAAQ,CAAC,CAAC;EACjC,cAAc,IAAI,QAAQ;EAC1B,OAAO;CACT,SAAS,OAAO;EACd,QAAQ,KAAK,kCAAkC,cAAc,IAAK,MAAgB,OAAO;EACzF,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.cjs","names":["__dirname","require"],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n let currentDir = dirname(require.resolve(packageName));\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n if (existsSync(packageJsonPath)) {\n return (JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as { version: string }).version;\n }\n currentDir = dirname(currentDir);\n }\n\n throw new Error(`Could not resolve installed version for ${packageName}`);\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", pkg.peerDependencies[\"@orpc/contract\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/client\": {\n version: getInstalledPackageVersion(\"@orpc/client\", pkg.peerDependencies[\"@orpc/client\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", pkg.peerDependencies[\"@orpc/server\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n} satisfies SharedDependencies;\n\nexport type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return pluginSharedDependencies;\n}\n\nexport function getPluginSharedDependenciesVersionRange(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies()).map(([name, config]) => [\n name,\n getMajorMinorVersion(config.version),\n ]),\n );\n}\n\nexport function getMajorMinorVersion(version: string): string {\n const clean = version.replace(/^[\\^~>=<]+/, \"\");\n const match = clean.match(/^(\\d+)\\.(\\d+)/);\n if (!match) return \"^0.0.0\";\n return `^${match[1]}.${match[2]}.0`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared-deps.cjs","names":["__dirname","require"],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n let currentDir = dirname(require.resolve(packageName));\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n if (existsSync(packageJsonPath)) {\n return (JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as { version: string }).version;\n }\n currentDir = dirname(currentDir);\n }\n\n throw new Error(`Could not resolve installed version for ${packageName}`);\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", pkg.peerDependencies[\"@orpc/contract\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/client\": {\n version: getInstalledPackageVersion(\"@orpc/client\", pkg.peerDependencies[\"@orpc/client\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", pkg.peerDependencies[\"@orpc/server\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n} satisfies SharedDependencies;\n\nexport type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return pluginSharedDependencies;\n}\n\nexport function getPluginSharedDependenciesVersionRange(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies()).map(([name, config]) => [\n name,\n getMajorMinorVersion(config.version),\n ]),\n );\n}\n\nexport function getMajorMinorVersion(version: string): string {\n const clean = version.replace(/^[\\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S,2BAA2B,gBAAgB,IAAI,iBAAiB,eAAe;EACxF,GAAG;CACL;CACA,gBAAgB;EACd,SAAS,2BAA2B,gBAAgB,IAAI,iBAAiB,eAAe;EACxF,GAAG;CACL;AACF;AAIA,SAAgB,8BAAkD;CAChE,OAAO;AACT;AAEA,SAAgB,0CAAkE;CAChF,OAAO,OAAO,YACZ,OAAO,QAAQ,4BAA4B,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CACpE,MACA,qBAAqB,OAAO,OAAO,CACrC,CAAC,CACH;AACF;AAEA,SAAgB,qBAAqB,SAAyB;CAE5D,MAAM,QADQ,QAAQ,QAAQ,cAAc,EAC1B,CAAC,CAAC,MAAM,eAAe;CACzC,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.d.cts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB
|
|
1
|
+
{"version":3,"file":"shared-deps.d.cts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU,qBAAqB,eAAe;cAgCnC;;IAvCM;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;KA2DF,0CAA0C;iBAEtC,+BAA+B;iBAI/B,2CAA2C;iBAS3C,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.d.mts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB
|
|
1
|
+
{"version":3,"file":"shared-deps.d.mts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU,qBAAqB,eAAe;cAgCnC;;IAvCM;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;IAJK;IACN;IACI;IACR;IACK;;;;KA2DF,0CAA0C;iBAEtC,+BAA+B;iBAI/B,2CAA2C;iBAS3C,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.mjs","names":[],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n let currentDir = dirname(require.resolve(packageName));\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n if (existsSync(packageJsonPath)) {\n return (JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as { version: string }).version;\n }\n currentDir = dirname(currentDir);\n }\n\n throw new Error(`Could not resolve installed version for ${packageName}`);\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", pkg.peerDependencies[\"@orpc/contract\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/client\": {\n version: getInstalledPackageVersion(\"@orpc/client\", pkg.peerDependencies[\"@orpc/client\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", pkg.peerDependencies[\"@orpc/server\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n} satisfies SharedDependencies;\n\nexport type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return pluginSharedDependencies;\n}\n\nexport function getPluginSharedDependenciesVersionRange(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies()).map(([name, config]) => [\n name,\n getMajorMinorVersion(config.version),\n ]),\n );\n}\n\nexport function getMajorMinorVersion(version: string): string {\n const clean = version.replace(/^[\\^~>=<]+/, \"\");\n const match = clean.match(/^(\\d+)\\.(\\d+)/);\n if (!match) return \"^0.0.0\";\n return `^${match[1]}.${match[2]}.0`;\n}\n"],"mappings":";;;;;;AAKA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"shared-deps.mjs","names":[],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n let currentDir = dirname(require.resolve(packageName));\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n if (existsSync(packageJsonPath)) {\n return (JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as { version: string }).version;\n }\n currentDir = dirname(currentDir);\n }\n\n throw new Error(`Could not resolve installed version for ${packageName}`);\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", pkg.peerDependencies[\"@orpc/contract\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/client\": {\n version: getInstalledPackageVersion(\"@orpc/client\", pkg.peerDependencies[\"@orpc/client\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", pkg.peerDependencies[\"@orpc/server\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n} satisfies SharedDependencies;\n\nexport type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return pluginSharedDependencies;\n}\n\nexport function getPluginSharedDependenciesVersionRange(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies()).map(([name, config]) => [\n name,\n getMajorMinorVersion(config.version),\n ]),\n );\n}\n\nexport function getMajorMinorVersion(version: string): string {\n const clean = version.replace(/^[\\^~>=<]+/, \"\");\n const match = clean.match(/^(\\d+)\\.(\\d+)/);\n if (!match) return \"^0.0.0\";\n return `^${match[1]}.${match[2]}.0`;\n}\n"],"mappings":";;;;;;AAKA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;AACxD,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;AAE7C,IAAI;AAEJ,IAAI;CACF,MAAM,KAAK,MAAM,aAAa,KAAK,WAAW,oBAAoB,GAAG,OAAO,CAAC;AAC/E,QAAQ;CACN,MAAM,QAAQ,2BAA2B;AAC3C;AAaA,MAAM,uBAAgE;CACpE,iBAAiB;CACjB,WAAW;CACX,eAAe;CACf,OAAO;CACP,YAAY;AACd;AAEA,SAAS,oBAAoB,OAAuB;CAClD,MAAM,QAAQ,MAAM,MAAM,mCAAmC;CAC7D,OAAO,QAAQ,MAAM,KAAK,MAAM,QAAQ,gBAAgB,EAAE;AAC5D;AAEA,SAAS,2BAA2B,aAAqB,iBAAiC;CACxF,IAAI;EACF,IAAI,aAAa,QAAQ,QAAQ,QAAQ,WAAW,CAA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
1
|
-
{"version":3,"file":"errors.cjs","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 CONNECTION_REFUSED: [\"ECONNREFUSED\"],\n HOST_NOT_FOUND: [\"ENOTFOUND\", \"EHOSTUNREACH\"],\n TIMEOUT: [\"ETIMEDOUT\", \"ESOCKETTIMEDOUT\", \"timeout\"],\n CONNECTION_RESET: [\"ECONNRESET\", \"EPIPE\"],\n PERMISSION: [\"EACCES\", \"EPERM\", \"permission denied\"],\n AUTH: [\"401\", \"unauthorized\", \"authentication failed\"],\n RATE_LIMITED: [\"429\", \"too many requests\", \"rate limit\"],\n SERVICE_UNAVAILABLE: [\"503\", \"service unavailable\"],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import individually or use the grouped PluginErrors export.\n *\n * @example\n * ```typescript\n * import { NOT_FOUND, FORBIDDEN, UNAUTHORIZED } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors({ NOT_FOUND, FORBIDDEN, UNAUTHORIZED })\n * });\n * ```\n */\n\nexport const UNAUTHORIZED = {\n status: 401,\n data: z.object({\n apiKeyProvided: z.boolean(),\n provider: z.string().optional(),\n authType: z.enum([\"apiKey\", \"oauth\", \"token\"]).optional(),\n }),\n} as const;\n\nexport const RATE_LIMITED = {\n status: 429,\n data: z.object({\n retryAfter: z.number().int().min(1),\n remainingRequests: z.number().int().min(0).optional(),\n resetTime: z.string().datetime().optional(),\n limitType: z.enum([\"requests\", \"tokens\", \"bandwidth\"]).optional(),\n }),\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n status: 503,\n data: z.object({\n retryAfter: z.number().int().optional(),\n maintenanceWindow: z.boolean().default(false),\n estimatedUptime: z.string().datetime().optional(),\n }),\n} as const;\n\nexport const BAD_REQUEST = {\n status: 400,\n data: z.object({\n invalidFields: z.array(z.string()).optional(),\n validationErrors: z\n .array(\n z.object({\n field: z.string(),\n message: z.string(),\n code: z.string().optional(),\n }),\n )\n .optional(),\n }),\n} as const;\n\nexport const NOT_FOUND = {\n status: 404,\n data: z.object({\n resource: z.string().optional(),\n resourceId: z.string().optional(),\n }),\n} as const;\n\nexport const FORBIDDEN = {\n status: 403,\n data: z.object({\n requiredPermissions: z.array(z.string()).optional(),\n action: z.string().optional(),\n }),\n} as const;\n\nexport const TIMEOUT = {\n status: 504,\n data: z.object({\n timeoutMs: z.number().int().min(0).optional(),\n operation: z.string().optional(),\n retryable: z.boolean().default(true),\n }),\n} as const;\n\nexport const CONNECTION_ERROR = {\n status: 502,\n data: z.object({\n errorCode: z.string().optional(),\n host: z.string().optional(),\n port: z.number().int().optional(),\n suggestion: z.string().optional(),\n }),\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n UNAUTHORIZED,\n RATE_LIMITED,\n SERVICE_UNAVAILABLE,\n BAD_REQUEST,\n NOT_FOUND,\n FORBIDDEN,\n TIMEOUT,\n CONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n extractFromFiberFailure,\n formatORPCError,\n isRetryableORPCCode,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.cjs","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 CONNECTION_REFUSED: [\"ECONNREFUSED\"],\n HOST_NOT_FOUND: [\"ENOTFOUND\", \"EHOSTUNREACH\"],\n TIMEOUT: [\"ETIMEDOUT\", \"ESOCKETTIMEDOUT\", \"timeout\"],\n CONNECTION_RESET: [\"ECONNRESET\", \"EPIPE\"],\n PERMISSION: [\"EACCES\", \"EPERM\", \"permission denied\"],\n AUTH: [\"401\", \"unauthorized\", \"authentication failed\"],\n RATE_LIMITED: [\"429\", \"too many requests\", \"rate limit\"],\n SERVICE_UNAVAILABLE: [\"503\", \"service unavailable\"],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import individually or use the grouped PluginErrors export.\n *\n * @example\n * ```typescript\n * import { NOT_FOUND, FORBIDDEN, UNAUTHORIZED } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors({ NOT_FOUND, FORBIDDEN, UNAUTHORIZED })\n * });\n * ```\n */\n\nexport const UNAUTHORIZED = {\n status: 401,\n data: z.object({\n apiKeyProvided: z.boolean(),\n provider: z.string().optional(),\n authType: z.enum([\"apiKey\", \"oauth\", \"token\"]).optional(),\n }),\n} as const;\n\nexport const RATE_LIMITED = {\n status: 429,\n data: z.object({\n retryAfter: z.number().int().min(1),\n remainingRequests: z.number().int().min(0).optional(),\n resetTime: z.string().datetime().optional(),\n limitType: z.enum([\"requests\", \"tokens\", \"bandwidth\"]).optional(),\n }),\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n status: 503,\n data: z.object({\n retryAfter: z.number().int().optional(),\n maintenanceWindow: z.boolean().default(false),\n estimatedUptime: z.string().datetime().optional(),\n }),\n} as const;\n\nexport const BAD_REQUEST = {\n status: 400,\n data: z.object({\n invalidFields: z.array(z.string()).optional(),\n validationErrors: z\n .array(\n z.object({\n field: z.string(),\n message: z.string(),\n code: z.string().optional(),\n }),\n )\n .optional(),\n }),\n} as const;\n\nexport const NOT_FOUND = {\n status: 404,\n data: z.object({\n resource: z.string().optional(),\n resourceId: z.string().optional(),\n }),\n} as const;\n\nexport const FORBIDDEN = {\n status: 403,\n data: z.object({\n requiredPermissions: z.array(z.string()).optional(),\n action: z.string().optional(),\n }),\n} as const;\n\nexport const TIMEOUT = {\n status: 504,\n data: z.object({\n timeoutMs: z.number().int().min(0).optional(),\n operation: z.string().optional(),\n retryable: z.boolean().default(true),\n }),\n} as const;\n\nexport const CONNECTION_ERROR = {\n status: 502,\n data: z.object({\n errorCode: z.string().optional(),\n host: z.string().optional(),\n port: z.number().int().optional(),\n suggestion: z.string().optional(),\n }),\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n UNAUTHORIZED,\n RATE_LIMITED,\n SERVICE_UNAVAILABLE,\n BAD_REQUEST,\n NOT_FOUND,\n FORBIDDEN,\n TIMEOUT,\n CONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n extractFromFiberFailure,\n formatORPCError,\n isRetryableORPCCode,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;;;AAKA,MAAa,iBAAiB;CAC5B,oBAAoB,CAAC,cAAc;CACnC,gBAAgB,CAAC,aAAa,cAAc;CAC5C,SAAS;EAAC;EAAa;EAAmB;CAAS;CACnD,kBAAkB,CAAC,cAAc,OAAO;CACxC,YAAY;EAAC;EAAU;EAAS;CAAmB;CACnD,MAAM;EAAC;EAAO;EAAgB;CAAuB;CACrD,cAAc;EAAC;EAAO;EAAqB;CAAY;CACvD,qBAAqB,CAAC,OAAO,qBAAqB;AACpD;;;;;;;;;;;;;;;AAiBA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,IAAE,OAAO;EACb,gBAAgBA,IAAE,QAAQ;EAC1B,UAAUA,IAAE,OAAO,CAAC,CAAC,SAAS;EAC9B,UAAUA,IAAE,KAAK;GAAC;GAAU;GAAS;EAAO,CAAC,CAAC,CAAC,SAAS;CAC1D,CAAC;AACH;AAEA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,IAAE,OAAO;EACb,YAAYA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAA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IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EAC5C,WAAWA,IAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,WAAWA,IAAE,QAAQ,CAAC,CAAC,QAAQ,IAAI;CACrC,CAAC;AACH;AAEA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,MAAMA,IAAE,OAAO;EACb,WAAWA,IAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,MAAMA,IAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,MAAMA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAChC,YAAYA,IAAE,OAAO,CAAC,CAAC,SAAS;CAClC,CAAC;AACH;;;;;AAMA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,qBAAqB"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "./zod.cjs";
|
|
2
2
|
import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
3
|
-
|
|
4
3
|
//#region src/errors.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Error pattern constants for categorizing infrastructure errors
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;cAKa;;;;;;;;;;;;;;;;;;;;;;;;cA0BA;;;;;;;;;;;;cASA;;;;;;;;;;;;;cAUA;;;;;;;;cASA;;;;;;;;;;;cAgBA;;;;;;;cAQA;;;;;;;cAQA;;;;;;;;cASA;;;;;;;;;;;;;cAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcA"}
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "./zod.mjs";
|
|
2
2
|
import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/errors.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Error pattern constants for categorizing infrastructure errors
|
package/dist/errors.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;cAKa;;;;;;;;;;;;;;;;;;;;;;;;cA0BA;;;;;;;;;;;;cASA;;;;;;;;;;;;;cAUA;;;;;;;;cASA;;;;;;;;;;;cAgBA;;;;;;;cAQA;;;;;;;cAQA;;;;;;;;cASA;;;;;;;;;;;;;cAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcA"}
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","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 CONNECTION_REFUSED: [\"ECONNREFUSED\"],\n HOST_NOT_FOUND: [\"ENOTFOUND\", \"EHOSTUNREACH\"],\n TIMEOUT: [\"ETIMEDOUT\", \"ESOCKETTIMEDOUT\", \"timeout\"],\n CONNECTION_RESET: [\"ECONNRESET\", \"EPIPE\"],\n PERMISSION: [\"EACCES\", \"EPERM\", \"permission denied\"],\n AUTH: [\"401\", \"unauthorized\", \"authentication failed\"],\n RATE_LIMITED: [\"429\", \"too many requests\", \"rate limit\"],\n SERVICE_UNAVAILABLE: [\"503\", \"service unavailable\"],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import individually or use the grouped PluginErrors export.\n *\n * @example\n * ```typescript\n * import { NOT_FOUND, FORBIDDEN, UNAUTHORIZED } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors({ NOT_FOUND, FORBIDDEN, UNAUTHORIZED })\n * });\n * ```\n */\n\nexport const UNAUTHORIZED = {\n status: 401,\n data: z.object({\n apiKeyProvided: z.boolean(),\n provider: z.string().optional(),\n authType: z.enum([\"apiKey\", \"oauth\", \"token\"]).optional(),\n }),\n} as const;\n\nexport const RATE_LIMITED = {\n status: 429,\n data: z.object({\n retryAfter: z.number().int().min(1),\n remainingRequests: z.number().int().min(0).optional(),\n resetTime: z.string().datetime().optional(),\n limitType: z.enum([\"requests\", \"tokens\", \"bandwidth\"]).optional(),\n }),\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n status: 503,\n data: z.object({\n retryAfter: z.number().int().optional(),\n maintenanceWindow: z.boolean().default(false),\n estimatedUptime: z.string().datetime().optional(),\n }),\n} as const;\n\nexport const BAD_REQUEST = {\n status: 400,\n data: z.object({\n invalidFields: z.array(z.string()).optional(),\n validationErrors: z\n .array(\n z.object({\n field: z.string(),\n message: z.string(),\n code: z.string().optional(),\n }),\n )\n .optional(),\n }),\n} as const;\n\nexport const NOT_FOUND = {\n status: 404,\n data: z.object({\n resource: z.string().optional(),\n resourceId: z.string().optional(),\n }),\n} as const;\n\nexport const FORBIDDEN = {\n status: 403,\n data: z.object({\n requiredPermissions: z.array(z.string()).optional(),\n action: z.string().optional(),\n }),\n} as const;\n\nexport const TIMEOUT = {\n status: 504,\n data: z.object({\n timeoutMs: z.number().int().min(0).optional(),\n operation: z.string().optional(),\n retryable: z.boolean().default(true),\n }),\n} as const;\n\nexport const CONNECTION_ERROR = {\n status: 502,\n data: z.object({\n errorCode: z.string().optional(),\n host: z.string().optional(),\n port: z.number().int().optional(),\n suggestion: z.string().optional(),\n }),\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n UNAUTHORIZED,\n RATE_LIMITED,\n SERVICE_UNAVAILABLE,\n BAD_REQUEST,\n NOT_FOUND,\n FORBIDDEN,\n TIMEOUT,\n CONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n extractFromFiberFailure,\n formatORPCError,\n isRetryableORPCCode,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;AAKA,MAAa,iBAAiB;CAC5B,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"errors.mjs","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 CONNECTION_REFUSED: [\"ECONNREFUSED\"],\n HOST_NOT_FOUND: [\"ENOTFOUND\", \"EHOSTUNREACH\"],\n TIMEOUT: [\"ETIMEDOUT\", \"ESOCKETTIMEDOUT\", \"timeout\"],\n CONNECTION_RESET: [\"ECONNRESET\", \"EPIPE\"],\n PERMISSION: [\"EACCES\", \"EPERM\", \"permission denied\"],\n AUTH: [\"401\", \"unauthorized\", \"authentication failed\"],\n RATE_LIMITED: [\"429\", \"too many requests\", \"rate limit\"],\n SERVICE_UNAVAILABLE: [\"503\", \"service unavailable\"],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import individually or use the grouped PluginErrors export.\n *\n * @example\n * ```typescript\n * import { NOT_FOUND, FORBIDDEN, UNAUTHORIZED } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors({ NOT_FOUND, FORBIDDEN, UNAUTHORIZED })\n * });\n * ```\n */\n\nexport const UNAUTHORIZED = {\n status: 401,\n data: z.object({\n apiKeyProvided: z.boolean(),\n provider: z.string().optional(),\n authType: z.enum([\"apiKey\", \"oauth\", \"token\"]).optional(),\n }),\n} as const;\n\nexport const RATE_LIMITED = {\n status: 429,\n data: z.object({\n retryAfter: z.number().int().min(1),\n remainingRequests: z.number().int().min(0).optional(),\n resetTime: z.string().datetime().optional(),\n limitType: z.enum([\"requests\", \"tokens\", \"bandwidth\"]).optional(),\n }),\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n status: 503,\n data: z.object({\n retryAfter: z.number().int().optional(),\n maintenanceWindow: z.boolean().default(false),\n estimatedUptime: z.string().datetime().optional(),\n }),\n} as const;\n\nexport const BAD_REQUEST = {\n status: 400,\n data: z.object({\n invalidFields: z.array(z.string()).optional(),\n validationErrors: z\n .array(\n z.object({\n field: z.string(),\n message: z.string(),\n code: z.string().optional(),\n }),\n )\n .optional(),\n }),\n} as const;\n\nexport const NOT_FOUND = {\n status: 404,\n data: z.object({\n resource: z.string().optional(),\n resourceId: z.string().optional(),\n }),\n} as const;\n\nexport const FORBIDDEN = {\n status: 403,\n data: z.object({\n requiredPermissions: z.array(z.string()).optional(),\n action: z.string().optional(),\n }),\n} as const;\n\nexport const TIMEOUT = {\n status: 504,\n data: z.object({\n timeoutMs: z.number().int().min(0).optional(),\n operation: z.string().optional(),\n retryable: z.boolean().default(true),\n }),\n} as const;\n\nexport const CONNECTION_ERROR = {\n status: 502,\n data: z.object({\n errorCode: z.string().optional(),\n host: z.string().optional(),\n port: z.number().int().optional(),\n suggestion: z.string().optional(),\n }),\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n UNAUTHORIZED,\n RATE_LIMITED,\n SERVICE_UNAVAILABLE,\n BAD_REQUEST,\n NOT_FOUND,\n FORBIDDEN,\n TIMEOUT,\n CONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n extractFromFiberFailure,\n formatORPCError,\n isRetryableORPCCode,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;AAKA,MAAa,iBAAiB;CAC5B,oBAAoB,CAAC,cAAc;CACnC,gBAAgB,CAAC,aAAa,cAAc;CAC5C,SAAS;EAAC;EAAa;EAAmB;CAAS;CACnD,kBAAkB,CAAC,cAAc,OAAO;CACxC,YAAY;EAAC;EAAU;EAAS;CAAmB;CACnD,MAAM;EAAC;EAAO;EAAgB;CAAuB;CACrD,cAAc;EAAC;EAAO;EAAqB;CAAY;CACvD,qBAAqB,CAAC,OAAO,qBAAqB;AACpD;;;;;;;;;;;;;;;AAiBA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,gBAAgB,EAAE,QAAQ;EAC1B,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;EAC9B,UAAU,EAAE,KAAK;GAAC;GAAU;GAAS;EAAO,CAAC,CAAC,CAAC,SAAS;CAC1D,CAAC;AACH;AAEA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;EAClC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EACpD,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;EAC1C,WAAW,EAAE,KAAK;GAAC;GAAY;GAAU;EAAW,CAAC,CAAC,CAAC,SAAS;CAClE,CAAC;AACH;AAEA,MAAa,sBAAsB;CACjC,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,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OAAO,CAAC,CAAC,SAAS;CAClC,CAAC;AACH;;;;;AAMA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,qBAAqB"}
|
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ exports.FORBIDDEN = require_errors$1.FORBIDDEN;
|
|
|
13
13
|
exports.ModuleFederationError = require_errors.ModuleFederationError;
|
|
14
14
|
exports.NOT_FOUND = require_errors$1.NOT_FOUND;
|
|
15
15
|
exports.PluginErrors = require_errors$1.PluginErrors;
|
|
16
|
+
exports.PluginIdTag = require_plugin.PluginIdTag;
|
|
16
17
|
exports.PluginRuntime = require_runtime_index.PluginRuntime;
|
|
17
18
|
exports.PluginRuntimeError = require_errors.PluginRuntimeError;
|
|
18
19
|
exports.RATE_LIMITED = require_errors$1.RATE_LIMITED;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
2
2
|
import { BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, ERROR_PATTERNS, FORBIDDEN, NOT_FOUND, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.cjs";
|
|
3
|
-
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginServicesTools, createPlugin, withPlugins } from "./plugin.cjs";
|
|
3
|
+
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginIdTag, PluginServicesTools, createPlugin, withPlugins } from "./plugin.cjs";
|
|
4
4
|
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.cjs";
|
|
5
5
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.cjs";
|
|
6
6
|
import { getNormalizedRemoteName } from "./runtime/services/normalize.cjs";
|
|
7
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, CreatePluginFn, CreatePluginWithPlugins, ERROR_PATTERNS, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginErrors, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, PluginServicesTools, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
7
|
+
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, CreatePluginFn, CreatePluginWithPlugins, ERROR_PATTERNS, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginErrors, PluginIdTag, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, PluginServicesTools, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
2
2
|
import { BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, ERROR_PATTERNS, FORBIDDEN, NOT_FOUND, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
3
|
-
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginServicesTools, createPlugin, withPlugins } from "./plugin.mjs";
|
|
3
|
+
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginIdTag, PluginServicesTools, createPlugin, withPlugins } from "./plugin.mjs";
|
|
4
4
|
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.mjs";
|
|
5
5
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
6
6
|
import { getNormalizedRemoteName } from "./runtime/services/normalize.mjs";
|
|
7
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, CreatePluginFn, CreatePluginWithPlugins, ERROR_PATTERNS, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginErrors, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, PluginServicesTools, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
7
|
+
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, CreatePluginFn, CreatePluginWithPlugins, ERROR_PATTERNS, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginErrors, PluginIdTag, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, PluginServicesTools, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
2
2
|
import { BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, ERROR_PATTERNS, FORBIDDEN, NOT_FOUND, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
3
|
-
import { createPlugin, withPlugins } from "./plugin.mjs";
|
|
3
|
+
import { PluginIdTag, createPlugin, withPlugins } from "./plugin.mjs";
|
|
4
4
|
import { getNormalizedRemoteName } from "./runtime/services/normalize.mjs";
|
|
5
5
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
6
6
|
|
|
7
|
-
export { BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, ERROR_PATTERNS, FORBIDDEN, ModuleFederationError, NOT_FOUND, PluginErrors, PluginRuntime, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
7
|
+
export { BAD_REQUEST, CONNECTION_ERROR, CommonPluginErrors, ERROR_PATTERNS, FORBIDDEN, ModuleFederationError, NOT_FOUND, PluginErrors, PluginIdTag, PluginRuntime, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/orpc.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
let _orpc_experimental_publisher_ioredis = require("@orpc/experimental-publisher/ioredis");
|
|
4
3
|
let _orpc_experimental_publisher_memory = require("@orpc/experimental-publisher/memory");
|
|
5
4
|
let _orpc_experimental_publisher_upstash_redis = require("@orpc/experimental-publisher/upstash-redis");
|
package/dist/plugin.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
1
|
const require_errors = require('./runtime/errors.cjs');
|
|
3
2
|
let _orpc_contract = require("@orpc/contract");
|
|
4
3
|
let effect = require("effect");
|
|
5
4
|
let _orpc_server = require("@orpc/server");
|
|
6
5
|
|
|
7
6
|
//#region src/plugin.ts
|
|
7
|
+
var PluginIdTag = class extends effect.Context.Tag("PluginId")() {};
|
|
8
8
|
const createPlugin = function createPlugin(config) {
|
|
9
9
|
const configSchema = {
|
|
10
10
|
variables: config.variables,
|
|
@@ -57,6 +57,7 @@ function withPlugins() {
|
|
|
57
57
|
createPlugin.withPlugins = withPlugins;
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
+
exports.PluginIdTag = PluginIdTag;
|
|
60
61
|
exports.createPlugin = createPlugin;
|
|
61
62
|
exports.withPlugins = withPlugins;
|
|
62
63
|
//# sourceMappingURL=plugin.cjs.map
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["Effect","extractFromFiberFailure","ORPCError","formatORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Effect, type Context as EffectContext, type Layer, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\n/**\n * Tools provided to plugin initialize/services for building long-lived scoped resources.\n */\ntype ServiceOf<T> = T extends EffectContext.Tag<any, infer S> ? S : never;\n\nexport type PluginServicesTools = {\n buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;\n};\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any>,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n /**\n * Initialize the plugin and build dependencies.\n * A third argument `tools` is provided for building long-lived scoped resources\n * (e.g. database pools) via `tools.buildService(tag, layer)`.\n */\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n tools: PluginServicesTools,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n tools: PluginServicesTools,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n tools: PluginServicesTools,\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P, tools).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n const formatted = formatORPCError(error);\n if (formatted) console.error(formatted);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["Context","Effect","extractFromFiberFailure","ORPCError","formatORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Context, Effect, type Context as EffectContext, type Layer, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\n/**\n * Tools provided to plugin initialize/services for building long-lived scoped resources.\n */\ntype ServiceOf<T> = T extends EffectContext.Tag<any, infer S> ? S : never;\n\nexport type PluginServicesTools = {\n buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;\n};\n\nexport class PluginIdTag extends Context.Tag(\"PluginId\")<PluginIdTag, string>() {}\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any>,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n /**\n * Initialize the plugin and build dependencies.\n * A third argument `tools` is provided for building long-lived scoped resources\n * (e.g. database pools) via `tools.buildService(tag, layer)`.\n */\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n tools: PluginServicesTools,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n tools: PluginServicesTools,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n tools: PluginServicesTools,\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P, tools).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n const formatted = formatORPCError(error);\n if (formatted) console.error(formatted);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Record<string, any> = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AAiCA,IAAa,cAAb,cAAiCA,eAAQ,IAAI,UAAU,CAAC,CAAsB,CAAC,CAAC,CAAC;AAgGjF,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,CAAC,GACpC,OAC4C;GAG5C,QAFa,OAAO,qBAAqBC,cAAO,QAAQ,CAAC,CAAU,GAExD,CAAC,cAAc,SAAc,KAAK,CAAC,CAAC,KAC7CA,cAAO,KAAK,SACVA,cAAO,WAAW;IAChB,KAAK,QAAQ;GACf,CAAC,CACH,GACAA,cAAO,UAAU,KAAK,KAAc,GACpCA,cAAO,UAAU,UAAU,KAAgB,CAC7C;EACF;EAEA,WAAuC;GACrC,MAAM,OAAO;GACb,OAAOA,cAAO,IAAI,aAAa;IAC7B,IAAI,OAAO,YAAY,KAAK,OAC1B,OAAO,OACJ,SAAS,KAAK,KAAK,CAAC,CACpB,KACCA,cAAO,UAAU,UACfA,cAAO,WAAW,mCAAmC,KAAK,MAAM,KAAK,CACvE,CACF;IAEJ,KAAK,QAAQ;GACf,CAAC;EACH;EAEA,aAAa,MAAqC;GAChD,MAAM,mCAAiB,OAAO,QAAQ,CAAC,CAAC,SAAyC;GACjF,MAAM,6CAA2B,UAAmB;IAClD,MAAM,YAAYC,uCAAwB,KAAK;IAE/C,IAAI,cAAc,SAAS,qBAAqBC,0BAC9C,MAAM;IAGR,MAAM,YAAYC,+BAAgB,KAAK;IACvC,IAAI,WAAW,QAAQ,MAAM,SAAS;IACtC,MAAM;GACR,CAAC;GAED,MAAM,UAAW,KAAa,IAAI,eAAe;GAEjD,OADe,OAAO,aAAa,MAAM,OAC7B;EACd;CACF;CAEA,MAAM,oBAAoB;CAU1B,kBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,OAAO;AACT;AAYA,SAAgB,cAA6E;CAC3F,QAOE,WACG,aAAyD,MAAa;AAC7E;AAEA,aAAa,cAAc"}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Scope } from "effect";
|
|
2
2
|
import { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
|
|
3
3
|
import { Implementer, Router } from "@orpc/server";
|
|
4
|
-
|
|
5
4
|
//#region src/plugin.d.ts
|
|
6
5
|
type ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;
|
|
7
6
|
type PluginConfigFor<V extends AnySchema, S extends AnySchema, TRequestContext extends AnySchema | undefined> = {
|
|
@@ -20,6 +19,8 @@ type ServiceOf<T> = T extends Context.Tag<any, infer S> ? S : never;
|
|
|
20
19
|
type PluginServicesTools = {
|
|
21
20
|
buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;
|
|
22
21
|
};
|
|
22
|
+
declare const PluginIdTag_base: Context.TagClass<PluginIdTag, "PluginId", string>;
|
|
23
|
+
declare class PluginIdTag extends PluginIdTag_base {}
|
|
23
24
|
type PluginDefinition<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined, TDeps extends Record<string, any>, P extends Record<string, unknown>> = {
|
|
24
25
|
variables: V;
|
|
25
26
|
secrets: S;
|
|
@@ -71,5 +72,5 @@ declare const createPlugin: CreatePluginFn;
|
|
|
71
72
|
type CreatePluginWithPlugins<P extends Record<string, unknown>> = <V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined, TDeps extends Record<string, any> = Record<never, never>>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;
|
|
72
73
|
declare function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P>;
|
|
73
74
|
//#endregion
|
|
74
|
-
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginServicesTools, createPlugin, withPlugins };
|
|
75
|
+
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginIdTag, PluginServicesTools, createPlugin, withPlugins };
|
|
75
76
|
//# sourceMappingURL=plugin.d.cts.map
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;KAOK,cAAc,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0BAA0B,uBAEpC,QAAQ,iBAAiB,GAAG,GAAG,WAAW,iBAAiB,OAAO,KACjE,wBAAwB,WAAW,GAAG,GAAG,iBAAiB;EAE7D,cAAc,UAAU,8BAA8B,wBAAwB;;cAGnE,cAAc;KAgGf,wBAAwB,UAAU,4BAC5C,UAAU,WACV,UAAU,WACV,kBAAkB,mBAClB,wBAAwB,mCACxB,cAAc,sBAAsB,sBAEpC,QAAQ,iBAAiB,GAAG,GAAG,WAAW,iBAAiB,OAAO,OAC/D,wBAAwB,WAAW,GAAG,GAAG,iBAAiB;iBAE/C,YAAY,UAAU,4BAA4B,wBAAwB"}
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
|
|
2
2
|
import { Context, Effect, Layer, Scope } from "effect";
|
|
3
3
|
import { Implementer, Router } from "@orpc/server";
|
|
4
|
-
|
|
5
4
|
//#region src/plugin.d.ts
|
|
6
5
|
type ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;
|
|
7
6
|
type PluginConfigFor<V extends AnySchema, S extends AnySchema, TRequestContext extends AnySchema | undefined> = {
|
|
@@ -20,6 +19,8 @@ type ServiceOf<T> = T extends Context.Tag<any, infer S> ? S : never;
|
|
|
20
19
|
type PluginServicesTools = {
|
|
21
20
|
buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;
|
|
22
21
|
};
|
|
22
|
+
declare const PluginIdTag_base: Context.TagClass<PluginIdTag, "PluginId", string>;
|
|
23
|
+
declare class PluginIdTag extends PluginIdTag_base {}
|
|
23
24
|
type PluginDefinition<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined, TDeps extends Record<string, any>, P extends Record<string, unknown>> = {
|
|
24
25
|
variables: V;
|
|
25
26
|
secrets: S;
|
|
@@ -71,5 +72,5 @@ declare const createPlugin: CreatePluginFn;
|
|
|
71
72
|
type CreatePluginWithPlugins<P extends Record<string, unknown>> = <V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined, TDeps extends Record<string, any> = Record<never, never>>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;
|
|
72
73
|
declare function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P>;
|
|
73
74
|
//#endregion
|
|
74
|
-
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginServicesTools, createPlugin, withPlugins };
|
|
75
|
+
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginIdTag, PluginServicesTools, createPlugin, withPlugins };
|
|
75
76
|
//# sourceMappingURL=plugin.d.mts.map
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;KAOK,cAAc,KAAK,UAAU,YAAY,kBAAkB,KAAK;KAEzD,gBACV,UAAU,WACV,UAAU,WACV,wBAAwB;EAExB,WAAW;EACX,SAAS;EACT,SAAS;;KAGN,sBAAsB,UAAU,WAAW,UAAU;EACxD,WAAW,kBAAkB;EAC7B,SAAS,kBAAkB;;;;;KAMxB,UAAU,KAAK,UAAU,QAAc,eAAe,KAAK;KAEpD;EACV,eAAe,GAAG,KAAK,GAAG,OAAO,MAAM,yBAAyB,OAAO,OAAO,UAAU;;;cAG7E,oBAAoB;KAE5B,iBACH,UAAU,WACV,UAAU,WACV,kBAAkB,mBAClB,wBAAwB,uBACxB,cAAc,qBACd,UAAU;EAEV,WAAW;EACX,SAAS;EACT,UAAU;EACV,UAAU;;;;;;EAMV,cACE,Q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PCError } from "./runtime/errors.mjs";
|
|
2
2
|
import { ORPCError } from "@orpc/contract";
|
|
3
|
-
import { Effect } from "effect";
|
|
3
|
+
import { Context, Effect } from "effect";
|
|
4
4
|
import { implement, onError } from "@orpc/server";
|
|
5
5
|
|
|
6
6
|
//#region src/plugin.ts
|
|
7
|
+
var PluginIdTag = class extends Context.Tag("PluginId")() {};
|
|
7
8
|
const createPlugin = function createPlugin(config) {
|
|
8
9
|
const configSchema = {
|
|
9
10
|
variables: config.variables,
|
|
@@ -56,5 +57,5 @@ function withPlugins() {
|
|
|
56
57
|
createPlugin.withPlugins = withPlugins;
|
|
57
58
|
|
|
58
59
|
//#endregion
|
|
59
|
-
export { createPlugin, withPlugins };
|
|
60
|
+
export { PluginIdTag, createPlugin, withPlugins };
|
|
60
61
|
//# sourceMappingURL=plugin.mjs.map
|