every-plugin 3.0.0-rc.0 → 3.0.0-rc.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.
- package/dist/errors.cjs +1 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.mts +2 -2
- package/dist/errors.mjs +2 -2
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/plugin.cjs +1 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +16 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +16 -2
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +1 -0
- package/dist/plugin.mjs.map +1 -1
- package/dist/runtime/errors.cjs +20 -0
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +23 -1
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +23 -1
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +20 -1
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +1 -1
- package/dist/runtime/mf-config.mjs +1 -1
- package/dist/runtime/services/module-federation.service.cjs +1 -7
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +1 -7
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +26 -1
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.mjs +26 -1
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/shared-identity.cjs +1 -1
- package/dist/runtime/services/shared-identity.cjs.map +1 -1
- package/dist/runtime/services/shared-identity.mjs +1 -1
- package/dist/runtime/services/shared-identity.mjs.map +1 -1
- package/dist/types.d.cts +3 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +3 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/version-manifest.cjs +1 -1
- package/dist/version-manifest.cjs.map +1 -1
- package/dist/version-manifest.mjs +1 -1
- package/dist/version-manifest.mjs.map +1 -1
- package/package.json +1 -1
- package/src/errors.ts +2 -1
- package/src/plugin.ts +20 -1
- package/src/runtime/errors.ts +44 -0
- package/src/runtime/services/module-federation.service.ts +4 -7
- package/src/runtime/services/plugin-loader.service.ts +32 -0
- package/src/runtime/services/shared-identity.ts +1 -1
- package/src/types.ts +3 -0
- package/src/version-manifest.ts +1 -1
package/dist/errors.cjs
CHANGED
|
@@ -137,6 +137,7 @@ exports.TIMEOUT = TIMEOUT;
|
|
|
137
137
|
exports.UNAUTHORIZED = UNAUTHORIZED;
|
|
138
138
|
exports.ValidationError = require_errors.ValidationError;
|
|
139
139
|
exports.classifyPluginFailure = require_errors.classifyPluginFailure;
|
|
140
|
+
exports.defaultMissingSecretWarnings = require_errors.defaultMissingSecretWarnings;
|
|
140
141
|
exports.extractFromFiberFailure = require_errors.extractFromFiberFailure;
|
|
141
142
|
exports.formatORPCError = require_errors.formatORPCError;
|
|
142
143
|
exports.toPluginRuntimeError = require_errors.toPluginRuntimeError;
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["z","COMMON_ERROR_STATUS_MAP"],"sources":["../src/errors.ts"],"sourcesContent":["import { COMMON_ERROR_STATUS_MAP } from \"@orpc/server\";\nimport { z } from \"zod\";\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 * Error-code -> HTTP-status map for handlers.\n *\n * oRPC v2 resolves statuses at the handler boundary via `errorStatusMap`\n * (default `COMMON_ERROR_STATUS_MAP`, where TIMEOUT is 408). Providing a\n * map REPLACES the default entirely, so the standard codes must be spread\n * back in. These custom entries preserve the v1 wire behavior:\n * TIMEOUT -> 504, CONNECTION_ERROR -> 502.\n */\nexport const PLUGIN_ERROR_STATUS_MAP: Record<string, number> = {\n ...COMMON_ERROR_STATUS_MAP,\n TIMEOUT: 504,\n CONNECTION_ERROR: 502,\n} as const;\n\nexport type { PluginLoadFailureInfo } from \"./runtime/errors\";\nexport {\n classifyPluginFailure,\n extractFromFiberFailure,\n formatORPCError,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,gBAAgBA,MAAE,QAAQ;EAC1B,UAAUA,MAAE,OAAO,CAAC,CAAC,SAAS;EAC9B,UAAUA,MAAE,KAAK;GAAC;GAAU;GAAS;EAAO,CAAC,CAAC,CAAC,SAAS;CAC1D,CAAC;AACH;AAEA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,YAAYA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;EAClC,mBAAmBA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EACpD,WAAWA,MAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;EAC1C,WAAWA,MAAE,KAAK;GAAC;GAAY;GAAU;EAAW,CAAC,CAAC,CAAC,SAAS;CAClE,CAAC;AACH;AAEA,MAAa,sBAAsB;CACjC,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,YAAYA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EACtC,mBAAmBA,MAAE,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,OAAO,CAAC,CAAC,SAAS;CAClC,CAAC;AACH;;;;;AAMA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAWA,MAAa,0BAAkD;CAC7D,GAAGC;CACH,SAAS;CACT,kBAAkB;AACpB"}
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":["z","COMMON_ERROR_STATUS_MAP"],"sources":["../src/errors.ts"],"sourcesContent":["import { COMMON_ERROR_STATUS_MAP } from \"@orpc/server\";\nimport { z } from \"zod\";\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 * Error-code -> HTTP-status map for handlers.\n *\n * oRPC v2 resolves statuses at the handler boundary via `errorStatusMap`\n * (default `COMMON_ERROR_STATUS_MAP`, where TIMEOUT is 408). Providing a\n * map REPLACES the default entirely, so the standard codes must be spread\n * back in. These custom entries preserve the v1 wire behavior:\n * TIMEOUT -> 504, CONNECTION_ERROR -> 502.\n */\nexport const PLUGIN_ERROR_STATUS_MAP: Record<string, number> = {\n ...COMMON_ERROR_STATUS_MAP,\n TIMEOUT: 504,\n CONNECTION_ERROR: 502,\n} as const;\n\nexport type { PluginLoadFailureInfo, PluginWarningInfo } from \"./runtime/errors\";\nexport {\n classifyPluginFailure,\n defaultMissingSecretWarnings,\n extractFromFiberFailure,\n formatORPCError,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,gBAAgBA,MAAE,QAAQ;EAC1B,UAAUA,MAAE,OAAO,CAAC,CAAC,SAAS;EAC9B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AAE,MAAMA,MAAE,OAAO,CAAC,CAAC,CAAC,SAAS;EAClD,QAAQA,MAAE,OAAO,CAAC,CAAC,SAAS;CAC9B,CAAC;AACH;AAEA,MAAa,UAAU;CACrB,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,WAAWA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EAC5C,WAAWA,MAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,WAAWA,MAAE,QAAQ,CAAC,CAAC,QAAQ,IAAI;CACrC,CAAC;AACH;AAEA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,WAAWA,MAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,MAAMA,MAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,MAAMA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAChC,YAAYA,MAAE,OAAO,CAAC,CAAC,SAAS;CAClC,CAAC;AACH;;;;;AAMA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAWA,MAAa,0BAAkD;CAC7D,GAAGC;CACH,SAAS;CACT,kBAAkB;AACpB"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
1
|
+
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -182,5 +182,5 @@ declare const PluginErrors: {
|
|
|
182
182
|
*/
|
|
183
183
|
declare const PLUGIN_ERROR_STATUS_MAP: Record<string, number>;
|
|
184
184
|
//#endregion
|
|
185
|
-
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, type PluginLoadFailureInfo, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
185
|
+
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, type PluginLoadFailureInfo, PluginRuntimeError, type PluginWarningInfo, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
186
186
|
//# sourceMappingURL=errors.d.cts.map
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
1
|
+
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -182,5 +182,5 @@ declare const PluginErrors: {
|
|
|
182
182
|
*/
|
|
183
183
|
declare const PLUGIN_ERROR_STATUS_MAP: Record<string, number>;
|
|
184
184
|
//#endregion
|
|
185
|
-
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, type PluginLoadFailureInfo, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
185
|
+
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, type PluginLoadFailureInfo, PluginRuntimeError, type PluginWarningInfo, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
186
186
|
//# sourceMappingURL=errors.d.mts.map
|
package/dist/errors.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleFederationError, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
1
|
+
import { ModuleFederationError, PluginRuntimeError, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
2
2
|
import { COMMON_ERROR_STATUS_MAP } from "@orpc/server";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
@@ -122,5 +122,5 @@ const PLUGIN_ERROR_STATUS_MAP = {
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
//#endregion
|
|
125
|
-
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
125
|
+
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
126
126
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { COMMON_ERROR_STATUS_MAP } from \"@orpc/server\";\nimport { z } from \"zod\";\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 * Error-code -> HTTP-status map for handlers.\n *\n * oRPC v2 resolves statuses at the handler boundary via `errorStatusMap`\n * (default `COMMON_ERROR_STATUS_MAP`, where TIMEOUT is 408). Providing a\n * map REPLACES the default entirely, so the standard codes must be spread\n * back in. These custom entries preserve the v1 wire behavior:\n * TIMEOUT -> 504, CONNECTION_ERROR -> 502.\n */\nexport const PLUGIN_ERROR_STATUS_MAP: Record<string, number> = {\n ...COMMON_ERROR_STATUS_MAP,\n TIMEOUT: 504,\n CONNECTION_ERROR: 502,\n} as const;\n\nexport type { PluginLoadFailureInfo } from \"./runtime/errors\";\nexport {\n classifyPluginFailure,\n extractFromFiberFailure,\n formatORPCError,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;;;;;;;;;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,OAAO,CAAC,CAAC,SAAS;CAClC,CAAC;AACH;AAEA,MAAa,YAAY;CACvB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,qBAAqB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;EAClD,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC9B,CAAC;AACH;AAEA,MAAa,UAAU;CACrB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EAC5C,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ,IAAI;CACrC,CAAC;AACH;AAEA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;EAC/B,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAChC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAClC,CAAC;AACH;;;;;AAMA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAWA,MAAa,0BAAkD;CAC7D,GAAG;CACH,SAAS;CACT,kBAAkB;AACpB"}
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { COMMON_ERROR_STATUS_MAP } from \"@orpc/server\";\nimport { z } from \"zod\";\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 * Error-code -> HTTP-status map for handlers.\n *\n * oRPC v2 resolves statuses at the handler boundary via `errorStatusMap`\n * (default `COMMON_ERROR_STATUS_MAP`, where TIMEOUT is 408). Providing a\n * map REPLACES the default entirely, so the standard codes must be spread\n * back in. These custom entries preserve the v1 wire behavior:\n * TIMEOUT -> 504, CONNECTION_ERROR -> 502.\n */\nexport const PLUGIN_ERROR_STATUS_MAP: Record<string, number> = {\n ...COMMON_ERROR_STATUS_MAP,\n TIMEOUT: 504,\n CONNECTION_ERROR: 502,\n} as const;\n\nexport type { PluginLoadFailureInfo, PluginWarningInfo } from \"./runtime/errors\";\nexport {\n classifyPluginFailure,\n defaultMissingSecretWarnings,\n extractFromFiberFailure,\n formatORPCError,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,gBAAgB,EAAE,QAAQ;EAC1B,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;EAC9B,UAAU,EAAE,KAAK;GAAC;GAAU;GAAS;EAAO,CAAC,CAAC,CAAC,SAAS;CAC1D,CAAC;AACH;AAEA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;EAClC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EACpD,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;EAC1C,WAAW,EAAE,KAAK;GAAC;GAAY;GAAU;EAAW,CAAC,CAAC,CAAC,SAAS;CAClE,CAAC;AACH;AAEA,MAAa,sBAAsB;CACjC,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EACtC,mBAAmB,EA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;CAClC,CAAC;AACH;;;;;AAMA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAWA,MAAa,0BAAkD;CAC7D,GAAG;CACH,SAAS;CACT,kBAAkB;AACpB"}
|
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ exports.buildScopedContext = require_effect_helpers.buildScopedContext;
|
|
|
27
27
|
exports.classifyPluginFailure = require_errors.classifyPluginFailure;
|
|
28
28
|
exports.createPlugin = require_plugin.createPlugin;
|
|
29
29
|
exports.createPluginRuntime = require_runtime_index.createPluginRuntime;
|
|
30
|
+
exports.defaultMissingSecretWarnings = require_errors.defaultMissingSecretWarnings;
|
|
30
31
|
exports.extractFromFiberFailure = require_errors.extractFromFiberFailure;
|
|
31
32
|
exports.formatORPCError = require_errors.formatORPCError;
|
|
32
33
|
exports.getNormalizedRemoteName = require_identity.remoteName;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { remoteName } from "./identity.cjs";
|
|
2
|
-
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
2
|
+
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
3
3
|
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.cjs";
|
|
4
4
|
import { buildScoped, buildScopedContext } from "./effect-helpers.cjs";
|
|
5
|
-
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, createPlugin, withPlugins } from "./plugin.cjs";
|
|
5
|
+
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins } from "./plugin.cjs";
|
|
6
6
|
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginServicesEntry, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.cjs";
|
|
7
7
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.cjs";
|
|
8
8
|
import "@orpc/openapi/extensions/route";
|
|
9
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginEnv, PluginErrors, PluginIdTag, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
9
|
+
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { remoteName } from "./identity.mjs";
|
|
2
|
-
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
2
|
+
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
3
3
|
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
4
4
|
import { buildScoped, buildScopedContext } from "./effect-helpers.mjs";
|
|
5
|
-
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, createPlugin, withPlugins } from "./plugin.mjs";
|
|
5
|
+
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins } from "./plugin.mjs";
|
|
6
6
|
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginServicesEntry, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.mjs";
|
|
7
7
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
8
8
|
import "@orpc/openapi/extensions/route";
|
|
9
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginEnv, PluginErrors, PluginIdTag, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginVariables, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
9
|
+
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildScoped, buildScopedContext } from "./effect-helpers.mjs";
|
|
2
|
-
import { ModuleFederationError, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
2
|
+
import { ModuleFederationError, PluginRuntimeError, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
3
3
|
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
4
4
|
import { PluginIdTag, createPlugin, withPlugins } from "./plugin.mjs";
|
|
5
5
|
import { remoteName } from "./identity.mjs";
|
|
6
6
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
7
7
|
import "@orpc/openapi/extensions/route";
|
|
8
8
|
|
|
9
|
-
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, PluginIdTag, PluginRuntime, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
9
|
+
export { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, ModuleFederationError, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, PluginIdTag, PluginRuntime, PluginRuntimeError, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/plugin.cjs
CHANGED
|
@@ -17,6 +17,7 @@ const createPlugin = function createPlugin(config) {
|
|
|
17
17
|
contract = config.contract;
|
|
18
18
|
configSchema = configSchema;
|
|
19
19
|
servicesTag = config.servicesTag;
|
|
20
|
+
warnings = config.warnings;
|
|
20
21
|
initialize(pluginConfig, plugins = {}) {
|
|
21
22
|
const init = config.initialize;
|
|
22
23
|
if (!init) return effect.Effect.succeed(effect.Layer.empty);
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["Context","Effect","Layer","toPluginRuntimeError","implement"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport type { WithEffectContext } from \"@orpc/experimental-effect\";\nimport \"@orpc/experimental-effect/extensions/effect\";\nimport type { ContractedRouter, Implementer } from \"@orpc/server\";\nimport { implement } from \"@orpc/server\";\nimport type { Scope } from \"effect\";\nimport { Context, Effect, Layer } from \"effect\";\nimport { type PluginRuntimeError, toPluginRuntimeError } 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\
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["Context","Effect","Layer","toPluginRuntimeError","implement"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport type { WithEffectContext } from \"@orpc/experimental-effect\";\nimport \"@orpc/experimental-effect/extensions/effect\";\nimport type { ContractedRouter, Implementer } from \"@orpc/server\";\nimport { implement } from \"@orpc/server\";\nimport type { Scope } from \"effect\";\nimport { Context, Effect, Layer } from \"effect\";\nimport type { PluginWarningInfo } from \"./runtime/errors\";\nimport { type PluginRuntimeError, toPluginRuntimeError } 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\nexport type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\n/**\n * A plugin's own config-derived warnings, evaluated once with the validated\n * config after initialization. Declaring `warnings` opts the plugin out of\n * the loader's default missing-secret warning — these messages replace it.\n */\nexport type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (\n config: PluginInitializeInput<V, S>,\n) => PluginWarningInfo[] | string[];\n\nexport class PluginIdTag extends Context.Service<PluginIdTag, string>()(\"PluginId\") {}\n\n/**\n * The `initialize` effect's environment: the plugin lifecycle scope plus the\n * framework-assigned plugin id.\n */\nexport type PluginEnv = Scope.Scope | PluginIdTag;\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n /**\n * Optional tag under which `initialize` exposes the plugin's services.\n * The host uses it to read services (e.g. the auth plugin's Better Auth\n * handler) from the built Effect context without importing the plugin\n * module statically.\n */\n servicesTag?: Context.Key<any, any>;\n /**\n * Optional warnings function evaluated once with the validated config after\n * initialization. Returns structured non-fatal warnings (e.g. an optional\n * secret was not set, so the feature depending on it is disabled).\n * Declaring it opts out of the loader's default missing-secret warning.\n */\n warnings?: PluginWarningsFn<V, S>;\n /**\n * Initialize the plugin by returning an Effect `Layer`.\n *\n * The runtime builds the Layer against the plugin's lifecycle scope —\n * scoped resources (db pools, repositories, caches, publishers) release\n * when the plugin shuts down. Services are provided to `.effect()`\n * handlers via the oRPC context (`yield* Tag`).\n */\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<Layer.Layer<any, Error, PluginEnv>, Error, PluginEnv>;\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * Services come from the Effect context — access them with\n * `yield* Tag` in `.effect()` handlers, or\n * `Context.get(context[\"effect/context\"], Tag)` in plain handlers.\n * Sibling plugin entries in `plugins` carry `{ client, router }`.\n */\n createRouter: (\n builder: Implementer<TContract, ContextOutput<TRequestContext> & WithEffectContext<any>>,\n plugins: P,\n ) => ContractedRouter<TContract, any>;\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> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n servicesTag?: Context.Key<any, any>;\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> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n readonly servicesTag?: Context.Key<any, any>;\n readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;\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 plugins Sibling plugin entries (`{ client, router }`) for\n * cross-plugin composition\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(plugins: Record<string, unknown>): ContractedRouter<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 P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\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 P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, 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> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n readonly servicesTag = config.servicesTag;\n readonly warnings = config.warnings;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv> {\n const init = config.initialize;\n if (!init) {\n return Effect.succeed(Layer.empty as unknown as Layer.Layer<any, Error, PluginEnv>);\n }\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(error, this.id, undefined, \"initialize-plugin\"),\n ),\n );\n }\n\n createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any> {\n const builder = implement(config.contract).$context<\n ContextOutput<TRequestContext> & WithEffectContext<any>\n >();\n return config.createRouter(builder as any, plugins as P) as ContractedRouter<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n servicesTag?: Context.Key<any, any>;\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 servicesTag: config.servicesTag,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\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>(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\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 >(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AAoCA,IAAa,cAAb,cAAiCA,eAAQ,QAA6B,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAyHrF,MAAa,eAA+B,SAAS,aAMnD,QAA+D;CAC/D,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,MAAM,cAAkE;;EAEtE;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EACxB,AAAS,cAAc,OAAO;EAC9B,AAAS,WAAW,OAAO;EAE3B,WACE,cACA,UAAmC,CAAC,GAC8C;GAClF,MAAM,OAAO,OAAO;GACpB,IAAI,CAAC,MACH,OAAOC,cAAO,QAAQC,aAAM,KAAsD;GAGpF,OAAO,KAAK,cAAc,OAAY,CAAC,CAAC,KACtCD,cAAO,UAAU,UACfE,oCAAqB,OAAO,KAAK,IAAI,QAAW,mBAAmB,CACrE,CACF;EACF;EAEA,aAAa,SAAoE;GAC/E,MAAM,cAAUC,wBAAU,OAAO,QAAQ,CAAC,CAAC,SAEzC;GACF,OAAO,OAAO,aAAa,SAAgB,OAAY;EACzD;CACF;CAEA,MAAM,oBAAoB;CAW1B,kBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,aAAa,OAAO;CACtB;CAEA,OAAO;AACT;AAWA,SAAgB,cAA6E;CAC3F,QAME,WACG,aAAkD,MAAa;AACtE;AAEA,aAAa,cAAc"}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginRuntimeError } from "./runtime/errors.cjs";
|
|
1
|
+
import { PluginRuntimeError, PluginWarningInfo } from "./runtime/errors.cjs";
|
|
2
2
|
import { ContractedRouter, Implementer } from "@orpc/server";
|
|
3
3
|
import { Context, Effect, Layer, Scope } from "effect";
|
|
4
4
|
import { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
|
|
@@ -15,6 +15,12 @@ type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
|
|
|
15
15
|
variables: InferSchemaOutput<V>;
|
|
16
16
|
secrets: InferSchemaOutput<S>;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* A plugin's own config-derived warnings, evaluated once with the validated
|
|
20
|
+
* config after initialization. Declaring `warnings` opts the plugin out of
|
|
21
|
+
* the loader's default missing-secret warning — these messages replace it.
|
|
22
|
+
*/
|
|
23
|
+
type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (config: PluginInitializeInput<V, S>) => PluginWarningInfo[] | string[];
|
|
18
24
|
declare const PluginIdTag_base: Context.ServiceClass<PluginIdTag, "PluginId", string>;
|
|
19
25
|
declare class PluginIdTag extends PluginIdTag_base {}
|
|
20
26
|
/**
|
|
@@ -34,6 +40,13 @@ type PluginDefinition<V extends AnySchema, S extends AnySchema, TContract extend
|
|
|
34
40
|
* module statically.
|
|
35
41
|
*/
|
|
36
42
|
servicesTag?: Context.Key<any, any>;
|
|
43
|
+
/**
|
|
44
|
+
* Optional warnings function evaluated once with the validated config after
|
|
45
|
+
* initialization. Returns structured non-fatal warnings (e.g. an optional
|
|
46
|
+
* secret was not set, so the feature depending on it is disabled).
|
|
47
|
+
* Declaring it opts out of the loader's default missing-secret warning.
|
|
48
|
+
*/
|
|
49
|
+
warnings?: PluginWarningsFn<V, S>;
|
|
37
50
|
/**
|
|
38
51
|
* Initialize the plugin by returning an Effect `Layer`.
|
|
39
52
|
*
|
|
@@ -73,6 +86,7 @@ interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySche
|
|
|
73
86
|
readonly contract: TContract;
|
|
74
87
|
readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;
|
|
75
88
|
readonly servicesTag?: Context.Key<any, any>;
|
|
89
|
+
readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;
|
|
76
90
|
initialize(config: PluginInitializeInput<TVariables, TSecrets>, plugins: Record<string, unknown>): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;
|
|
77
91
|
/**
|
|
78
92
|
* Creates the strongly-typed oRPC router for this plugin.
|
|
@@ -91,5 +105,5 @@ declare const createPlugin: CreatePluginFn;
|
|
|
91
105
|
type CreatePluginWithPlugins<P extends Record<string, unknown>> = <V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined>(config: PluginDefinition<V, S, TContract, TRequestContext, P>) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
92
106
|
declare function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P>;
|
|
93
107
|
//#endregion
|
|
94
|
-
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, createPlugin, withPlugins };
|
|
108
|
+
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins };
|
|
95
109
|
//# sourceMappingURL=plugin.d.cts.map
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;KAUK,cAAc,KAAK,UAAU,YAAY,kBAAkB,KAAK;KAEzD,gBACV,UAAU,WACV,UAAU,WACV,wBAAwB;EAExB,WAAW;EACX,SAAS;EACT,SAAS;;KAGC,sBAAsB,UAAU,WAAW,UAAU;EAC/D,WAAW,kBAAkB;EAC7B,SAAS,kBAAkB;;;;;;;KAQjB,iBAAiB,UAAU,WAAW,UAAU,cAC1D,QAAQ,sBAAsB,GAAG,OAC9B;;cAEQ,oBAAoB;;;;;KAMrB,YAAY,MAAM,QAAQ;KAEjC,iBACH,UAAU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package/dist/plugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginRuntimeError } from "./runtime/errors.mjs";
|
|
1
|
+
import { PluginRuntimeError, PluginWarningInfo } from "./runtime/errors.mjs";
|
|
2
2
|
import { Context, Effect, Layer, Scope } from "effect";
|
|
3
3
|
import { ContractedRouter, Implementer } from "@orpc/server";
|
|
4
4
|
import "@orpc/experimental-effect/extensions/effect";
|
|
@@ -15,6 +15,12 @@ type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
|
|
|
15
15
|
variables: InferSchemaOutput<V>;
|
|
16
16
|
secrets: InferSchemaOutput<S>;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* A plugin's own config-derived warnings, evaluated once with the validated
|
|
20
|
+
* config after initialization. Declaring `warnings` opts the plugin out of
|
|
21
|
+
* the loader's default missing-secret warning — these messages replace it.
|
|
22
|
+
*/
|
|
23
|
+
type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (config: PluginInitializeInput<V, S>) => PluginWarningInfo[] | string[];
|
|
18
24
|
declare const PluginIdTag_base: Context.ServiceClass<PluginIdTag, "PluginId", string>;
|
|
19
25
|
declare class PluginIdTag extends PluginIdTag_base {}
|
|
20
26
|
/**
|
|
@@ -34,6 +40,13 @@ type PluginDefinition<V extends AnySchema, S extends AnySchema, TContract extend
|
|
|
34
40
|
* module statically.
|
|
35
41
|
*/
|
|
36
42
|
servicesTag?: Context.Key<any, any>;
|
|
43
|
+
/**
|
|
44
|
+
* Optional warnings function evaluated once with the validated config after
|
|
45
|
+
* initialization. Returns structured non-fatal warnings (e.g. an optional
|
|
46
|
+
* secret was not set, so the feature depending on it is disabled).
|
|
47
|
+
* Declaring it opts out of the loader's default missing-secret warning.
|
|
48
|
+
*/
|
|
49
|
+
warnings?: PluginWarningsFn<V, S>;
|
|
37
50
|
/**
|
|
38
51
|
* Initialize the plugin by returning an Effect `Layer`.
|
|
39
52
|
*
|
|
@@ -73,6 +86,7 @@ interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySche
|
|
|
73
86
|
readonly contract: TContract;
|
|
74
87
|
readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;
|
|
75
88
|
readonly servicesTag?: Context.Key<any, any>;
|
|
89
|
+
readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;
|
|
76
90
|
initialize(config: PluginInitializeInput<TVariables, TSecrets>, plugins: Record<string, unknown>): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;
|
|
77
91
|
/**
|
|
78
92
|
* Creates the strongly-typed oRPC router for this plugin.
|
|
@@ -91,5 +105,5 @@ declare const createPlugin: CreatePluginFn;
|
|
|
91
105
|
type CreatePluginWithPlugins<P extends Record<string, unknown>> = <V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TRequestContext extends AnySchema | undefined = undefined>(config: PluginDefinition<V, S, TContract, TRequestContext, P>) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
92
106
|
declare function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P>;
|
|
93
107
|
//#endregion
|
|
94
|
-
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, createPlugin, withPlugins };
|
|
108
|
+
export { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins };
|
|
95
109
|
//# sourceMappingURL=plugin.d.mts.map
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;KAUK,cAAc,KAAK,UAAU,YAAY,kBAAkB,KAAK;KAEzD,gBACV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,KAC1D,wBAAwB,WAAW,GAAG,GAAG;EAE5C,cAAc,UAAU,8BAA8B,wBAAwB;;cAGnE,cAAc;KAmEf,wBAAwB,UAAU,4BAC5C,UAAU,WACV,UAAU,WACV,kBAAkB,mBAClB,wBAAwB,mCAExB,QAAQ,iBAAiB,GAAG,GAAG,WAAW,iBAAiB,OACxD,wBAAwB,WAAW,GAAG,GAAG;iBAE9B,YAAY,UAAU,4BAA4B,wBAAwB"}
|
package/dist/plugin.mjs
CHANGED
|
@@ -17,6 +17,7 @@ const createPlugin = function createPlugin(config) {
|
|
|
17
17
|
contract = config.contract;
|
|
18
18
|
configSchema = configSchema;
|
|
19
19
|
servicesTag = config.servicesTag;
|
|
20
|
+
warnings = config.warnings;
|
|
20
21
|
initialize(pluginConfig, plugins = {}) {
|
|
21
22
|
const init = config.initialize;
|
|
22
23
|
if (!init) return Effect.succeed(Layer.empty);
|
package/dist/plugin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport type { WithEffectContext } from \"@orpc/experimental-effect\";\nimport \"@orpc/experimental-effect/extensions/effect\";\nimport type { ContractedRouter, Implementer } from \"@orpc/server\";\nimport { implement } from \"@orpc/server\";\nimport type { Scope } from \"effect\";\nimport { Context, Effect, Layer } from \"effect\";\nimport { type PluginRuntimeError, toPluginRuntimeError } 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\
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport type { WithEffectContext } from \"@orpc/experimental-effect\";\nimport \"@orpc/experimental-effect/extensions/effect\";\nimport type { ContractedRouter, Implementer } from \"@orpc/server\";\nimport { implement } from \"@orpc/server\";\nimport type { Scope } from \"effect\";\nimport { Context, Effect, Layer } from \"effect\";\nimport type { PluginWarningInfo } from \"./runtime/errors\";\nimport { type PluginRuntimeError, toPluginRuntimeError } 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\nexport type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\n/**\n * A plugin's own config-derived warnings, evaluated once with the validated\n * config after initialization. Declaring `warnings` opts the plugin out of\n * the loader's default missing-secret warning — these messages replace it.\n */\nexport type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (\n config: PluginInitializeInput<V, S>,\n) => PluginWarningInfo[] | string[];\n\nexport class PluginIdTag extends Context.Service<PluginIdTag, string>()(\"PluginId\") {}\n\n/**\n * The `initialize` effect's environment: the plugin lifecycle scope plus the\n * framework-assigned plugin id.\n */\nexport type PluginEnv = Scope.Scope | PluginIdTag;\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n /**\n * Optional tag under which `initialize` exposes the plugin's services.\n * The host uses it to read services (e.g. the auth plugin's Better Auth\n * handler) from the built Effect context without importing the plugin\n * module statically.\n */\n servicesTag?: Context.Key<any, any>;\n /**\n * Optional warnings function evaluated once with the validated config after\n * initialization. Returns structured non-fatal warnings (e.g. an optional\n * secret was not set, so the feature depending on it is disabled).\n * Declaring it opts out of the loader's default missing-secret warning.\n */\n warnings?: PluginWarningsFn<V, S>;\n /**\n * Initialize the plugin by returning an Effect `Layer`.\n *\n * The runtime builds the Layer against the plugin's lifecycle scope —\n * scoped resources (db pools, repositories, caches, publishers) release\n * when the plugin shuts down. Services are provided to `.effect()`\n * handlers via the oRPC context (`yield* Tag`).\n */\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<Layer.Layer<any, Error, PluginEnv>, Error, PluginEnv>;\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * Services come from the Effect context — access them with\n * `yield* Tag` in `.effect()` handlers, or\n * `Context.get(context[\"effect/context\"], Tag)` in plain handlers.\n * Sibling plugin entries in `plugins` carry `{ client, router }`.\n */\n createRouter: (\n builder: Implementer<TContract, ContextOutput<TRequestContext> & WithEffectContext<any>>,\n plugins: P,\n ) => ContractedRouter<TContract, any>;\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> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n servicesTag?: Context.Key<any, any>;\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> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n readonly servicesTag?: Context.Key<any, any>;\n readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;\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 plugins Sibling plugin entries (`{ client, router }`) for\n * cross-plugin composition\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(plugins: Record<string, unknown>): ContractedRouter<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 P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\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 P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, 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> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n readonly servicesTag = config.servicesTag;\n readonly warnings = config.warnings;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv> {\n const init = config.initialize;\n if (!init) {\n return Effect.succeed(Layer.empty as unknown as Layer.Layer<any, Error, PluginEnv>);\n }\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(error, this.id, undefined, \"initialize-plugin\"),\n ),\n );\n }\n\n createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any> {\n const builder = implement(config.contract).$context<\n ContextOutput<TRequestContext> & WithEffectContext<any>\n >();\n return config.createRouter(builder as any, plugins as P) as ContractedRouter<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n servicesTag?: Context.Key<any, any>;\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 servicesTag: config.servicesTag,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\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>(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;\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 >(\n config: PluginDefinition<V, S, TContract, TRequestContext, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AAoCA,IAAa,cAAb,cAAiC,QAAQ,QAA6B,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAyHrF,MAAa,eAA+B,SAAS,aAMnD,QAA+D;CAC/D,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;CAClB;CAEA,MAAM,cAAkE;;EAEtE;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EACxB,AAAS,cAAc,OAAO;EAC9B,AAAS,WAAW,OAAO;EAE3B,WACE,cACA,UAAmC,CAAC,GAC8C;GAClF,MAAM,OAAO,OAAO;GACpB,IAAI,CAAC,MACH,OAAO,OAAO,QAAQ,MAAM,KAAsD;GAGpF,OAAO,KAAK,cAAc,OAAY,CAAC,CAAC,KACtC,OAAO,UAAU,UACf,qBAAqB,OAAO,KAAK,IAAI,QAAW,mBAAmB,CACrE,CACF;EACF;EAEA,aAAa,SAAoE;GAC/E,MAAM,UAAU,UAAU,OAAO,QAAQ,CAAC,CAAC,SAEzC;GACF,OAAO,OAAO,aAAa,SAAgB,OAAY;EACzD;CACF;CAEA,MAAM,oBAAoB;CAW1B,kBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,aAAa,OAAO;CACtB;CAEA,OAAO;AACT;AAWA,SAAgB,cAA6E;CAC3F,QAME,WACG,aAAkD,MAAa;AACtE;AAEA,aAAa,cAAc"}
|
package/dist/runtime/errors.cjs
CHANGED
|
@@ -148,6 +148,25 @@ const formatORPCError = (error) => {
|
|
|
148
148
|
lines.push(`╰${"─".repeat(50)}\n`);
|
|
149
149
|
return lines.join("\n");
|
|
150
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* The loader's default warning policy for declared-but-unset secrets: a
|
|
153
|
+
* successfully initialized plugin whose declared secret names resolved to
|
|
154
|
+
* nothing (missing or empty in the environment) gets one consolidated
|
|
155
|
+
* warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB
|
|
156
|
+
* fallback, and a genuinely-missing DB URL fails initialization (a `failure`,
|
|
157
|
+
* not a warning). A plugin that declares its own `warnings` function opts out
|
|
158
|
+
* of this default.
|
|
159
|
+
*/
|
|
160
|
+
const defaultMissingSecretWarnings = (pluginKey, declaredKeys, resolvedKeys) => {
|
|
161
|
+
const resolved = new Set(resolvedKeys);
|
|
162
|
+
const missing = declaredKeys.filter((key) => !resolved.has(key) && !key.endsWith("_DATABASE_URL"));
|
|
163
|
+
if (missing.length === 0) return [];
|
|
164
|
+
return [{
|
|
165
|
+
pluginKey,
|
|
166
|
+
message: missing.length === 1 ? `Declared secret ${missing[0]} is not set — features depending on it are disabled` : `${missing.length} declared secrets are not set: ${missing.join(", ")} — features depending on them are disabled`,
|
|
167
|
+
hint: "Set the secret(s) in your environment (.env in development); see the plugin's config schema for what each enables"
|
|
168
|
+
}];
|
|
169
|
+
};
|
|
151
170
|
const NETWORK_RETRYABLE_PATTERNS = [
|
|
152
171
|
"ETIMEDOUT",
|
|
153
172
|
"ECONNRESET",
|
|
@@ -271,6 +290,7 @@ exports.PluginRuntimeError = PluginRuntimeError;
|
|
|
271
290
|
exports.ValidationError = ValidationError;
|
|
272
291
|
exports.classifyPluginFailure = classifyPluginFailure;
|
|
273
292
|
exports.deepestErrorStack = deepestErrorStack;
|
|
293
|
+
exports.defaultMissingSecretWarnings = defaultMissingSecretWarnings;
|
|
274
294
|
exports.extractFromFiberFailure = extractFromFiberFailure;
|
|
275
295
|
exports.formatORPCError = formatORPCError;
|
|
276
296
|
exports.toPluginRuntimeError = toPluginRuntimeError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["Data","ORPCError","Cause"],"sources":["../../src/runtime/errors.ts"],"sourcesContent":["import { ORPCError } from \"@orpc/server\";\nimport { Cause, Data } from \"effect\";\nimport type { z } from \"zod\";\n\nexport class PluginRuntimeError extends Data.TaggedError(\"PluginRuntimeError\")<{\n readonly pluginId?: string;\n readonly operation?: string;\n readonly procedureName?: string;\n readonly cause?: Error;\n}> {\n override get message() {\n return this.cause?.message ?? \"Plugin operation failed\";\n }\n}\n\nexport class ModuleFederationError extends Data.TaggedError(\"ModuleFederationError\")<{\n readonly pluginId: string;\n readonly remoteUrl: string;\n readonly cause?: Error;\n}> {}\n\nexport class ValidationError extends Data.TaggedError(\"ValidationError\")<{\n readonly pluginId: string;\n readonly stage: \"config\" | \"input\" | \"output\" | \"state\";\n readonly zodError: z.ZodError;\n}> {}\n\nconst stringifyUnknown = (value: unknown): string => {\n if (value === null) return \"null\";\n if (value === undefined) return \"undefined\";\n if (value instanceof Error) return value.message;\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\") {\n return `${value}`;\n }\n if (typeof value === \"symbol\") return value.description ?? \"\";\n try {\n return JSON.stringify(value) ?? \"[Unserializable value]\";\n } catch {\n return \"[Unserializable value]\";\n }\n};\n\nconst extractErrorMessage = (error: unknown): string => {\n if (!error) return \"Unknown error\";\n\n if (error instanceof Error) {\n if (error.message) return error.message;\n if ((error as any).cause instanceof Error) {\n return extractErrorMessage((error as any).cause);\n }\n }\n\n if (error instanceof AggregateError && error.errors?.length) {\n return error.errors.map((e) => extractErrorMessage(e)).join(\"; \");\n }\n\n if (typeof error === \"object\" && \"message\" in error) {\n return String((error as any).message);\n }\n\n return stringifyUnknown(error);\n};\n\n/**\n * The deepest Error along the cause chain — the original throw site. Wrapper\n * errors (PluginRuntimeError, ModuleFederationError) carry their own stacks\n * (the wrapping frames); diagnosis needs the cause's stack (the actual\n * failing module inside the evaluated remote entry).\n */\nexport const deepestErrorStack = (error: unknown): string | undefined => {\n let current = error;\n let deepest: string | undefined;\n let hops = 0;\n while (current instanceof Error && hops < 8) {\n if (current.stack) deepest = current.stack;\n current = (current as { cause?: unknown }).cause as unknown;\n hops += 1;\n }\n if (current instanceof Error && current.stack) deepest = current.stack;\n return deepest;\n};\n\nconst formatValidationIssue = (issue: any, index: number, maxDisplay: number): string => {\n if (index >= maxDisplay) return \"\";\n\n const path =\n Array.isArray(issue.path) && issue.path.length > 0\n ? issue.path.join(\".\")\n : issue.path || \"root\";\n\n const message = issue.message || \"Validation failed\";\n\n return `│ ${index + 1}. ${path}: ${message}`;\n};\n\nconst formatDataPreview = (data: unknown, maxLength = 100): string => {\n if (!data) return \"undefined\";\n\n try {\n const str = JSON.stringify(data);\n if (str.length <= maxLength) return str;\n\n if (typeof data === \"object\" && data !== null) {\n if (Array.isArray(data)) {\n return `Array(${data.length}) [...]`;\n }\n const keys = Object.keys(data);\n return `{ ${keys.slice(0, 3).join(\", \")}${keys.length > 3 ? \", ...\" : \"\"} }`;\n }\n\n return `${str.slice(0, maxLength)}...`;\n } catch {\n return stringifyUnknown(data).slice(0, maxLength);\n }\n};\n\nconst formatORPCValidationError = (error: any): string[] | null => {\n const cause = error?.cause || error;\n\n if (!cause?.issues || !Array.isArray(cause.issues) || cause.issues.length === 0) {\n return null;\n }\n\n const lines: string[] = [];\n const errorType = error?.message || cause?.message || \"Validation failed\";\n\n lines.push(`\\n╭─ oRPC Validation Error ${\"─\".repeat(30)}`);\n lines.push(`│ ${errorType}`);\n lines.push(`│`);\n\n const maxDisplay = 10;\n const totalIssues = cause.issues.length;\n\n lines.push(`│ Issues (${totalIssues}):`);\n\n const displayedIssues = cause.issues.slice(0, maxDisplay);\n displayedIssues.forEach((issue: any, idx: number) => {\n const formatted = formatValidationIssue(issue, idx, maxDisplay);\n if (formatted) lines.push(formatted);\n });\n\n if (totalIssues > maxDisplay) {\n lines.push(`│ ... and ${totalIssues - maxDisplay} more`);\n }\n\n if (cause.data !== undefined) {\n lines.push(`│`);\n lines.push(`│ Data preview: ${formatDataPreview(cause.data, 80)}`);\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n\n return lines;\n};\n\nconst formatUnknownError = (error: any): string | null => {\n if (!error) return null;\n const message = extractErrorMessage(error);\n const lines: string[] = [];\n lines.push(`\\n╭─ Unhandled error ${\"─\".repeat(37)}`);\n for (const line of message.split(\"\\n\")) {\n lines.push(`│ ${line}`);\n }\n const stack = error instanceof Error ? error.stack?.split(\"\\n\").slice(1, 6) : undefined;\n if (stack && stack.length > 0) {\n lines.push(`│`);\n for (const line of stack) {\n lines.push(`│ ${line.trim()}`);\n }\n }\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nexport const formatORPCError = (error: any): string | null => {\n if (!(error instanceof ORPCError)) {\n // Unknown errors used to return null, leaving internal failures (e.g. a\n // storage backend throw) invisible in host logs while oRPC serialized\n // them client-side as a bare INTERNAL_SERVER_ERROR.\n return formatUnknownError(error);\n }\n\n const validationLines = formatORPCValidationError(error);\n if (validationLines) {\n return validationLines.join(\"\\n\");\n }\n\n const lines: string[] = [];\n const code = error.code || \"UNKNOWN\";\n const message = error.message || \"An error occurred\";\n\n lines.push(`\\n╭─ oRPC Error ${\"─\".repeat(40)}`);\n const messageLines = message.split(\"\\n\");\n for (const line of messageLines) {\n lines.push(`│ ${line}`);\n }\n lines.push(`│ Code: ${code}`);\n lines.push(`│`);\n\n if (error.data) {\n const dataType = typeof error.data;\n if (dataType === \"object\" && error.data !== null) {\n if (\"retryAfter\" in error.data) {\n lines.push(`│ Retry after: ${error.data.retryAfter} seconds`);\n }\n if (\"remainingRequests\" in error.data) {\n lines.push(`│ Remaining: ${error.data.remainingRequests} requests`);\n }\n if (\"host\" in error.data) {\n lines.push(`│ Host: ${error.data.host}`);\n }\n if (\"port\" in error.data) {\n lines.push(`│ Port: ${error.data.port}`);\n }\n if (\"suggestion\" in error.data) {\n lines.push(`│ → ${error.data.suggestion}`);\n }\n if (\"resource\" in error.data) {\n lines.push(`│ Resource: ${error.data.resource}`);\n }\n if (\"resourceId\" in error.data) {\n lines.push(`│ ID: ${error.data.resourceId}`);\n }\n }\n }\n\n switch (code) {\n case \"UNAUTHORIZED\":\n lines.push(`│ → Check your API key or credentials`);\n break;\n case \"TOO_MANY_REQUESTS\":\n lines.push(`│ → Wait before retrying`);\n break;\n case \"SERVICE_UNAVAILABLE\":\n case \"BAD_GATEWAY\":\n case \"GATEWAY_TIMEOUT\":\n lines.push(`│ → The service may be temporarily unavailable`);\n break;\n case \"TIMEOUT\":\n lines.push(`│ → The operation took too long`);\n break;\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nexport type PluginFailureKind =\n | \"mf\"\n | \"integrity\"\n | \"config\"\n | \"validation\"\n | \"network\"\n | \"unknown\";\n\nexport interface PluginFailureClassification {\n kind: PluginFailureKind;\n retryable: boolean;\n message: string;\n suggestion?: string;\n}\n\n/**\n * Structured report of one plugin-load failure, built by a loader (the host's\n * plugin boot, the dev server) from a `PluginFailureClassification` plus\n * loader context. This is the shape health endpoints and dashboards consume —\n * keep it serializable.\n */\nexport interface PluginLoadFailureInfo {\n /** loader-side key (host entry key, dev plugin id) */\n pluginKey: string;\n pluginUrl?: string;\n /** failing runtime stage when the cause is stage-attributed */\n operation?: string;\n kind: string;\n retryable: boolean;\n message: string;\n suggestion?: string;\n /** loader context: which env secret the plugin's DB binding expects */\n dbSecret?: string;\n dbUrlMasked?: string;\n}\n\nconst NETWORK_RETRYABLE_PATTERNS = [\"ETIMEDOUT\", \"ECONNRESET\", \"timeout\", \"503\", \"429\"] as const;\nconst NETWORK_DEAD_PATTERNS = [\"ECONNREFUSED\", \"ENOTFOUND\", \"EHOSTUNREACH\"] as const;\nconst RETRYABLE_ORPC_CODES = new Set([\n \"TOO_MANY_REQUESTS\",\n \"SERVICE_UNAVAILABLE\",\n \"BAD_GATEWAY\",\n \"GATEWAY_TIMEOUT\",\n \"TIMEOUT\",\n]);\n\n/**\n * One classification for plugin lifecycle failures across MF / validation /\n * network sources. This is the recovery policy — nothing in the runtime\n * retries on it today by design (the host degrades and runs without a failed\n * plugin); consumers (host bootstrap messages, the dev server retry loop)\n * read kind / retryable / suggestion to decide what to tell the author.\n */\nexport const classifyPluginFailure = (error: unknown): PluginFailureClassification => {\n let current: unknown = extractFromFiberFailure(error);\n let hops = 0;\n while (current && typeof current === \"object\" && hops < 8) {\n if (current instanceof ModuleFederationError) {\n return {\n kind: \"mf\",\n retryable: false,\n message: extractErrorMessage(current),\n suggestion:\n \"Run bos mf check — the deployed plugin bundle is likely stale (sharedDep / pluginVersion skew), then redeploy the plugin and bos publish --deploy --packages local\",\n };\n }\n if (current instanceof ValidationError) {\n return {\n kind: \"validation\",\n retryable: false,\n message: `${current.stage}: ${extractErrorMessage(current.zodError)}`,\n suggestion: `Fix the plugin's ${current.stage} schema at plugins/${current.pluginId}`,\n };\n }\n if (current instanceof ORPCError) {\n const retryableByCode = RETRYABLE_ORPC_CODES.has(current.code);\n return {\n kind: \"network\",\n retryable: retryableByCode,\n message: current.message,\n suggestion: retryableByCode\n ? \"The plugin procedure failed transiently — retry the call\"\n : undefined,\n };\n }\n current = (current as { cause?: unknown }).cause;\n hops += 1;\n }\n\n const message = extractErrorMessage(error);\n const lower = message.toLowerCase();\n\n if (NETWORK_RETRYABLE_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {\n return {\n kind: \"network\",\n retryable: true,\n message,\n suggestion: \"The remote may be temporarily unavailable — retry after redeploying the plugin\",\n };\n }\n if (NETWORK_DEAD_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {\n return {\n kind: \"network\",\n retryable: false,\n message,\n suggestion:\n \"The plugin host is unreachable — check plugins.<id> entry URLs in bos.config.json\",\n };\n }\n if (lower.includes(\"integrity\") || lower.includes(\"sri\")) {\n return {\n kind: \"integrity\",\n retryable: true,\n message,\n suggestion:\n \"The deployed bundle content does not match its recorded integrity — redeploy the plugin so bos.config.json is republished with a fresh hash\",\n };\n }\n\n return { kind: \"unknown\", retryable: false, message };\n};\n\n// Convert ORPC errors from plugin procedures to PluginRuntimeError\nexport const wrapORPCError = (\n orpcError: ORPCError<string, unknown>,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n cause: orpcError as Error,\n });\n};\n\n/**\n * Extracts the underlying error from Effect's FiberFailure wrapper.\n * When Effect.runPromise rejects, errors are wrapped in FiberFailure.\n * This extracts the original error so oRPC can handle it properly.\n */\nexport const extractFromFiberFailure = (error: unknown): unknown => {\n if (!error || typeof error !== \"object\") return error;\n\n if (\"cause\" in error) {\n const cause = (error as { cause?: unknown }).cause;\n\n if (cause && typeof cause === \"object\" && \"_tag\" in cause) {\n try {\n const squashed = Cause.squash(cause as unknown as Cause.Cause<unknown>);\n if (squashed instanceof ORPCError) {\n return squashed;\n }\n return squashed;\n } catch {\n // Not a valid Cause\n }\n }\n\n if (cause instanceof ORPCError) {\n return cause;\n }\n }\n\n return error;\n};\n\n// Universal error converter for the runtime\nexport const toPluginRuntimeError = (\n error: unknown,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n if (error instanceof ORPCError) {\n return wrapORPCError(error, pluginId, procedureName, operation);\n }\n\n if (error instanceof PluginRuntimeError) {\n return error;\n }\n\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n cause: error instanceof Error ? error : new Error(extractErrorMessage(error)),\n });\n};\n"],"mappings":";;;;AAIA,IAAa,qBAAb,cAAwCA,YAAK,YAAY,oBAAoB,CAAC,CAK3E;CACD,IAAa,UAAU;EACrB,OAAO,KAAK,OAAO,WAAW;CAChC;AACF;AAEA,IAAa,wBAAb,cAA2CA,YAAK,YAAY,uBAAuB,CAAC,CAIjF,CAAC;AAEJ,IAAa,kBAAb,cAAqCA,YAAK,YAAY,iBAAiB,CAAC,CAIrE,CAAC;AAEJ,MAAM,oBAAoB,UAA2B;CACnD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,QAAW,OAAO;CAChC,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,OAAO,GAAG;CAEZ,IAAI,OAAO,UAAU,UAAU,OAAO,MAAM,eAAe;CAC3D,IAAI;EACF,OAAO,KAAK,UAAU,KAAK,KAAK;CAClC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,uBAAuB,UAA2B;CACtD,IAAI,CAAC,OAAO,OAAO;CAEnB,IAAI,iBAAiB,OAAO;EAC1B,IAAI,MAAM,SAAS,OAAO,MAAM;EAChC,IAAK,MAAc,iBAAiB,OAClC,OAAO,oBAAqB,MAAc,KAAK;CAEnD;CAEA,IAAI,iBAAiB,kBAAkB,MAAM,QAAQ,QACnD,OAAO,MAAM,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W;EACX;EACA,YAAY;CACd;CAEF,IAAI,sBAAsB,MAAM,MAAM,MAAM,SAAS,EAAE,YAAY,CAAC,CAAC,GACnE,OAAO;EACL,MAAM;EACN,WAAW;EACX;EACA,YACE;CACJ;CAEF,IAAI,MAAM,SAAS,WAAW,KAAK,MAAM,SAAS,KAAK,GACrD,OAAO;EACL,MAAM;EACN,WAAW;EACX;EACA,YACE;CACJ;CAGF,OAAO;EAAE,MAAM;EAAW,WAAW;EAAO;CAAQ;AACtD;AAGA,MAAa,iBACX,WACA,UACA,eACA,cACuB;CACvB,OAAO,IAAI,mBAAmB;EAC5B;EACA;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;;;AAOA,MAAa,2BAA2B,UAA4B;CAClE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAEhD,IAAI,WAAW,OAAO;EACpB,MAAM,QAAS,MAA8B;EAE7C,IAAI,SAAS,OAAO,UAAU,YAAY,UAAU,OAClD,IAAI;GACF,MAAM,WAAWC,aAAM,OAAO,KAAwC;GACtE,IAAI,oBAAoBD,wBACtB,OAAO;GAET,OAAO;EACT,QAAQ,CAER;EAGF,IAAI,iBAAiBA,wBACnB,OAAO;CAEX;CAEA,OAAO;AACT;AAGA,MAAa,wBACX,OACA,UACA,eACA,cACuB;CACvB,IAAI,iBAAiBA,wBACnB,OAAO,cAAc,OAAO,UAAU,eAAe,SAAS;CAGhE,IAAI,iBAAiB,oBACnB,OAAO;CAGT,OAAO,IAAI,mBAAmB;EAC5B;EACA;EACA;EACA,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,oBAAoB,KAAK,CAAC;CAC9E,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":["Data","ORPCError","Cause"],"sources":["../../src/runtime/errors.ts"],"sourcesContent":["import { ORPCError } from \"@orpc/server\";\nimport { Cause, Data } from \"effect\";\nimport type { z } from \"zod\";\n\nexport class PluginRuntimeError extends Data.TaggedError(\"PluginRuntimeError\")<{\n readonly pluginId?: string;\n readonly operation?: string;\n readonly procedureName?: string;\n readonly cause?: Error;\n}> {\n override get message() {\n return this.cause?.message ?? \"Plugin operation failed\";\n }\n}\n\nexport class ModuleFederationError extends Data.TaggedError(\"ModuleFederationError\")<{\n readonly pluginId: string;\n readonly remoteUrl: string;\n readonly cause?: Error;\n}> {}\n\nexport class ValidationError extends Data.TaggedError(\"ValidationError\")<{\n readonly pluginId: string;\n readonly stage: \"config\" | \"input\" | \"output\" | \"state\";\n readonly zodError: z.ZodError;\n}> {}\n\nconst stringifyUnknown = (value: unknown): string => {\n if (value === null) return \"null\";\n if (value === undefined) return \"undefined\";\n if (value instanceof Error) return value.message;\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\") {\n return `${value}`;\n }\n if (typeof value === \"symbol\") return value.description ?? \"\";\n try {\n return JSON.stringify(value) ?? \"[Unserializable value]\";\n } catch {\n return \"[Unserializable value]\";\n }\n};\n\nconst extractErrorMessage = (error: unknown): string => {\n if (!error) return \"Unknown error\";\n\n if (error instanceof Error) {\n if (error.message) return error.message;\n if ((error as any).cause instanceof Error) {\n return extractErrorMessage((error as any).cause);\n }\n }\n\n if (error instanceof AggregateError && error.errors?.length) {\n return error.errors.map((e) => extractErrorMessage(e)).join(\"; \");\n }\n\n if (typeof error === \"object\" && \"message\" in error) {\n return String((error as any).message);\n }\n\n return stringifyUnknown(error);\n};\n\n/**\n * The deepest Error along the cause chain — the original throw site. Wrapper\n * errors (PluginRuntimeError, ModuleFederationError) carry their own stacks\n * (the wrapping frames); diagnosis needs the cause's stack (the actual\n * failing module inside the evaluated remote entry).\n */\nexport const deepestErrorStack = (error: unknown): string | undefined => {\n let current = error;\n let deepest: string | undefined;\n let hops = 0;\n while (current instanceof Error && hops < 8) {\n if (current.stack) deepest = current.stack;\n current = (current as { cause?: unknown }).cause as unknown;\n hops += 1;\n }\n if (current instanceof Error && current.stack) deepest = current.stack;\n return deepest;\n};\n\nconst formatValidationIssue = (issue: any, index: number, maxDisplay: number): string => {\n if (index >= maxDisplay) return \"\";\n\n const path =\n Array.isArray(issue.path) && issue.path.length > 0\n ? issue.path.join(\".\")\n : issue.path || \"root\";\n\n const message = issue.message || \"Validation failed\";\n\n return `│ ${index + 1}. ${path}: ${message}`;\n};\n\nconst formatDataPreview = (data: unknown, maxLength = 100): string => {\n if (!data) return \"undefined\";\n\n try {\n const str = JSON.stringify(data);\n if (str.length <= maxLength) return str;\n\n if (typeof data === \"object\" && data !== null) {\n if (Array.isArray(data)) {\n return `Array(${data.length}) [...]`;\n }\n const keys = Object.keys(data);\n return `{ ${keys.slice(0, 3).join(\", \")}${keys.length > 3 ? \", ...\" : \"\"} }`;\n }\n\n return `${str.slice(0, maxLength)}...`;\n } catch {\n return stringifyUnknown(data).slice(0, maxLength);\n }\n};\n\nconst formatORPCValidationError = (error: any): string[] | null => {\n const cause = error?.cause || error;\n\n if (!cause?.issues || !Array.isArray(cause.issues) || cause.issues.length === 0) {\n return null;\n }\n\n const lines: string[] = [];\n const errorType = error?.message || cause?.message || \"Validation failed\";\n\n lines.push(`\\n╭─ oRPC Validation Error ${\"─\".repeat(30)}`);\n lines.push(`│ ${errorType}`);\n lines.push(`│`);\n\n const maxDisplay = 10;\n const totalIssues = cause.issues.length;\n\n lines.push(`│ Issues (${totalIssues}):`);\n\n const displayedIssues = cause.issues.slice(0, maxDisplay);\n displayedIssues.forEach((issue: any, idx: number) => {\n const formatted = formatValidationIssue(issue, idx, maxDisplay);\n if (formatted) lines.push(formatted);\n });\n\n if (totalIssues > maxDisplay) {\n lines.push(`│ ... and ${totalIssues - maxDisplay} more`);\n }\n\n if (cause.data !== undefined) {\n lines.push(`│`);\n lines.push(`│ Data preview: ${formatDataPreview(cause.data, 80)}`);\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n\n return lines;\n};\n\nconst formatUnknownError = (error: any): string | null => {\n if (!error) return null;\n const message = extractErrorMessage(error);\n const lines: string[] = [];\n lines.push(`\\n╭─ Unhandled error ${\"─\".repeat(37)}`);\n for (const line of message.split(\"\\n\")) {\n lines.push(`│ ${line}`);\n }\n const stack = error instanceof Error ? error.stack?.split(\"\\n\").slice(1, 6) : undefined;\n if (stack && stack.length > 0) {\n lines.push(`│`);\n for (const line of stack) {\n lines.push(`│ ${line.trim()}`);\n }\n }\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nexport const formatORPCError = (error: any): string | null => {\n if (!(error instanceof ORPCError)) {\n // Unknown errors used to return null, leaving internal failures (e.g. a\n // storage backend throw) invisible in host logs while oRPC serialized\n // them client-side as a bare INTERNAL_SERVER_ERROR.\n return formatUnknownError(error);\n }\n\n const validationLines = formatORPCValidationError(error);\n if (validationLines) {\n return validationLines.join(\"\\n\");\n }\n\n const lines: string[] = [];\n const code = error.code || \"UNKNOWN\";\n const message = error.message || \"An error occurred\";\n\n lines.push(`\\n╭─ oRPC Error ${\"─\".repeat(40)}`);\n const messageLines = message.split(\"\\n\");\n for (const line of messageLines) {\n lines.push(`│ ${line}`);\n }\n lines.push(`│ Code: ${code}`);\n lines.push(`│`);\n\n if (error.data) {\n const dataType = typeof error.data;\n if (dataType === \"object\" && error.data !== null) {\n if (\"retryAfter\" in error.data) {\n lines.push(`│ Retry after: ${error.data.retryAfter} seconds`);\n }\n if (\"remainingRequests\" in error.data) {\n lines.push(`│ Remaining: ${error.data.remainingRequests} requests`);\n }\n if (\"host\" in error.data) {\n lines.push(`│ Host: ${error.data.host}`);\n }\n if (\"port\" in error.data) {\n lines.push(`│ Port: ${error.data.port}`);\n }\n if (\"suggestion\" in error.data) {\n lines.push(`│ → ${error.data.suggestion}`);\n }\n if (\"resource\" in error.data) {\n lines.push(`│ Resource: ${error.data.resource}`);\n }\n if (\"resourceId\" in error.data) {\n lines.push(`│ ID: ${error.data.resourceId}`);\n }\n }\n }\n\n switch (code) {\n case \"UNAUTHORIZED\":\n lines.push(`│ → Check your API key or credentials`);\n break;\n case \"TOO_MANY_REQUESTS\":\n lines.push(`│ → Wait before retrying`);\n break;\n case \"SERVICE_UNAVAILABLE\":\n case \"BAD_GATEWAY\":\n case \"GATEWAY_TIMEOUT\":\n lines.push(`│ → The service may be temporarily unavailable`);\n break;\n case \"TIMEOUT\":\n lines.push(`│ → The operation took too long`);\n break;\n }\n\n lines.push(`╰${\"─\".repeat(50)}\\n`);\n return lines.join(\"\\n\");\n};\n\nexport type PluginFailureKind =\n | \"mf\"\n | \"integrity\"\n | \"config\"\n | \"validation\"\n | \"network\"\n | \"unknown\";\n\nexport interface PluginFailureClassification {\n kind: PluginFailureKind;\n retryable: boolean;\n message: string;\n suggestion?: string;\n}\n\n/**\n * Structured report of one plugin-load failure, built by a loader (the host's\n * plugin boot, the dev server) from a `PluginFailureClassification` plus\n * loader context. This is the shape health endpoints and dashboards consume —\n * keep it serializable.\n */\nexport interface PluginLoadFailureInfo {\n /** loader-side key (host entry key, dev plugin id) */\n pluginKey: string;\n pluginUrl?: string;\n /** failing runtime stage when the cause is stage-attributed */\n operation?: string;\n kind: string;\n retryable: boolean;\n message: string;\n suggestion?: string;\n /** loader context: which env secret the plugin's DB binding expects */\n dbSecret?: string;\n dbUrlMasked?: string;\n}\n\n/**\n * Structured, serializable warning surfaced alongside plugin failures in\n * health endpoints and dashboards. Warnings are non-fatal: the plugin loaded\n * and initialized successfully, but runs with reduced functionality (e.g. an\n * optional secret was not set, so the feature depending on it is disabled).\n */\nexport interface PluginWarningInfo {\n /** loader-side key (host entry key, dev plugin id) */\n pluginKey: string;\n message: string;\n hint?: string;\n}\n\n/**\n * The loader's default warning policy for declared-but-unset secrets: a\n * successfully initialized plugin whose declared secret names resolved to\n * nothing (missing or empty in the environment) gets one consolidated\n * warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB\n * fallback, and a genuinely-missing DB URL fails initialization (a `failure`,\n * not a warning). A plugin that declares its own `warnings` function opts out\n * of this default.\n */\nexport const defaultMissingSecretWarnings = (\n pluginKey: string,\n declaredKeys: readonly string[],\n resolvedKeys: readonly string[],\n): PluginWarningInfo[] => {\n const resolved = new Set(resolvedKeys);\n const missing = declaredKeys.filter(\n (key) => !resolved.has(key) && !key.endsWith(\"_DATABASE_URL\"),\n );\n if (missing.length === 0) return [];\n return [\n {\n pluginKey,\n message:\n missing.length === 1\n ? `Declared secret ${missing[0]} is not set — features depending on it are disabled`\n : `${missing.length} declared secrets are not set: ${missing.join(\", \")} — features depending on them are disabled`,\n hint: \"Set the secret(s) in your environment (.env in development); see the plugin's config schema for what each enables\",\n },\n ];\n};\n\nconst NETWORK_RETRYABLE_PATTERNS = [\"ETIMEDOUT\", \"ECONNRESET\", \"timeout\", \"503\", \"429\"] as const;\nconst NETWORK_DEAD_PATTERNS = [\"ECONNREFUSED\", \"ENOTFOUND\", \"EHOSTUNREACH\"] as const;\nconst RETRYABLE_ORPC_CODES = new Set([\n \"TOO_MANY_REQUESTS\",\n \"SERVICE_UNAVAILABLE\",\n \"BAD_GATEWAY\",\n \"GATEWAY_TIMEOUT\",\n \"TIMEOUT\",\n]);\n\n/**\n * One classification for plugin lifecycle failures across MF / validation /\n * network sources. This is the recovery policy — nothing in the runtime\n * retries on it today by design (the host degrades and runs without a failed\n * plugin); consumers (host bootstrap messages, the dev server retry loop)\n * read kind / retryable / suggestion to decide what to tell the author.\n */\nexport const classifyPluginFailure = (error: unknown): PluginFailureClassification => {\n let current: unknown = extractFromFiberFailure(error);\n let hops = 0;\n while (current && typeof current === \"object\" && hops < 8) {\n if (current instanceof ModuleFederationError) {\n return {\n kind: \"mf\",\n retryable: false,\n message: extractErrorMessage(current),\n suggestion:\n \"Run bos mf check — the deployed plugin bundle is likely stale (sharedDep / pluginVersion skew), then redeploy the plugin and bos publish --deploy --packages local\",\n };\n }\n if (current instanceof ValidationError) {\n return {\n kind: \"validation\",\n retryable: false,\n message: `${current.stage}: ${extractErrorMessage(current.zodError)}`,\n suggestion: `Fix the plugin's ${current.stage} schema at plugins/${current.pluginId}`,\n };\n }\n if (current instanceof ORPCError) {\n const retryableByCode = RETRYABLE_ORPC_CODES.has(current.code);\n return {\n kind: \"network\",\n retryable: retryableByCode,\n message: current.message,\n suggestion: retryableByCode\n ? \"The plugin procedure failed transiently — retry the call\"\n : undefined,\n };\n }\n current = (current as { cause?: unknown }).cause;\n hops += 1;\n }\n\n const message = extractErrorMessage(error);\n const lower = message.toLowerCase();\n\n if (NETWORK_RETRYABLE_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {\n return {\n kind: \"network\",\n retryable: true,\n message,\n suggestion: \"The remote may be temporarily unavailable — retry after redeploying the plugin\",\n };\n }\n if (NETWORK_DEAD_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {\n return {\n kind: \"network\",\n retryable: false,\n message,\n suggestion:\n \"The plugin host is unreachable — check plugins.<id> entry URLs in bos.config.json\",\n };\n }\n if (lower.includes(\"integrity\") || lower.includes(\"sri\")) {\n return {\n kind: \"integrity\",\n retryable: true,\n message,\n suggestion:\n \"The deployed bundle content does not match its recorded integrity — redeploy the plugin so bos.config.json is republished with a fresh hash\",\n };\n }\n\n return { kind: \"unknown\", retryable: false, message };\n};\n\n// Convert ORPC errors from plugin procedures to PluginRuntimeError\nexport const wrapORPCError = (\n orpcError: ORPCError<string, unknown>,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n cause: orpcError as Error,\n });\n};\n\n/**\n * Extracts the underlying error from Effect's FiberFailure wrapper.\n * When Effect.runPromise rejects, errors are wrapped in FiberFailure.\n * This extracts the original error so oRPC can handle it properly.\n */\nexport const extractFromFiberFailure = (error: unknown): unknown => {\n if (!error || typeof error !== \"object\") return error;\n\n if (\"cause\" in error) {\n const cause = (error as { cause?: unknown }).cause;\n\n if (cause && typeof cause === \"object\" && \"_tag\" in cause) {\n try {\n const squashed = Cause.squash(cause as unknown as Cause.Cause<unknown>);\n if (squashed instanceof ORPCError) {\n return squashed;\n }\n return squashed;\n } catch {\n // Not a valid Cause\n }\n }\n\n if (cause instanceof ORPCError) {\n return cause;\n }\n }\n\n return error;\n};\n\n// Universal error converter for the runtime\nexport const toPluginRuntimeError = (\n error: unknown,\n pluginId?: string,\n procedureName?: string,\n operation?: string,\n): PluginRuntimeError => {\n if (error instanceof ORPCError) {\n return wrapORPCError(error, pluginId, procedureName, operation);\n }\n\n if (error instanceof PluginRuntimeError) {\n return error;\n }\n\n return new PluginRuntimeError({\n pluginId,\n operation,\n procedureName,\n cause: error instanceof Error ? error : new Error(extractErrorMessage(error)),\n });\n};\n"],"mappings":";;;;AAIA,IAAa,qBAAb,cAAwCA,YAAK,YAAY,oBAAoB,CAAC,CAK3E;CACD,IAAa,UAAU;EACrB,OAAO,KAAK,OAAO,WAAW;CAChC;AACF;AAEA,IAAa,wBAAb,cAA2CA,YAAK,YAAY,uBAAuB,CAAC,CAIjF,CAAC;AAEJ,IAAa,kBAAb,cAAqCA,YAAK,YAAY,iBAAiB,CAAC,CAIrE,CAAC;AAEJ,MAAM,oBAAoB,UAA2B;CACnD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,QAAW,OAAO;CAChC,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,OAAO,GAAG;CAEZ,IAAI,OAAO,UAAU,UAAU,OAAO,MAAM,eAAe;CAC3D,IAAI;EACF,OAAO,KAAK,UAAU,KAAK,KAAK;CAClC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,uBAAuB,UAA2B;CACtD,IAAI,CAAC,OAAO,OAAO;CAEnB,IAAI,iBAAiB,OAAO;EAC1B,IAAI,MAAM,SAAS,OAAO,MAAM;EAChC,IAAK,MAAc,iBAAiB,OAClC,OAAO,oBAAqB,MAAc,KAAK;CAEnD;CAEA,IAAI,iBAAiB,kBAAkB,M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iBA,wBACnB,OAAO,cAAc,OAAO,UAAU,eAAe,SAAS;CAGhE,IAAI,iBAAiB,oBACnB,OAAO;CAGT,OAAO,IAAI,mBAAmB;EAC5B;EACA;EACA;EACA,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,oBAAoB,KAAK,CAAC;CAC9E,CAAC;AACH"}
|
|
@@ -57,6 +57,28 @@ interface PluginLoadFailureInfo {
|
|
|
57
57
|
dbSecret?: string;
|
|
58
58
|
dbUrlMasked?: string;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Structured, serializable warning surfaced alongside plugin failures in
|
|
62
|
+
* health endpoints and dashboards. Warnings are non-fatal: the plugin loaded
|
|
63
|
+
* and initialized successfully, but runs with reduced functionality (e.g. an
|
|
64
|
+
* optional secret was not set, so the feature depending on it is disabled).
|
|
65
|
+
*/
|
|
66
|
+
interface PluginWarningInfo {
|
|
67
|
+
/** loader-side key (host entry key, dev plugin id) */
|
|
68
|
+
pluginKey: string;
|
|
69
|
+
message: string;
|
|
70
|
+
hint?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The loader's default warning policy for declared-but-unset secrets: a
|
|
74
|
+
* successfully initialized plugin whose declared secret names resolved to
|
|
75
|
+
* nothing (missing or empty in the environment) gets one consolidated
|
|
76
|
+
* warning. `*_DATABASE_URL` keys are excluded — they have the shared-API-DB
|
|
77
|
+
* fallback, and a genuinely-missing DB URL fails initialization (a `failure`,
|
|
78
|
+
* not a warning). A plugin that declares its own `warnings` function opts out
|
|
79
|
+
* of this default.
|
|
80
|
+
*/
|
|
81
|
+
declare const defaultMissingSecretWarnings: (pluginKey: string, declaredKeys: readonly string[], resolvedKeys: readonly string[]) => PluginWarningInfo[];
|
|
60
82
|
/**
|
|
61
83
|
* One classification for plugin lifecycle failures across MF / validation /
|
|
62
84
|
* network sources. This is the recovery policy — nothing in the runtime
|
|
@@ -74,5 +96,5 @@ declare const wrapORPCError: (orpcError: ORPCError<string, unknown>, pluginId?:
|
|
|
74
96
|
declare const extractFromFiberFailure: (error: unknown) => unknown;
|
|
75
97
|
declare const toPluginRuntimeError: (error: unknown, pluginId?: string, procedureName?: string, operation?: string) => PluginRuntimeError;
|
|
76
98
|
//#endregion
|
|
77
|
-
export { ModuleFederationError, PluginFailureClassification, PluginFailureKind, PluginLoadFailureInfo, PluginRuntimeError, ValidationError, classifyPluginFailure, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
99
|
+
export { ModuleFederationError, PluginFailureClassification, PluginFailureKind, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
78
100
|
//# sourceMappingURL=errors.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/runtime/errors.ts"],"mappings":";;;;;;;cAIa,2BAA2B;WAC7B;WACA;WACA;WACA,QAAQ;;MAEJ;;;;;cAKF,8BAA8B;WAChC;WACA;WACA,QAAQ;;;;;cAGN,wBAAwB;WAC1B;WACA;WACA,UAAU,EAAE;;cAuJV,kBAAe;KAyEhB;UAQK;EACf,MAAM;EACN;EACA;EACA;;;;;;;;UASe;;EAEf;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/runtime/errors.ts"],"mappings":";;;;;;;cAIa,2BAA2B;WAC7B;WACA;WACA;WACA,QAAQ;;MAEJ;;;;;cAKF,8BAA8B;WAChC;WACA;WACA,QAAQ;;;;;cAGN,wBAAwB;WAC1B;WACA;WACA,UAAU,EAAE;;cAuJV,kBAAe;KAyEhB;UAQK;EACf,MAAM;EACN;EACA;EACA;;;;;;;;UASe;;EAEf;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;;;;;;;;UASe;;EAEf;EACA;EACA;;;;;;;;;;;cAYW,+BAA4B,mBACtB,iCACc,oCAE9B;;;;;;;;cAmCU,wBAAqB,mBAAqB;cAsE1C,gBAAa,WACb,4BAA0B,mBACpB,wBACK,uBAErB;;;;;;cAcU,0BAAuB;cA2BvB,uBAAoB,gBACjB,mBACG,wBACK,uBAErB"}
|