every-plugin 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +0 -4
  2. package/dist/_virtual/rolldown_runtime.mjs +1 -10
  3. package/dist/build/rspack/module-federation.cjs +11 -12
  4. package/dist/build/rspack/module-federation.cjs.map +1 -1
  5. package/dist/build/rspack/module-federation.mjs +11 -12
  6. package/dist/build/rspack/module-federation.mjs.map +1 -1
  7. package/dist/errors.cjs +41 -0
  8. package/dist/errors.cjs.map +1 -1
  9. package/dist/errors.d.cts +29 -1
  10. package/dist/errors.d.cts.map +1 -1
  11. package/dist/errors.d.mts +29 -1
  12. package/dist/errors.d.mts.map +1 -1
  13. package/dist/errors.mjs +41 -1
  14. package/dist/errors.mjs.map +1 -1
  15. package/dist/index.cjs +1 -0
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.mjs +2 -2
  19. package/dist/package.cjs +20 -161
  20. package/dist/package.cjs.map +1 -1
  21. package/dist/package.mjs +13 -163
  22. package/dist/package.mjs.map +1 -1
  23. package/dist/runtime/errors.cjs +54 -2
  24. package/dist/runtime/errors.cjs.map +1 -1
  25. package/dist/runtime/errors.mjs +54 -2
  26. package/dist/runtime/errors.mjs.map +1 -1
  27. package/dist/runtime/services/module-federation.service.cjs +7 -8
  28. package/dist/runtime/services/module-federation.service.cjs.map +1 -1
  29. package/dist/runtime/services/module-federation.service.mjs +7 -9
  30. package/dist/runtime/services/module-federation.service.mjs.map +1 -1
  31. package/dist/runtime/services/plugin-loader.service.cjs +11 -4
  32. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  33. package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
  34. package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
  35. package/dist/runtime/services/plugin-loader.service.mjs +11 -4
  36. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  37. package/package.json +1 -1
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
8
  var __copyProps = (to, from, except, desc) => {
12
9
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
10
  key = keys[i];
@@ -26,6 +23,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
23
 
27
24
  //#endregion
28
25
 
29
- exports.__commonJS = __commonJS;
30
26
  exports.__reExport = __reExport;
31
27
  exports.__toESM = __toESM;
@@ -1,15 +1,10 @@
1
1
  import { createRequire } from "node:module";
2
2
 
3
3
  //#region rolldown:runtime
4
- var __create = Object.create;
5
4
  var __defProp = Object.defineProperty;
6
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __commonJS = (cb, mod) => function() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
8
  var __copyProps = (to, from, except, desc) => {
14
9
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
10
  key = keys[i];
@@ -21,11 +16,7 @@ var __copyProps = (to, from, except, desc) => {
21
16
  return to;
22
17
  };
23
18
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
- value: mod,
26
- enumerable: true
27
- }) : target, mod));
28
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
29
20
 
30
21
  //#endregion
31
- export { __commonJS, __reExport, __require, __toESM };
22
+ export { __reExport, __require };
@@ -1,41 +1,40 @@
1
- const require_package$1 = require('../../package.cjs');
1
+ const require_package = require('../../package.cjs');
2
2
 
3
3
  //#region src/build/rspack/module-federation.ts
4
4
  function buildSharedDependencies(pluginInfo) {
5
- const everyPluginPkg = require_package$1.default();
6
5
  return {
7
6
  "every-plugin": {
8
- version: everyPluginPkg.version,
7
+ version: require_package.version,
9
8
  singleton: true,
10
- requiredVersion: `${everyPluginPkg.version}`,
9
+ requiredVersion: `${require_package.version}`,
11
10
  strictVersion: false,
12
11
  eager: false
13
12
  },
14
13
  effect: {
15
- version: everyPluginPkg.dependencies.effect,
14
+ version: require_package.dependencies.effect,
16
15
  singleton: true,
17
- requiredVersion: `${everyPluginPkg.dependencies.effect}`,
16
+ requiredVersion: `${require_package.dependencies.effect}`,
18
17
  strictVersion: false,
19
18
  eager: false
20
19
  },
21
20
  zod: {
22
- version: everyPluginPkg.dependencies.zod,
21
+ version: require_package.dependencies.zod,
23
22
  singleton: true,
24
- requiredVersion: `${everyPluginPkg.dependencies.zod}`,
23
+ requiredVersion: `${require_package.dependencies.zod}`,
25
24
  strictVersion: false,
26
25
  eager: false
27
26
  },
28
27
  "@orpc/contract": {
29
- version: everyPluginPkg.dependencies["@orpc/contract"],
28
+ version: require_package.dependencies["@orpc/contract"],
30
29
  singleton: true,
31
- requiredVersion: `${everyPluginPkg.dependencies["@orpc/contract"]}`,
30
+ requiredVersion: `${require_package.dependencies["@orpc/contract"]}`,
32
31
  strictVersion: false,
33
32
  eager: false
34
33
  },
35
34
  "@orpc/server": {
36
- version: everyPluginPkg.dependencies["@orpc/server"],
35
+ version: require_package.dependencies["@orpc/server"],
37
36
  singleton: true,
38
- requiredVersion: `${everyPluginPkg.dependencies["@orpc/server"]}`,
37
+ requiredVersion: `${require_package.dependencies["@orpc/server"]}`,
39
38
  strictVersion: false,
40
39
  eager: false
41
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"module-federation.cjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n // Get every-plugin package info for version constraints\n const everyPluginPkg = require('every-plugin/package.json');\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAEA,SAAgB,wBAAwB,YAAwB;CAE9D,MAAM;AAEN,QAAO;EACL,gBAAgB;GACd,SAAS,eAAe;GACxB,WAAW;GACX,iBAAiB,GAAG,eAAe;GACnC,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
1
+ {"version":3,"file":"module-federation.cjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import everyPluginPkg from '../../../package.json';\nimport type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,wBAAwB,YAAwB;AAE9D,QAAO;EACL,gBAAgB;GACd;GACA,WAAW;GACX,iBAAiB;GACjB,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sCAAqC;GACrC,WAAW;GACX,iBAAiB,gCAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
@@ -1,41 +1,40 @@
1
- import { require_package } from "../../package.mjs";
1
+ import { dependencies, version } from "../../package.mjs";
2
2
 
3
3
  //#region src/build/rspack/module-federation.ts
4
4
  function buildSharedDependencies(pluginInfo) {
5
- const everyPluginPkg = require_package();
6
5
  return {
7
6
  "every-plugin": {
8
- version: everyPluginPkg.version,
7
+ version,
9
8
  singleton: true,
10
- requiredVersion: `${everyPluginPkg.version}`,
9
+ requiredVersion: `${version}`,
11
10
  strictVersion: false,
12
11
  eager: false
13
12
  },
14
13
  effect: {
15
- version: everyPluginPkg.dependencies.effect,
14
+ version: dependencies.effect,
16
15
  singleton: true,
17
- requiredVersion: `${everyPluginPkg.dependencies.effect}`,
16
+ requiredVersion: `${dependencies.effect}`,
18
17
  strictVersion: false,
19
18
  eager: false
20
19
  },
21
20
  zod: {
22
- version: everyPluginPkg.dependencies.zod,
21
+ version: dependencies.zod,
23
22
  singleton: true,
24
- requiredVersion: `${everyPluginPkg.dependencies.zod}`,
23
+ requiredVersion: `${dependencies.zod}`,
25
24
  strictVersion: false,
26
25
  eager: false
27
26
  },
28
27
  "@orpc/contract": {
29
- version: everyPluginPkg.dependencies["@orpc/contract"],
28
+ version: dependencies["@orpc/contract"],
30
29
  singleton: true,
31
- requiredVersion: `${everyPluginPkg.dependencies["@orpc/contract"]}`,
30
+ requiredVersion: `${dependencies["@orpc/contract"]}`,
32
31
  strictVersion: false,
33
32
  eager: false
34
33
  },
35
34
  "@orpc/server": {
36
- version: everyPluginPkg.dependencies["@orpc/server"],
35
+ version: dependencies["@orpc/server"],
37
36
  singleton: true,
38
- requiredVersion: `${everyPluginPkg.dependencies["@orpc/server"]}`,
37
+ requiredVersion: `${dependencies["@orpc/server"]}`,
39
38
  strictVersion: false,
40
39
  eager: false
41
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"module-federation.mjs","names":[],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n // Get every-plugin package info for version constraints\n const everyPluginPkg = require('every-plugin/package.json');\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAEA,SAAgB,wBAAwB,YAAwB;CAE9D,MAAM;AAEN,QAAO;EACL,gBAAgB;GACd,SAAS,eAAe;GACxB,WAAW;GACX,iBAAiB,GAAG,eAAe;GACnC,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,SAAS,eAAe,aAAa;GACrC,WAAW;GACX,iBAAiB,GAAG,eAAe,aAAa;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
1
+ {"version":3,"file":"module-federation.mjs","names":["everyPluginPkg.version"],"sources":["../../../src/build/rspack/module-federation.ts"],"sourcesContent":["import everyPluginPkg from '../../../package.json';\nimport type { PluginInfo } from './utils';\n\nexport function buildSharedDependencies(pluginInfo: PluginInfo) {\n\n return {\n 'every-plugin': {\n version: everyPluginPkg.version,\n singleton: true,\n requiredVersion: `${everyPluginPkg.version}`,\n strictVersion: false,\n eager: false,\n },\n effect: {\n version: everyPluginPkg.dependencies.effect,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.effect}`,\n strictVersion: false,\n eager: false,\n },\n zod: {\n version: everyPluginPkg.dependencies.zod,\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies.zod}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/contract': {\n version: everyPluginPkg.dependencies['@orpc/contract'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/contract']}`,\n strictVersion: false,\n eager: false,\n },\n '@orpc/server': {\n version: everyPluginPkg.dependencies['@orpc/server'],\n singleton: true,\n requiredVersion: `${everyPluginPkg.dependencies['@orpc/server']}`,\n strictVersion: false,\n eager: false,\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,wBAAwB,YAAwB;AAE9D,QAAO;EACL,gBAAgB;GACLA;GACT,WAAW;GACX,iBAAiB,GAAGA;GACpB,eAAe;GACf,OAAO;GACR;EACD,QAAQ;GACN,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,KAAK;GACH,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,kBAAkB;GAChB,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACD,gBAAgB;GACd,sBAAqC;GACrC,WAAW;GACX,iBAAiB,gBAA+B;GAChD,eAAe;GACf,OAAO;GACR;EACF"}
package/dist/errors.cjs CHANGED
@@ -2,6 +2,35 @@ const require_zod = require('./zod.cjs');
2
2
 
3
3
  //#region src/errors.ts
4
4
  /**
5
+ * Error pattern constants for categorizing infrastructure errors
6
+ */
7
+ const ERROR_PATTERNS = {
8
+ CONNECTION_REFUSED: ["ECONNREFUSED"],
9
+ HOST_NOT_FOUND: ["ENOTFOUND", "EHOSTUNREACH"],
10
+ TIMEOUT: [
11
+ "ETIMEDOUT",
12
+ "ESOCKETTIMEDOUT",
13
+ "timeout"
14
+ ],
15
+ CONNECTION_RESET: ["ECONNRESET", "EPIPE"],
16
+ PERMISSION: [
17
+ "EACCES",
18
+ "EPERM",
19
+ "permission denied"
20
+ ],
21
+ AUTH: [
22
+ "401",
23
+ "unauthorized",
24
+ "authentication failed"
25
+ ],
26
+ RATE_LIMITED: [
27
+ "429",
28
+ "too many requests",
29
+ "rate limit"
30
+ ],
31
+ SERVICE_UNAVAILABLE: ["503", "service unavailable"]
32
+ };
33
+ /**
5
34
  * Common error schemas for plugin contracts.
6
35
  * Import these to ensure consistent error handling across plugins.
7
36
  *
@@ -55,9 +84,21 @@ const CommonPluginErrors = {
55
84
  FORBIDDEN: { data: require_zod.zod_exports.z.object({
56
85
  requiredPermissions: require_zod.zod_exports.z.array(require_zod.zod_exports.z.string()).optional(),
57
86
  action: require_zod.zod_exports.z.string().optional()
87
+ }) },
88
+ TIMEOUT: { data: require_zod.zod_exports.z.object({
89
+ timeoutMs: require_zod.zod_exports.z.number().int().min(0).optional(),
90
+ operation: require_zod.zod_exports.z.string().optional(),
91
+ retryable: require_zod.zod_exports.z.boolean().default(true)
92
+ }) },
93
+ CONNECTION_ERROR: { data: require_zod.zod_exports.z.object({
94
+ errorCode: require_zod.zod_exports.z.string().optional(),
95
+ host: require_zod.zod_exports.z.string().optional(),
96
+ port: require_zod.zod_exports.z.number().int().optional(),
97
+ suggestion: require_zod.zod_exports.z.string().optional()
58
98
  }) }
59
99
  };
60
100
 
61
101
  //#endregion
62
102
  exports.CommonPluginErrors = CommonPluginErrors;
103
+ exports.ERROR_PATTERNS = ERROR_PATTERNS;
63
104
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,qBAAqB;CACjC,cAAc,EACb,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,EACF;CACD,cAAc,EACb,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,EACF;CACD,qBAAqB,EACpB,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,EACF;CACD,aAAa,EACZ,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,EACF;CACD,WAAW,EACV,8BAAM,EAAE,OAAO;EACd,kCAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,oCAAY,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,EACF;CACD,WAAW,EACV,8BAAM,EAAE,OAAO;EACd,6CAAqB,EAAE,8BAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,gCAAQ,EAAE,QAAQ,CAAC,UAAU;EAC7B,CAAC,EACF;CACD"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n\tCONNECTION_REFUSED: ['ECONNREFUSED'],\n\tHOST_NOT_FOUND: ['ENOTFOUND', 'EHOSTUNREACH'],\n\tTIMEOUT: ['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'timeout'],\n\tCONNECTION_RESET: ['ECONNRESET', 'EPIPE'],\n\tPERMISSION: ['EACCES', 'EPERM', 'permission denied'],\n\tAUTH: ['401', 'unauthorized', 'authentication failed'],\n\tRATE_LIMITED: ['429', 'too many requests', 'rate limit'],\n\tSERVICE_UNAVAILABLE: ['503', 'service unavailable'],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t},\n\tTIMEOUT: {\n\t\tdata: z.object({\n\t\t\ttimeoutMs: z.number().int().min(0).optional(),\n\t\t\toperation: z.string().optional(),\n\t\t\tretryable: z.boolean().default(true),\n\t\t})\n\t},\n\tCONNECTION_ERROR: {\n\t\tdata: z.object({\n\t\t\terrorCode: z.string().optional(),\n\t\t\thost: z.string().optional(),\n\t\t\tport: z.number().int().optional(),\n\t\t\tsuggestion: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":";;;;;;AAKA,MAAa,iBAAiB;CAC7B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACnD;;;;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AE,QAAQ,CAAC,UAAU;EAC7B,CAAC,EACF;CACD,SAAS,EACR,8BAAM,EAAE,OAAO;EACd,mCAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,mCAAW,EAAE,SAAS,CAAC,QAAQ,KAAK;EACpC,CAAC,EACF;CACD,kBAAkB,EACjB,8BAAM,EAAE,OAAO;EACd,mCAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,8BAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,8BAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,oCAAY,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,EACF;CACD"}
package/dist/errors.d.cts CHANGED
@@ -2,6 +2,19 @@ import { zod_d_exports } from "./zod.cjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
 
5
+ /**
6
+ * Error pattern constants for categorizing infrastructure errors
7
+ */
8
+ declare const ERROR_PATTERNS: {
9
+ readonly CONNECTION_REFUSED: readonly ["ECONNREFUSED"];
10
+ readonly HOST_NOT_FOUND: readonly ["ENOTFOUND", "EHOSTUNREACH"];
11
+ readonly TIMEOUT: readonly ["ETIMEDOUT", "ESOCKETTIMEDOUT", "timeout"];
12
+ readonly CONNECTION_RESET: readonly ["ECONNRESET", "EPIPE"];
13
+ readonly PERMISSION: readonly ["EACCES", "EPERM", "permission denied"];
14
+ readonly AUTH: readonly ["401", "unauthorized", "authentication failed"];
15
+ readonly RATE_LIMITED: readonly ["429", "too many requests", "rate limit"];
16
+ readonly SERVICE_UNAVAILABLE: readonly ["503", "service unavailable"];
17
+ };
5
18
  /**
6
19
  * Common error schemas for plugin contracts.
7
20
  * Import these to ensure consistent error handling across plugins.
@@ -69,7 +82,22 @@ declare const CommonPluginErrors: {
69
82
  action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
70
83
  }, zod_d_exports.z.core.$strip>;
71
84
  };
85
+ readonly TIMEOUT: {
86
+ readonly data: zod_d_exports.z.ZodObject<{
87
+ timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
88
+ operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
89
+ retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
90
+ }, zod_d_exports.z.core.$strip>;
91
+ };
92
+ readonly CONNECTION_ERROR: {
93
+ readonly data: zod_d_exports.z.ZodObject<{
94
+ errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
95
+ host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
96
+ port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
97
+ suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
98
+ }, zod_d_exports.z.core.$strip>;
99
+ };
72
100
  };
73
101
  //#endregion
74
- export { CommonPluginErrors };
102
+ export { CommonPluginErrors, ERROR_PATTERNS };
75
103
  //# sourceMappingURL=errors.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;AAgBA;;;;;;;;;;;;cAAa"}
1
+ {"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAyBa,cAzBA,cAqFH,EAAA;;;;;;;;;;;;;;;;;;;;;;;;cA5DG"}
package/dist/errors.d.mts CHANGED
@@ -2,6 +2,19 @@ import { zod_d_exports } from "./zod.mjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
 
5
+ /**
6
+ * Error pattern constants for categorizing infrastructure errors
7
+ */
8
+ declare const ERROR_PATTERNS: {
9
+ readonly CONNECTION_REFUSED: readonly ["ECONNREFUSED"];
10
+ readonly HOST_NOT_FOUND: readonly ["ENOTFOUND", "EHOSTUNREACH"];
11
+ readonly TIMEOUT: readonly ["ETIMEDOUT", "ESOCKETTIMEDOUT", "timeout"];
12
+ readonly CONNECTION_RESET: readonly ["ECONNRESET", "EPIPE"];
13
+ readonly PERMISSION: readonly ["EACCES", "EPERM", "permission denied"];
14
+ readonly AUTH: readonly ["401", "unauthorized", "authentication failed"];
15
+ readonly RATE_LIMITED: readonly ["429", "too many requests", "rate limit"];
16
+ readonly SERVICE_UNAVAILABLE: readonly ["503", "service unavailable"];
17
+ };
5
18
  /**
6
19
  * Common error schemas for plugin contracts.
7
20
  * Import these to ensure consistent error handling across plugins.
@@ -69,7 +82,22 @@ declare const CommonPluginErrors: {
69
82
  action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
70
83
  }, zod_d_exports.z.core.$strip>;
71
84
  };
85
+ readonly TIMEOUT: {
86
+ readonly data: zod_d_exports.z.ZodObject<{
87
+ timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
88
+ operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
89
+ retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
90
+ }, zod_d_exports.z.core.$strip>;
91
+ };
92
+ readonly CONNECTION_ERROR: {
93
+ readonly data: zod_d_exports.z.ZodObject<{
94
+ errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
95
+ host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
96
+ port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
97
+ suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
98
+ }, zod_d_exports.z.core.$strip>;
99
+ };
72
100
  };
73
101
  //#endregion
74
- export { CommonPluginErrors };
102
+ export { CommonPluginErrors, ERROR_PATTERNS };
75
103
  //# sourceMappingURL=errors.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;AAgBA;;;;;;;;;;;;cAAa"}
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAyBa,cAzBA,cAqFH,EAAA;;;;;;;;;;;;;;;;;;;;;;;;cA5DG"}
package/dist/errors.mjs CHANGED
@@ -2,6 +2,35 @@ import { zod_exports } from "./zod.mjs";
2
2
 
3
3
  //#region src/errors.ts
4
4
  /**
5
+ * Error pattern constants for categorizing infrastructure errors
6
+ */
7
+ const ERROR_PATTERNS = {
8
+ CONNECTION_REFUSED: ["ECONNREFUSED"],
9
+ HOST_NOT_FOUND: ["ENOTFOUND", "EHOSTUNREACH"],
10
+ TIMEOUT: [
11
+ "ETIMEDOUT",
12
+ "ESOCKETTIMEDOUT",
13
+ "timeout"
14
+ ],
15
+ CONNECTION_RESET: ["ECONNRESET", "EPIPE"],
16
+ PERMISSION: [
17
+ "EACCES",
18
+ "EPERM",
19
+ "permission denied"
20
+ ],
21
+ AUTH: [
22
+ "401",
23
+ "unauthorized",
24
+ "authentication failed"
25
+ ],
26
+ RATE_LIMITED: [
27
+ "429",
28
+ "too many requests",
29
+ "rate limit"
30
+ ],
31
+ SERVICE_UNAVAILABLE: ["503", "service unavailable"]
32
+ };
33
+ /**
5
34
  * Common error schemas for plugin contracts.
6
35
  * Import these to ensure consistent error handling across plugins.
7
36
  *
@@ -55,9 +84,20 @@ const CommonPluginErrors = {
55
84
  FORBIDDEN: { data: zod_exports.z.object({
56
85
  requiredPermissions: zod_exports.z.array(zod_exports.z.string()).optional(),
57
86
  action: zod_exports.z.string().optional()
87
+ }) },
88
+ TIMEOUT: { data: zod_exports.z.object({
89
+ timeoutMs: zod_exports.z.number().int().min(0).optional(),
90
+ operation: zod_exports.z.string().optional(),
91
+ retryable: zod_exports.z.boolean().default(true)
92
+ }) },
93
+ CONNECTION_ERROR: { data: zod_exports.z.object({
94
+ errorCode: zod_exports.z.string().optional(),
95
+ host: zod_exports.z.string().optional(),
96
+ port: zod_exports.z.number().int().optional(),
97
+ suggestion: zod_exports.z.string().optional()
58
98
  }) }
59
99
  };
60
100
 
61
101
  //#endregion
62
- export { CommonPluginErrors };
102
+ export { CommonPluginErrors, ERROR_PATTERNS };
63
103
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.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AAW,EACV,MAAMA,cAAE,OAAO;EACd,qBAAqBA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,QAAQA,cAAE,QAAQ,CAAC,UAAU;EAC7B,CAAC,EACF;CACD"}
1
+ {"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n\tCONNECTION_REFUSED: ['ECONNREFUSED'],\n\tHOST_NOT_FOUND: ['ENOTFOUND', 'EHOSTUNREACH'],\n\tTIMEOUT: ['ETIMEDOUT', 'ESOCKETTIMEDOUT', 'timeout'],\n\tCONNECTION_RESET: ['ECONNRESET', 'EPIPE'],\n\tPERMISSION: ['EACCES', 'EPERM', 'permission denied'],\n\tAUTH: ['401', 'unauthorized', 'authentication failed'],\n\tRATE_LIMITED: ['429', 'too many requests', 'rate limit'],\n\tSERVICE_UNAVAILABLE: ['503', 'service unavailable'],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import these to ensure consistent error handling across plugins.\n *\n * @example\n * ```typescript\n * import { CommonPluginErrors } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors(CommonPluginErrors)\n * });\n * ```\n */\nexport const CommonPluginErrors = {\n\tUNAUTHORIZED: {\n\t\tdata: z.object({\n\t\t\tapiKeyProvided: z.boolean(),\n\t\t\tprovider: z.string().optional(),\n\t\t\tauthType: z.enum(['apiKey', 'oauth', 'token']).optional(),\n\t\t})\n\t},\n\tRATE_LIMITED: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().min(1),\n\t\t\tremainingRequests: z.number().int().min(0).optional(),\n\t\t\tresetTime: z.string().datetime().optional(),\n\t\t\tlimitType: z.enum(['requests', 'tokens', 'bandwidth']).optional(),\n\t\t})\n\t},\n\tSERVICE_UNAVAILABLE: {\n\t\tdata: z.object({\n\t\t\tretryAfter: z.number().int().optional(),\n\t\t\tmaintenanceWindow: z.boolean().default(false),\n\t\t\testimatedUptime: z.string().datetime().optional(),\n\t\t})\n\t},\n\tBAD_REQUEST: {\n\t\tdata: z.object({\n\t\t\tinvalidFields: z.array(z.string()).optional(),\n\t\t\tvalidationErrors: z.array(z.object({\n\t\t\t\tfield: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tcode: z.string().optional(),\n\t\t\t})).optional(),\n\t\t})\n\t},\n\tNOT_FOUND: {\n\t\tdata: z.object({\n\t\t\tresource: z.string().optional(),\n\t\t\tresourceId: z.string().optional(),\n\t\t})\n\t},\n\tFORBIDDEN: {\n\t\tdata: z.object({\n\t\t\trequiredPermissions: z.array(z.string()).optional(),\n\t\t\taction: z.string().optional(),\n\t\t})\n\t},\n\tTIMEOUT: {\n\t\tdata: z.object({\n\t\t\ttimeoutMs: z.number().int().min(0).optional(),\n\t\t\toperation: z.string().optional(),\n\t\t\tretryable: z.boolean().default(true),\n\t\t})\n\t},\n\tCONNECTION_ERROR: {\n\t\tdata: z.object({\n\t\t\terrorCode: z.string().optional(),\n\t\t\thost: z.string().optional(),\n\t\t\tport: z.number().int().optional(),\n\t\t\tsuggestion: z.string().optional(),\n\t\t})\n\t}\n} as const;\n"],"mappings":";;;;;;AAKA,MAAa,iBAAiB;CAC7B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACnD;;;;;;;;;;;;;;;AAgBD,MAAa,qBAAqB;CACjC,cAAc,EACb,MAAMA,cAAE,OAAO;EACd,gBAAgBA,cAAE,SAAS;EAC3B,UAAUA,cAAE,QAAQ,CAAC,UAA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,CAAC,UAAU;EAC7C,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,WAAWA,cAAE,SAAS,CAAC,QAAQ,KAAK;EACpC,CAAC,EACF;CACD,kBAAkB,EACjB,MAAMA,cAAE,OAAO;EACd,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,MAAMA,cAAE,QAAQ,CAAC,UAAU;EAC3B,MAAMA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,YAAYA,cAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,EACF;CACD"}
package/dist/index.cjs CHANGED
@@ -4,6 +4,7 @@ const require_runtime_services_normalize = require('./runtime/services/normalize
4
4
  const require_runtime_index = require('./runtime/index.cjs');
5
5
 
6
6
  exports.CommonPluginErrors = require_errors.CommonPluginErrors;
7
+ exports.ERROR_PATTERNS = require_errors.ERROR_PATTERNS;
7
8
  exports.PluginRuntime = require_runtime_index.PluginRuntime;
8
9
  exports.createPlugin = require_plugin.createPlugin;
9
10
  exports.createPluginRuntime = require_runtime_index.createPluginRuntime;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { CommonPluginErrors } from "./errors.cjs";
1
+ import { CommonPluginErrors, ERROR_PATTERNS } from "./errors.cjs";
2
2
  import { LoadedPluginWithBinding, Plugin, PluginConfigFor, createPlugin } from "./plugin.cjs";
3
3
  import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginVariables, RegisteredPlugins, SecretsConfig } from "./types.cjs";
4
4
  import { PluginRuntime, createPluginRuntime } from "./runtime/index.cjs";
5
5
  import { getNormalizedRemoteName } from "./runtime/services/normalize.cjs";
6
- export { type AnyPlugin, CommonPluginErrors, type EveryPlugin, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, type PluginSecrets, type PluginVariables, type RegisteredPlugins, type SecretsConfig, createPlugin, createPluginRuntime, getNormalizedRemoteName };
6
+ export { type AnyPlugin, CommonPluginErrors, ERROR_PATTERNS, type EveryPlugin, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, type PluginSecrets, type PluginVariables, type RegisteredPlugins, type SecretsConfig, createPlugin, createPluginRuntime, getNormalizedRemoteName };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { CommonPluginErrors } from "./errors.mjs";
1
+ import { CommonPluginErrors, ERROR_PATTERNS } from "./errors.mjs";
2
2
  import { LoadedPluginWithBinding, Plugin, PluginConfigFor, createPlugin } from "./plugin.mjs";
3
3
  import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginVariables, RegisteredPlugins, SecretsConfig } from "./types.mjs";
4
4
  import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
5
5
  import { getNormalizedRemoteName } from "./runtime/services/normalize.mjs";
6
- export { type AnyPlugin, CommonPluginErrors, type EveryPlugin, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, type PluginSecrets, type PluginVariables, type RegisteredPlugins, type SecretsConfig, createPlugin, createPluginRuntime, getNormalizedRemoteName };
6
+ export { type AnyPlugin, CommonPluginErrors, ERROR_PATTERNS, type EveryPlugin, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginInstance, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, type PluginSecrets, type PluginVariables, type RegisteredPlugins, type SecretsConfig, createPlugin, createPluginRuntime, getNormalizedRemoteName };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { CommonPluginErrors } from "./errors.mjs";
1
+ import { CommonPluginErrors, ERROR_PATTERNS } from "./errors.mjs";
2
2
  import { createPlugin } from "./plugin.mjs";
3
3
  import { getNormalizedRemoteName } from "./runtime/services/normalize.mjs";
4
4
  import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
5
5
 
6
- export { CommonPluginErrors, PluginRuntime, createPlugin, createPluginRuntime, getNormalizedRemoteName };
6
+ export { CommonPluginErrors, ERROR_PATTERNS, PluginRuntime, createPlugin, createPluginRuntime, getNormalizedRemoteName };