every-plugin 0.9.0 → 2.2.3

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.
Files changed (179) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +15 -1
  2. package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +15 -2
  3. package/dist/build/rspack/dev-server-middleware.cjs +15 -4
  4. package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
  5. package/dist/build/rspack/dev-server-middleware.mjs +15 -4
  6. package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
  7. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +44 -0
  8. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -0
  9. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +11 -0
  10. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -0
  11. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +11 -0
  12. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -0
  13. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +43 -0
  14. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -0
  15. package/dist/build/rspack/index.cjs +8 -4
  16. package/dist/build/rspack/index.d.cts +3 -2
  17. package/dist/build/rspack/index.d.mts +3 -2
  18. package/dist/build/rspack/index.mjs +3 -2
  19. package/dist/build/rspack/module-federation.cjs +3 -3
  20. package/dist/build/rspack/module-federation.cjs.map +1 -1
  21. package/dist/build/rspack/module-federation.mjs +1 -1
  22. package/dist/build/rspack/module-federation.mjs.map +1 -1
  23. package/dist/build/rspack/plugin.cjs +83 -5
  24. package/dist/build/rspack/plugin.cjs.map +1 -1
  25. package/dist/build/rspack/plugin.d.cts +12 -1
  26. package/dist/build/rspack/plugin.d.cts.map +1 -1
  27. package/dist/build/rspack/plugin.d.mts +12 -1
  28. package/dist/build/rspack/plugin.d.mts.map +1 -1
  29. package/dist/build/rspack/plugin.mjs +80 -5
  30. package/dist/build/rspack/plugin.mjs.map +1 -1
  31. package/dist/build/rspack/utils.cjs +5 -4
  32. package/dist/build/rspack/utils.cjs.map +1 -1
  33. package/dist/build/rspack/utils.mjs +3 -2
  34. package/dist/build/rspack/utils.mjs.map +1 -1
  35. package/dist/build/shared-deps.cjs +50 -42
  36. package/dist/build/shared-deps.cjs.map +1 -1
  37. package/dist/build/shared-deps.d.cts +27 -2
  38. package/dist/build/shared-deps.d.cts.map +1 -1
  39. package/dist/build/shared-deps.d.mts +27 -2
  40. package/dist/build/shared-deps.d.mts.map +1 -1
  41. package/dist/build/shared-deps.mjs +48 -43
  42. package/dist/build/shared-deps.mjs.map +1 -1
  43. package/dist/errors.cjs +1 -0
  44. package/dist/errors.cjs.map +1 -1
  45. package/dist/errors.d.cts.map +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs.map +1 -1
  48. package/dist/index.cjs +2 -0
  49. package/dist/index.d.cts +2 -2
  50. package/dist/index.d.mts +2 -2
  51. package/dist/index.mjs +2 -2
  52. package/dist/orpc-client.cjs +17 -0
  53. package/dist/orpc-client.d.cts +2 -0
  54. package/dist/orpc-client.d.mts +2 -0
  55. package/dist/orpc-client.mjs +5 -0
  56. package/dist/orpc-openapi.cjs +17 -0
  57. package/dist/orpc-openapi.d.cts +2 -0
  58. package/dist/orpc-openapi.d.mts +2 -0
  59. package/dist/orpc-openapi.mjs +5 -0
  60. package/dist/orpc.cjs +8 -7
  61. package/dist/plugin.cjs +9 -7
  62. package/dist/plugin.cjs.map +1 -1
  63. package/dist/plugin.d.cts +23 -24
  64. package/dist/plugin.d.cts.map +1 -1
  65. package/dist/plugin.d.mts +23 -24
  66. package/dist/plugin.d.mts.map +1 -1
  67. package/dist/plugin.mjs +8 -7
  68. package/dist/plugin.mjs.map +1 -1
  69. package/dist/runtime/errors.cjs +2 -2
  70. package/dist/runtime/errors.cjs.map +1 -1
  71. package/dist/runtime/errors.d.cts +4 -4
  72. package/dist/runtime/errors.d.cts.map +1 -1
  73. package/dist/runtime/errors.d.mts +4 -4
  74. package/dist/runtime/errors.d.mts.map +1 -1
  75. package/dist/runtime/errors.mjs +1 -1
  76. package/dist/runtime/errors.mjs.map +1 -1
  77. package/dist/runtime/index.cjs +41 -37
  78. package/dist/runtime/index.cjs.map +1 -1
  79. package/dist/runtime/index.d.cts +3 -3
  80. package/dist/runtime/index.d.cts.map +1 -1
  81. package/dist/runtime/index.d.mts +3 -3
  82. package/dist/runtime/index.d.mts.map +1 -1
  83. package/dist/runtime/index.mjs +12 -9
  84. package/dist/runtime/index.mjs.map +1 -1
  85. package/dist/runtime/mf-config.cjs +33 -0
  86. package/dist/runtime/mf-config.cjs.map +1 -0
  87. package/dist/runtime/mf-config.d.cts +41 -0
  88. package/dist/runtime/mf-config.d.cts.map +1 -0
  89. package/dist/runtime/mf-config.d.mts +41 -0
  90. package/dist/runtime/mf-config.d.mts.map +1 -0
  91. package/dist/runtime/mf-config.mjs +29 -0
  92. package/dist/runtime/mf-config.mjs.map +1 -0
  93. package/dist/runtime/services/module-federation.service.cjs +19 -56
  94. package/dist/runtime/services/module-federation.service.cjs.map +1 -1
  95. package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
  96. package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
  97. package/dist/runtime/services/module-federation.service.mjs +18 -55
  98. package/dist/runtime/services/module-federation.service.mjs.map +1 -1
  99. package/dist/runtime/services/normalize.cjs +3 -2
  100. package/dist/runtime/services/normalize.cjs.map +1 -1
  101. package/dist/runtime/services/normalize.mjs +2 -2
  102. package/dist/runtime/services/normalize.mjs.map +1 -1
  103. package/dist/runtime/services/plugin-lifecycle.service.cjs +1 -1
  104. package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
  105. package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
  106. package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
  107. package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
  108. package/dist/runtime/services/plugin-loader.service.cjs +3 -3
  109. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  110. package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
  111. package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
  112. package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
  113. package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
  114. package/dist/runtime/services/plugin-loader.service.mjs +2 -2
  115. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  116. package/dist/runtime/services/plugin.service.cjs +1 -1
  117. package/dist/runtime/services/plugin.service.cjs.map +1 -1
  118. package/dist/runtime/services/plugin.service.d.cts +6 -7
  119. package/dist/runtime/services/plugin.service.d.cts.map +1 -1
  120. package/dist/runtime/services/plugin.service.d.mts +6 -7
  121. package/dist/runtime/services/plugin.service.d.mts.map +1 -1
  122. package/dist/runtime/services/plugin.service.mjs.map +1 -1
  123. package/dist/runtime/services/secrets.service.cjs +1 -1
  124. package/dist/runtime/services/secrets.service.cjs.map +1 -1
  125. package/dist/runtime/services/secrets.service.d.cts.map +1 -1
  126. package/dist/runtime/services/secrets.service.d.mts.map +1 -1
  127. package/dist/runtime/services/secrets.service.mjs.map +1 -1
  128. package/dist/runtime/validation.cjs +1 -1
  129. package/dist/runtime/validation.cjs.map +1 -1
  130. package/dist/runtime/validation.mjs.map +1 -1
  131. package/dist/testing/index.cjs +2 -1
  132. package/dist/testing/index.cjs.map +1 -1
  133. package/dist/testing/index.d.cts +0 -2
  134. package/dist/testing/index.d.cts.map +1 -1
  135. package/dist/testing/index.d.mts +0 -2
  136. package/dist/testing/index.d.mts.map +1 -1
  137. package/dist/testing/index.mjs +1 -1
  138. package/dist/testing/index.mjs.map +1 -1
  139. package/dist/types.d.cts +6 -6
  140. package/dist/types.d.cts.map +1 -1
  141. package/dist/types.d.mts +6 -6
  142. package/dist/types.d.mts.map +1 -1
  143. package/dist/zod.cjs +4 -3
  144. package/dist/zod.mjs +2 -2
  145. package/package.json +200 -182
  146. package/src/build/rspack/dev-server-middleware.ts +233 -0
  147. package/src/build/rspack/fix-mf-data-uri-plugin.ts +49 -0
  148. package/src/build/rspack/index.ts +14 -0
  149. package/src/build/rspack/module-federation.ts +6 -0
  150. package/src/build/rspack/plugin.ts +252 -0
  151. package/src/build/rspack/utils.ts +60 -0
  152. package/src/build/shared-deps.ts +79 -0
  153. package/src/effect.ts +1 -0
  154. package/src/errors.ts +140 -0
  155. package/src/index.ts +26 -0
  156. package/src/orpc-client.ts +2 -0
  157. package/src/orpc-openapi.ts +2 -0
  158. package/src/orpc.ts +9 -0
  159. package/src/plugin.ts +220 -0
  160. package/src/runtime/errors.ts +332 -0
  161. package/src/runtime/index.ts +258 -0
  162. package/src/runtime/mf-config.ts +39 -0
  163. package/src/runtime/services/module-federation.service.ts +181 -0
  164. package/src/runtime/services/normalize.ts +18 -0
  165. package/src/runtime/services/plugin-lifecycle.service.ts +86 -0
  166. package/src/runtime/services/plugin-loader.service.ts +254 -0
  167. package/src/runtime/services/plugin.service.ts +66 -0
  168. package/src/runtime/services/secrets.service.ts +74 -0
  169. package/src/runtime/services.ts +5 -0
  170. package/src/runtime/validation.ts +23 -0
  171. package/src/testing/index.ts +87 -0
  172. package/src/testing/mocks/module-federation.service.ts +41 -0
  173. package/src/types.ts +309 -0
  174. package/src/zod-core.ts +4 -0
  175. package/src/zod.ts +1 -0
  176. package/dist/package.cjs +0 -45
  177. package/dist/package.cjs.map +0 -1
  178. package/dist/package.mjs +0 -27
  179. package/dist/package.mjs.map +0 -1
@@ -1,14 +1,39 @@
1
1
  //#region src/build/shared-deps.d.ts
2
2
  interface SharedDependencyConfig {
3
3
  version: string;
4
+ requiredVersion: string | false;
4
5
  singleton: boolean;
5
6
  strictVersion: boolean;
6
7
  eager: boolean;
7
8
  }
8
9
  type SharedDependencies = Record<string, SharedDependencyConfig>;
10
+ declare const pluginSharedDependencies: {
11
+ "every-plugin": {
12
+ requiredVersion: string | false;
13
+ singleton: boolean;
14
+ strictVersion: boolean;
15
+ eager: boolean;
16
+ version: string;
17
+ };
18
+ effect: {
19
+ requiredVersion: string | false;
20
+ singleton: boolean;
21
+ strictVersion: boolean;
22
+ eager: boolean;
23
+ version: string;
24
+ };
25
+ zod: {
26
+ requiredVersion: string | false;
27
+ singleton: boolean;
28
+ strictVersion: boolean;
29
+ eager: boolean;
30
+ version: string;
31
+ };
32
+ };
33
+ type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;
9
34
  declare function getPluginSharedDependencies(): SharedDependencies;
35
+ declare function getPluginSharedDependenciesVersionRange(): Record<string, string>;
10
36
  declare function getMajorMinorVersion(version: string): string;
11
- declare function getPluginSharedDependenciesVersionRange(): SharedDependencies;
12
37
  //#endregion
13
- export { SharedDependencies, SharedDependencyConfig, getMajorMinorVersion, getPluginSharedDependencies, getPluginSharedDependenciesVersionRange };
38
+ export { PluginSharedDependencyName, SharedDependencies, SharedDependencyConfig, getMajorMinorVersion, getPluginSharedDependencies, getPluginSharedDependenciesVersionRange, pluginSharedDependencies };
14
39
  //# sourceMappingURL=shared-deps.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-deps.d.cts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAEiB,sBAAA;EACf,OAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,iBAEhC,2BAAA,CAAA,GAA+B,kBAAA;AAAA,iBAmC/B,oBAAA,CAAqB,OAAA;AAAA,iBAOrB,uCAAA,CAAA,GAA2C,kBAAA"}
1
+ {"version":3,"file":"shared-deps.d.cts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB,sBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,cAsBnC,wBAAA;;;;;;;;;;;;;;;;;;;;;;;KAYD,0BAAA,gBAA0C,wBAAA;AAAA,iBAEtC,2BAAA,CAAA,GAA+B,kBAAA;AAAA,iBAI/B,uCAAA,CAAA,GAA2C,MAAA;AAAA,iBAS3C,oBAAA,CAAqB,OAAA"}
@@ -1,14 +1,39 @@
1
1
  //#region src/build/shared-deps.d.ts
2
2
  interface SharedDependencyConfig {
3
3
  version: string;
4
+ requiredVersion: string | false;
4
5
  singleton: boolean;
5
6
  strictVersion: boolean;
6
7
  eager: boolean;
7
8
  }
8
9
  type SharedDependencies = Record<string, SharedDependencyConfig>;
10
+ declare const pluginSharedDependencies: {
11
+ "every-plugin": {
12
+ requiredVersion: string | false;
13
+ singleton: boolean;
14
+ strictVersion: boolean;
15
+ eager: boolean;
16
+ version: string;
17
+ };
18
+ effect: {
19
+ requiredVersion: string | false;
20
+ singleton: boolean;
21
+ strictVersion: boolean;
22
+ eager: boolean;
23
+ version: string;
24
+ };
25
+ zod: {
26
+ requiredVersion: string | false;
27
+ singleton: boolean;
28
+ strictVersion: boolean;
29
+ eager: boolean;
30
+ version: string;
31
+ };
32
+ };
33
+ type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;
9
34
  declare function getPluginSharedDependencies(): SharedDependencies;
35
+ declare function getPluginSharedDependenciesVersionRange(): Record<string, string>;
10
36
  declare function getMajorMinorVersion(version: string): string;
11
- declare function getPluginSharedDependenciesVersionRange(): SharedDependencies;
12
37
  //#endregion
13
- export { SharedDependencies, SharedDependencyConfig, getMajorMinorVersion, getPluginSharedDependencies, getPluginSharedDependenciesVersionRange };
38
+ export { PluginSharedDependencyName, SharedDependencies, SharedDependencyConfig, getMajorMinorVersion, getPluginSharedDependencies, getPluginSharedDependenciesVersionRange, pluginSharedDependencies };
14
39
  //# sourceMappingURL=shared-deps.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-deps.d.mts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAEiB,sBAAA;EACf,OAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,iBAEhC,2BAAA,CAAA,GAA+B,kBAAA;AAAA,iBAmC/B,oBAAA,CAAqB,OAAA;AAAA,iBAOrB,uCAAA,CAAA,GAA2C,kBAAA"}
1
+ {"version":3,"file":"shared-deps.d.mts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB,sBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,cAsBnC,wBAAA;;;;;;;;;;;;;;;;;;;;;;;KAYD,0BAAA,gBAA0C,wBAAA;AAAA,iBAEtC,2BAAA,CAAA,GAA+B,kBAAA;AAAA,iBAI/B,uCAAA,CAAA,GAA2C,MAAA;AAAA,iBAS3C,oBAAA,CAAqB,OAAA"}
@@ -1,55 +1,60 @@
1
- import { dependencies, peerDependencies, version as version$1 } from "../package.mjs";
1
+ import { createRequire } from "node:module";
2
+ import { readFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
2
5
 
3
6
  //#region src/build/shared-deps.ts
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const require = createRequire(import.meta.url);
9
+ let pkg;
10
+ try {
11
+ pkg = JSON.parse(readFileSync(join(__dirname, "../../package.json"), "utf-8"));
12
+ } catch {
13
+ pkg = require("every-plugin/package.json");
14
+ }
15
+ const DEFAULT_SHARE_CONFIG = {
16
+ requiredVersion: false,
17
+ singleton: true,
18
+ strictVersion: false,
19
+ eager: false
20
+ };
21
+ function extractExactVersion(input) {
22
+ const match = input.match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?/);
23
+ return match ? match[0] : input.replace(/^[\^~>=<\s]+/, "");
24
+ }
25
+ function getInstalledPackageVersion(packageName, fallbackVersion) {
26
+ try {
27
+ return require(`${packageName}/package.json`).version;
28
+ } catch {
29
+ return extractExactVersion(fallbackVersion);
30
+ }
31
+ }
32
+ const pluginSharedDependencies = {
33
+ "every-plugin": {
34
+ version: pkg.version,
35
+ ...DEFAULT_SHARE_CONFIG
36
+ },
37
+ effect: {
38
+ version: getInstalledPackageVersion("effect", pkg.peerDependencies.effect),
39
+ ...DEFAULT_SHARE_CONFIG
40
+ },
41
+ zod: {
42
+ version: getInstalledPackageVersion("zod", pkg.peerDependencies.zod),
43
+ ...DEFAULT_SHARE_CONFIG
44
+ }
45
+ };
4
46
  function getPluginSharedDependencies() {
5
- return {
6
- "every-plugin": {
7
- version: version$1,
8
- singleton: true,
9
- strictVersion: false,
10
- eager: false
11
- },
12
- effect: {
13
- version: peerDependencies.effect,
14
- singleton: true,
15
- strictVersion: false,
16
- eager: false
17
- },
18
- zod: {
19
- version: peerDependencies.zod,
20
- singleton: true,
21
- strictVersion: false,
22
- eager: false
23
- },
24
- "@orpc/contract": {
25
- version: dependencies["@orpc/contract"],
26
- singleton: true,
27
- strictVersion: false,
28
- eager: false
29
- },
30
- "@orpc/server": {
31
- version: dependencies["@orpc/server"],
32
- singleton: true,
33
- strictVersion: false,
34
- eager: false
35
- }
36
- };
47
+ return pluginSharedDependencies;
48
+ }
49
+ function getPluginSharedDependenciesVersionRange() {
50
+ return Object.fromEntries(Object.entries(getPluginSharedDependencies()).map(([name, config]) => [name, getMajorMinorVersion(config.version)]));
37
51
  }
38
52
  function getMajorMinorVersion(version) {
39
53
  const match = version.replace(/^[\^~>=<]+/, "").match(/^(\d+)\.(\d+)/);
40
54
  if (!match) return "^0.0.0";
41
55
  return `^${match[1]}.${match[2]}.0`;
42
56
  }
43
- function getPluginSharedDependenciesVersionRange() {
44
- const deps = getPluginSharedDependencies();
45
- const result = {};
46
- for (const [key, config] of Object.entries(deps)) result[key] = {
47
- ...config,
48
- version: getMajorMinorVersion(config.version)
49
- };
50
- return result;
51
- }
52
57
 
53
58
  //#endregion
54
- export { getMajorMinorVersion, getPluginSharedDependencies, getPluginSharedDependenciesVersionRange };
59
+ export { getMajorMinorVersion, getPluginSharedDependencies, getPluginSharedDependenciesVersionRange, pluginSharedDependencies };
55
60
  //# sourceMappingURL=shared-deps.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-deps.mjs","names":["pkg.version"],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import pkg from \"../../package.json\";\n\nexport interface SharedDependencyConfig {\n version: string;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return {\n \"every-plugin\": {\n version: pkg.version,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: pkg.peerDependencies.effect,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: pkg.peerDependencies.zod,\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n \"@orpc/contract\": {\n version: pkg.dependencies[\"@orpc/contract\"],\n singleton: true,\n strictVersion: false,\n eager: false,\n },\n \"@orpc/server\": {\n version: pkg.dependencies[\"@orpc/server\"],\n singleton: true,\n strictVersion: false,\n eager: false,\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\nexport function getPluginSharedDependenciesVersionRange(): SharedDependencies {\n const deps = getPluginSharedDependencies();\n const result: SharedDependencies = {};\n \n for (const [key, config] of Object.entries(deps)) {\n result[key] = {\n ...config,\n version: getMajorMinorVersion(config.version),\n };\n }\n \n return result;\n}\n"],"mappings":";;;AAWA,SAAgB,8BAAkD;AAChE,QAAO;EACL,gBAAgB;GACd,SAASA;GACT,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,0BAA8B;GAC9B,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,0BAA8B;GAC9B,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sBAA0B;GAC1B,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sBAA0B;GAC1B,WAAW;GACX,eAAe;GACf,OAAO;GACR;EACF;;AAGH,SAAgB,qBAAqB,SAAyB;CAE5D,MAAM,QADQ,QAAQ,QAAQ,cAAc,GAAG,CAC3B,MAAM,gBAAgB;AAC1C,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG;;AAGlC,SAAgB,0CAA8D;CAC5E,MAAM,OAAO,6BAA6B;CAC1C,MAAM,SAA6B,EAAE;AAErC,MAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,KAAK,CAC9C,QAAO,OAAO;EACZ,GAAG;EACH,SAAS,qBAAqB,OAAO,QAAQ;EAC9C;AAGH,QAAO"}
1
+ {"version":3,"file":"shared-deps.mjs","names":[],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { 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}\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};\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 return require(`${packageName}/package.json`).version as string;\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} 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,IAAI,CAAC;AACzD,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAI;AAEJ,IAAI;AACF,OAAM,KAAK,MAAM,aAAa,KAAK,WAAW,qBAAqB,EAAE,QAAQ,CAAC;QACxE;AACN,OAAM,QAAQ,4BAA4B;;AAa5C,MAAM,uBAAgE;CACpE,iBAAiB;CACjB,WAAW;CACX,eAAe;CACf,OAAO;CACR;AAED,SAAS,oBAAoB,OAAuB;CAClD,MAAM,QAAQ,MAAM,MAAM,oCAAoC;AAC9D,QAAO,QAAQ,MAAM,KAAK,MAAM,QAAQ,gBAAgB,GAAG;;AAG7D,SAAS,2BAA2B,aAAqB,iBAAiC;AACxF,KAAI;AACF,SAAO,QAAQ,GAAG,YAAY,eAAe,CAAC;SACxC;AACN,SAAO,oBAAoB,gBAAgB;;;AAI/C,MAAa,2BAA2B;CACtC,gBAAgB;EAAE,SAAS,IAAI;EAAS,GAAG;EAAsB;CACjE,QAAQ;EACN,SAAS,2BAA2B,UAAU,IAAI,iBAAiB,OAAO;EAC1E,GAAG;EACJ;CACD,KAAK;EACH,SAAS,2BAA2B,OAAO,IAAI,iBAAiB,IAAI;EACpE,GAAG;EACJ;CACF;AAID,SAAgB,8BAAkD;AAChE,QAAO;;AAGT,SAAgB,0CAAkE;AAChF,QAAO,OAAO,YACZ,OAAO,QAAQ,6BAA6B,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CACpE,MACA,qBAAqB,OAAO,QAAQ,CACrC,CAAC,CACH;;AAGH,SAAgB,qBAAqB,SAAyB;CAE5D,MAAM,QADQ,QAAQ,QAAQ,cAAc,GAAG,CAC3B,MAAM,gBAAgB;AAC1C,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG"}
package/dist/errors.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_zod = require('./zod.cjs');
2
3
  const require_errors = require('./runtime/errors.cjs');
3
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n\tCONNECTION_REFUSED: ['ECONNREFUSED'],\n\tHOST_NOT_FOUND: ['ENOTFOUND', 'EHOSTUNREACH'],\n\tTIMEOUT: ['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'timeout'],\n\tCONNECTION_RESET: ['ECONNRESET', 'EPIPE'],\n\tPERMISSION: ['EACCES', 'EPERM', 'permission denied'],\n\tAUTH: ['401', 'unauthorized', 'authentication failed'],\n\tRATE_LIMITED: ['429', 'too many requests', 'rate limit'],\n\tSERVICE_UNAVAILABLE: ['503', 'service unavailable'],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import 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\tstatus: 401,\n\tdata: z.object({\n\t\tapiKeyProvided: z.boolean(),\n\t\tprovider: z.string().optional(),\n\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t})\n} as const;\n\nexport const RATE_LIMITED = {\n\tstatus: 429,\n\tdata: z.object({\n\t\tretryAfter: z.number().int().min(1),\n\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\tresetTime: z.string().datetime().optional(),\n\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t})\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n\tstatus: 503,\n\tdata: z.object({\n\t\tretryAfter: z.number().int().optional(),\n\t\tmaintenanceWindow: z.boolean().default(false),\n\t\testimatedUptime: z.string().datetime().optional(),\n\t})\n} as const;\n\nexport const BAD_REQUEST = {\n\tstatus: 400,\n\tdata: z.object({\n\t\tinvalidFields: z.array(z.string()).optional(),\n\t\tvalidationErrors: z.array(z.object({\n\t\t\tfield: z.string(),\n\t\t\tmessage: z.string(),\n\t\t\tcode: z.string().optional(),\n\t\t})).optional(),\n\t})\n} as const;\n\nexport const NOT_FOUND = {\n\tstatus: 404,\n\tdata: z.object({\n\t\tresource: z.string().optional(),\n\t\tresourceId: z.string().optional(),\n\t})\n} as const;\n\nexport const FORBIDDEN = {\n\tstatus: 403,\n\tdata: z.object({\n\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\taction: z.string().optional(),\n\t})\n} as const;\n\nexport const TIMEOUT = {\n\tstatus: 504,\n\tdata: z.object({\n\t\ttimeoutMs: z.number().int().min(0).optional(),\n\t\toperation: z.string().optional(),\n\t\tretryable: z.boolean().default(true),\n\t})\n} as const;\n\nexport const CONNECTION_ERROR = {\n\tstatus: 502,\n\tdata: z.object({\n\t\terrorCode: z.string().optional(),\n\t\thost: z.string().optional(),\n\t\tport: z.number().int().optional(),\n\t\tsuggestion: z.string().optional(),\n\t})\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n\tUNAUTHORIZED,\n\tRATE_LIMITED,\n\tSERVICE_UNAVAILABLE,\n\tBAD_REQUEST,\n\tNOT_FOUND,\n\tFORBIDDEN,\n\tTIMEOUT,\n\tCONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n\tformatORPCError,\n\tisRetryableORPCCode,\n\twrapORPCError,\n\ttoPluginRuntimeError,\n\textractFromFiberFailure,\n\tPluginRuntimeError,\n\tModuleFederationError,\n\tValidationError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;AAKA,MAAa,iBAAiB;CAC7B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACnD;;;;;;;;;;;;;;;AAiBD,MAAa,eAAe;CAC3B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,wCAAgB,EAAE,SAAS;EAC3B,kCAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,kCAAU,EAAE,KAAK;GAAC;GAAU;GAAS;GAAQ,CAAC,CAAC,UAAU;EACzD,CAAC;CACF;AAED,MAAa,eAAe;CAC3B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,oCAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;EACnC,2CAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EACrD,mCAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAC3C,mCAAW,EAAE,KAAK;GAAC;GAAY;GAAU;GAAY,CAAC,CAAC,UAAU;EACjE,CAAC;CACF;AAED,MAAa,sBAAsB;CAClC,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,oCAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACvC,2CAAmB,EAAE,SAAS,CAAC,QAAQ,MAAM;EAC7C,yCAAiB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EACjD,CAAC;CACF;AAED,MAAa,cAAc;CAC1B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,uCAAe,EAAE,8BAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAC7C,0CAAkB,EAAE,8BAAM,EAAE,OAAO;GAClC,+BAAO,EAAE,QAAQ;GACjB,iCAAS,EAAE,QAAQ;GACnB,8BAAM,EAAE,QAAQ,CAAC,UAAU;GAC3B,CAAC,CAAC,CAAC,UAAU;EACd,CAAC;CACF;AAED,MAAa,YAAY;CACxB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,kCAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,oCAAY,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC;CACF;AAED,MAAa,YAAY;CACxB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,6CAAqB,EAAE,8BAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,gCAAQ,EAAE,QAAQ,CAAC,UAAU;EAC7B,CAAC;CACF;AAED,MAAa,UAAU;CACtB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,mCAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,mCAAW,EAAE,SAAS,CAAC,QAAQ,KAAK;EACpC,CAAC;CACF;AAED,MAAa,mBAAmB;CAC/B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACd,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,8BAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,8BAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,oCAAY,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC;CACF;;;;;AAMD,MAAa,eAAe;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;AAKD,MAAa,qBAAqB"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n 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,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACpD;;;;;;;;;;;;;;;AAiBD,MAAa,eAAe;CAC1B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,wCAAgB,EAAE,SAAS;EAC3B,kCAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,kCAAU,EAAE,KAAK;GAAC;GAAU;GAAS;GAAQ,CAAC,CAAC,UAAU;EAC1D,CAAC;CACH;AAED,MAAa,eAAe;CAC1B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,oCAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;EACnC,2CAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EACrD,mCAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAC3C,mCAAW,EAAE,KAAK;GAAC;GAAY;GAAU;GAAY,CAAC,CAAC,UAAU;EAClE,CAAC;CACH;AAED,MAAa,sBAAsB;CACjC,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,oCAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACvC,2CAAmB,EAAE,SAAS,CAAC,QAAQ,MAAM;EAC7C,yCAAiB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAClD,CAAC;CACH;AAED,MAAa,cAAc;CACzB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,uCAAe,EAAE,8BAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAC7C,0CAAkB,EACf,8BACC,EAAE,OAAO;GACP,+BAAO,EAAE,QAAQ;GACjB,iCAAS,EAAE,QAAQ;GACnB,8BAAM,EAAE,QAAQ,CAAC,UAAU;GAC5B,CAAC,CACH,CACA,UAAU;EACd,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,kCAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,oCAAY,EAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,6CAAqB,EAAE,8BAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,gCAAQ,EAAE,QAAQ,CAAC,UAAU;EAC9B,CAAC;CACH;AAED,MAAa,UAAU;CACrB,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,mCAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,mCAAW,EAAE,SAAS,CAAC,QAAQ,KAAK;EACrC,CAAC;CACH;AAED,MAAa,mBAAmB;CAC9B,QAAQ;CACR,8BAAM,EAAE,OAAO;EACb,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,8BAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,8BAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,oCAAY,EAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;;;;;AAMD,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;cAKa,cAAA;EAAA;;;;;;;;;;;;;AA0Bb;;;;;;;;;;cAAa,YAAA;EAAA;;;;;;;;;;;cASA,YAAA;EAAA;;;;;;;;;;;;cAUA,mBAAA;EAAA;;;;;;;cASA,WAAA;EAAA;;;;;;;;;;cAYA,SAAA;EAAA;;;;;;cAQA,SAAA;EAAA;;;;;;cAQA,OAAA;EAAA;;;;;;;cASA,gBAAA;EAAA;;;;;;;;;;;;cAcA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcA,kBAAA;EAAA"}
1
+ {"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;cAKa,cAAA;EAAA;;;;;;;;;;;;;AA0Bb;;;;;;;;;;cAAa,YAAA;EAAA;;;;;;;;;;;cASA,YAAA;EAAA;;;;;;;;;;;;cAUA,mBAAA;EAAA;;;;;;;cASA,WAAA;EAAA;;;;;;;;;;cAgBA,SAAA;EAAA;;;;;;cAQA,SAAA;EAAA;;;;;;cAQA,OAAA;EAAA;;;;;;;cASA,gBAAA;EAAA;;;;;;;;;;;;cAcA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcA,kBAAA;EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;cAKa,cAAA;EAAA;;;;;;;;;;;;;AA0Bb;;;;;;;;;;cAAa,YAAA;EAAA;;;;;;;;;;;cASA,YAAA;EAAA;;;;;;;;;;;;cAUA,mBAAA;EAAA;;;;;;;cASA,WAAA;EAAA;;;;;;;;;;cAYA,SAAA;EAAA;;;;;;cAQA,SAAA;EAAA;;;;;;cAQA,OAAA;EAAA;;;;;;;cASA,gBAAA;EAAA;;;;;;;;;;;;cAcA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcA,kBAAA;EAAA"}
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;cAKa,cAAA;EAAA;;;;;;;;;;;;;AA0Bb;;;;;;;;;;cAAa,YAAA;EAAA;;;;;;;;;;;cASA,YAAA;EAAA;;;;;;;;;;;;cAUA,mBAAA;EAAA;;;;;;;cASA,WAAA;EAAA;;;;;;;;;;cAgBA,SAAA;EAAA;;;;;;cAQA,SAAA;EAAA;;;;;;cAQA,OAAA;EAAA;;;;;;;cASA,gBAAA;EAAA;;;;;;;;;;;;cAcA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcA,kBAAA;EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n\tCONNECTION_REFUSED: ['ECONNREFUSED'],\n\tHOST_NOT_FOUND: ['ENOTFOUND', 'EHOSTUNREACH'],\n\tTIMEOUT: ['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'timeout'],\n\tCONNECTION_RESET: ['ECONNRESET', 'EPIPE'],\n\tPERMISSION: ['EACCES', 'EPERM', 'permission denied'],\n\tAUTH: ['401', 'unauthorized', 'authentication failed'],\n\tRATE_LIMITED: ['429', 'too many requests', 'rate limit'],\n\tSERVICE_UNAVAILABLE: ['503', 'service unavailable'],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import 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\tstatus: 401,\n\tdata: z.object({\n\t\tapiKeyProvided: z.boolean(),\n\t\tprovider: z.string().optional(),\n\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t})\n} as const;\n\nexport const RATE_LIMITED = {\n\tstatus: 429,\n\tdata: z.object({\n\t\tretryAfter: z.number().int().min(1),\n\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\tresetTime: z.string().datetime().optional(),\n\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t})\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n\tstatus: 503,\n\tdata: z.object({\n\t\tretryAfter: z.number().int().optional(),\n\t\tmaintenanceWindow: z.boolean().default(false),\n\t\testimatedUptime: z.string().datetime().optional(),\n\t})\n} as const;\n\nexport const BAD_REQUEST = {\n\tstatus: 400,\n\tdata: z.object({\n\t\tinvalidFields: z.array(z.string()).optional(),\n\t\tvalidationErrors: z.array(z.object({\n\t\t\tfield: z.string(),\n\t\t\tmessage: z.string(),\n\t\t\tcode: z.string().optional(),\n\t\t})).optional(),\n\t})\n} as const;\n\nexport const NOT_FOUND = {\n\tstatus: 404,\n\tdata: z.object({\n\t\tresource: z.string().optional(),\n\t\tresourceId: z.string().optional(),\n\t})\n} as const;\n\nexport const FORBIDDEN = {\n\tstatus: 403,\n\tdata: z.object({\n\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\taction: z.string().optional(),\n\t})\n} as const;\n\nexport const TIMEOUT = {\n\tstatus: 504,\n\tdata: z.object({\n\t\ttimeoutMs: z.number().int().min(0).optional(),\n\t\toperation: z.string().optional(),\n\t\tretryable: z.boolean().default(true),\n\t})\n} as const;\n\nexport const CONNECTION_ERROR = {\n\tstatus: 502,\n\tdata: z.object({\n\t\terrorCode: z.string().optional(),\n\t\thost: z.string().optional(),\n\t\tport: z.number().int().optional(),\n\t\tsuggestion: z.string().optional(),\n\t})\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n\tUNAUTHORIZED,\n\tRATE_LIMITED,\n\tSERVICE_UNAVAILABLE,\n\tBAD_REQUEST,\n\tNOT_FOUND,\n\tFORBIDDEN,\n\tTIMEOUT,\n\tCONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n\tformatORPCError,\n\tisRetryableORPCCode,\n\twrapORPCError,\n\ttoPluginRuntimeError,\n\textractFromFiberFailure,\n\tPluginRuntimeError,\n\tModuleFederationError,\n\tValidationError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;AAKA,MAAa,iBAAiB;CAC7B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACnD;;;;;;;;;;;;;;;AAiBD,MAAa,eAAe;CAC3B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,gBAAgBA,cAAE,SAAS;EAC3B,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,UAAUA,cAAE,KAAK;GAAC;GAAU;GAAS;GAAQ,CAAC,CAAC,UAAU;EACzD,CAAC;CACF;AAED,MAAa,eAAe;CAC3B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,YAAYA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;EACnC,mBAAmBA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EACrD,WAAWA,cAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAC3C,WAAWA,cAAE,KAAK;GAAC;GAAY;GAAU;GAAY,CAAC,CAAC,UAAU;EACjE,CAAC;CACF;AAED,MAAa,sBAAsB;CAClC,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,YAAYA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACvC,mBAAmBA,cAAE,SAAS,CAAC,QAAQ,MAAM;EAC7C,iBAAiBA,cAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EACjD,CAAC;CACF;AAED,MAAa,cAAc;CAC1B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,eAAeA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EAC7C,kBAAkBA,cAAE,MAAMA,cAAE,OAAO;GAClC,OAAOA,cAAE,QAAQ;GACjB,SAASA,cAAE,QAAQ;GACnB,MAAMA,cAAE,QAAQ,CAAC,UAAU;GAC3B,CAAC,CAAC,CAAC,UAAU;EACd,CAAC;CACF;AAED,MAAa,YAAY;CACxB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,YAAYA,cAAE,QAAQ,CAAC,UAAU;EACjC,CAAC;CACF;AAED,MAAa,YAAY;CACxB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,qBAAqBA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,QAAQA,cAAE,QAAQ,CAAC,UAAU;EAC7B,CAAC;CACF;AAED,MAAa,UAAU;CACtB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,WAAWA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,WAAWA,cAAE,SAAS,CAAC,QAAQ,KAAK;EACpC,CAAC;CACF;AAED,MAAa,mBAAmB;CAC/B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACd,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,MAAMA,cAAE,QAAQ,CAAC,UAAU;EAC3B,MAAMA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,YAAYA,cAAE,QAAQ,CAAC,UAAU;EACjC,CAAC;CACF;;;;;AAMD,MAAa,eAAe;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;AAKD,MAAa,qBAAqB"}
1
+ {"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n 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,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACpD;;;;;;;;;;;;;;;AAiBD,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,gBAAgBA,cAAE,SAAS;EAC3B,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,UAAUA,cAAE,KAAK;GAAC;GAAU;GAAS;GAAQ,CAAC,CAAC,UAAU;EAC1D,CAAC;CACH;AAED,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,YAAYA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;EACnC,mBAAmBA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EACrD,WAAWA,cAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAC3C,WAAWA,cAAE,KAAK;GAAC;GAAY;GAAU;GAAY,CAAC,CAAC,UAAU;EAClE,CAAC;CACH;AAED,MAAa,sBAAsB;CACjC,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,YAAYA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACvC,mBAAmBA,cAAE,SAAS,CAAC,QAAQ,MAAM;EAC7C,iBAAiBA,cAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAClD,CAAC;CACH;AAED,MAAa,cAAc;CACzB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,eAAeA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EAC7C,kBAAkBA,cACf,MACCA,cAAE,OAAO;GACP,OAAOA,cAAE,QAAQ;GACjB,SAASA,cAAE,QAAQ;GACnB,MAAMA,cAAE,QAAQ,CAAC,UAAU;GAC5B,CAAC,CACH,CACA,UAAU;EACd,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,YAAYA,cAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,qBAAqBA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,QAAQA,cAAE,QAAQ,CAAC,UAAU;EAC9B,CAAC;CACH;AAED,MAAa,UAAU;CACrB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,WAAWA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,WAAWA,cAAE,SAAS,CAAC,QAAQ,KAAK;EACrC,CAAC;CACH;AAED,MAAa,mBAAmB;CAC9B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,MAAMA,cAAE,QAAQ,CAAC,UAAU;EAC3B,MAAMA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,YAAYA,cAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;;;;;AAMD,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,qBAAqB"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_errors = require('./runtime/errors.cjs');
2
3
  const require_errors$1 = require('./errors.cjs');
3
4
  const require_plugin = require('./plugin.cjs');
@@ -26,4 +27,5 @@ exports.formatORPCError = require_errors.formatORPCError;
26
27
  exports.getNormalizedRemoteName = require_runtime_services_normalize.getNormalizedRemoteName;
27
28
  exports.isRetryableORPCCode = require_errors.isRetryableORPCCode;
28
29
  exports.toPluginRuntimeError = require_errors.toPluginRuntimeError;
30
+ exports.withPlugins = require_plugin.withPlugins;
29
31
  exports.wrapORPCError = require_errors.wrapORPCError;
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 { LoadedPluginWithBinding, Plugin, PluginConfigFor, createPlugin } from "./plugin.cjs";
3
+ import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, 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 } 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, 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, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, 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, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, 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 { LoadedPluginWithBinding, Plugin, PluginConfigFor, createPlugin } from "./plugin.mjs";
3
+ import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, 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 } 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, 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, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, ValidationError, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, getNormalizedRemoteName, isRetryableORPCCode, toPluginRuntimeError, 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, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, 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 } from "./plugin.mjs";
3
+ import { 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, wrapORPCError };
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 };
@@ -0,0 +1,17 @@
1
+
2
+
3
+ var _orpc_client = require("@orpc/client");
4
+ Object.keys(_orpc_client).forEach(function (k) {
5
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
6
+ enumerable: true,
7
+ get: function () { return _orpc_client[k]; }
8
+ });
9
+ });
10
+
11
+ var _orpc_react_query = require("@orpc/react-query");
12
+ Object.keys(_orpc_react_query).forEach(function (k) {
13
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14
+ enumerable: true,
15
+ get: function () { return _orpc_react_query[k]; }
16
+ });
17
+ });
@@ -0,0 +1,2 @@
1
+ export * from "@orpc/client";
2
+ export * from "@orpc/react-query";
@@ -0,0 +1,2 @@
1
+ export * from "@orpc/client";
2
+ export * from "@orpc/react-query";
@@ -0,0 +1,5 @@
1
+ export * from "@orpc/client"
2
+
3
+ export * from "@orpc/react-query"
4
+
5
+ export { };
@@ -0,0 +1,17 @@
1
+
2
+
3
+ var _orpc_openapi = require("@orpc/openapi");
4
+ Object.keys(_orpc_openapi).forEach(function (k) {
5
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
6
+ enumerable: true,
7
+ get: function () { return _orpc_openapi[k]; }
8
+ });
9
+ });
10
+
11
+ var _orpc_zod = require("@orpc/zod");
12
+ Object.keys(_orpc_zod).forEach(function (k) {
13
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14
+ enumerable: true,
15
+ get: function () { return _orpc_zod[k]; }
16
+ });
17
+ });
@@ -0,0 +1,2 @@
1
+ export * from "@orpc/openapi";
2
+ export * from "@orpc/zod";
@@ -0,0 +1,2 @@
1
+ export * from "@orpc/openapi";
2
+ export * from "@orpc/zod";
@@ -0,0 +1,5 @@
1
+ export * from "@orpc/openapi"
2
+
3
+ export * from "@orpc/zod"
4
+
5
+ export { };
package/dist/orpc.cjs CHANGED
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  let _orpc_experimental_publisher_ioredis = require("@orpc/experimental-publisher/ioredis");
3
4
  let _orpc_experimental_publisher_memory = require("@orpc/experimental-publisher/memory");
4
5
  let _orpc_experimental_publisher_upstash_redis = require("@orpc/experimental-publisher/upstash-redis");
@@ -29,18 +30,18 @@ Object.keys(_orpc_contract).forEach(function (k) {
29
30
  });
30
31
  });
31
32
 
32
- var _orpc_server = require("@orpc/server");
33
- Object.keys(_orpc_server).forEach(function (k) {
33
+ var _orpc_experimental_publisher = require("@orpc/experimental-publisher");
34
+ Object.keys(_orpc_experimental_publisher).forEach(function (k) {
34
35
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
35
36
  enumerable: true,
36
- get: function () { return _orpc_server[k]; }
37
+ get: function () { return _orpc_experimental_publisher[k]; }
37
38
  });
38
39
  });
39
40
 
40
- var _orpc_experimental_publisher = require("@orpc/experimental-publisher");
41
- Object.keys(_orpc_experimental_publisher).forEach(function (k) {
41
+ var _orpc_server = require("@orpc/server");
42
+ Object.keys(_orpc_server).forEach(function (k) {
42
43
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
43
44
  enumerable: true,
44
- get: function () { return _orpc_experimental_publisher[k]; }
45
+ get: function () { return _orpc_server[k]; }
45
46
  });
46
47
  });
package/dist/plugin.cjs CHANGED
@@ -1,14 +1,11 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
2
  const require_errors = require('./runtime/errors.cjs');
3
3
  let _orpc_contract = require("@orpc/contract");
4
4
  let effect = require("effect");
5
5
  let _orpc_server = require("@orpc/server");
6
6
 
7
7
  //#region src/plugin.ts
8
- /**
9
- * Factory function to create plugins
10
- */
11
- function createPlugin(config) {
8
+ const createPlugin = function createPlugin(config) {
12
9
  const configSchema = {
13
10
  variables: config.variables,
14
11
  secrets: config.secrets,
@@ -20,8 +17,8 @@ function createPlugin(config) {
20
17
  contract = config.contract;
21
18
  configSchema = configSchema;
22
19
  _deps = null;
23
- initialize(pluginConfig) {
24
- return (config.initialize ?? (() => effect.Effect.succeed({})))(pluginConfig).pipe(effect.Effect.tap((deps) => effect.Effect.sync(() => {
20
+ initialize(pluginConfig, plugins = {}) {
21
+ return (config.initialize ?? (() => effect.Effect.succeed({})))(pluginConfig, plugins).pipe(effect.Effect.tap((deps) => effect.Effect.sync(() => {
25
22
  this._deps = deps;
26
23
  })), effect.Effect.map(() => this._deps), effect.Effect.mapError((error) => error));
27
24
  }
@@ -48,8 +45,13 @@ function createPlugin(config) {
48
45
  context: config.context
49
46
  };
50
47
  return PluginConstructor;
48
+ };
49
+ function withPlugins() {
50
+ return (config) => createPlugin(config);
51
51
  }
52
+ createPlugin.withPlugins = withPlugins;
52
53
 
53
54
  //#endregion
54
55
  exports.createPlugin = createPlugin;
56
+ exports.withPlugins = withPlugins;
55
57
  //# sourceMappingURL=plugin.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["Effect","extractFromFiberFailure","ORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport type { Context, Implementer, Router } from \"@orpc/server\";\nimport { ORPCError } from \"@orpc/contract\";\nimport { implement, onError, os } from \"@orpc/server\";\nimport { Effect, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : {};\n\n/**\n * Helper type that correctly constructs the config schema type\n */\nexport type PluginConfigFor<V extends AnySchema, S extends AnySchema, TRequestContext extends AnySchema | undefined> = {\n\tvariables: V;\n\tsecrets: S;\n\tcontext: TRequestContext;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n\tTContract extends AnyContractRouter,\n\tTVariables extends AnySchema,\n\tTSecrets extends AnySchema,\n\tTRequestContext extends AnySchema | undefined,\n\tTDeps extends Context = Record<never, never>\n> {\n\tnew(): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n\tbinding: {\n\t\tcontract: TContract;\n\t\tvariables: TVariables;\n\t\tsecrets: TSecrets;\n\t\tcontext: TRequestContext;\n\t};\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n\tTContract extends AnyContractRouter,\n\tTVariables extends AnySchema,\n\tTSecrets extends AnySchema,\n\tTRequestContext extends AnySchema | undefined,\n\tTDeps extends Context = Record<never, never>\n> {\n\treadonly id: string;\n\treadonly contract: TContract;\n\treadonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n\t// Plugin lifecycle\n\tinitialize(\n\t\tconfig: { variables: InferSchemaOutput<TVariables>; secrets: InferSchemaOutput<TSecrets> }\n\t): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n\tshutdown(): Effect.Effect<void, never>;\n\n\t/**\n\t * Creates the strongly-typed oRPC router for this plugin.\n\t * The router's procedure types are inferred directly from the contract.\n\t * @param deps The initialized plugin dependencies\n\t * @returns A router with procedures matching the plugin's contract\n\t */\n\tcreateRouter(deps: TDeps): Router<TContract, any>;\n}\n\n/**\n * Factory function to create plugins\n */\nexport function createPlugin<\n\tV extends AnySchema,\n\tS extends AnySchema,\n\tTContract extends AnyContractRouter,\n\tTRequestContext extends AnySchema | undefined = undefined,\n\tTDeps extends Context = Record<never, never>\n>(config: {\n\tvariables: V;\n\tsecrets: S;\n\tcontract: TContract;\n\tcontext?: TRequestContext;\n\tinitialize?: (\n\t\tconfig: { variables: InferSchemaOutput<V>; secrets: InferSchemaOutput<S> }\n\t) => Effect.Effect<TDeps, Error, Scope.Scope>;\n\tcreateRouter: (\n\t\tdeps: TDeps,\n\t\tbuilder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>\n\t) => Router<TContract, any>;\n\tshutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n}) {\n\tconst configSchema: PluginConfigFor<V, S, TRequestContext> = {\n\t\tvariables: config.variables,\n\t\tsecrets: config.secrets,\n\t\tcontext: config.context as TRequestContext\n\t};\n\n\tclass CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n\t\t/** set during instantiation - registry key */\n\t\tid!: string;\n\t\treadonly contract = config.contract;\n\t\treadonly configSchema = configSchema;\n\n\t\tprivate _deps: TDeps | null = null;\n\n\t\tinitialize(\n\t\t\tpluginConfig: { variables: InferSchemaOutput<V>; secrets: InferSchemaOutput<S> }\n\t\t): Effect.Effect<TDeps, unknown, Scope.Scope> {\n\t\t\tconst init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n\t\t\treturn init(pluginConfig).pipe(\n\t\t\t\tEffect.tap((deps) => Effect.sync(() => { this._deps = deps; })),\n\t\t\t\tEffect.map(() => this._deps as TDeps),\n\t\t\t\tEffect.mapError((error) => error as unknown)\n\t\t\t);\n\t\t}\n\n\t\tshutdown(): Effect.Effect<void, never> {\n\t\t\tconst self = this;\n\t\t\treturn Effect.gen(function* () {\n\t\t\t\tif (config.shutdown && self._deps) {\n\t\t\t\t\tyield* config.shutdown(self._deps).pipe(\n\t\t\t\t\t\tEffect.catchAll(() => Effect.void)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tcreateRouter(deps: TDeps): Router<TContract, any> {\n\t\t\tconst base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n\t\t\tconst builder = (base as any).use(onError((error: unknown) => {\n\t\t\t\tconst unwrapped = extractFromFiberFailure(error);\n\t\t\t\t\n\t\t\t\tif (unwrapped !== error && unwrapped instanceof ORPCError) {\n\t\t\t\t\tthrow unwrapped;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tformatORPCError(error);\n\t\t\t}));\n\t\t\tconst router = config.createRouter(deps, builder as any);\n\t\t\treturn router as Router<TContract, any>;\n\t\t}\n\t}\n\n\tconst PluginConstructor = CreatedPlugin as unknown as {\n\t\tnew(): Plugin<TContract, V, S, TRequestContext, TDeps>;\n\t\tbinding: {\n\t\t\tcontract: TContract;\n\t\t\tvariables: V;\n\t\t\tsecrets: S;\n\t\t\tcontext: TRequestContext;\n\t\t};\n\t};\n\n\tPluginConstructor.binding = {\n\t\tcontract: config.contract,\n\t\tvariables: config.variables,\n\t\tsecrets: config.secrets,\n\t\tcontext: config.context as TRequestContext\n\t};\n\n\treturn PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n}\n"],"mappings":";;;;;;;;;;AAsEA,SAAgB,aAMd,QAaC;CACF,MAAM,eAAuD;EAC5D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB;CAED,MAAM,cAAyE;;EAE9E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACC,cAC6C;AAG7C,WAFa,OAAO,qBAAqBA,cAAO,QAAQ,EAAE,CAAU,GAExD,aAAa,CAAC,KACzBA,cAAO,KAAK,SAASA,cAAO,WAAW;AAAE,SAAK,QAAQ;KAAQ,CAAC,EAC/DA,cAAO,UAAU,KAAK,MAAe,EACrCA,cAAO,UAAU,UAAU,MAAiB,CAC5C;;EAGF,WAAuC;GACtC,MAAM,OAAO;AACb,UAAOA,cAAO,IAAI,aAAa;AAC9B,QAAI,OAAO,YAAY,KAAK,MAC3B,QAAO,OAAO,SAAS,KAAK,MAAM,CAAC,KAClCA,cAAO,eAAeA,cAAO,KAAK,CAClC;KAED;;EAGH,aAAa,MAAqC;GAEjD,MAAM,sCADiB,OAAO,SAAS,CAAC,UAA0C,CACpD,+BAAa,UAAmB;IAC7D,MAAM,YAAYC,uCAAwB,MAAM;AAEhD,QAAI,cAAc,SAAS,qBAAqBC,yBAC/C,OAAM;AAGP,mCAAgB,MAAM;KACrB,CAAC;AAEH,UADe,OAAO,aAAa,MAAM,QAAe;;;CAK1D,MAAM,oBAAoB;AAU1B,mBAAkB,UAAU;EAC3B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB;AAED,QAAO"}
1
+ {"version":3,"file":"plugin.cjs","names":["Effect","extractFromFiberFailure","ORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Context, Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Effect, 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\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\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 Context = 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 Context = 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 ): 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 Context = 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 Context = 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 ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P).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.shutdown(self._deps).pipe(Effect.catchAll(() => Effect.void));\n }\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const builder = (base as any).use(\n onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n formatORPCError(error);\n }),\n );\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 Context = 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 Context = 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":";;;;;;;AA+GA,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;CAED,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,EAAE,EACO;AAG5C,WAFa,OAAO,qBAAqBA,cAAO,QAAQ,EAAE,CAAU,GAExD,cAAc,QAAa,CAAC,KACtCA,cAAO,KAAK,SACVA,cAAO,WAAW;AAChB,SAAK,QAAQ;KACb,CACH,EACDA,cAAO,UAAU,KAAK,MAAe,EACrCA,cAAO,UAAU,UAAU,MAAiB,CAC7C;;EAGH,WAAuC;GACrC,MAAM,OAAO;AACb,UAAOA,cAAO,IAAI,aAAa;AAC7B,QAAI,OAAO,YAAY,KAAK,MAC1B,QAAO,OAAO,SAAS,KAAK,MAAM,CAAC,KAAKA,cAAO,eAAeA,cAAO,KAAK,CAAC;KAE7E;;EAGJ,aAAa,MAAqC;GAEhD,MAAM,sCADiB,OAAO,SAAS,CAAC,UAA0C,CACpD,+BACnB,UAAmB;IAC1B,MAAM,YAAYC,uCAAwB,MAAM;AAEhD,QAAI,cAAc,SAAS,qBAAqBC,yBAC9C,OAAM;AAGR,mCAAgB,MAAM;KACtB,CACH;AAED,UADe,OAAO,aAAa,MAAM,QAAe;;;CAK5D,MAAM,oBAAoB;AAU1B,mBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;AAED,QAAO;;AAaT,SAAgB,cAA6E;AAC3F,SAOE,WACG,aAAyD,OAAc;;AAG9E,aAAa,cAAc"}