every-plugin 2.5.10 → 2.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +0 -16
  2. package/dist/_virtual/_rolldown/runtime.mjs +1 -33
  3. package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
  4. package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
  5. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
  6. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
  7. package/dist/build/rspack/plugin.cjs.map +1 -1
  8. package/dist/build/rspack/plugin.mjs.map +1 -1
  9. package/dist/build/shared-deps.cjs.map +1 -1
  10. package/dist/build/shared-deps.mjs.map +1 -1
  11. package/dist/errors.cjs +37 -35
  12. package/dist/errors.cjs.map +1 -1
  13. package/dist/errors.d.cts +130 -130
  14. package/dist/errors.d.mts +130 -130
  15. package/dist/errors.mjs +35 -35
  16. package/dist/errors.mjs.map +1 -1
  17. package/dist/plugin.cjs.map +1 -1
  18. package/dist/plugin.mjs.map +1 -1
  19. package/dist/runtime/errors.cjs.map +1 -1
  20. package/dist/runtime/errors.mjs.map +1 -1
  21. package/dist/runtime/index.cjs.map +1 -1
  22. package/dist/runtime/index.mjs.map +1 -1
  23. package/dist/runtime/mf-config.cjs +1 -1
  24. package/dist/runtime/mf-config.mjs +1 -1
  25. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  26. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  27. package/dist/runtime/services/secrets.service.cjs +2 -1
  28. package/dist/runtime/services/secrets.service.cjs.map +1 -1
  29. package/dist/runtime/services/secrets.service.mjs +2 -2
  30. package/dist/runtime/services/secrets.service.mjs.map +1 -1
  31. package/dist/testing/index.cjs.map +1 -1
  32. package/dist/testing/index.mjs.map +1 -1
  33. package/dist/zod.cjs +5 -17
  34. package/dist/zod.d.cts +2 -8
  35. package/dist/zod.d.mts +2 -8
  36. package/dist/zod.mjs +2 -11
  37. package/package.json +6 -6
  38. package/skills/plugin-development/SKILL.md +16 -8
  39. package/skills/plugin-testing/SKILL.md +19 -9
  40. package/src/runtime/services/secrets.service.ts +1 -1
  41. package/src/zod-core.ts +0 -3
  42. package/src/zod.ts +3 -1
  43. package/dist/zod.cjs.map +0 -1
  44. package/dist/zod.d.cts.map +0 -1
  45. package/dist/zod.d.mts.map +0 -1
  46. package/dist/zod.mjs.map +0 -1
package/dist/errors.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { zod_d_exports } from "./zod.mjs";
1
+ import { z } from "./zod.mjs";
2
2
  import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
3
3
 
4
4
  //#region src/errors.d.ts
@@ -31,78 +31,78 @@ declare const ERROR_PATTERNS: {
31
31
  */
32
32
  declare const UNAUTHORIZED: {
33
33
  readonly status: 401;
34
- readonly data: zod_d_exports.z.ZodObject<{
35
- apiKeyProvided: zod_d_exports.z.ZodBoolean;
36
- provider: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
37
- authType: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodEnum<{
34
+ readonly data: z.ZodObject<{
35
+ apiKeyProvided: z.ZodBoolean;
36
+ provider: z.ZodOptional<z.ZodString>;
37
+ authType: z.ZodOptional<z.ZodEnum<{
38
38
  apiKey: "apiKey";
39
39
  oauth: "oauth";
40
40
  token: "token";
41
41
  }>>;
42
- }, zod_d_exports.z.core.$strip>;
42
+ }, z.core.$strip>;
43
43
  };
44
44
  declare const RATE_LIMITED: {
45
45
  readonly status: 429;
46
- readonly data: zod_d_exports.z.ZodObject<{
47
- retryAfter: zod_d_exports.z.ZodNumber;
48
- remainingRequests: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
49
- resetTime: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
50
- limitType: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodEnum<{
46
+ readonly data: z.ZodObject<{
47
+ retryAfter: z.ZodNumber;
48
+ remainingRequests: z.ZodOptional<z.ZodNumber>;
49
+ resetTime: z.ZodOptional<z.ZodString>;
50
+ limitType: z.ZodOptional<z.ZodEnum<{
51
51
  requests: "requests";
52
52
  tokens: "tokens";
53
53
  bandwidth: "bandwidth";
54
54
  }>>;
55
- }, zod_d_exports.z.core.$strip>;
55
+ }, z.core.$strip>;
56
56
  };
57
57
  declare const SERVICE_UNAVAILABLE: {
58
58
  readonly status: 503;
59
- readonly data: zod_d_exports.z.ZodObject<{
60
- retryAfter: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
61
- maintenanceWindow: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
62
- estimatedUptime: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
63
- }, zod_d_exports.z.core.$strip>;
59
+ readonly data: z.ZodObject<{
60
+ retryAfter: z.ZodOptional<z.ZodNumber>;
61
+ maintenanceWindow: z.ZodDefault<z.ZodBoolean>;
62
+ estimatedUptime: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>;
64
64
  };
65
65
  declare const BAD_REQUEST: {
66
66
  readonly status: 400;
67
- readonly data: zod_d_exports.z.ZodObject<{
68
- invalidFields: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodString>>;
69
- validationErrors: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodObject<{
70
- field: zod_d_exports.z.ZodString;
71
- message: zod_d_exports.z.ZodString;
72
- code: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
73
- }, zod_d_exports.z.core.$strip>>>;
74
- }, zod_d_exports.z.core.$strip>;
67
+ readonly data: z.ZodObject<{
68
+ invalidFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
+ validationErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
70
+ field: z.ZodString;
71
+ message: z.ZodString;
72
+ code: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>>>;
74
+ }, z.core.$strip>;
75
75
  };
76
76
  declare const NOT_FOUND: {
77
77
  readonly status: 404;
78
- readonly data: zod_d_exports.z.ZodObject<{
79
- resource: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
80
- resourceId: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
81
- }, zod_d_exports.z.core.$strip>;
78
+ readonly data: z.ZodObject<{
79
+ resource: z.ZodOptional<z.ZodString>;
80
+ resourceId: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>;
82
82
  };
83
83
  declare const FORBIDDEN: {
84
84
  readonly status: 403;
85
- readonly data: zod_d_exports.z.ZodObject<{
86
- requiredPermissions: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodString>>;
87
- action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
88
- }, zod_d_exports.z.core.$strip>;
85
+ readonly data: z.ZodObject<{
86
+ requiredPermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
+ action: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>;
89
89
  };
90
90
  declare const TIMEOUT: {
91
91
  readonly status: 504;
92
- readonly data: zod_d_exports.z.ZodObject<{
93
- timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
94
- operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
95
- retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
96
- }, zod_d_exports.z.core.$strip>;
92
+ readonly data: z.ZodObject<{
93
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
94
+ operation: z.ZodOptional<z.ZodString>;
95
+ retryable: z.ZodDefault<z.ZodBoolean>;
96
+ }, z.core.$strip>;
97
97
  };
98
98
  declare const CONNECTION_ERROR: {
99
99
  readonly status: 502;
100
- readonly data: zod_d_exports.z.ZodObject<{
101
- errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
102
- host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
103
- port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
104
- suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
105
- }, zod_d_exports.z.core.$strip>;
100
+ readonly data: z.ZodObject<{
101
+ errorCode: z.ZodOptional<z.ZodString>;
102
+ host: z.ZodOptional<z.ZodString>;
103
+ port: z.ZodOptional<z.ZodNumber>;
104
+ suggestion: z.ZodOptional<z.ZodString>;
105
+ }, z.core.$strip>;
106
106
  };
107
107
  /**
108
108
  * Grouped export for all plugin errors.
@@ -111,78 +111,78 @@ declare const CONNECTION_ERROR: {
111
111
  declare const PluginErrors: {
112
112
  readonly UNAUTHORIZED: {
113
113
  readonly status: 401;
114
- readonly data: zod_d_exports.z.ZodObject<{
115
- apiKeyProvided: zod_d_exports.z.ZodBoolean;
116
- provider: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
117
- authType: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodEnum<{
114
+ readonly data: z.ZodObject<{
115
+ apiKeyProvided: z.ZodBoolean;
116
+ provider: z.ZodOptional<z.ZodString>;
117
+ authType: z.ZodOptional<z.ZodEnum<{
118
118
  apiKey: "apiKey";
119
119
  oauth: "oauth";
120
120
  token: "token";
121
121
  }>>;
122
- }, zod_d_exports.z.core.$strip>;
122
+ }, z.core.$strip>;
123
123
  };
124
124
  readonly RATE_LIMITED: {
125
125
  readonly status: 429;
126
- readonly data: zod_d_exports.z.ZodObject<{
127
- retryAfter: zod_d_exports.z.ZodNumber;
128
- remainingRequests: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
129
- resetTime: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
130
- limitType: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodEnum<{
126
+ readonly data: z.ZodObject<{
127
+ retryAfter: z.ZodNumber;
128
+ remainingRequests: z.ZodOptional<z.ZodNumber>;
129
+ resetTime: z.ZodOptional<z.ZodString>;
130
+ limitType: z.ZodOptional<z.ZodEnum<{
131
131
  requests: "requests";
132
132
  tokens: "tokens";
133
133
  bandwidth: "bandwidth";
134
134
  }>>;
135
- }, zod_d_exports.z.core.$strip>;
135
+ }, z.core.$strip>;
136
136
  };
137
137
  readonly SERVICE_UNAVAILABLE: {
138
138
  readonly status: 503;
139
- readonly data: zod_d_exports.z.ZodObject<{
140
- retryAfter: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
141
- maintenanceWindow: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
142
- estimatedUptime: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
143
- }, zod_d_exports.z.core.$strip>;
139
+ readonly data: z.ZodObject<{
140
+ retryAfter: z.ZodOptional<z.ZodNumber>;
141
+ maintenanceWindow: z.ZodDefault<z.ZodBoolean>;
142
+ estimatedUptime: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strip>;
144
144
  };
145
145
  readonly BAD_REQUEST: {
146
146
  readonly status: 400;
147
- readonly data: zod_d_exports.z.ZodObject<{
148
- invalidFields: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodString>>;
149
- validationErrors: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodObject<{
150
- field: zod_d_exports.z.ZodString;
151
- message: zod_d_exports.z.ZodString;
152
- code: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
153
- }, zod_d_exports.z.core.$strip>>>;
154
- }, zod_d_exports.z.core.$strip>;
147
+ readonly data: z.ZodObject<{
148
+ invalidFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
149
+ validationErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
150
+ field: z.ZodString;
151
+ message: z.ZodString;
152
+ code: z.ZodOptional<z.ZodString>;
153
+ }, z.core.$strip>>>;
154
+ }, z.core.$strip>;
155
155
  };
156
156
  readonly NOT_FOUND: {
157
157
  readonly status: 404;
158
- readonly data: zod_d_exports.z.ZodObject<{
159
- resource: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
160
- resourceId: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
161
- }, zod_d_exports.z.core.$strip>;
158
+ readonly data: z.ZodObject<{
159
+ resource: z.ZodOptional<z.ZodString>;
160
+ resourceId: z.ZodOptional<z.ZodString>;
161
+ }, z.core.$strip>;
162
162
  };
163
163
  readonly FORBIDDEN: {
164
164
  readonly status: 403;
165
- readonly data: zod_d_exports.z.ZodObject<{
166
- requiredPermissions: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodString>>;
167
- action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
168
- }, zod_d_exports.z.core.$strip>;
165
+ readonly data: z.ZodObject<{
166
+ requiredPermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
167
+ action: z.ZodOptional<z.ZodString>;
168
+ }, z.core.$strip>;
169
169
  };
170
170
  readonly TIMEOUT: {
171
171
  readonly status: 504;
172
- readonly data: zod_d_exports.z.ZodObject<{
173
- timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
174
- operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
175
- retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
176
- }, zod_d_exports.z.core.$strip>;
172
+ readonly data: z.ZodObject<{
173
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
174
+ operation: z.ZodOptional<z.ZodString>;
175
+ retryable: z.ZodDefault<z.ZodBoolean>;
176
+ }, z.core.$strip>;
177
177
  };
178
178
  readonly CONNECTION_ERROR: {
179
179
  readonly status: 502;
180
- readonly data: zod_d_exports.z.ZodObject<{
181
- errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
182
- host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
183
- port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
184
- suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
185
- }, zod_d_exports.z.core.$strip>;
180
+ readonly data: z.ZodObject<{
181
+ errorCode: z.ZodOptional<z.ZodString>;
182
+ host: z.ZodOptional<z.ZodString>;
183
+ port: z.ZodOptional<z.ZodNumber>;
184
+ suggestion: z.ZodOptional<z.ZodString>;
185
+ }, z.core.$strip>;
186
186
  };
187
187
  };
188
188
  /**
@@ -191,78 +191,78 @@ declare const PluginErrors: {
191
191
  declare const CommonPluginErrors: {
192
192
  readonly UNAUTHORIZED: {
193
193
  readonly status: 401;
194
- readonly data: zod_d_exports.z.ZodObject<{
195
- apiKeyProvided: zod_d_exports.z.ZodBoolean;
196
- provider: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
197
- authType: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodEnum<{
194
+ readonly data: z.ZodObject<{
195
+ apiKeyProvided: z.ZodBoolean;
196
+ provider: z.ZodOptional<z.ZodString>;
197
+ authType: z.ZodOptional<z.ZodEnum<{
198
198
  apiKey: "apiKey";
199
199
  oauth: "oauth";
200
200
  token: "token";
201
201
  }>>;
202
- }, zod_d_exports.z.core.$strip>;
202
+ }, z.core.$strip>;
203
203
  };
204
204
  readonly RATE_LIMITED: {
205
205
  readonly status: 429;
206
- readonly data: zod_d_exports.z.ZodObject<{
207
- retryAfter: zod_d_exports.z.ZodNumber;
208
- remainingRequests: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
209
- resetTime: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
210
- limitType: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodEnum<{
206
+ readonly data: z.ZodObject<{
207
+ retryAfter: z.ZodNumber;
208
+ remainingRequests: z.ZodOptional<z.ZodNumber>;
209
+ resetTime: z.ZodOptional<z.ZodString>;
210
+ limitType: z.ZodOptional<z.ZodEnum<{
211
211
  requests: "requests";
212
212
  tokens: "tokens";
213
213
  bandwidth: "bandwidth";
214
214
  }>>;
215
- }, zod_d_exports.z.core.$strip>;
215
+ }, z.core.$strip>;
216
216
  };
217
217
  readonly SERVICE_UNAVAILABLE: {
218
218
  readonly status: 503;
219
- readonly data: zod_d_exports.z.ZodObject<{
220
- retryAfter: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
221
- maintenanceWindow: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
222
- estimatedUptime: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
223
- }, zod_d_exports.z.core.$strip>;
219
+ readonly data: z.ZodObject<{
220
+ retryAfter: z.ZodOptional<z.ZodNumber>;
221
+ maintenanceWindow: z.ZodDefault<z.ZodBoolean>;
222
+ estimatedUptime: z.ZodOptional<z.ZodString>;
223
+ }, z.core.$strip>;
224
224
  };
225
225
  readonly BAD_REQUEST: {
226
226
  readonly status: 400;
227
- readonly data: zod_d_exports.z.ZodObject<{
228
- invalidFields: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodString>>;
229
- validationErrors: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodObject<{
230
- field: zod_d_exports.z.ZodString;
231
- message: zod_d_exports.z.ZodString;
232
- code: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
233
- }, zod_d_exports.z.core.$strip>>>;
234
- }, zod_d_exports.z.core.$strip>;
227
+ readonly data: z.ZodObject<{
228
+ invalidFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
229
+ validationErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
230
+ field: z.ZodString;
231
+ message: z.ZodString;
232
+ code: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$strip>>>;
234
+ }, z.core.$strip>;
235
235
  };
236
236
  readonly NOT_FOUND: {
237
237
  readonly status: 404;
238
- readonly data: zod_d_exports.z.ZodObject<{
239
- resource: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
240
- resourceId: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
241
- }, zod_d_exports.z.core.$strip>;
238
+ readonly data: z.ZodObject<{
239
+ resource: z.ZodOptional<z.ZodString>;
240
+ resourceId: z.ZodOptional<z.ZodString>;
241
+ }, z.core.$strip>;
242
242
  };
243
243
  readonly FORBIDDEN: {
244
244
  readonly status: 403;
245
- readonly data: zod_d_exports.z.ZodObject<{
246
- requiredPermissions: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodArray<zod_d_exports.z.ZodString>>;
247
- action: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
248
- }, zod_d_exports.z.core.$strip>;
245
+ readonly data: z.ZodObject<{
246
+ requiredPermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
247
+ action: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strip>;
249
249
  };
250
250
  readonly TIMEOUT: {
251
251
  readonly status: 504;
252
- readonly data: zod_d_exports.z.ZodObject<{
253
- timeoutMs: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
254
- operation: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
255
- retryable: zod_d_exports.z.ZodDefault<zod_d_exports.z.ZodBoolean>;
256
- }, zod_d_exports.z.core.$strip>;
252
+ readonly data: z.ZodObject<{
253
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
254
+ operation: z.ZodOptional<z.ZodString>;
255
+ retryable: z.ZodDefault<z.ZodBoolean>;
256
+ }, z.core.$strip>;
257
257
  };
258
258
  readonly CONNECTION_ERROR: {
259
259
  readonly status: 502;
260
- readonly data: zod_d_exports.z.ZodObject<{
261
- errorCode: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
262
- host: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
263
- port: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodNumber>;
264
- suggestion: zod_d_exports.z.ZodOptional<zod_d_exports.z.ZodString>;
265
- }, zod_d_exports.z.core.$strip>;
260
+ readonly data: z.ZodObject<{
261
+ errorCode: z.ZodOptional<z.ZodString>;
262
+ host: z.ZodOptional<z.ZodString>;
263
+ port: z.ZodOptional<z.ZodNumber>;
264
+ suggestion: z.ZodOptional<z.ZodString>;
265
+ }, z.core.$strip>;
266
266
  };
267
267
  };
268
268
  //#endregion
package/dist/errors.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { zod_exports } from "./zod.mjs";
1
+ import { z } from "./zod.mjs";
2
2
  import { ModuleFederationError, PluginRuntimeError, ValidationError, extractFromFiberFailure, formatORPCError, isRetryableORPCCode, toPluginRuntimeError, wrapORPCError } from "./runtime/errors.mjs";
3
3
 
4
4
  //#region src/errors.ts
@@ -47,10 +47,10 @@ const ERROR_PATTERNS = {
47
47
  */
48
48
  const UNAUTHORIZED = {
49
49
  status: 401,
50
- data: zod_exports.z.object({
51
- apiKeyProvided: zod_exports.z.boolean(),
52
- provider: zod_exports.z.string().optional(),
53
- authType: zod_exports.z.enum([
50
+ data: z.object({
51
+ apiKeyProvided: z.boolean(),
52
+ provider: z.string().optional(),
53
+ authType: z.enum([
54
54
  "apiKey",
55
55
  "oauth",
56
56
  "token"
@@ -59,11 +59,11 @@ const UNAUTHORIZED = {
59
59
  };
60
60
  const RATE_LIMITED = {
61
61
  status: 429,
62
- data: zod_exports.z.object({
63
- retryAfter: zod_exports.z.number().int().min(1),
64
- remainingRequests: zod_exports.z.number().int().min(0).optional(),
65
- resetTime: zod_exports.z.string().datetime().optional(),
66
- limitType: zod_exports.z.enum([
62
+ data: z.object({
63
+ retryAfter: z.number().int().min(1),
64
+ remainingRequests: z.number().int().min(0).optional(),
65
+ resetTime: z.string().datetime().optional(),
66
+ limitType: z.enum([
67
67
  "requests",
68
68
  "tokens",
69
69
  "bandwidth"
@@ -72,52 +72,52 @@ const RATE_LIMITED = {
72
72
  };
73
73
  const SERVICE_UNAVAILABLE = {
74
74
  status: 503,
75
- data: zod_exports.z.object({
76
- retryAfter: zod_exports.z.number().int().optional(),
77
- maintenanceWindow: zod_exports.z.boolean().default(false),
78
- estimatedUptime: zod_exports.z.string().datetime().optional()
75
+ data: z.object({
76
+ retryAfter: z.number().int().optional(),
77
+ maintenanceWindow: z.boolean().default(false),
78
+ estimatedUptime: z.string().datetime().optional()
79
79
  })
80
80
  };
81
81
  const BAD_REQUEST = {
82
82
  status: 400,
83
- data: zod_exports.z.object({
84
- invalidFields: zod_exports.z.array(zod_exports.z.string()).optional(),
85
- validationErrors: zod_exports.z.array(zod_exports.z.object({
86
- field: zod_exports.z.string(),
87
- message: zod_exports.z.string(),
88
- code: zod_exports.z.string().optional()
83
+ data: z.object({
84
+ invalidFields: z.array(z.string()).optional(),
85
+ validationErrors: z.array(z.object({
86
+ field: z.string(),
87
+ message: z.string(),
88
+ code: z.string().optional()
89
89
  })).optional()
90
90
  })
91
91
  };
92
92
  const NOT_FOUND = {
93
93
  status: 404,
94
- data: zod_exports.z.object({
95
- resource: zod_exports.z.string().optional(),
96
- resourceId: zod_exports.z.string().optional()
94
+ data: z.object({
95
+ resource: z.string().optional(),
96
+ resourceId: z.string().optional()
97
97
  })
98
98
  };
99
99
  const FORBIDDEN = {
100
100
  status: 403,
101
- data: zod_exports.z.object({
102
- requiredPermissions: zod_exports.z.array(zod_exports.z.string()).optional(),
103
- action: zod_exports.z.string().optional()
101
+ data: z.object({
102
+ requiredPermissions: z.array(z.string()).optional(),
103
+ action: z.string().optional()
104
104
  })
105
105
  };
106
106
  const TIMEOUT = {
107
107
  status: 504,
108
- data: zod_exports.z.object({
109
- timeoutMs: zod_exports.z.number().int().min(0).optional(),
110
- operation: zod_exports.z.string().optional(),
111
- retryable: zod_exports.z.boolean().default(true)
108
+ data: z.object({
109
+ timeoutMs: z.number().int().min(0).optional(),
110
+ operation: z.string().optional(),
111
+ retryable: z.boolean().default(true)
112
112
  })
113
113
  };
114
114
  const CONNECTION_ERROR = {
115
115
  status: 502,
116
- data: zod_exports.z.object({
117
- errorCode: zod_exports.z.string().optional(),
118
- host: zod_exports.z.string().optional(),
119
- port: zod_exports.z.number().int().optional(),
120
- suggestion: zod_exports.z.string().optional()
116
+ data: z.object({
117
+ errorCode: z.string().optional(),
118
+ host: z.string().optional(),
119
+ port: z.number().int().optional(),
120
+ suggestion: z.string().optional()
121
121
  })
122
122
  };
123
123
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n CONNECTION_REFUSED: [\"ECONNREFUSED\"],\n HOST_NOT_FOUND: [\"ENOTFOUND\", \"EHOSTUNREACH\"],\n TIMEOUT: [\"ETIMEDOUT\", \"ESOCKETTIMEDOUT\", \"timeout\"],\n CONNECTION_RESET: [\"ECONNRESET\", \"EPIPE\"],\n PERMISSION: [\"EACCES\", \"EPERM\", \"permission denied\"],\n AUTH: [\"401\", \"unauthorized\", \"authentication failed\"],\n RATE_LIMITED: [\"429\", \"too many requests\", \"rate limit\"],\n SERVICE_UNAVAILABLE: [\"503\", \"service unavailable\"],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import individually or use the grouped PluginErrors export.\n *\n * @example\n * ```typescript\n * import { NOT_FOUND, FORBIDDEN, UNAUTHORIZED } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors({ NOT_FOUND, FORBIDDEN, UNAUTHORIZED })\n * });\n * ```\n */\n\nexport const UNAUTHORIZED = {\n status: 401,\n data: z.object({\n apiKeyProvided: z.boolean(),\n provider: z.string().optional(),\n authType: z.enum([\"apiKey\", \"oauth\", \"token\"]).optional(),\n }),\n} as const;\n\nexport const RATE_LIMITED = {\n status: 429,\n data: z.object({\n retryAfter: z.number().int().min(1),\n remainingRequests: z.number().int().min(0).optional(),\n resetTime: z.string().datetime().optional(),\n limitType: z.enum([\"requests\", \"tokens\", \"bandwidth\"]).optional(),\n }),\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n status: 503,\n data: z.object({\n retryAfter: z.number().int().optional(),\n maintenanceWindow: z.boolean().default(false),\n estimatedUptime: z.string().datetime().optional(),\n }),\n} as const;\n\nexport const BAD_REQUEST = {\n status: 400,\n data: z.object({\n invalidFields: z.array(z.string()).optional(),\n validationErrors: z\n .array(\n z.object({\n field: z.string(),\n message: z.string(),\n code: z.string().optional(),\n }),\n )\n .optional(),\n }),\n} as const;\n\nexport const NOT_FOUND = {\n status: 404,\n data: z.object({\n resource: z.string().optional(),\n resourceId: z.string().optional(),\n }),\n} as const;\n\nexport const FORBIDDEN = {\n status: 403,\n data: z.object({\n requiredPermissions: z.array(z.string()).optional(),\n action: z.string().optional(),\n }),\n} as const;\n\nexport const TIMEOUT = {\n status: 504,\n data: z.object({\n timeoutMs: z.number().int().min(0).optional(),\n operation: z.string().optional(),\n retryable: z.boolean().default(true),\n }),\n} as const;\n\nexport const CONNECTION_ERROR = {\n status: 502,\n data: z.object({\n errorCode: z.string().optional(),\n host: z.string().optional(),\n port: z.number().int().optional(),\n suggestion: z.string().optional(),\n }),\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n UNAUTHORIZED,\n RATE_LIMITED,\n SERVICE_UNAVAILABLE,\n BAD_REQUEST,\n NOT_FOUND,\n FORBIDDEN,\n TIMEOUT,\n CONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n extractFromFiberFailure,\n formatORPCError,\n isRetryableORPCCode,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;AAKA,MAAa,iBAAiB;CAC5B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACpD;;;;;;;;;;;;;;;AAiBD,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,gBAAgBA,cAAE,SAAS;EAC3B,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,UAAUA,cAAE,KAAK;GAAC;GAAU;GAAS;GAAQ,CAAC,CAAC,UAAU;EAC1D,CAAC;CACH;AAED,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,YAAYA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;EACnC,mBAAmBA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EACrD,WAAWA,cAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAC3C,WAAWA,cAAE,KAAK;GAAC;GAAY;GAAU;GAAY,CAAC,CAAC,UAAU;EAClE,CAAC;CACH;AAED,MAAa,sBAAsB;CACjC,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,YAAYA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACvC,mBAAmBA,cAAE,SAAS,CAAC,QAAQ,MAAM;EAC7C,iBAAiBA,cAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAClD,CAAC;CACH;AAED,MAAa,cAAc;CACzB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,eAAeA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EAC7C,kBAAkBA,cACf,MACCA,cAAE,OAAO;GACP,OAAOA,cAAE,QAAQ;GACjB,SAASA,cAAE,QAAQ;GACnB,MAAMA,cAAE,QAAQ,CAAC,UAAU;GAC5B,CAAC,CACH,CACA,UAAU;EACd,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,UAAUA,cAAE,QAAQ,CAAC,UAAU;EAC/B,YAAYA,cAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,qBAAqBA,cAAE,MAAMA,cAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,QAAQA,cAAE,QAAQ,CAAC,UAAU;EAC9B,CAAC;CACH;AAED,MAAa,UAAU;CACrB,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,WAAWA,cAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,WAAWA,cAAE,SAAS,CAAC,QAAQ,KAAK;EACrC,CAAC;CACH;AAED,MAAa,mBAAmB;CAC9B,QAAQ;CACR,MAAMA,cAAE,OAAO;EACb,WAAWA,cAAE,QAAQ,CAAC,UAAU;EAChC,MAAMA,cAAE,QAAQ,CAAC,UAAU;EAC3B,MAAMA,cAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,YAAYA,cAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;;;;;AAMD,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,qBAAqB"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { z } from \"./zod\";\n\n/**\n * Error pattern constants for categorizing infrastructure errors\n */\nexport const ERROR_PATTERNS = {\n CONNECTION_REFUSED: [\"ECONNREFUSED\"],\n HOST_NOT_FOUND: [\"ENOTFOUND\", \"EHOSTUNREACH\"],\n TIMEOUT: [\"ETIMEDOUT\", \"ESOCKETTIMEDOUT\", \"timeout\"],\n CONNECTION_RESET: [\"ECONNRESET\", \"EPIPE\"],\n PERMISSION: [\"EACCES\", \"EPERM\", \"permission denied\"],\n AUTH: [\"401\", \"unauthorized\", \"authentication failed\"],\n RATE_LIMITED: [\"429\", \"too many requests\", \"rate limit\"],\n SERVICE_UNAVAILABLE: [\"503\", \"service unavailable\"],\n} as const;\n\n/**\n * Common error schemas for plugin contracts.\n * Import individually or use the grouped PluginErrors export.\n *\n * @example\n * ```typescript\n * import { NOT_FOUND, FORBIDDEN, UNAUTHORIZED } from \"every-plugin/errors\";\n *\n * export const contract = oc.router({\n * getData: oc.route(...)\n * .errors({ NOT_FOUND, FORBIDDEN, UNAUTHORIZED })\n * });\n * ```\n */\n\nexport const UNAUTHORIZED = {\n status: 401,\n data: z.object({\n apiKeyProvided: z.boolean(),\n provider: z.string().optional(),\n authType: z.enum([\"apiKey\", \"oauth\", \"token\"]).optional(),\n }),\n} as const;\n\nexport const RATE_LIMITED = {\n status: 429,\n data: z.object({\n retryAfter: z.number().int().min(1),\n remainingRequests: z.number().int().min(0).optional(),\n resetTime: z.string().datetime().optional(),\n limitType: z.enum([\"requests\", \"tokens\", \"bandwidth\"]).optional(),\n }),\n} as const;\n\nexport const SERVICE_UNAVAILABLE = {\n status: 503,\n data: z.object({\n retryAfter: z.number().int().optional(),\n maintenanceWindow: z.boolean().default(false),\n estimatedUptime: z.string().datetime().optional(),\n }),\n} as const;\n\nexport const BAD_REQUEST = {\n status: 400,\n data: z.object({\n invalidFields: z.array(z.string()).optional(),\n validationErrors: z\n .array(\n z.object({\n field: z.string(),\n message: z.string(),\n code: z.string().optional(),\n }),\n )\n .optional(),\n }),\n} as const;\n\nexport const NOT_FOUND = {\n status: 404,\n data: z.object({\n resource: z.string().optional(),\n resourceId: z.string().optional(),\n }),\n} as const;\n\nexport const FORBIDDEN = {\n status: 403,\n data: z.object({\n requiredPermissions: z.array(z.string()).optional(),\n action: z.string().optional(),\n }),\n} as const;\n\nexport const TIMEOUT = {\n status: 504,\n data: z.object({\n timeoutMs: z.number().int().min(0).optional(),\n operation: z.string().optional(),\n retryable: z.boolean().default(true),\n }),\n} as const;\n\nexport const CONNECTION_ERROR = {\n status: 502,\n data: z.object({\n errorCode: z.string().optional(),\n host: z.string().optional(),\n port: z.number().int().optional(),\n suggestion: z.string().optional(),\n }),\n} as const;\n\n/**\n * Grouped export for all plugin errors.\n * Use individual imports for cleaner code.\n */\nexport const PluginErrors = {\n UNAUTHORIZED,\n RATE_LIMITED,\n SERVICE_UNAVAILABLE,\n BAD_REQUEST,\n NOT_FOUND,\n FORBIDDEN,\n TIMEOUT,\n CONNECTION_ERROR,\n} as const;\n\n/**\n * @deprecated Use individual imports or PluginErrors instead\n */\nexport const CommonPluginErrors = PluginErrors;\n\nexport {\n extractFromFiberFailure,\n formatORPCError,\n isRetryableORPCCode,\n ModuleFederationError,\n PluginRuntimeError,\n toPluginRuntimeError,\n ValidationError,\n wrapORPCError,\n} from \"./runtime/errors\";\n"],"mappings":";;;;;;;AAKA,MAAa,iBAAiB;CAC5B,oBAAoB,CAAC,eAAe;CACpC,gBAAgB,CAAC,aAAa,eAAe;CAC7C,SAAS;EAAC;EAAa;EAAmB;EAAU;CACpD,kBAAkB,CAAC,cAAc,QAAQ;CACzC,YAAY;EAAC;EAAU;EAAS;EAAoB;CACpD,MAAM;EAAC;EAAO;EAAgB;EAAwB;CACtD,cAAc;EAAC;EAAO;EAAqB;EAAa;CACxD,qBAAqB,CAAC,OAAO,sBAAsB;CACpD;;;;;;;;;;;;;;;AAiBD,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,gBAAgB,EAAE,SAAS;EAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,UAAU,EAAE,KAAK;GAAC;GAAU;GAAS;GAAQ,CAAC,CAAC,UAAU;EAC1D,CAAC;CACH;AAED,MAAa,eAAe;CAC1B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;EACnC,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EACrD,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAC3C,WAAW,EAAE,KAAK;GAAC;GAAY;GAAU;GAAY,CAAC,CAAC,UAAU;EAClE,CAAC;CACH;AAED,MAAa,sBAAsB;CACjC,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACvC,mBAAmB,EAAE,SAAS,CAAC,QAAQ,MAAM;EAC7C,iBAAiB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;EAClD,CAAC;CACH;AAED,MAAa,cAAc;CACzB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAC7C,kBAAkB,EACf,MACC,EAAE,OAAO;GACP,OAAO,EAAE,QAAQ;GACjB,SAAS,EAAE,QAAQ;GACnB,MAAM,EAAE,QAAQ,CAAC,UAAU;GAC5B,CAAC,CACH,CACA,UAAU;EACd,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,UAAU,EAAE,QAAQ,CAAC,UAAU;EAC/B,YAAY,EAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;AAED,MAAa,YAAY;CACvB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,qBAAqB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EACnD,QAAQ,EAAE,QAAQ,CAAC,UAAU;EAC9B,CAAC;CACH;AAED,MAAa,UAAU;CACrB,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,WAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,WAAW,EAAE,SAAS,CAAC,QAAQ,KAAK;EACrC,CAAC;CACH;AAED,MAAa,mBAAmB;CAC9B,QAAQ;CACR,MAAM,EAAE,OAAO;EACb,WAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,MAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACjC,YAAY,EAAE,QAAQ,CAAC,UAAU;EAClC,CAAC;CACH;;;;;AAMD,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["Effect","extractFromFiberFailure","ORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Context, Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Effect, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n formatORPCError(error);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;;AA+GA,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;CAED,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,EAAE,EACO;AAG5C,WAFa,OAAO,qBAAqBA,cAAO,QAAQ,EAAE,CAAU,GAExD,cAAc,QAAa,CAAC,KACtCA,cAAO,KAAK,SACVA,cAAO,WAAW;AAChB,SAAK,QAAQ;KACb,CACH,EACDA,cAAO,UAAU,KAAK,MAAe,EACrCA,cAAO,UAAU,UAAU,MAAiB,CAC7C;;EAGH,WAAuC;GACrC,MAAM,OAAO;AACb,UAAOA,cAAO,IAAI,aAAa;AAC7B,QAAI,OAAO,YAAY,KAAK,MAC1B,QAAO,OACJ,SAAS,KAAK,MAAM,CACpB,KACCA,cAAO,UAAU,UACfA,cAAO,WAAW,mCAAmC,KAAK,MAAM,MAAM,CACvE,CACF;AAEL,SAAK,QAAQ;KACb;;EAGJ,aAAa,MAAqC;GAChD,MAAM,mCAAiB,OAAO,SAAS,CAAC,UAA0C;GAClF,MAAM,6CAA2B,UAAmB;IAClD,MAAM,YAAYC,uCAAwB,MAAM;AAEhD,QAAI,cAAc,SAAS,qBAAqBC,yBAC9C,OAAM;AAGR,mCAAgB,MAAM;AACtB,UAAM;KACN;GAEF,MAAM,UAAW,KAAa,IAAI,gBAAgB;AAElD,UADe,OAAO,aAAa,MAAM,QAAe;;;CAK5D,MAAM,oBAAoB;AAU1B,mBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;AAED,QAAO;;AAaT,SAAgB,cAA6E;AAC3F,SAOE,WACG,aAAyD,OAAc;;AAG9E,aAAa,cAAc"}
1
+ {"version":3,"file":"plugin.cjs","names":["Effect","extractFromFiberFailure","ORPCError"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Context, Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Effect, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n formatORPCError(error);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;;AA+GA,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;CAED,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,EAAE,EACO;AAG5C,WAFa,OAAO,qBAAqBA,cAAO,QAAQ,EAAE,CAAU,GAExD,cAAc,QAAa,CAAC,KACtCA,cAAO,KAAK,SACVA,cAAO,WAAW;AAChB,SAAK,QAAQ;KACb,CACH,EACDA,cAAO,UAAU,KAAK,MAAe,EACrCA,cAAO,UAAU,UAAU,MAAiB,CAC7C;;EAGH,WAAuC;GACrC,MAAM,OAAO;AACb,UAAOA,cAAO,IAAI,aAAa;AAC7B,QAAI,OAAO,YAAY,KAAK,MAC1B,QAAO,OACJ,SAAS,KAAK,MAAM,CACpB,KACCA,cAAO,UAAU,UACfA,cAAO,WAAW,mCAAmC,KAAK,MAAM,MAAM,CACvE,CACF;AAEL,SAAK,QAAQ;KACb;;EAGJ,aAAa,MAAqC;GAChD,MAAM,mCAAiB,OAAO,SAAS,CAAC,UAA0C;GAClF,MAAM,6CAA2B,UAAmB;IAClD,MAAM,YAAYC,uCAAwB,MAAM;AAEhD,QAAI,cAAc,SAAS,qBAAqBC,yBAC9C,OAAM;AAGR,mCAAgB,MAAM;AACtB,UAAM;KACN;GAEF,MAAM,UAAW,KAAa,IAAI,gBAAgB;AAElD,UADe,OAAO,aAAa,MAAM,QAC5B;;;CAIjB,MAAM,oBAAoB;AAU1B,mBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;AAED,QAAO;;AAaT,SAAgB,cAA6E;AAC3F,SAOE,WACG,aAAyD,OAAc;;AAG9E,aAAa,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Context, Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Effect, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n formatORPCError(error);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AA+GA,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;CAED,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,EAAE,EACO;AAG5C,WAFa,OAAO,qBAAqB,OAAO,QAAQ,EAAE,CAAU,GAExD,cAAc,QAAa,CAAC,KACtC,OAAO,KAAK,SACV,OAAO,WAAW;AAChB,SAAK,QAAQ;KACb,CACH,EACD,OAAO,UAAU,KAAK,MAAe,EACrC,OAAO,UAAU,UAAU,MAAiB,CAC7C;;EAGH,WAAuC;GACrC,MAAM,OAAO;AACb,UAAO,OAAO,IAAI,aAAa;AAC7B,QAAI,OAAO,YAAY,KAAK,MAC1B,QAAO,OACJ,SAAS,KAAK,MAAM,CACpB,KACC,OAAO,UAAU,UACf,OAAO,WAAW,mCAAmC,KAAK,MAAM,MAAM,CACvE,CACF;AAEL,SAAK,QAAQ;KACb;;EAGJ,aAAa,MAAqC;GAChD,MAAM,OAAO,UAAU,OAAO,SAAS,CAAC,UAA0C;GAClF,MAAM,kBAAkB,SAAS,UAAmB;IAClD,MAAM,YAAY,wBAAwB,MAAM;AAEhD,QAAI,cAAc,SAAS,qBAAqB,UAC9C,OAAM;AAGR,oBAAgB,MAAM;AACtB,UAAM;KACN;GAEF,MAAM,UAAW,KAAa,IAAI,gBAAgB;AAElD,UADe,OAAO,aAAa,MAAM,QAAe;;;CAK5D,MAAM,oBAAoB;AAU1B,mBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;AAED,QAAO;;AAaT,SAAgB,cAA6E;AAC3F,SAOE,WACG,aAAyD,OAAc;;AAG9E,aAAa,cAAc"}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { AnyContractRouter, AnySchema, InferSchemaOutput } from \"@orpc/contract\";\nimport { ORPCError } from \"@orpc/contract\";\nimport type { Context, Implementer, Router } from \"@orpc/server\";\nimport { implement, onError } from \"@orpc/server\";\nimport { Effect, type Scope } from \"effect\";\nimport { extractFromFiberFailure, formatORPCError } from \"./runtime/errors\";\n\ntype ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;\n\nexport type PluginConfigFor<\n V extends AnySchema,\n S extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n> = {\n variables: V;\n secrets: S;\n context: TRequestContext;\n};\n\ntype PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {\n variables: InferSchemaOutput<V>;\n secrets: InferSchemaOutput<S>;\n};\n\ntype PluginDefinition<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context,\n P extends Record<string, unknown>,\n> = {\n variables: V;\n secrets: S;\n contract: TContract;\n context?: TRequestContext;\n initialize?: (\n config: PluginInitializeInput<V, S>,\n plugins: P,\n ) => Effect.Effect<TDeps, Error, Scope.Scope>;\n createRouter: (\n deps: TDeps,\n builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,\n ) => Router<TContract, any>;\n shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;\n};\n\n/**\n * Loaded plugin with static binding property\n */\nexport interface LoadedPluginWithBinding<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: TVariables;\n secrets: TSecrets;\n context: TRequestContext;\n };\n}\n\n/**\n * Plugin interface\n */\nexport interface Plugin<\n TContract extends AnyContractRouter,\n TVariables extends AnySchema,\n TSecrets extends AnySchema,\n TRequestContext extends AnySchema | undefined,\n TDeps extends Context = Record<never, never>,\n> {\n readonly id: string;\n readonly contract: TContract;\n readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;\n\n initialize(\n config: PluginInitializeInput<TVariables, TSecrets>,\n plugins: Record<string, unknown>,\n ): Effect.Effect<TDeps, unknown, Scope.Scope>;\n\n shutdown(): Effect.Effect<void, never>;\n\n /**\n * Creates the strongly-typed oRPC router for this plugin.\n * The router's procedure types are inferred directly from the contract.\n * @param deps The initialized plugin dependencies\n * @returns A router with procedures matching the plugin's contract\n */\n createRouter(deps: TDeps): Router<TContract, any>;\n}\n\nexport interface CreatePluginFn {\n <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\n withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;\n}\n\nexport const createPlugin: CreatePluginFn = function createPlugin<\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n P extends Record<string, unknown> = Record<string, never>,\n>(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {\n const configSchema: PluginConfigFor<V, S, TRequestContext> = {\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {\n /** set during instantiation - registry key */\n id!: string;\n readonly contract = config.contract;\n readonly configSchema = configSchema;\n\n private _deps: TDeps | null = null;\n\n initialize(\n pluginConfig: PluginInitializeInput<V, S>,\n plugins: Record<string, unknown> = {},\n ): Effect.Effect<TDeps, unknown, Scope.Scope> {\n const init = config.initialize ?? (() => Effect.succeed({} as TDeps));\n\n return init(pluginConfig, plugins as P).pipe(\n Effect.tap((deps) =>\n Effect.sync(() => {\n this._deps = deps;\n }),\n ),\n Effect.map(() => this._deps as TDeps),\n Effect.mapError((error) => error as unknown),\n );\n }\n\n shutdown(): Effect.Effect<void, never> {\n const self = this;\n return Effect.gen(function* () {\n if (config.shutdown && self._deps) {\n yield* config\n .shutdown(self._deps)\n .pipe(\n Effect.catchAll((error) =>\n Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),\n ),\n );\n }\n self._deps = null;\n });\n }\n\n createRouter(deps: TDeps): Router<TContract, any> {\n const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();\n const errorMiddleware = onError((error: unknown) => {\n const unwrapped = extractFromFiberFailure(error);\n\n if (unwrapped !== error && unwrapped instanceof ORPCError) {\n throw unwrapped;\n }\n\n formatORPCError(error);\n throw error;\n }) as any;\n\n const builder = (base as any).use(errorMiddleware);\n const router = config.createRouter(deps, builder as any);\n return router as Router<TContract, any>;\n }\n }\n\n const PluginConstructor = CreatedPlugin as unknown as {\n new (): Plugin<TContract, V, S, TRequestContext, TDeps>;\n binding: {\n contract: TContract;\n variables: V;\n secrets: S;\n context: TRequestContext;\n };\n };\n\n PluginConstructor.binding = {\n contract: config.contract,\n variables: config.variables,\n secrets: config.secrets,\n context: config.context as TRequestContext,\n };\n\n return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n};\n\nexport type CreatePluginWithPlugins<P extends Record<string, unknown>> = <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n>(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;\n\nexport function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {\n return <\n V extends AnySchema,\n S extends AnySchema,\n TContract extends AnyContractRouter,\n TRequestContext extends AnySchema | undefined = undefined,\n TDeps extends Context = Record<never, never>,\n >(\n config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,\n ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);\n}\n\ncreatePlugin.withPlugins = withPlugins;\n"],"mappings":";;;;;;AA+GA,MAAa,eAA+B,SAAS,aAOnD,QAAsE;CACtE,MAAM,eAAuD;EAC3D,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;CAED,MAAM,cAAyE;;EAE7E;EACA,AAAS,WAAW,OAAO;EAC3B,AAAS,eAAe;EAExB,AAAQ,QAAsB;EAE9B,WACE,cACA,UAAmC,EAAE,EACO;AAG5C,WAFa,OAAO,qBAAqB,OAAO,QAAQ,EAAE,CAAU,GAExD,cAAc,QAAa,CAAC,KACtC,OAAO,KAAK,SACV,OAAO,WAAW;AAChB,SAAK,QAAQ;KACb,CACH,EACD,OAAO,UAAU,KAAK,MAAe,EACrC,OAAO,UAAU,UAAU,MAAiB,CAC7C;;EAGH,WAAuC;GACrC,MAAM,OAAO;AACb,UAAO,OAAO,IAAI,aAAa;AAC7B,QAAI,OAAO,YAAY,KAAK,MAC1B,QAAO,OACJ,SAAS,KAAK,MAAM,CACpB,KACC,OAAO,UAAU,UACf,OAAO,WAAW,mCAAmC,KAAK,MAAM,MAAM,CACvE,CACF;AAEL,SAAK,QAAQ;KACb;;EAGJ,aAAa,MAAqC;GAChD,MAAM,OAAO,UAAU,OAAO,SAAS,CAAC,UAA0C;GAClF,MAAM,kBAAkB,SAAS,UAAmB;IAClD,MAAM,YAAY,wBAAwB,MAAM;AAEhD,QAAI,cAAc,SAAS,qBAAqB,UAC9C,OAAM;AAGR,oBAAgB,MAAM;AACtB,UAAM;KACN;GAEF,MAAM,UAAW,KAAa,IAAI,gBAAgB;AAElD,UADe,OAAO,aAAa,MAAM,QAC5B;;;CAIjB,MAAM,oBAAoB;AAU1B,mBAAkB,UAAU;EAC1B,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,SAAS,OAAO;EACjB;AAED,QAAO;;AAaT,SAAgB,cAA6E;AAC3F,SAOE,WACG,aAAyD,OAAc;;AAG9E,aAAa,cAAc"}