@temporary-name/server 1.9.3-alpha.f9f5ce625d5edee78250b87b3a64f1d9760c2244 → 1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3
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/adapters/aws-lambda/index.d.mts +5 -6
- package/dist/adapters/aws-lambda/index.d.ts +5 -6
- package/dist/adapters/aws-lambda/index.mjs +5 -6
- package/dist/adapters/fetch/index.d.mts +8 -85
- package/dist/adapters/fetch/index.d.ts +8 -85
- package/dist/adapters/fetch/index.mjs +17 -157
- package/dist/adapters/node/index.d.mts +9 -63
- package/dist/adapters/node/index.d.ts +9 -63
- package/dist/adapters/node/index.mjs +15 -122
- package/dist/handler/index.d.mts +28 -0
- package/dist/handler/index.d.ts +28 -0
- package/dist/handler/index.mjs +8 -0
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +356 -206
- package/dist/index.d.ts +356 -206
- package/dist/index.mjs +466 -163
- package/dist/openapi/index.d.mts +18 -53
- package/dist/openapi/index.d.ts +18 -53
- package/dist/openapi/index.mjs +391 -368
- package/dist/shared/server.-tR-4rQ5.mjs +523 -0
- package/dist/shared/server.BwcJq6aP.d.mts +808 -0
- package/dist/shared/server.BwcJq6aP.d.ts +808 -0
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CjPiuQYH.d.mts +51 -0
- package/dist/shared/server.CjPiuQYH.d.ts +51 -0
- package/dist/shared/server.D2NXNHIf.mjs +156 -0
- package/dist/shared/server.Deg5phAY.d.ts +39 -0
- package/dist/shared/server.DvgWQUGK.mjs +496 -0
- package/dist/shared/server.hAH-LVh_.d.mts +39 -0
- package/dist/shared/server.n1y5fcVQ.mjs +315 -0
- package/package.json +13 -31
- package/dist/adapters/standard/index.d.mts +0 -30
- package/dist/adapters/standard/index.d.ts +0 -30
- package/dist/adapters/standard/index.mjs +0 -9
- package/dist/plugins/index.d.mts +0 -84
- package/dist/plugins/index.d.ts +0 -84
- package/dist/plugins/index.mjs +0 -122
- package/dist/shared/server.7aL9gcoU.d.mts +0 -23
- package/dist/shared/server.BL2R5jcp.d.mts +0 -228
- package/dist/shared/server.BL2R5jcp.d.ts +0 -228
- package/dist/shared/server.CVBLzkro.mjs +0 -255
- package/dist/shared/server.ClhVCxfg.mjs +0 -413
- package/dist/shared/server.D6Qs_UcF.d.mts +0 -55
- package/dist/shared/server.DFptr1Nz.d.ts +0 -23
- package/dist/shared/server.DpoO_ER_.d.ts +0 -55
- package/dist/shared/server.JtIZ8YG7.mjs +0 -237
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { isObject, NullProtoObj, fallbackContractConfig, stringifyJSON, isAsyncIteratorObject, tryDecodeURIComponent, toHttpPath, runWithSpan, ORPC_NAME, asyncIteratorWithSpan, setSpanError } from '@temporary-name/shared';
|
|
2
|
+
import { e as encodeError, i as isAPIErrorStatus, s as standardizeHTTPPath, A as APIError, B as BadRequestError, t as toAPIError$1 } from './server.DvgWQUGK.mjs';
|
|
3
|
+
import { c as createProcedureClient } from './server.D2NXNHIf.mjs';
|
|
4
|
+
import { toAPIError, traverseContractProcedures, getLazyMeta, unlazy } from '@temporary-name/server';
|
|
5
|
+
import { mapEventIterator, ErrorEvent } from '@temporary-name/standard-server';
|
|
6
|
+
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
7
|
+
|
|
8
|
+
function bracketNotationDeserialize(serialized, { maxArrayIndex = 9999 } = {}) {
|
|
9
|
+
if (serialized.length === 0) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
13
|
+
const ref = { value: [] };
|
|
14
|
+
for (const [path, value] of serialized) {
|
|
15
|
+
const segments = parsePath(path);
|
|
16
|
+
let currentRef = ref;
|
|
17
|
+
let nextSegment = "value";
|
|
18
|
+
segments.forEach((segment, i) => {
|
|
19
|
+
if (!Array.isArray(currentRef[nextSegment]) && !isObject(currentRef[nextSegment])) {
|
|
20
|
+
currentRef[nextSegment] = [];
|
|
21
|
+
}
|
|
22
|
+
if (i !== segments.length - 1) {
|
|
23
|
+
if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment, maxArrayIndex)) {
|
|
24
|
+
if (arrayPushStyles.has(currentRef[nextSegment])) {
|
|
25
|
+
arrayPushStyles.delete(currentRef[nextSegment]);
|
|
26
|
+
currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
|
|
27
|
+
} else {
|
|
28
|
+
currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
if (Array.isArray(currentRef[nextSegment])) {
|
|
33
|
+
if (segment === "") {
|
|
34
|
+
if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) {
|
|
35
|
+
currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
if (arrayPushStyles.has(currentRef[nextSegment])) {
|
|
39
|
+
arrayPushStyles.delete(currentRef[nextSegment]);
|
|
40
|
+
currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
|
|
41
|
+
} else if (!isValidArrayIndex(segment, maxArrayIndex)) {
|
|
42
|
+
currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
currentRef = currentRef[nextSegment];
|
|
48
|
+
nextSegment = segment;
|
|
49
|
+
});
|
|
50
|
+
if (Array.isArray(currentRef) && nextSegment === "") {
|
|
51
|
+
arrayPushStyles.add(currentRef);
|
|
52
|
+
currentRef.push(value);
|
|
53
|
+
} else if (nextSegment in currentRef) {
|
|
54
|
+
if (Array.isArray(currentRef[nextSegment])) {
|
|
55
|
+
currentRef[nextSegment].push(value);
|
|
56
|
+
} else {
|
|
57
|
+
currentRef[nextSegment] = [currentRef[nextSegment], value];
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
currentRef[nextSegment] = value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return ref.value;
|
|
64
|
+
}
|
|
65
|
+
function parsePath(path) {
|
|
66
|
+
const segments = [];
|
|
67
|
+
let inBrackets = false;
|
|
68
|
+
let currentSegment = "";
|
|
69
|
+
let backslashCount = 0;
|
|
70
|
+
for (let i = 0; i < path.length; i++) {
|
|
71
|
+
const char = path[i];
|
|
72
|
+
const nextChar = path[i + 1];
|
|
73
|
+
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[") && backslashCount % 2 === 0) {
|
|
74
|
+
if (nextChar === void 0) {
|
|
75
|
+
inBrackets = false;
|
|
76
|
+
}
|
|
77
|
+
segments.push(currentSegment);
|
|
78
|
+
currentSegment = "";
|
|
79
|
+
i++;
|
|
80
|
+
} else if (segments.length === 0 && char === "[" && backslashCount % 2 === 0) {
|
|
81
|
+
inBrackets = true;
|
|
82
|
+
segments.push(currentSegment);
|
|
83
|
+
currentSegment = "";
|
|
84
|
+
} else if (char === "\\") {
|
|
85
|
+
backslashCount++;
|
|
86
|
+
} else {
|
|
87
|
+
currentSegment += "\\".repeat(backslashCount / 2) + char;
|
|
88
|
+
backslashCount = 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return inBrackets || segments.length === 0 ? [path] : segments;
|
|
92
|
+
}
|
|
93
|
+
function isValidArrayIndex(value, maxIndex) {
|
|
94
|
+
return /^0$|^[1-9]\d*$/.test(value) && Number(value) <= maxIndex;
|
|
95
|
+
}
|
|
96
|
+
function arrayToObject(array) {
|
|
97
|
+
const obj = new NullProtoObj();
|
|
98
|
+
array.forEach((item, i) => {
|
|
99
|
+
obj[i] = item;
|
|
100
|
+
});
|
|
101
|
+
return obj;
|
|
102
|
+
}
|
|
103
|
+
function pushStyleArrayToObject(array) {
|
|
104
|
+
const obj = new NullProtoObj();
|
|
105
|
+
obj[""] = array.length === 1 ? array[0] : array;
|
|
106
|
+
return obj;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function decode(request, pathParams) {
|
|
110
|
+
return {
|
|
111
|
+
path: pathParams ?? {},
|
|
112
|
+
query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
|
|
113
|
+
headers: request.headers,
|
|
114
|
+
body: await request.body() ?? {}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function asyncSafeSerialize(data) {
|
|
118
|
+
if (isAsyncIteratorObject(data)) {
|
|
119
|
+
return mapEventIterator(data, {
|
|
120
|
+
value: async (value) => value,
|
|
121
|
+
error: async (e) => {
|
|
122
|
+
return new ErrorEvent({
|
|
123
|
+
data: encodeError(toAPIError(e))["body"],
|
|
124
|
+
cause: e
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
function encode(output, procedure) {
|
|
132
|
+
const successStatus = fallbackContractConfig(
|
|
133
|
+
"defaultSuccessStatus",
|
|
134
|
+
procedure["~orpc"].route.successStatus
|
|
135
|
+
);
|
|
136
|
+
const outputStructure = fallbackContractConfig(
|
|
137
|
+
"defaultOutputStructure",
|
|
138
|
+
procedure["~orpc"].route.outputStructure
|
|
139
|
+
);
|
|
140
|
+
if (outputStructure === "compact") {
|
|
141
|
+
return {
|
|
142
|
+
status: successStatus,
|
|
143
|
+
headers: new Headers(),
|
|
144
|
+
body: asyncSafeSerialize(output)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (!isDetailedOutput(output)) {
|
|
148
|
+
throw new Error(`
|
|
149
|
+
Invalid "detailed" output structure:
|
|
150
|
+
\u2022 Expected an object with optional properties:
|
|
151
|
+
- status (number 200-399)
|
|
152
|
+
- headers (Record<string, string | string[]>)
|
|
153
|
+
- body (any)
|
|
154
|
+
\u2022 No extra keys allowed.
|
|
155
|
+
|
|
156
|
+
Actual value:
|
|
157
|
+
${stringifyJSON(output)}
|
|
158
|
+
`);
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
status: output.status ?? successStatus,
|
|
162
|
+
headers: output.headers ?? new Headers(),
|
|
163
|
+
body: asyncSafeSerialize(output.body)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function isDetailedOutput(output) {
|
|
167
|
+
if (!isObject(output)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (output.headers && !isObject(output.headers)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isAPIErrorStatus(output.status))) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function resolveFriendlyStandardHandleOptions(options) {
|
|
180
|
+
return {
|
|
181
|
+
...options,
|
|
182
|
+
context: options.context ?? {}
|
|
183
|
+
// Context only optional if all fields are optional
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function toRou3Pattern(path) {
|
|
187
|
+
return standardizeHTTPPath(path).replace(/\/\{\+([^}]+)\}/g, "/**:$1").replace(/\/\{([^}]+)\}/g, "/:$1");
|
|
188
|
+
}
|
|
189
|
+
function decodeParams(params) {
|
|
190
|
+
return Object.fromEntries(
|
|
191
|
+
Object.entries(params).map(([key, value]) => [key, tryDecodeURIComponent(value)])
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
class StandardOpenAPIMatcher {
|
|
196
|
+
tree = createRouter();
|
|
197
|
+
pendingRouters = [];
|
|
198
|
+
init(router, path = []) {
|
|
199
|
+
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
|
200
|
+
const { path: path2, contract } = traverseOptions;
|
|
201
|
+
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
202
|
+
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
203
|
+
addRoute(this.tree, method, httpPath, {
|
|
204
|
+
path: path2,
|
|
205
|
+
// cast is safe because router is typed as Router (not ContractRouter)
|
|
206
|
+
procedure: contract,
|
|
207
|
+
router
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
this.pendingRouters.push(
|
|
211
|
+
...laziedOptions.map((option) => ({
|
|
212
|
+
...option,
|
|
213
|
+
httpPathPrefix: toHttpPath(option.path),
|
|
214
|
+
laziedPrefix: getLazyMeta(option.router).prefix
|
|
215
|
+
}))
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
async match(method, pathname) {
|
|
219
|
+
if (this.pendingRouters.length) {
|
|
220
|
+
const newPendingRouters = [];
|
|
221
|
+
for (const pendingRouter of this.pendingRouters) {
|
|
222
|
+
if (!pendingRouter.laziedPrefix || pathname.startsWith(pendingRouter.laziedPrefix) || pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
|
223
|
+
const { default: router } = await unlazy(pendingRouter.router);
|
|
224
|
+
this.init(router, pendingRouter.path);
|
|
225
|
+
} else {
|
|
226
|
+
newPendingRouters.push(pendingRouter);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
this.pendingRouters = newPendingRouters;
|
|
230
|
+
}
|
|
231
|
+
const match = findRoute(this.tree, method, pathname);
|
|
232
|
+
if (!match) {
|
|
233
|
+
return void 0;
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
path: match.data.path,
|
|
237
|
+
procedure: match.data.procedure,
|
|
238
|
+
params: match.params ? decodeParams(match.params) : void 0
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
class StandardHandler {
|
|
244
|
+
matcher;
|
|
245
|
+
constructor(router) {
|
|
246
|
+
this.matcher = new StandardOpenAPIMatcher();
|
|
247
|
+
this.matcher.init(router);
|
|
248
|
+
}
|
|
249
|
+
async handle(request, options) {
|
|
250
|
+
const prefix = options.prefix?.replace(/\/$/, "") || void 0;
|
|
251
|
+
if (prefix && !request.url.pathname.startsWith(`${prefix}/`) && request.url.pathname !== prefix) {
|
|
252
|
+
return { matched: false, response: void 0 };
|
|
253
|
+
}
|
|
254
|
+
return runWithSpan({ name: `${request.method} ${request.url.pathname}` }, async (span) => {
|
|
255
|
+
let step;
|
|
256
|
+
try {
|
|
257
|
+
const context = options.context;
|
|
258
|
+
const method = request.method;
|
|
259
|
+
const url = request.url;
|
|
260
|
+
const pathname = prefix ? url.pathname.replace(prefix, "") : url.pathname;
|
|
261
|
+
const match = await runWithSpan(
|
|
262
|
+
{ name: "find_procedure" },
|
|
263
|
+
() => this.matcher.match(method, `/${pathname.replace(/^\/|\/$/g, "")}`)
|
|
264
|
+
);
|
|
265
|
+
if (!match) {
|
|
266
|
+
return { matched: false, response: void 0 };
|
|
267
|
+
}
|
|
268
|
+
span?.updateName(`${ORPC_NAME}.${match.path.join("/")}`);
|
|
269
|
+
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
270
|
+
span?.setAttribute("rpc.method", match.path.join("."));
|
|
271
|
+
step = "decode_input";
|
|
272
|
+
const input = await runWithSpan({ name: "decode_input" }, () => decode(request, match.params));
|
|
273
|
+
step = void 0;
|
|
274
|
+
if (isAsyncIteratorObject(input.body)) {
|
|
275
|
+
input.body = asyncIteratorWithSpan(
|
|
276
|
+
{ name: "consume_event_iterator_input", signal: request.signal },
|
|
277
|
+
input.body
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
const client = createProcedureClient(match.procedure, {
|
|
281
|
+
context,
|
|
282
|
+
path: match.path
|
|
283
|
+
});
|
|
284
|
+
step = "call_procedure";
|
|
285
|
+
const output = await client(input, {
|
|
286
|
+
request,
|
|
287
|
+
signal: request.signal,
|
|
288
|
+
lastEventId: request.headers.get("last-event-id") ?? void 0
|
|
289
|
+
});
|
|
290
|
+
step = void 0;
|
|
291
|
+
const response = encode(output, match.procedure);
|
|
292
|
+
return {
|
|
293
|
+
matched: true,
|
|
294
|
+
response
|
|
295
|
+
};
|
|
296
|
+
} catch (e) {
|
|
297
|
+
if (step !== "call_procedure") {
|
|
298
|
+
setSpanError(span, e);
|
|
299
|
+
}
|
|
300
|
+
const error = step === "decode_input" && !(e instanceof APIError) ? new BadRequestError({
|
|
301
|
+
code: "malformed_request",
|
|
302
|
+
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
303
|
+
cause: e
|
|
304
|
+
}) : toAPIError$1(e);
|
|
305
|
+
const response = encodeError(error);
|
|
306
|
+
return {
|
|
307
|
+
matched: true,
|
|
308
|
+
response
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { StandardHandler as S, StandardOpenAPIMatcher as a, decodeParams as b, decode as d, encode as e, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -23,15 +23,10 @@
|
|
|
23
23
|
"import": "./dist/helpers/index.mjs",
|
|
24
24
|
"default": "./dist/helpers/index.mjs"
|
|
25
25
|
},
|
|
26
|
-
"./plugins": {
|
|
27
|
-
"types": "./dist/plugins/index.d.mts",
|
|
28
|
-
"import": "./dist/plugins/index.mjs",
|
|
29
|
-
"default": "./dist/plugins/index.mjs"
|
|
30
|
-
},
|
|
31
26
|
"./standard": {
|
|
32
|
-
"types": "./dist/
|
|
33
|
-
"import": "./dist/
|
|
34
|
-
"default": "./dist/
|
|
27
|
+
"types": "./dist/handler/index.d.mts",
|
|
28
|
+
"import": "./dist/handler/index.mjs",
|
|
29
|
+
"default": "./dist/handler/index.mjs"
|
|
35
30
|
},
|
|
36
31
|
"./fetch": {
|
|
37
32
|
"types": "./dist/adapters/fetch/index.d.mts",
|
|
@@ -57,31 +52,17 @@
|
|
|
57
52
|
"files": [
|
|
58
53
|
"dist"
|
|
59
54
|
],
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"drizzle-orm": "^0.44.5",
|
|
62
|
-
"drizzle-zod": "^0.8.3"
|
|
63
|
-
},
|
|
64
|
-
"peerDependenciesMeta": {
|
|
65
|
-
"drizzle-orm": {
|
|
66
|
-
"optional": true
|
|
67
|
-
},
|
|
68
|
-
"drizzle-zod": {
|
|
69
|
-
"optional": true
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
55
|
"dependencies": {
|
|
73
56
|
"cookie": "^1.0.2",
|
|
74
57
|
"rou3": "^0.7.7",
|
|
75
58
|
"zod": "^4.1.12",
|
|
76
|
-
"@temporary-name/
|
|
77
|
-
"@temporary-name/
|
|
78
|
-
"@temporary-name/
|
|
79
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
80
|
-
"@temporary-name/
|
|
81
|
-
"@temporary-name/
|
|
82
|
-
"@temporary-name/
|
|
83
|
-
"@temporary-name/json-schema": "1.9.3-alpha.f9f5ce625d5edee78250b87b3a64f1d9760c2244",
|
|
84
|
-
"@temporary-name/zod": "1.9.3-alpha.f9f5ce625d5edee78250b87b3a64f1d9760c2244"
|
|
59
|
+
"@temporary-name/standard-server": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
60
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
61
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
62
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
63
|
+
"@temporary-name/interop": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
64
|
+
"@temporary-name/zod": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
65
|
+
"@temporary-name/shared": "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3"
|
|
85
66
|
},
|
|
86
67
|
"devDependencies": {
|
|
87
68
|
"@types/supertest": "^6.0.3",
|
|
@@ -91,6 +72,7 @@
|
|
|
91
72
|
"scripts": {
|
|
92
73
|
"build": "unbuild",
|
|
93
74
|
"build:watch": "pnpm run build --watch",
|
|
94
|
-
"
|
|
75
|
+
"clean": "tsc -b --clean",
|
|
76
|
+
"lint:tsc": "tsc -b"
|
|
95
77
|
}
|
|
96
78
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, c as StandardHandleOptions, d as StandardHandleResult, e as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.D6Qs_UcF.mjs';
|
|
2
|
-
import { AnyProcedure, AnyRouter } from '@temporary-name/server';
|
|
3
|
-
import { StandardLazyRequest, StandardHeaders, StandardResponse, ORPCError, HTTPPath } from '@temporary-name/shared';
|
|
4
|
-
export { F as FriendlyStandardHandleOptions, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.7aL9gcoU.mjs';
|
|
5
|
-
import '@temporary-name/contract';
|
|
6
|
-
import '../../shared/server.BL2R5jcp.mjs';
|
|
7
|
-
|
|
8
|
-
declare function decode(request: StandardLazyRequest, pathParams: Record<string, string> | undefined): Promise<{
|
|
9
|
-
path: unknown;
|
|
10
|
-
query: unknown;
|
|
11
|
-
headers: StandardHeaders;
|
|
12
|
-
body: unknown;
|
|
13
|
-
}>;
|
|
14
|
-
declare function encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
15
|
-
declare function encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
16
|
-
|
|
17
|
-
type StandardMatchResult = {
|
|
18
|
-
path: readonly string[];
|
|
19
|
-
procedure: AnyProcedure;
|
|
20
|
-
params?: Record<string, string>;
|
|
21
|
-
} | undefined;
|
|
22
|
-
declare class StandardOpenAPIMatcher {
|
|
23
|
-
private readonly tree;
|
|
24
|
-
private pendingRouters;
|
|
25
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
|
26
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { StandardOpenAPIMatcher, decode, encode, encodeError };
|
|
30
|
-
export type { StandardMatchResult };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, c as StandardHandleOptions, d as StandardHandleResult, e as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.DpoO_ER_.js';
|
|
2
|
-
import { AnyProcedure, AnyRouter } from '@temporary-name/server';
|
|
3
|
-
import { StandardLazyRequest, StandardHeaders, StandardResponse, ORPCError, HTTPPath } from '@temporary-name/shared';
|
|
4
|
-
export { F as FriendlyStandardHandleOptions, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.DFptr1Nz.js';
|
|
5
|
-
import '@temporary-name/contract';
|
|
6
|
-
import '../../shared/server.BL2R5jcp.js';
|
|
7
|
-
|
|
8
|
-
declare function decode(request: StandardLazyRequest, pathParams: Record<string, string> | undefined): Promise<{
|
|
9
|
-
path: unknown;
|
|
10
|
-
query: unknown;
|
|
11
|
-
headers: StandardHeaders;
|
|
12
|
-
body: unknown;
|
|
13
|
-
}>;
|
|
14
|
-
declare function encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
15
|
-
declare function encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
16
|
-
|
|
17
|
-
type StandardMatchResult = {
|
|
18
|
-
path: readonly string[];
|
|
19
|
-
procedure: AnyProcedure;
|
|
20
|
-
params?: Record<string, string>;
|
|
21
|
-
} | undefined;
|
|
22
|
-
declare class StandardOpenAPIMatcher {
|
|
23
|
-
private readonly tree;
|
|
24
|
-
private pendingRouters;
|
|
25
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
|
26
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { StandardOpenAPIMatcher, decode, encode, encodeError };
|
|
30
|
-
export type { StandardMatchResult };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, b as StandardOpenAPIMatcher, d as decode, c as decodeParams, e as encode, a as encodeError, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.CVBLzkro.mjs';
|
|
2
|
-
import '@temporary-name/shared';
|
|
3
|
-
import '@temporary-name/standard-server';
|
|
4
|
-
import '../../shared/server.ClhVCxfg.mjs';
|
|
5
|
-
import '@temporary-name/contract';
|
|
6
|
-
import '@temporary-name/zod';
|
|
7
|
-
import '../../shared/server.JtIZ8YG7.mjs';
|
|
8
|
-
import '@temporary-name/server';
|
|
9
|
-
import 'rou3';
|
package/dist/plugins/index.d.mts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
|
-
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.D6Qs_UcF.mjs';
|
|
3
|
-
import { C as Context, G as ProcedureClientInterceptorOptions } from '../shared/server.BL2R5jcp.mjs';
|
|
4
|
-
import { Meta } from '@temporary-name/contract';
|
|
5
|
-
|
|
6
|
-
interface CORSOptions<T extends Context> {
|
|
7
|
-
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
8
|
-
origin: string,
|
|
9
|
-
options: StandardHandlerInterceptorOptions<T>
|
|
10
|
-
]>;
|
|
11
|
-
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
12
|
-
origin: string,
|
|
13
|
-
options: StandardHandlerInterceptorOptions<T>
|
|
14
|
-
]>;
|
|
15
|
-
allowMethods?: readonly string[];
|
|
16
|
-
allowHeaders?: readonly string[];
|
|
17
|
-
maxAge?: number;
|
|
18
|
-
credentials?: boolean;
|
|
19
|
-
exposeHeaders?: readonly string[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
|
|
23
|
-
*
|
|
24
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
|
|
25
|
-
*/
|
|
26
|
-
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
27
|
-
private readonly options;
|
|
28
|
-
order: number;
|
|
29
|
-
constructor(options?: CORSOptions<T>);
|
|
30
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
34
|
-
/**
|
|
35
|
-
* The name of the header to check.
|
|
36
|
-
*
|
|
37
|
-
* @default 'x-csrf-token'
|
|
38
|
-
*/
|
|
39
|
-
headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
|
|
40
|
-
/**
|
|
41
|
-
* The value of the header to check.
|
|
42
|
-
*
|
|
43
|
-
* @default 'orpc'
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
|
|
47
|
-
/**
|
|
48
|
-
* Exclude a procedure from the plugin.
|
|
49
|
-
*
|
|
50
|
-
* @default false
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
exclude?: Value<Promisable<boolean>, [
|
|
54
|
-
options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
|
|
55
|
-
]>;
|
|
56
|
-
/**
|
|
57
|
-
* The error thrown when the CSRF token is invalid.
|
|
58
|
-
*
|
|
59
|
-
* @default new ORPCError('CSRF_TOKEN_MISMATCH', {
|
|
60
|
-
* status: 403,
|
|
61
|
-
* message: 'Invalid CSRF token',
|
|
62
|
-
* })
|
|
63
|
-
*/
|
|
64
|
-
error?: InstanceType<typeof ORPCError>;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
|
|
68
|
-
* It helps ensure that requests to your procedures originate from JavaScript code,
|
|
69
|
-
* not from other sources like standard HTML forms or direct browser navigation.
|
|
70
|
-
*
|
|
71
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
|
|
72
|
-
*/
|
|
73
|
-
declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
74
|
-
private readonly headerName;
|
|
75
|
-
private readonly headerValue;
|
|
76
|
-
private readonly exclude;
|
|
77
|
-
private readonly error;
|
|
78
|
-
constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
|
|
79
|
-
order: number;
|
|
80
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
84
|
-
export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
|
package/dist/plugins/index.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
|
-
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.DpoO_ER_.js';
|
|
3
|
-
import { C as Context, G as ProcedureClientInterceptorOptions } from '../shared/server.BL2R5jcp.js';
|
|
4
|
-
import { Meta } from '@temporary-name/contract';
|
|
5
|
-
|
|
6
|
-
interface CORSOptions<T extends Context> {
|
|
7
|
-
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
8
|
-
origin: string,
|
|
9
|
-
options: StandardHandlerInterceptorOptions<T>
|
|
10
|
-
]>;
|
|
11
|
-
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
12
|
-
origin: string,
|
|
13
|
-
options: StandardHandlerInterceptorOptions<T>
|
|
14
|
-
]>;
|
|
15
|
-
allowMethods?: readonly string[];
|
|
16
|
-
allowHeaders?: readonly string[];
|
|
17
|
-
maxAge?: number;
|
|
18
|
-
credentials?: boolean;
|
|
19
|
-
exposeHeaders?: readonly string[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
|
|
23
|
-
*
|
|
24
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
|
|
25
|
-
*/
|
|
26
|
-
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
27
|
-
private readonly options;
|
|
28
|
-
order: number;
|
|
29
|
-
constructor(options?: CORSOptions<T>);
|
|
30
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
34
|
-
/**
|
|
35
|
-
* The name of the header to check.
|
|
36
|
-
*
|
|
37
|
-
* @default 'x-csrf-token'
|
|
38
|
-
*/
|
|
39
|
-
headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
|
|
40
|
-
/**
|
|
41
|
-
* The value of the header to check.
|
|
42
|
-
*
|
|
43
|
-
* @default 'orpc'
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
|
|
47
|
-
/**
|
|
48
|
-
* Exclude a procedure from the plugin.
|
|
49
|
-
*
|
|
50
|
-
* @default false
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
exclude?: Value<Promisable<boolean>, [
|
|
54
|
-
options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
|
|
55
|
-
]>;
|
|
56
|
-
/**
|
|
57
|
-
* The error thrown when the CSRF token is invalid.
|
|
58
|
-
*
|
|
59
|
-
* @default new ORPCError('CSRF_TOKEN_MISMATCH', {
|
|
60
|
-
* status: 403,
|
|
61
|
-
* message: 'Invalid CSRF token',
|
|
62
|
-
* })
|
|
63
|
-
*/
|
|
64
|
-
error?: InstanceType<typeof ORPCError>;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
|
|
68
|
-
* It helps ensure that requests to your procedures originate from JavaScript code,
|
|
69
|
-
* not from other sources like standard HTML forms or direct browser navigation.
|
|
70
|
-
*
|
|
71
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
|
|
72
|
-
*/
|
|
73
|
-
declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
74
|
-
private readonly headerName;
|
|
75
|
-
private readonly headerValue;
|
|
76
|
-
private readonly exclude;
|
|
77
|
-
private readonly error;
|
|
78
|
-
constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
|
|
79
|
-
order: number;
|
|
80
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
84
|
-
export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
|