every-plugin 3.0.0-rc.14 → 3.0.0-rc.16
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/build/artifact-names.cjs +9 -6
- package/dist/build/artifact-names.cjs.map +1 -1
- package/dist/build/artifact-names.d.cts +7 -5
- package/dist/build/artifact-names.d.cts.map +1 -1
- package/dist/build/artifact-names.d.mts +7 -5
- package/dist/build/artifact-names.d.mts.map +1 -1
- package/dist/build/artifact-names.mjs +8 -5
- package/dist/build/artifact-names.mjs.map +1 -1
- package/dist/build/contract-types.cjs +1 -1
- package/dist/build/rspack/build-report-plugin.cjs +1 -1
- package/dist/build/rspack/chunk-completeness-plugin.cjs +1 -1
- package/dist/build/rspack/compose.cjs +3 -3
- package/dist/build/rspack/generated-config.cjs +2 -2
- package/dist/build/rspack/index.cjs +5 -5
- package/dist/build/rspack/module-federation.cjs +1 -1
- package/dist/build/rspack/plugin.cjs +8 -8
- package/dist/build/rspack/utils.cjs +2 -2
- package/dist/build/ui/factory.cjs +3 -3
- package/dist/build/ui/generated-config.cjs +2 -2
- package/dist/build/ui/hash-artifacts-plugin.cjs +2 -2
- package/dist/build/ui/index.cjs +9 -9
- package/dist/build/ui/manifest-plugin.cjs +1 -1
- package/dist/build/ui/rsbuild-config.cjs +10 -10
- package/dist/build/ui/stubs.cjs +2 -7
- package/dist/build/ui/stubs.cjs.map +1 -1
- package/dist/build/ui/stubs.d.cts.map +1 -1
- package/dist/build/ui/stubs.d.mts.map +1 -1
- package/dist/build/ui/stubs.mjs +2 -7
- package/dist/build/ui/stubs.mjs.map +1 -1
- package/dist/cli.cjs +3 -3
- package/dist/client.cjs +8 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +8 -4
- package/dist/client.mjs.map +1 -1
- package/dist/dev/serve.cjs +9 -9
- package/dist/errors.cjs +12 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +15 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +15 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +11 -2
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plugin.cjs +1 -1
- package/dist/remote-entry.cjs +1 -1
- package/dist/runtime/index.cjs +3 -3
- package/dist/runtime/mf-config.cjs +2 -2
- package/dist/runtime/mf-config.mjs +1 -1
- package/dist/runtime/services/module-federation.service.cjs +5 -5
- package/dist/runtime/services/normalize.cjs +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +5 -5
- package/dist/runtime/services/plugin.service.cjs +4 -4
- package/dist/runtime/services/secrets.service.cjs +2 -2
- package/dist/runtime/services/shared-identity.cjs +1 -1
- package/dist/runtime/validation.cjs +1 -1
- package/dist/ui/manifest/construct.cjs +18 -43
- package/dist/ui/manifest/construct.cjs.map +1 -1
- package/dist/ui/manifest/construct.d.cts +4 -13
- package/dist/ui/manifest/construct.d.cts.map +1 -1
- package/dist/ui/manifest/construct.d.mts +4 -13
- package/dist/ui/manifest/construct.d.mts.map +1 -1
- package/dist/ui/manifest/construct.mjs +14 -39
- package/dist/ui/manifest/construct.mjs.map +1 -1
- package/dist/ui/manifest/contract.cjs +1 -1
- package/dist/ui/manifest/descriptor.cjs +2 -2
- package/dist/ui/manifest/descriptor.mjs +1 -1
- package/dist/ui/manifest/generator.cjs +6 -6
- package/dist/ui/manifest/index.cjs +7 -7
- package/dist/ui/manifest/index.d.cts +3 -3
- package/dist/ui/manifest/index.d.mts +3 -3
- package/dist/ui/manifest/manifest-schema.cjs +1 -1
- package/dist/ui/manifest/mount-registry.cjs +6 -13
- package/dist/ui/manifest/mount-registry.cjs.map +1 -1
- package/dist/ui/manifest/mount-registry.d.cts +29 -36
- package/dist/ui/manifest/mount-registry.d.cts.map +1 -1
- package/dist/ui/manifest/mount-registry.d.mts +29 -36
- package/dist/ui/manifest/mount-registry.d.mts.map +1 -1
- package/dist/ui/manifest/mount-registry.mjs +6 -13
- package/dist/ui/manifest/mount-registry.mjs.map +1 -1
- package/dist/version-manifest.cjs +25 -0
- package/dist/version-manifest.cjs.map +1 -1
- package/dist/version-manifest.d.cts +13 -1
- package/dist/version-manifest.d.cts.map +1 -1
- package/dist/version-manifest.d.mts +13 -1
- package/dist/version-manifest.d.mts.map +1 -1
- package/dist/version-manifest.mjs +24 -1
- package/dist/version-manifest.mjs.map +1 -1
- package/package.json +28 -28
- package/skills/plugin-client/SKILL.md +2 -2
- package/src/build/artifact-names.ts +8 -5
- package/src/build/ui/stubs.ts +2 -7
- package/src/client.ts +9 -3
- package/src/errors.ts +10 -0
- package/src/ui/manifest/construct.ts +20 -65
- package/src/ui/manifest/index.ts +0 -2
- package/src/ui/manifest/mount-registry.ts +20 -20
- package/src/version-manifest.ts +27 -0
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { createORPCClient, onError } from \"@orpc/client\";\nimport { RPCLink } from \"@orpc/client/fetch\";\nimport type { ContractRouterClient, RouterContract } from \"@orpc/contract\";\n\nexport type RpcConnectionErrorCopy = () => { title: string; description: string };\n\nexport interface RpcClientConfig {\n hostUrl: string;\n path: `/${string}`;\n connectionError?: RpcConnectionErrorCopy;\n}\n\nconst RATE_LIMIT_MAX_RETRIES = 3;\nconst RATE_LIMIT_RETRY_CAP_MS = 2_000;\nconst browserClients = new Map<string, unknown>();\ntype FetchInput = Parameters<typeof fetch>[0];\n\nasync function fetchWithRateLimitRetry(\n fetchUrl: FetchInput,\n options?: RequestInit,\n): Promise<Response> {\n let response = await fetch(fetchUrl, options);\n for (let attempt = 1; attempt <= RATE_LIMIT_MAX_RETRIES && response.status === 429; attempt++) {\n const retryAfterSeconds = Number(response.headers.get(\"retry-after\"));\n const delay =\n Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0\n ? Math.min(retryAfterSeconds * 1000, RATE_LIMIT_RETRY_CAP_MS)\n : 100 * attempt;\n await new Promise((resolve) => setTimeout(resolve, delay));\n response = await fetch(fetchUrl, options);\n }\n\n return response;\n}\n\nfunction createRpcLink(config: RpcClientConfig, headers?: Headers) {\n return new RPCLink({\n origin: config.hostUrl,\n url: config.path,\n interceptors: [\n onError((error: unknown) => {\n const browserWindow = (globalThis as { window?: unknown }).window;\n if (typeof browserWindow === \"undefined\") {\n return;\n }\n\n if (error && typeof error === \"object\" && \"message\" in error) {\n const message = String(error.message).toLowerCase();\n if (\n message.includes(\"fetch\") ||\n message.includes(\"network\") ||\n message.includes(\"failed to fetch\")\n ) {\n void import(\"sonner\")\n .then(({ toast }) => {\n const message = config.connectionError?.() ?? {\n title: \"Unable to connect to API\",\n description: \"The API is currently unavailable. Please try again later.\",\n };\n toast.error(message.title, {\n id: \"api-connection-error\",\n description: message.description,\n });\n })\n .catch(() => {});\n }\n }\n }),\n ],\n fetch(fetchUrl: FetchInput, options?: RequestInit) {\n return fetchWithRateLimitRetry(fetchUrl, {\n ...options,\n credentials: \"include\",\n headers: headers
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { createORPCClient, onError } from \"@orpc/client\";\nimport { RPCLink } from \"@orpc/client/fetch\";\nimport type { ContractRouterClient, RouterContract } from \"@orpc/contract\";\n\nexport type RpcConnectionErrorCopy = () => { title: string; description: string };\n\nexport interface RpcClientConfig {\n hostUrl: string;\n path: `/${string}`;\n connectionError?: RpcConnectionErrorCopy;\n}\n\nconst RATE_LIMIT_MAX_RETRIES = 3;\nconst RATE_LIMIT_RETRY_CAP_MS = 2_000;\nconst browserClients = new Map<string, unknown>();\ntype FetchInput = Parameters<typeof fetch>[0];\n\nasync function fetchWithRateLimitRetry(\n fetchUrl: FetchInput,\n options?: RequestInit,\n): Promise<Response> {\n let response = await fetch(fetchUrl, options);\n for (let attempt = 1; attempt <= RATE_LIMIT_MAX_RETRIES && response.status === 429; attempt++) {\n const retryAfterSeconds = Number(response.headers.get(\"retry-after\"));\n const delay =\n Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0\n ? Math.min(retryAfterSeconds * 1000, RATE_LIMIT_RETRY_CAP_MS)\n : 100 * attempt;\n await new Promise((resolve) => setTimeout(resolve, delay));\n response = await fetch(fetchUrl, options);\n }\n\n return response;\n}\n\nfunction mergeHeaders(base: Headers, overrides?: RequestInit[\"headers\"]): Headers {\n const merged = new Headers(base);\n new Headers(overrides).forEach((value, key) => {\n merged.set(key, value);\n });\n return merged;\n}\n\nfunction createRpcLink(config: RpcClientConfig, headers?: Headers) {\n return new RPCLink({\n origin: config.hostUrl,\n url: config.path,\n interceptors: [\n onError((error: unknown) => {\n const browserWindow = (globalThis as { window?: unknown }).window;\n if (typeof browserWindow === \"undefined\") {\n return;\n }\n\n if (error && typeof error === \"object\" && \"message\" in error) {\n const message = String(error.message).toLowerCase();\n if (\n message.includes(\"fetch\") ||\n message.includes(\"network\") ||\n message.includes(\"failed to fetch\")\n ) {\n void import(\"sonner\")\n .then(({ toast }) => {\n const message = config.connectionError?.() ?? {\n title: \"Unable to connect to API\",\n description: \"The API is currently unavailable. Please try again later.\",\n };\n toast.error(message.title, {\n id: \"api-connection-error\",\n description: message.description,\n });\n })\n .catch(() => {});\n }\n }\n }),\n ],\n fetch(fetchUrl: FetchInput, options?: RequestInit) {\n return fetchWithRateLimitRetry(fetchUrl, {\n ...options,\n credentials: \"include\",\n headers: headers ? mergeHeaders(headers, options?.headers) : options?.headers,\n });\n },\n });\n}\n\nfunction buildRpcClient<T extends RouterContract>(\n config: RpcClientConfig,\n headers?: Headers,\n): ContractRouterClient<T> {\n if (!config.hostUrl) {\n throw new Error(\"Missing runtime host URL\");\n }\n\n return createORPCClient(createRpcLink(config, headers)) as ContractRouterClient<T>;\n}\n\nexport function createRpcClient<T extends RouterContract = RouterContract>(\n config: RpcClientConfig,\n headers?: Headers,\n): ContractRouterClient<T> {\n const browserWindow = (globalThis as { window?: unknown }).window;\n if (typeof browserWindow !== \"undefined\" && !headers) {\n const key = `${config.hostUrl}${config.path}`;\n const memoized = browserClients.get(key);\n if (memoized) {\n return memoized as ContractRouterClient<T>;\n }\n\n const client = buildRpcClient<T>(config, headers);\n browserClients.set(key, client);\n return client;\n }\n\n return buildRpcClient<T>(config, headers);\n}\n"],"mappings":";;;;AAYA,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,iCAAiB,IAAI,IAAqB;AAGhD,eAAe,wBACb,UACA,SACmB;CACnB,IAAI,WAAW,MAAM,MAAM,UAAU,OAAO;CAC5C,KAAK,IAAI,UAAU,GAAG,WAAW,0BAA0B,SAAS,WAAW,KAAK,WAAW;EAC7F,MAAM,oBAAoB,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;EACpE,MAAM,QACJ,OAAO,SAAS,iBAAiB,KAAK,oBAAoB,IACtD,KAAK,IAAI,oBAAoB,KAAM,uBAAuB,IAC1D,MAAM;EACZ,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,KAAK,CAAC;EACzD,WAAW,MAAM,MAAM,UAAU,OAAO;CAC1C;CAEA,OAAO;AACT;AAEA,SAAS,aAAa,MAAe,WAA6C;CAChF,MAAM,SAAS,IAAI,QAAQ,IAAI;CAC/B,IAAI,QAAQ,SAAS,CAAC,CAAC,SAAS,OAAO,QAAQ;EAC7C,OAAO,IAAI,KAAK,KAAK;CACvB,CAAC;CACD,OAAO;AACT;AAEA,SAAS,cAAc,QAAyB,SAAmB;CACjE,OAAO,IAAI,QAAQ;EACjB,QAAQ,OAAO;EACf,KAAK,OAAO;EACZ,cAAc,CACZ,SAAS,UAAmB;GAE1B,IAAI,OADmB,WAAoC,WAC9B,aAC3B;GAGF,IAAI,SAAS,OAAO,UAAU,YAAY,aAAa,OAAO;IAC5D,MAAM,UAAU,OAAO,MAAM,OAAO,CAAC,CAAC,YAAY;IAClD,IACE,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,SAAS,KAC1B,QAAQ,SAAS,iBAAiB,GAElC,AAAK,OAAO,SAAS,CAClB,MAAM,EAAE,YAAY;KACnB,MAAM,UAAU,OAAO,kBAAkB,KAAK;MAC5C,OAAO;MACP,aAAa;KACf;KACA,MAAM,MAAM,QAAQ,OAAO;MACzB,IAAI;MACJ,aAAa,QAAQ;KACvB,CAAC;IACH,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GAErB;EACF,CAAC,CACH;EACA,MAAM,UAAsB,SAAuB;GACjD,OAAO,wBAAwB,UAAU;IACvC,GAAG;IACH,aAAa;IACb,SAAS,UAAU,aAAa,SAAS,SAAS,OAAO,IAAI,SAAS;GACxE,CAAC;EACH;CACF,CAAC;AACH;AAEA,SAAS,eACP,QACA,SACyB;CACzB,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,MAAM,0BAA0B;CAG5C,OAAO,iBAAiB,cAAc,QAAQ,OAAO,CAAC;AACxD;AAEA,SAAgB,gBACd,QACA,SACyB;CAEzB,IAAI,OADmB,WAAoC,WAC9B,eAAe,CAAC,SAAS;EACpD,MAAM,MAAM,GAAG,OAAO,UAAU,OAAO;EACvC,MAAM,WAAW,eAAe,IAAI,GAAG;EACvC,IAAI,UACF,OAAO;EAGT,MAAM,SAAS,eAAkB,QAAQ,OAAO;EAChD,eAAe,IAAI,KAAK,MAAM;EAC9B,OAAO;CACT;CAEA,OAAO,eAAkB,QAAQ,OAAO;AAC1C"}
|
package/dist/dev/serve.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require_errors = require(
|
|
4
|
-
const require_build_artifact_names = require(
|
|
5
|
-
const require_remote_entry = require(
|
|
6
|
-
const require_utils = require(
|
|
7
|
-
const require_generated_config = require(
|
|
8
|
-
const require_dev_host = require(
|
|
9
|
-
const require_generated_config$1 = require(
|
|
10
|
-
const require_watch_kill = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_errors = require("../errors.cjs");
|
|
4
|
+
const require_build_artifact_names = require("../build/artifact-names.cjs");
|
|
5
|
+
const require_remote_entry = require("../remote-entry.cjs");
|
|
6
|
+
const require_utils = require("../build/rspack/utils.cjs");
|
|
7
|
+
const require_generated_config = require("../build/ui/generated-config.cjs");
|
|
8
|
+
const require_dev_host = require("./host.cjs");
|
|
9
|
+
const require_generated_config$1 = require("../build/rspack/generated-config.cjs");
|
|
10
|
+
const require_watch_kill = require("./watch-kill.cjs");
|
|
11
11
|
let effect = require("effect");
|
|
12
12
|
let node_fs = require("node:fs");
|
|
13
13
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
package/dist/errors.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_errors = require(
|
|
2
|
+
const require_errors = require("./runtime/errors.cjs");
|
|
3
3
|
let _orpc_server = require("@orpc/server");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
|
|
@@ -69,6 +69,13 @@ const NOT_FOUND = {
|
|
|
69
69
|
resourceId: zod.z.string().optional()
|
|
70
70
|
})
|
|
71
71
|
};
|
|
72
|
+
const CONFLICT = {
|
|
73
|
+
status: 409,
|
|
74
|
+
data: zod.z.object({
|
|
75
|
+
resource: zod.z.string().optional(),
|
|
76
|
+
detail: zod.z.string().optional()
|
|
77
|
+
})
|
|
78
|
+
};
|
|
72
79
|
const FORBIDDEN = {
|
|
73
80
|
status: 403,
|
|
74
81
|
data: zod.z.object({
|
|
@@ -103,6 +110,7 @@ const PluginErrors = {
|
|
|
103
110
|
SERVICE_UNAVAILABLE,
|
|
104
111
|
BAD_REQUEST,
|
|
105
112
|
NOT_FOUND,
|
|
113
|
+
CONFLICT,
|
|
106
114
|
FORBIDDEN,
|
|
107
115
|
TIMEOUT,
|
|
108
116
|
CONNECTION_ERROR
|
|
@@ -119,11 +127,13 @@ const PluginErrors = {
|
|
|
119
127
|
const PLUGIN_ERROR_STATUS_MAP = {
|
|
120
128
|
..._orpc_server.COMMON_ERROR_STATUS_MAP,
|
|
121
129
|
TIMEOUT: 504,
|
|
122
|
-
CONNECTION_ERROR: 502
|
|
130
|
+
CONNECTION_ERROR: 502,
|
|
131
|
+
CONFLICT: 409
|
|
123
132
|
};
|
|
124
133
|
|
|
125
134
|
//#endregion
|
|
126
135
|
exports.BAD_REQUEST = BAD_REQUEST;
|
|
136
|
+
exports.CONFLICT = CONFLICT;
|
|
127
137
|
exports.CONNECTION_ERROR = CONNECTION_ERROR;
|
|
128
138
|
exports.FORBIDDEN = FORBIDDEN;
|
|
129
139
|
exports.ModuleFederationError = require_errors.ModuleFederationError;
|
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, 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,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,QAAQ,CAAC,CAAC,QAAQ,KAAK;EAC5C,iBAAiBA,MAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAClD,CAAC;AACH;AAEA,MAAa,cAAc;CACzB,QAAQ;CACR,MAAMA,MAAE,OAAO;EACb,eAAeA,MAAE,MAAMA,MAAE,OAAO,CAAC,CAAC,CAAC,SAAS;EAC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US_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 CONFLICT = {\n status: 409,\n data: z.object({\n resource: z.string().optional(),\n detail: 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 CONFLICT,\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 CONFLICT: 409,\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,UAAUA,MAAE,KAAK;GAAC;GAAU;GAAS;EAAO,CAAC,CAAC,CAAC,SAAS;CAC1D,CAAC;AACH;AAEA,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,MAAE,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,OAAO;EACb,qBAAqBA,MAAE,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;CACA;AACF;;;;;;;;;;AAWA,MAAa,0BAAkD;CAC7D,GAAGC;CACH,SAAS;CACT,kBAAkB;CAClB,UAAU;AACZ"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -66,6 +66,13 @@ declare const NOT_FOUND: {
|
|
|
66
66
|
resourceId: z.ZodOptional<z.ZodString>;
|
|
67
67
|
}, z.core.$strip>;
|
|
68
68
|
};
|
|
69
|
+
declare const CONFLICT: {
|
|
70
|
+
readonly status: 409;
|
|
71
|
+
readonly data: z.ZodObject<{
|
|
72
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
73
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
};
|
|
69
76
|
declare const FORBIDDEN: {
|
|
70
77
|
readonly status: 403;
|
|
71
78
|
readonly data: z.ZodObject<{
|
|
@@ -146,6 +153,13 @@ declare const PluginErrors: {
|
|
|
146
153
|
resourceId: z.ZodOptional<z.ZodString>;
|
|
147
154
|
}, z.core.$strip>;
|
|
148
155
|
};
|
|
156
|
+
readonly CONFLICT: {
|
|
157
|
+
readonly status: 409;
|
|
158
|
+
readonly data: z.ZodObject<{
|
|
159
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
160
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
};
|
|
149
163
|
readonly FORBIDDEN: {
|
|
150
164
|
readonly status: 403;
|
|
151
165
|
readonly data: z.ZodObject<{
|
|
@@ -182,5 +196,5 @@ declare const PluginErrors: {
|
|
|
182
196
|
*/
|
|
183
197
|
declare const PLUGIN_ERROR_STATUS_MAP: Record<string, number>;
|
|
184
198
|
//#endregion
|
|
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 };
|
|
199
|
+
export { BAD_REQUEST, CONFLICT, 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
200
|
//# sourceMappingURL=errors.d.cts.map
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;cAkBa;WACX;WACA,MAAI,EAAA;;;;;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAQO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;cAcO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAYO;;
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;cAkBa;WACX;WACA,MAAI,EAAA;;;;;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAQO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;cAcO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAYO;;aA1FH;;;;;;;;;;;;aASA;;;;;;;;;;;;;aAUA;;;;;;;;aASA;;;;;;;;;;;aAgBA;;;;;;;aAQA;;;;;;;aAQA;;;;;;;aAQA;;;;;;;;aASA;;;;;;;;;;;;;;;;;;cAkCG,yBAAyB"}
|
package/dist/errors.d.mts
CHANGED
|
@@ -66,6 +66,13 @@ declare const NOT_FOUND: {
|
|
|
66
66
|
resourceId: z.ZodOptional<z.ZodString>;
|
|
67
67
|
}, z.core.$strip>;
|
|
68
68
|
};
|
|
69
|
+
declare const CONFLICT: {
|
|
70
|
+
readonly status: 409;
|
|
71
|
+
readonly data: z.ZodObject<{
|
|
72
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
73
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
};
|
|
69
76
|
declare const FORBIDDEN: {
|
|
70
77
|
readonly status: 403;
|
|
71
78
|
readonly data: z.ZodObject<{
|
|
@@ -146,6 +153,13 @@ declare const PluginErrors: {
|
|
|
146
153
|
resourceId: z.ZodOptional<z.ZodString>;
|
|
147
154
|
}, z.core.$strip>;
|
|
148
155
|
};
|
|
156
|
+
readonly CONFLICT: {
|
|
157
|
+
readonly status: 409;
|
|
158
|
+
readonly data: z.ZodObject<{
|
|
159
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
160
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
};
|
|
149
163
|
readonly FORBIDDEN: {
|
|
150
164
|
readonly status: 403;
|
|
151
165
|
readonly data: z.ZodObject<{
|
|
@@ -182,5 +196,5 @@ declare const PluginErrors: {
|
|
|
182
196
|
*/
|
|
183
197
|
declare const PLUGIN_ERROR_STATUS_MAP: Record<string, number>;
|
|
184
198
|
//#endregion
|
|
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 };
|
|
199
|
+
export { BAD_REQUEST, CONFLICT, 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
200
|
//# sourceMappingURL=errors.d.mts.map
|
package/dist/errors.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;cAkBa;WACX;WACA,MAAI,EAAA;;;;;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAQO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;cAcO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAYO;;
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;cAkBa;WACX;WACA,MAAI,EAAA;;;;;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAQO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;cAcO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;cAMO;WACX;WACA,MAAI,EAAA;;;;;;cAOO;WACX;WACA,MAAI,EAAA;;;;;;;;;;;cAYO;;aA1FH;;;;;;;;;;;;aASA;;;;;;;;;;;;;aAUA;;;;;;;;aASA;;;;;;;;;;;aAgBA;;;;;;;aAQA;;;;;;;aAQA;;;;;;;aAQA;;;;;;;;aASA;;;;;;;;;;;;;;;;;;cAkCG,yBAAyB"}
|
package/dist/errors.mjs
CHANGED
|
@@ -68,6 +68,13 @@ const NOT_FOUND = {
|
|
|
68
68
|
resourceId: z.string().optional()
|
|
69
69
|
})
|
|
70
70
|
};
|
|
71
|
+
const CONFLICT = {
|
|
72
|
+
status: 409,
|
|
73
|
+
data: z.object({
|
|
74
|
+
resource: z.string().optional(),
|
|
75
|
+
detail: z.string().optional()
|
|
76
|
+
})
|
|
77
|
+
};
|
|
71
78
|
const FORBIDDEN = {
|
|
72
79
|
status: 403,
|
|
73
80
|
data: z.object({
|
|
@@ -102,6 +109,7 @@ const PluginErrors = {
|
|
|
102
109
|
SERVICE_UNAVAILABLE,
|
|
103
110
|
BAD_REQUEST,
|
|
104
111
|
NOT_FOUND,
|
|
112
|
+
CONFLICT,
|
|
105
113
|
FORBIDDEN,
|
|
106
114
|
TIMEOUT,
|
|
107
115
|
CONNECTION_ERROR
|
|
@@ -118,9 +126,10 @@ const PluginErrors = {
|
|
|
118
126
|
const PLUGIN_ERROR_STATUS_MAP = {
|
|
119
127
|
...COMMON_ERROR_STATUS_MAP,
|
|
120
128
|
TIMEOUT: 504,
|
|
121
|
-
CONNECTION_ERROR: 502
|
|
129
|
+
CONNECTION_ERROR: 502,
|
|
130
|
+
CONFLICT: 409
|
|
122
131
|
};
|
|
123
132
|
|
|
124
133
|
//#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, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError };
|
|
134
|
+
export { BAD_REQUEST, CONFLICT, 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
135
|
//# 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, 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,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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;
|
|
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 CONFLICT = {\n status: 409,\n data: z.object({\n resource: z.string().optional(),\n detail: 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 CONFLICT,\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 CONFLICT: 409,\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,EAAE,QAAQ,CAAC,CAAC,QAAQ,KAAK;EAC5C,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAClD,CAAC;AACH;AAEA,MAAa,cAAc;CACzB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;EAC5C,kBAAkB,EACf,MACC,EAAE,OAAO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MAAa,0BAAkD;CAC7D,GAAG;CACH,SAAS;CACT,kBAAkB;CAClB,UAAU;AACZ"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_client = require(
|
|
3
|
-
const require_effect_helpers = require(
|
|
4
|
-
const require_errors = require(
|
|
5
|
-
const require_errors$1 = require(
|
|
6
|
-
const require_plugin = require(
|
|
7
|
-
const require_identity = require(
|
|
8
|
-
const require_runtime_index = require(
|
|
2
|
+
const require_client = require("./client.cjs");
|
|
3
|
+
const require_effect_helpers = require("./effect-helpers.cjs");
|
|
4
|
+
const require_errors = require("./runtime/errors.cjs");
|
|
5
|
+
const require_errors$1 = require("./errors.cjs");
|
|
6
|
+
const require_plugin = require("./plugin.cjs");
|
|
7
|
+
const require_identity = require("./identity.cjs");
|
|
8
|
+
const require_runtime_index = require("./runtime/index.cjs");
|
|
9
9
|
require("@orpc/openapi/extensions/route");
|
|
10
10
|
|
|
11
11
|
exports.BAD_REQUEST = require_errors$1.BAD_REQUEST;
|
|
12
|
+
exports.CONFLICT = require_errors$1.CONFLICT;
|
|
12
13
|
exports.CONNECTION_ERROR = require_errors$1.CONNECTION_ERROR;
|
|
13
14
|
exports.FORBIDDEN = require_errors$1.FORBIDDEN;
|
|
14
15
|
exports.ModuleFederationError = require_errors.ModuleFederationError;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { remoteName } from "./identity.cjs";
|
|
2
2
|
import { RpcClientConfig, RpcConnectionErrorCopy, createRpcClient } from "./client.cjs";
|
|
3
3
|
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.cjs";
|
|
4
|
-
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.cjs";
|
|
4
|
+
import { BAD_REQUEST, CONFLICT, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.cjs";
|
|
5
5
|
import { buildScoped, buildScopedContext } from "./effect-helpers.cjs";
|
|
6
6
|
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins } from "./plugin.cjs";
|
|
7
7
|
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, ModuleClientEntry, ModuleEndpoint, ModuleSurface, ModuleTransport, PluginClientEntry, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginEndpoint, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginServicesEntry, PluginSurface, PluginTransport, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.cjs";
|
|
8
8
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.cjs";
|
|
9
9
|
import "@orpc/openapi/extensions/route";
|
|
10
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, type ModuleClientEntry, type ModuleEndpoint, ModuleFederationError, type ModuleSurface, type ModuleTransport, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientEntry, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginEndpoint, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginSurface, type PluginTransport, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, RpcClientConfig, RpcConnectionErrorCopy, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
10
|
+
export { type AnyPlugin, BAD_REQUEST, CONFLICT, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, type ModuleClientEntry, type ModuleEndpoint, ModuleFederationError, type ModuleSurface, type ModuleTransport, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientEntry, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginEndpoint, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginSurface, type PluginTransport, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, RpcClientConfig, RpcConnectionErrorCopy, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { remoteName } from "./identity.mjs";
|
|
2
2
|
import { RpcClientConfig, RpcConnectionErrorCopy, createRpcClient } from "./client.mjs";
|
|
3
3
|
import { ModuleFederationError, PluginLoadFailureInfo, PluginRuntimeError, PluginWarningInfo, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
4
|
-
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
4
|
+
import { BAD_REQUEST, CONFLICT, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
5
5
|
import { buildScoped, buildScopedContext } from "./effect-helpers.mjs";
|
|
6
6
|
import { CreatePluginFn, CreatePluginWithPlugins, LoadedPluginWithBinding, Plugin, PluginConfigFor, PluginEnv, PluginIdTag, PluginInitializeInput, PluginWarningsFn, createPlugin, withPlugins } from "./plugin.mjs";
|
|
7
7
|
import { AnyPlugin, EveryPlugin, InitializedPlugin, LoadedPlugin, ModuleClientEntry, ModuleEndpoint, ModuleSurface, ModuleTransport, PluginClientEntry, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginEndpoint, PluginInstance, PluginMetadata, PluginRegistry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginServicesEntry, PluginSurface, PluginTransport, PluginVariables, RegisteredPlugins, SecretsConfig, UsePluginResult } from "./types.mjs";
|
|
8
8
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
9
9
|
import "@orpc/openapi/extensions/route";
|
|
10
|
-
export { type AnyPlugin, BAD_REQUEST, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, type ModuleClientEntry, type ModuleEndpoint, ModuleFederationError, type ModuleSurface, type ModuleTransport, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientEntry, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginEndpoint, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginSurface, type PluginTransport, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, RpcClientConfig, RpcConnectionErrorCopy, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
10
|
+
export { type AnyPlugin, BAD_REQUEST, CONFLICT, CONNECTION_ERROR, CreatePluginFn, CreatePluginWithPlugins, type EveryPlugin, FORBIDDEN, type InitializedPlugin, type LoadedPlugin, LoadedPluginWithBinding, type ModuleClientEntry, type ModuleEndpoint, ModuleFederationError, type ModuleSurface, type ModuleTransport, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, Plugin, type PluginClientEntry, type PluginClientType, PluginConfigFor, type PluginConfigInput, type PluginContext, type PluginContract, type PluginEndpoint, PluginEnv, PluginErrors, PluginIdTag, PluginInitializeInput, type PluginInstance, type PluginLoadFailureInfo, type PluginMetadata, type PluginRegistry, type PluginRouterType, PluginRuntime, type PluginRuntimeConfig, PluginRuntimeError, type PluginSecrets, type PluginServicesEntry, type PluginSurface, type PluginTransport, type PluginVariables, type PluginWarningInfo, PluginWarningsFn, RATE_LIMITED, type RegisteredPlugins, RpcClientConfig, RpcConnectionErrorCopy, SERVICE_UNAVAILABLE, type SecretsConfig, TIMEOUT, UNAUTHORIZED, type UsePluginResult, ValidationError, buildScoped, buildScopedContext, classifyPluginFailure, createPlugin, createPluginRuntime, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRpcClient } from "./client.mjs";
|
|
2
2
|
import { buildScoped, buildScopedContext } from "./effect-helpers.mjs";
|
|
3
3
|
import { ModuleFederationError, PluginRuntimeError, ValidationError, classifyPluginFailure, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
|
|
4
|
-
import { BAD_REQUEST, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
4
|
+
import { BAD_REQUEST, CONFLICT, CONNECTION_ERROR, FORBIDDEN, NOT_FOUND, PLUGIN_ERROR_STATUS_MAP, PluginErrors, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNAUTHORIZED } from "./errors.mjs";
|
|
5
5
|
import { PluginIdTag, createPlugin, withPlugins } from "./plugin.mjs";
|
|
6
6
|
import { remoteName } from "./identity.mjs";
|
|
7
7
|
import { PluginRuntime, createPluginRuntime } from "./runtime/index.mjs";
|
|
8
8
|
import "@orpc/openapi/extensions/route";
|
|
9
9
|
|
|
10
|
-
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, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
|
10
|
+
export { BAD_REQUEST, CONFLICT, 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, createRpcClient, defaultMissingSecretWarnings, extractFromFiberFailure, formatORPCError, remoteName as getNormalizedRemoteName, toPluginRuntimeError, withPlugins, wrapORPCError };
|
package/dist/plugin.cjs
CHANGED
package/dist/remote-entry.cjs
CHANGED
package/dist/runtime/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_errors = require(
|
|
3
|
-
const require_build_artifact_names = require(
|
|
4
|
-
const require_plugin_service = require(
|
|
2
|
+
const require_errors = require("./errors.cjs");
|
|
3
|
+
const require_build_artifact_names = require("../build/artifact-names.cjs");
|
|
4
|
+
const require_plugin_service = require("./services/plugin.service.cjs");
|
|
5
5
|
require("@orpc/openapi/extensions/route");
|
|
6
6
|
let effect = require("effect");
|
|
7
7
|
let _orpc_server = require("@orpc/server");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_shared_deps_spec = require(
|
|
2
|
+
const require_shared_deps_spec = require("../shared-deps-spec.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/mf-config.ts
|
|
6
|
-
const PLUGIN_VERSION = "3.0.0-rc.
|
|
6
|
+
const PLUGIN_VERSION = "3.0.0-rc.16";
|
|
7
7
|
const MF_CORE_SHARED_DEPS = require_shared_deps_spec.buildMfCoreSharedDependencies({ ownVersion: PLUGIN_VERSION });
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import { buildMfCoreSharedDependencies } from "../shared-deps-spec.mjs";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/runtime/mf-config.ts
|
|
5
|
-
const PLUGIN_VERSION = "3.0.0-rc.
|
|
5
|
+
const PLUGIN_VERSION = "3.0.0-rc.16";
|
|
6
6
|
const MF_CORE_SHARED_DEPS = buildMfCoreSharedDependencies({ ownVersion: PLUGIN_VERSION });
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_errors = require(
|
|
2
|
-
const require_build_artifact_names = require(
|
|
3
|
-
const require_runtime_mf_config = require(
|
|
4
|
-
const require_identity = require(
|
|
5
|
-
const require_shared_identity = require(
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
|
+
const require_build_artifact_names = require("../../build/artifact-names.cjs");
|
|
3
|
+
const require_runtime_mf_config = require("../mf-config.cjs");
|
|
4
|
+
const require_identity = require("../../identity.cjs");
|
|
5
|
+
const require_shared_identity = require("./shared-identity.cjs");
|
|
6
6
|
let effect = require("effect");
|
|
7
7
|
let _module_federation_enhanced_runtime = require("@module-federation/enhanced/runtime");
|
|
8
8
|
let _module_federation_runtime_core = require("@module-federation/runtime-core");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_errors = require(
|
|
2
|
-
const require_plugin = require(
|
|
3
|
-
const require_module_federation_service = require(
|
|
4
|
-
const require_validation = require(
|
|
5
|
-
const require_secrets_service = require(
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
|
+
const require_plugin = require("../../plugin.cjs");
|
|
3
|
+
const require_module_federation_service = require("./module-federation.service.cjs");
|
|
4
|
+
const require_validation = require("../validation.cjs");
|
|
5
|
+
const require_secrets_service = require("./secrets.service.cjs");
|
|
6
6
|
let effect = require("effect");
|
|
7
7
|
|
|
8
8
|
//#region src/runtime/services/plugin-loader.service.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_module_federation_service = require(
|
|
2
|
-
const require_plugin_lifecycle_service = require(
|
|
3
|
-
const require_secrets_service = require(
|
|
4
|
-
const require_plugin_loader_service = require(
|
|
1
|
+
const require_module_federation_service = require("./module-federation.service.cjs");
|
|
2
|
+
const require_plugin_lifecycle_service = require("./plugin-lifecycle.service.cjs");
|
|
3
|
+
const require_secrets_service = require("./secrets.service.cjs");
|
|
4
|
+
const require_plugin_loader_service = require("./plugin-loader.service.cjs");
|
|
5
5
|
let effect = require("effect");
|
|
6
6
|
|
|
7
7
|
//#region src/runtime/services/plugin.service.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_errors = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_errors = require("../errors.cjs");
|
|
3
3
|
let effect = require("effect");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
zod = require_runtime.__toESM(zod, 1);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_ui_manifest_contract = require(
|
|
2
|
-
const require_mount_registry = require(
|
|
3
|
-
const require_descriptor = require(
|
|
4
|
-
const require_nav = require(
|
|
5
|
-
const require_route_config = require(
|
|
1
|
+
const require_ui_manifest_contract = require("./contract.cjs");
|
|
2
|
+
const require_mount_registry = require("./mount-registry.cjs");
|
|
3
|
+
const require_descriptor = require("./descriptor.cjs");
|
|
4
|
+
const require_nav = require("./nav.cjs");
|
|
5
|
+
const require_route_config = require("./route-config.cjs");
|
|
6
6
|
let _tanstack_react_router = require("@tanstack/react-router");
|
|
7
7
|
|
|
8
8
|
//#region src/ui/manifest/construct.ts
|
|
@@ -10,9 +10,10 @@ let _tanstack_react_router = require("@tanstack/react-router");
|
|
|
10
10
|
* Host-side route-graph construction (ADR 0008 §1): manifests + route
|
|
11
11
|
* configs in → host-built tree out. The host constructs ITS OWN Route
|
|
12
12
|
* objects from validated manifest data via public `createRoute` APIs; no
|
|
13
|
-
* foreign route object is ever mutated.
|
|
14
|
-
*
|
|
15
|
-
* mount's
|
|
13
|
+
* foreign route object is ever mutated. Mount guards are ordinary
|
|
14
|
+
* beforeLoads attached HOST-side from ConstructInput.guards — plugins
|
|
15
|
+
* cannot ship a route that escapes its mount's guard because plugins never
|
|
16
|
+
* construct route objects.
|
|
16
17
|
*
|
|
17
18
|
* Mounts are the ONLY cross-source parenting points: a root-level
|
|
18
19
|
* pathless layout file (`_public.tsx`) declares the mount for the whole
|
|
@@ -31,33 +32,6 @@ let _tanstack_react_router = require("@tanstack/react-router");
|
|
|
31
32
|
function toAnyRoute(route) {
|
|
32
33
|
return route;
|
|
33
34
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Gate redirects are absolute: gates attach to root-level mount routes, and
|
|
36
|
-
* relatives would silently shift if a mount ever moved deeper in the tree.
|
|
37
|
-
* The login surface is plugin-owned, never core-known.
|
|
38
|
-
*/
|
|
39
|
-
const LOGIN_TO = "/login";
|
|
40
|
-
const HOME_TO = "/";
|
|
41
|
-
/**
|
|
42
|
-
* Gate implementations by mount gate kind. Only `session` and `admin` are
|
|
43
|
-
* implemented (ADR 0008 §3); unimplemented mounts are rejected during mount
|
|
44
|
-
* declaration before any gate lookup, and gates are optional by type — a
|
|
45
|
-
* mount without an entry (or `none`) renders ungated.
|
|
46
|
-
*/
|
|
47
|
-
const GATES = {
|
|
48
|
-
session: ({ context, location }) => {
|
|
49
|
-
if (!userOf(context)) throw (0, _tanstack_react_router.redirect)({
|
|
50
|
-
to: LOGIN_TO,
|
|
51
|
-
search: { redirect: location.pathname + location.searchStr }
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
admin: ({ context }) => {
|
|
55
|
-
const user = userOf(context);
|
|
56
|
-
if (!user) throw (0, _tanstack_react_router.redirect)({ to: LOGIN_TO });
|
|
57
|
-
if (user.role !== "admin") throw (0, _tanstack_react_router.redirect)({ to: HOME_TO });
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const userOf = (context) => context?.user ?? context?.session?.user;
|
|
61
35
|
function joinPath(a, b) {
|
|
62
36
|
const left = a && a !== "/" ? a.replace(/\/+$/, "") : "";
|
|
63
37
|
const right = b && b !== "/" ? b.replace(/^\/+/, "") : "";
|
|
@@ -70,14 +44,14 @@ const navOf = (options) => {
|
|
|
70
44
|
if (nav && typeof nav === "object" && typeof nav.label === "string") return nav;
|
|
71
45
|
};
|
|
72
46
|
/** Layout routes (mount or pathless) pass their authored options through,
|
|
73
|
-
* like every other route kind. On mount routes the
|
|
47
|
+
* like every other route kind. On mount routes the mount's guard composes
|
|
74
48
|
* BEFORE the declaration's own beforeLoad so a source can never escape its
|
|
75
|
-
* mount's
|
|
49
|
+
* mount's guard (ADR 0008 §3), while the declaration's return value still
|
|
76
50
|
* flows to children as route context. */
|
|
77
|
-
function layoutBeforeLoad(
|
|
78
|
-
if (!
|
|
79
|
-
return (args) => {
|
|
80
|
-
|
|
51
|
+
function layoutBeforeLoad(guard, declared) {
|
|
52
|
+
if (!guard) return declared;
|
|
53
|
+
return async (args) => {
|
|
54
|
+
await guard(args);
|
|
81
55
|
return declared?.(args);
|
|
82
56
|
};
|
|
83
57
|
}
|
|
@@ -161,12 +135,13 @@ async function constructTree(input) {
|
|
|
161
135
|
const declaration = declarations.get(mountId);
|
|
162
136
|
if (!declaration) continue;
|
|
163
137
|
const def = require_mount_registry.MOUNT_REGISTRY[mountId];
|
|
164
|
-
const
|
|
138
|
+
const guard = input.guards?.[mountId];
|
|
139
|
+
if (def.guarded && !guard) throw new Error(`mount "${mountId}" requires a guard — add one to ConstructInput.guards`);
|
|
165
140
|
const options = declaration.options;
|
|
166
141
|
const route = (0, _tanstack_react_router.createRoute)({
|
|
167
142
|
id: `__mount_${mountId}`,
|
|
168
143
|
getParentRoute: () => rootRoute,
|
|
169
|
-
...
|
|
144
|
+
...guard || options.beforeLoad ? { beforeLoad: layoutBeforeLoad(guard, options.beforeLoad) } : {},
|
|
170
145
|
...authoredOptions(options),
|
|
171
146
|
component: options.component ?? _tanstack_react_router.Outlet
|
|
172
147
|
});
|