better-call 0.0.0-experimental.01ff4b77

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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +265 -0
  3. package/dist/capability.cjs +417 -0
  4. package/dist/capability.cjs.map +1 -0
  5. package/dist/capability.d.cts +189 -0
  6. package/dist/capability.d.mts +189 -0
  7. package/dist/capability.mjs +401 -0
  8. package/dist/capability.mjs.map +1 -0
  9. package/dist/error.cjs +76 -0
  10. package/dist/error.cjs.map +1 -0
  11. package/dist/error.d.cts +51 -0
  12. package/dist/error.d.mts +51 -0
  13. package/dist/error.mjs +72 -0
  14. package/dist/error.mjs.map +1 -0
  15. package/dist/fn.cjs +350 -0
  16. package/dist/fn.cjs.map +1 -0
  17. package/dist/fn.d.cts +378 -0
  18. package/dist/fn.d.mts +378 -0
  19. package/dist/fn.mjs +350 -0
  20. package/dist/fn.mjs.map +1 -0
  21. package/dist/index.cjs +43 -0
  22. package/dist/index.cjs.map +1 -0
  23. package/dist/index.d.cts +50 -0
  24. package/dist/index.d.mts +50 -0
  25. package/dist/index.mjs +24 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/module.cjs +176 -0
  28. package/dist/module.cjs.map +1 -0
  29. package/dist/module.d.cts +283 -0
  30. package/dist/module.d.mts +283 -0
  31. package/dist/module.mjs +166 -0
  32. package/dist/module.mjs.map +1 -0
  33. package/dist/plugins/db.cjs +24 -0
  34. package/dist/plugins/db.cjs.map +1 -0
  35. package/dist/plugins/db.d.cts +18 -0
  36. package/dist/plugins/db.d.mts +18 -0
  37. package/dist/plugins/db.mjs +19 -0
  38. package/dist/plugins/db.mjs.map +1 -0
  39. package/dist/plugins/http/attrs.cjs +91 -0
  40. package/dist/plugins/http/attrs.cjs.map +1 -0
  41. package/dist/plugins/http/attrs.d.cts +26 -0
  42. package/dist/plugins/http/attrs.d.mts +26 -0
  43. package/dist/plugins/http/attrs.mjs +87 -0
  44. package/dist/plugins/http/attrs.mjs.map +1 -0
  45. package/dist/plugins/http/cookie.cjs +117 -0
  46. package/dist/plugins/http/cookie.cjs.map +1 -0
  47. package/dist/plugins/http/cookie.d.cts +637 -0
  48. package/dist/plugins/http/cookie.d.mts +637 -0
  49. package/dist/plugins/http/cookie.mjs +113 -0
  50. package/dist/plugins/http/cookie.mjs.map +1 -0
  51. package/dist/plugins/http/error.cjs +39 -0
  52. package/dist/plugins/http/error.cjs.map +1 -0
  53. package/dist/plugins/http/error.d.cts +38 -0
  54. package/dist/plugins/http/error.d.mts +38 -0
  55. package/dist/plugins/http/error.mjs +35 -0
  56. package/dist/plugins/http/error.mjs.map +1 -0
  57. package/dist/plugins/http/handle.cjs +73 -0
  58. package/dist/plugins/http/handle.cjs.map +1 -0
  59. package/dist/plugins/http/handle.d.cts +955 -0
  60. package/dist/plugins/http/handle.d.mts +955 -0
  61. package/dist/plugins/http/handle.mjs +72 -0
  62. package/dist/plugins/http/handle.mjs.map +1 -0
  63. package/dist/plugins/http/redirect.cjs +82 -0
  64. package/dist/plugins/http/redirect.cjs.map +1 -0
  65. package/dist/plugins/http/redirect.d.cts +67 -0
  66. package/dist/plugins/http/redirect.d.mts +67 -0
  67. package/dist/plugins/http/redirect.mjs +79 -0
  68. package/dist/plugins/http/redirect.mjs.map +1 -0
  69. package/dist/plugins/http/request.cjs +63 -0
  70. package/dist/plugins/http/request.cjs.map +1 -0
  71. package/dist/plugins/http/request.d.cts +142 -0
  72. package/dist/plugins/http/request.d.mts +142 -0
  73. package/dist/plugins/http/request.mjs +61 -0
  74. package/dist/plugins/http/request.mjs.map +1 -0
  75. package/dist/plugins/http/response.cjs +13 -0
  76. package/dist/plugins/http/response.cjs.map +1 -0
  77. package/dist/plugins/http/response.d.cts +18 -0
  78. package/dist/plugins/http/response.d.mts +18 -0
  79. package/dist/plugins/http/response.mjs +13 -0
  80. package/dist/plugins/http/response.mjs.map +1 -0
  81. package/dist/plugins/http.cjs +64 -0
  82. package/dist/plugins/http.cjs.map +1 -0
  83. package/dist/plugins/http.d.cts +945 -0
  84. package/dist/plugins/http.d.mts +945 -0
  85. package/dist/plugins/http.mjs +37 -0
  86. package/dist/plugins/http.mjs.map +1 -0
  87. package/dist/plugins/read-only.cjs +19 -0
  88. package/dist/plugins/read-only.cjs.map +1 -0
  89. package/dist/plugins/read-only.d.cts +17 -0
  90. package/dist/plugins/read-only.d.mts +17 -0
  91. package/dist/plugins/read-only.mjs +19 -0
  92. package/dist/plugins/read-only.mjs.map +1 -0
  93. package/dist/schema.cjs +245 -0
  94. package/dist/schema.cjs.map +1 -0
  95. package/dist/schema.d.cts +411 -0
  96. package/dist/schema.d.mts +411 -0
  97. package/dist/schema.mjs +235 -0
  98. package/dist/schema.mjs.map +1 -0
  99. package/dist/scope.d.cts +31 -0
  100. package/dist/scope.d.mts +31 -0
  101. package/dist/storage.cjs +308 -0
  102. package/dist/storage.cjs.map +1 -0
  103. package/dist/storage.d.cts +220 -0
  104. package/dist/storage.d.mts +220 -0
  105. package/dist/storage.mjs +302 -0
  106. package/dist/storage.mjs.map +1 -0
  107. package/dist/types.d.cts +8 -0
  108. package/dist/types.d.mts +8 -0
  109. package/dist/var.cjs +186 -0
  110. package/dist/var.cjs.map +1 -0
  111. package/dist/var.d.cts +46 -0
  112. package/dist/var.d.mts +46 -0
  113. package/dist/var.mjs +177 -0
  114. package/dist/var.mjs.map +1 -0
  115. package/package.json +114 -0
@@ -0,0 +1,142 @@
1
+ import { TypeDefination } from "../../schema.mjs";
2
+ import { FnDefination } from "../../fn.mjs";
3
+ import { VarDefination } from "../../var.mjs";
4
+ import { HttpResponse } from "./response.mjs";
5
+ //#region src/plugins/http/request.d.ts
6
+ /** The whole request-side state, as ONE value: `c.req` and
7
+ * everything is there - no per-piece vars to require one by one. */
8
+ type HttpRequest = {
9
+ /** The fetch Request itself, untouched. */
10
+ raw: Request;
11
+ method: string;
12
+ path: string;
13
+ headers: Headers;
14
+ query: Record<string, string | string[]>;
15
+ cookies: Record<string, string>;
16
+ /** Parsed by `fromRequest` when the content type says json/text -
17
+ * anything else stays on `raw`. */
18
+ body: unknown;
19
+ };
20
+ /** Build the `req` value from a fetch Request. The body cannot be read
21
+ * synchronously, so it comes in from whoever already awaited it -
22
+ * `fromRequest` does that for you. */
23
+ declare const toHttpRequest: (raw: Request, body?: unknown) => HttpRequest;
24
+ declare const req: VarDefination<"req", HttpRequest | null, undefined, never>;
25
+ declare const fromRequest: FnDefination<{
26
+ readonly request: Request;
27
+ }, Promise<{
28
+ method: string;
29
+ path: string;
30
+ }>, "http.from_request", {
31
+ readonly request: TypeDefination<Request, Request, never>;
32
+ }, readonly ["req"], {}, {
33
+ res?: ({
34
+ headers: {
35
+ append: (name: string, value: string) => void;
36
+ delete: (name: string) => void;
37
+ get: (name: string) => string | null;
38
+ getSetCookie: () => string[];
39
+ has: (name: string) => boolean;
40
+ set: (name: string, value: string) => void;
41
+ forEach: (callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any) => void;
42
+ entries: () => HeadersIterator<[string, string]>;
43
+ keys: () => HeadersIterator<string>;
44
+ values: () => HeadersIterator<string>;
45
+ [Symbol.iterator]: () => HeadersIterator<[string, string]>;
46
+ };
47
+ status?: number | undefined;
48
+ statusText?: string | undefined;
49
+ } & HttpResponse) | null | undefined;
50
+ req?: ({
51
+ raw: {
52
+ readonly cache: RequestCache;
53
+ readonly credentials: RequestCredentials;
54
+ readonly destination: RequestDestination;
55
+ readonly headers: {
56
+ append: (name: string, value: string) => void;
57
+ delete: (name: string) => void;
58
+ get: (name: string) => string | null;
59
+ getSetCookie: () => string[];
60
+ has: (name: string) => boolean;
61
+ set: (name: string, value: string) => void;
62
+ forEach: (callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any) => void;
63
+ entries: () => HeadersIterator<[string, string]>;
64
+ keys: () => HeadersIterator<string>;
65
+ values: () => HeadersIterator<string>;
66
+ [Symbol.iterator]: () => HeadersIterator<[string, string]>;
67
+ };
68
+ readonly integrity: string;
69
+ readonly keepalive: boolean;
70
+ readonly method: string;
71
+ readonly mode: RequestMode;
72
+ readonly redirect: RequestRedirect;
73
+ readonly referrer: string;
74
+ readonly referrerPolicy: ReferrerPolicy;
75
+ readonly signal: {
76
+ readonly aborted: boolean;
77
+ onabort: ((this: AbortSignal, ev: Event) => any) | null;
78
+ readonly reason: any;
79
+ throwIfAborted: () => void;
80
+ addEventListener: {
81
+ <K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
82
+ (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
83
+ };
84
+ removeEventListener: {
85
+ <K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
86
+ (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
87
+ };
88
+ dispatchEvent: (event: Event) => boolean;
89
+ };
90
+ readonly url: string;
91
+ clone: () => Request;
92
+ readonly body: {
93
+ readonly locked: boolean;
94
+ cancel: (reason?: any) => Promise<void>;
95
+ getReader: {
96
+ (options: {
97
+ mode: "byob";
98
+ }): ReadableStreamBYOBReader;
99
+ (): ReadableStreamDefaultReader<Uint8Array<ArrayBuffer>>;
100
+ (options?: ReadableStreamGetReaderOptions): ReadableStreamReader<Uint8Array<ArrayBuffer>>;
101
+ };
102
+ pipeThrough: <T>(transform: ReadableWritablePair<T, Uint8Array<ArrayBuffer>>, options?: StreamPipeOptions) => ReadableStream<T>;
103
+ pipeTo: (destination: WritableStream<Uint8Array<ArrayBuffer>>, options?: StreamPipeOptions) => Promise<void>;
104
+ tee: () => [ReadableStream<Uint8Array<ArrayBuffer>>, ReadableStream<Uint8Array<ArrayBuffer>>];
105
+ values: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator<Uint8Array<ArrayBuffer>>;
106
+ [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator<Uint8Array<ArrayBuffer>>;
107
+ } | null;
108
+ readonly bodyUsed: boolean;
109
+ arrayBuffer: () => Promise<ArrayBuffer>;
110
+ blob: () => Promise<Blob>;
111
+ bytes: () => Promise<Uint8Array<ArrayBuffer>>;
112
+ formData: () => Promise<FormData>;
113
+ json: () => Promise<any>;
114
+ text: () => Promise<string>;
115
+ };
116
+ method: string;
117
+ path: string;
118
+ headers: {
119
+ append: (name: string, value: string) => void;
120
+ delete: (name: string) => void;
121
+ get: (name: string) => string | null;
122
+ getSetCookie: () => string[];
123
+ has: (name: string) => boolean;
124
+ set: (name: string, value: string) => void;
125
+ forEach: (callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any) => void;
126
+ entries: () => HeadersIterator<[string, string]>;
127
+ keys: () => HeadersIterator<string>;
128
+ values: () => HeadersIterator<string>;
129
+ [Symbol.iterator]: () => HeadersIterator<[string, string]>;
130
+ };
131
+ query: {
132
+ [x: string]: string | string[];
133
+ };
134
+ cookies: {
135
+ [x: string]: string;
136
+ };
137
+ body: unknown;
138
+ } & HttpRequest) | null | undefined;
139
+ }, unknown>;
140
+ //#endregion
141
+ export { HttpRequest, fromRequest, req, toHttpRequest };
142
+ //# sourceMappingURL=request.d.mts.map
@@ -0,0 +1,61 @@
1
+ import { v } from "../../index.mjs";
2
+ import { res } from "./response.mjs";
3
+ //#region src/plugins/http/request.ts
4
+ const parseQuery = (url) => {
5
+ const q = {};
6
+ for (const [key, value] of url.searchParams) {
7
+ const current = q[key];
8
+ q[key] = current === void 0 ? value : Array.isArray(current) ? [...current, value] : [current, value];
9
+ }
10
+ return q;
11
+ };
12
+ const parseCookies = (header) => {
13
+ const jar = {};
14
+ for (const part of (header ?? "").split(";")) {
15
+ const [name, ...rest] = part.trim().split("=");
16
+ if (name) jar[name] = decodeURIComponent(rest.join("="));
17
+ }
18
+ return jar;
19
+ };
20
+ /** Build the `req` value from a fetch Request. The body cannot be read
21
+ * synchronously, so it comes in from whoever already awaited it -
22
+ * `fromRequest` does that for you. */
23
+ const toHttpRequest = (raw, body) => {
24
+ const url = new URL(raw.url);
25
+ return {
26
+ raw,
27
+ method: raw.method.toUpperCase(),
28
+ path: url.pathname,
29
+ headers: raw.headers,
30
+ query: parseQuery(url),
31
+ cookies: parseCookies(raw.headers.get("cookie")),
32
+ body
33
+ };
34
+ };
35
+ const req = v.var("req", { default: null });
36
+ const fromRequest = v.fn({ use: [{
37
+ req,
38
+ res
39
+ }] }).fn("http.from_request", {
40
+ input: { request: v.any() },
41
+ provides: ["req"]
42
+ }, async (c) => {
43
+ const raw = c.input.request;
44
+ let body;
45
+ if (raw.method !== "GET" && raw.method !== "HEAD") {
46
+ const contentType = raw.headers.get("content-type") ?? "";
47
+ if (contentType.includes("json")) body = await raw.clone().json().catch(() => void 0);
48
+ else if (contentType.includes("text")) body = await raw.clone().text().catch(() => void 0);
49
+ }
50
+ const value = toHttpRequest(raw, body);
51
+ c.req = value;
52
+ c.res = { headers: new Headers() };
53
+ return {
54
+ method: value.method,
55
+ path: value.path
56
+ };
57
+ });
58
+ //#endregion
59
+ export { fromRequest, req, toHttpRequest };
60
+
61
+ //# sourceMappingURL=request.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.mjs","names":[],"sources":["../../../src/plugins/http/request.ts"],"sourcesContent":["import { v } from \"../../index\";\nimport { res } from \"./response\";\n\nconst parseQuery = (url: URL) => {\n\tconst q: Record<string, string | string[]> = {};\n\tfor (const [key, value] of url.searchParams) {\n\t\tconst current = q[key];\n\t\tq[key] =\n\t\t\tcurrent === undefined\n\t\t\t\t? value\n\t\t\t\t: Array.isArray(current)\n\t\t\t\t\t? [...current, value]\n\t\t\t\t\t: [current, value];\n\t}\n\treturn q;\n};\n\nconst parseCookies = (header: string | null) => {\n\tconst jar: Record<string, string> = {};\n\tfor (const part of (header ?? \"\").split(\";\")) {\n\t\tconst [name, ...rest] = part.trim().split(\"=\");\n\t\tif (name) jar[name] = decodeURIComponent(rest.join(\"=\"));\n\t}\n\treturn jar;\n};\n\n/** The whole request-side state, as ONE value: `c.req` and\n * everything is there - no per-piece vars to require one by one. */\nexport type HttpRequest = {\n\t/** The fetch Request itself, untouched. */\n\traw: Request;\n\tmethod: string;\n\tpath: string;\n\theaders: Headers;\n\tquery: Record<string, string | string[]>;\n\tcookies: Record<string, string>;\n\t/** Parsed by `fromRequest` when the content type says json/text -\n\t * anything else stays on `raw`. */\n\tbody: unknown;\n};\n\n/** Build the `req` value from a fetch Request. The body cannot be read\n * synchronously, so it comes in from whoever already awaited it -\n * `fromRequest` does that for you. */\nexport const toHttpRequest = (raw: Request, body?: unknown): HttpRequest => {\n\tconst url = new URL(raw.url);\n\treturn {\n\t\traw,\n\t\tmethod: raw.method.toUpperCase(),\n\t\tpath: url.pathname,\n\t\theaders: raw.headers,\n\t\tquery: parseQuery(url),\n\t\tcookies: parseCookies(raw.headers.get(\"cookie\")),\n\t\tbody,\n\t};\n};\n\nexport const req = v.var(\"req\", { default: null as HttpRequest | null });\n\nconst h = v.fn({ use: [{ req, res }] });\n\nexport const fromRequest = h.fn(\n\t\"http.from_request\",\n\t{ input: { request: v.any<Request>() }, provides: [\"req\"] },\n\tasync (c) => {\n\t\tconst raw = c.input.request;\n\t\tlet body: unknown;\n\t\tif (raw.method !== \"GET\" && raw.method !== \"HEAD\") {\n\t\t\tconst contentType = raw.headers.get(\"content-type\") ?? \"\";\n\t\t\tif (contentType.includes(\"json\")) {\n\t\t\t\tbody = await raw\n\t\t\t\t\t.clone()\n\t\t\t\t\t.json()\n\t\t\t\t\t.catch(() => undefined);\n\t\t\t} else if (contentType.includes(\"text\")) {\n\t\t\t\tbody = await raw\n\t\t\t\t\t.clone()\n\t\t\t\t\t.text()\n\t\t\t\t\t.catch(() => undefined);\n\t\t\t}\n\t\t}\n\t\tconst value = toHttpRequest(raw, body);\n\t\tc.req = value;\n\t\tc.res = { headers: new Headers() };\n\t\treturn { method: value.method, path: value.path };\n\t},\n);\n"],"mappings":";;;AAGA,MAAM,cAAc,QAAa;CAChC,MAAM,IAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,KAAK,UAAU,IAAI,cAAc;EAC5C,MAAM,UAAU,EAAE;EAClB,EAAE,OACD,YAAY,KAAA,IACT,QACA,MAAM,QAAQ,OAAO,IACpB,CAAC,GAAG,SAAS,KAAK,IAClB,CAAC,SAAS,KAAK;CACrB;CACA,OAAO;AACR;AAEA,MAAM,gBAAgB,WAA0B;CAC/C,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,SAAS,UAAU,GAAA,CAAI,MAAM,GAAG,GAAG;EAC7C,MAAM,CAAC,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,MAAM,GAAG;EAC7C,IAAI,MAAM,IAAI,QAAQ,mBAAmB,KAAK,KAAK,GAAG,CAAC;CACxD;CACA,OAAO;AACR;;;;AAoBA,MAAa,iBAAiB,KAAc,SAAgC;CAC3E,MAAM,MAAM,IAAI,IAAI,IAAI,GAAG;CAC3B,OAAO;EACN;EACA,QAAQ,IAAI,OAAO,YAAY;EAC/B,MAAM,IAAI;EACV,SAAS,IAAI;EACb,OAAO,WAAW,GAAG;EACrB,SAAS,aAAa,IAAI,QAAQ,IAAI,QAAQ,CAAC;EAC/C;CACD;AACD;AAEA,MAAa,MAAM,EAAE,IAAI,OAAO,EAAE,SAAS,KAA2B,CAAC;AAIvE,MAAa,cAFH,EAAE,GAAG,EAAE,KAAK,CAAC;CAAE;CAAK;AAAI,CAAC,EAAE,CAEV,CAAA,CAAE,GAC5B,qBACA;CAAE,OAAO,EAAE,SAAS,EAAE,IAAa,EAAE;CAAG,UAAU,CAAC,KAAK;AAAE,GAC1D,OAAO,MAAM;CACZ,MAAM,MAAM,EAAE,MAAM;CACpB,IAAI;CACJ,IAAI,IAAI,WAAW,SAAS,IAAI,WAAW,QAAQ;EAClD,MAAM,cAAc,IAAI,QAAQ,IAAI,cAAc,KAAK;EACvD,IAAI,YAAY,SAAS,MAAM,GAC9B,OAAO,MAAM,IACX,MAAM,CAAC,CACP,KAAK,CAAC,CACN,YAAY,KAAA,CAAS;OACjB,IAAI,YAAY,SAAS,MAAM,GACrC,OAAO,MAAM,IACX,MAAM,CAAC,CACP,KAAK,CAAC,CACN,YAAY,KAAA,CAAS;CAEzB;CACA,MAAM,QAAQ,cAAc,KAAK,IAAI;CACrC,EAAE,MAAM;CACR,EAAE,MAAM,EAAE,SAAS,IAAI,QAAQ,EAAE;CACjC,OAAO;EAAE,QAAQ,MAAM;EAAQ,MAAM,MAAM;CAAK;AACjD,CACD"}
@@ -0,0 +1,13 @@
1
+ //#region src/plugins/http/response.ts
2
+ const res = require("../../index.cjs").v.var("res", { default: null });
3
+ /** Build a fetch {@link Response} from the scope's response state. */
4
+ const toResponse = (response, body = null) => new Response(body, {
5
+ status: response.status ?? 200,
6
+ statusText: response.statusText,
7
+ headers: response.headers
8
+ });
9
+ //#endregion
10
+ exports.res = res;
11
+ exports.toResponse = toResponse;
12
+
13
+ //# sourceMappingURL=response.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.cjs","names":["v"],"sources":["../../../src/plugins/http/response.ts"],"sourcesContent":["import { v } from \"../../index\";\n\n/** The response side, as ONE value. `headers` and `status` are meant to\n * be MUTATED in place (`res.headers.set(...)`, `res.status = 201`) - the\n * object is shared with whoever builds the final Response, so in-place\n * writes are exactly what travels back. */\nexport type HttpResponse = {\n\theaders: Headers;\n\t/** Steers the answering Response's status - assign it in place. */\n\tstatus?: number;\n\tstatusText?: string;\n};\n\nexport const res = v.var(\"res\", { default: null as HttpResponse | null });\n\n/** Build a fetch {@link Response} from the scope's response state. */\nexport const toResponse = (\n\tresponse: HttpResponse,\n\tbody: BodyInit | null = null,\n): Response =>\n\tnew Response(body, {\n\t\tstatus: response.status ?? 200,\n\t\tstatusText: response.statusText,\n\t\theaders: response.headers,\n\t});\n"],"mappings":";AAaA,MAAa,+BAAMA,CAAAA,CAAAA,EAAE,IAAI,OAAO,EAAE,SAAS,KAA4B,CAAC;;AAGxE,MAAa,cACZ,UACA,OAAwB,SAExB,IAAI,SAAS,MAAM;CAClB,QAAQ,SAAS,UAAU;CAC3B,YAAY,SAAS;CACrB,SAAS,SAAS;AACnB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { VarDefination } from "../../var.cjs";
2
+ //#region src/plugins/http/response.d.ts
3
+ /** The response side, as ONE value. `headers` and `status` are meant to
4
+ * be MUTATED in place (`res.headers.set(...)`, `res.status = 201`) - the
5
+ * object is shared with whoever builds the final Response, so in-place
6
+ * writes are exactly what travels back. */
7
+ type HttpResponse = {
8
+ headers: Headers;
9
+ /** Steers the answering Response's status - assign it in place. */
10
+ status?: number;
11
+ statusText?: string;
12
+ };
13
+ declare const res: VarDefination<"res", HttpResponse | null, undefined, never>;
14
+ /** Build a fetch {@link Response} from the scope's response state. */
15
+ declare const toResponse: (response: HttpResponse, body?: BodyInit | null) => Response;
16
+ //#endregion
17
+ export { HttpResponse, res, toResponse };
18
+ //# sourceMappingURL=response.d.cts.map
@@ -0,0 +1,18 @@
1
+ import { VarDefination } from "../../var.mjs";
2
+ //#region src/plugins/http/response.d.ts
3
+ /** The response side, as ONE value. `headers` and `status` are meant to
4
+ * be MUTATED in place (`res.headers.set(...)`, `res.status = 201`) - the
5
+ * object is shared with whoever builds the final Response, so in-place
6
+ * writes are exactly what travels back. */
7
+ type HttpResponse = {
8
+ headers: Headers;
9
+ /** Steers the answering Response's status - assign it in place. */
10
+ status?: number;
11
+ statusText?: string;
12
+ };
13
+ declare const res: VarDefination<"res", HttpResponse | null, undefined, never>;
14
+ /** Build a fetch {@link Response} from the scope's response state. */
15
+ declare const toResponse: (response: HttpResponse, body?: BodyInit | null) => Response;
16
+ //#endregion
17
+ export { HttpResponse, res, toResponse };
18
+ //# sourceMappingURL=response.d.mts.map
@@ -0,0 +1,13 @@
1
+ import { v } from "../../index.mjs";
2
+ //#region src/plugins/http/response.ts
3
+ const res = v.var("res", { default: null });
4
+ /** Build a fetch {@link Response} from the scope's response state. */
5
+ const toResponse = (response, body = null) => new Response(body, {
6
+ status: response.status ?? 200,
7
+ statusText: response.statusText,
8
+ headers: response.headers
9
+ });
10
+ //#endregion
11
+ export { res, toResponse };
12
+
13
+ //# sourceMappingURL=response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.mjs","names":[],"sources":["../../../src/plugins/http/response.ts"],"sourcesContent":["import { v } from \"../../index\";\n\n/** The response side, as ONE value. `headers` and `status` are meant to\n * be MUTATED in place (`res.headers.set(...)`, `res.status = 201`) - the\n * object is shared with whoever builds the final Response, so in-place\n * writes are exactly what travels back. */\nexport type HttpResponse = {\n\theaders: Headers;\n\t/** Steers the answering Response's status - assign it in place. */\n\tstatus?: number;\n\tstatusText?: string;\n};\n\nexport const res = v.var(\"res\", { default: null as HttpResponse | null });\n\n/** Build a fetch {@link Response} from the scope's response state. */\nexport const toResponse = (\n\tresponse: HttpResponse,\n\tbody: BodyInit | null = null,\n): Response =>\n\tnew Response(body, {\n\t\tstatus: response.status ?? 200,\n\t\tstatusText: response.statusText,\n\t\theaders: response.headers,\n\t});\n"],"mappings":";;AAaA,MAAa,MAAM,EAAE,IAAI,OAAO,EAAE,SAAS,KAA4B,CAAC;;AAGxE,MAAa,cACZ,UACA,OAAwB,SAExB,IAAI,SAAS,MAAM;CAClB,QAAQ,SAAS,UAAU;CAC3B,YAAY,SAAS;CACrB,SAAS,SAAS;AACnB,CAAC"}
@@ -0,0 +1,64 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_attrs = require("./http/attrs.cjs");
3
+ const require_response = require("./http/response.cjs");
4
+ const require_request = require("./http/request.cjs");
5
+ const require_cookie = require("./http/cookie.cjs");
6
+ const require_error = require("./http/error.cjs");
7
+ const require_redirect = require("./http/redirect.cjs");
8
+ const require_handle = require("./http/handle.cjs");
9
+ //#region src/plugins/http/index.ts
10
+ const http = {
11
+ req: require_request.req,
12
+ res: require_response.res,
13
+ cookieOptions: require_cookie.cookieOptions,
14
+ fromRequest: require_request.fromRequest,
15
+ handler: require_handle.handler,
16
+ createHandler: require_handle.createHandler,
17
+ getCookie: require_cookie.getCookie,
18
+ setCookie: require_cookie.setCookie,
19
+ deleteCookie: require_cookie.deleteCookie,
20
+ err: require_error.err,
21
+ statusOf: require_error.statusOf,
22
+ errorStatus: require_error.errorStatus,
23
+ applyError: require_error.applyError,
24
+ redirect: require_redirect.redirect,
25
+ applyRedirect: require_redirect.applyRedirect,
26
+ asResponse: require_redirect.asResponse,
27
+ toResponse: require_response.toResponse,
28
+ Redirect: require_redirect.Redirect,
29
+ serverOnly: require_attrs.serverOnly,
30
+ clientSchema: require_attrs.clientSchema,
31
+ rejectServerOnly: require_attrs.rejectServerOnly,
32
+ wireInput: require_attrs.wireInput,
33
+ fromJsonBody: require_attrs.fromJsonBody
34
+ };
35
+ //#endregion
36
+ exports.Redirect = require_redirect.Redirect;
37
+ exports.applyError = require_error.applyError;
38
+ exports.applyRedirect = require_redirect.applyRedirect;
39
+ exports.asResponse = require_redirect.asResponse;
40
+ exports.clientSchema = require_attrs.clientSchema;
41
+ exports.cookieOptions = require_cookie.cookieOptions;
42
+ exports.cookieShape = require_cookie.cookieShape;
43
+ exports.createHandler = require_handle.createHandler;
44
+ exports.deleteCookie = require_cookie.deleteCookie;
45
+ exports.err = require_error.err;
46
+ exports.errorStatus = require_error.errorStatus;
47
+ exports.fromJsonBody = require_attrs.fromJsonBody;
48
+ exports.fromRequest = require_request.fromRequest;
49
+ exports.getCookie = require_cookie.getCookie;
50
+ exports.handler = require_handle.handler;
51
+ exports.http = http;
52
+ exports.kHttpErr = require_error.kHttpErr;
53
+ exports.redirect = require_redirect.redirect;
54
+ exports.rejectServerOnly = require_attrs.rejectServerOnly;
55
+ exports.req = require_request.req;
56
+ exports.res = require_response.res;
57
+ exports.serverOnly = require_attrs.serverOnly;
58
+ exports.setCookie = require_cookie.setCookie;
59
+ exports.statusOf = require_error.statusOf;
60
+ exports.toHttpRequest = require_request.toHttpRequest;
61
+ exports.toResponse = require_response.toResponse;
62
+ exports.wireInput = require_attrs.wireInput;
63
+
64
+ //# sourceMappingURL=http.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.cjs","names":[],"sources":["../../src/plugins/http/index.ts"],"sourcesContent":["import {\n\tclientSchema,\n\tfromJsonBody,\n\trejectServerOnly,\n\tserverOnly,\n\twireInput,\n} from \"./attrs\";\nimport { cookieOptions, deleteCookie, getCookie, setCookie } from \"./cookie\";\nimport { applyError, err, errorStatus, statusOf } from \"./error\";\nimport { createHandler, handler } from \"./handle\";\nimport { applyRedirect, asResponse, Redirect, redirect } from \"./redirect\";\nimport { fromRequest, req } from \"./request\";\nimport { res, toResponse } from \"./response\";\n\nexport {\n\tclientSchema,\n\tfromJsonBody,\n\trejectServerOnly,\n\tserverOnly,\n\twireInput,\n} from \"./attrs\";\nexport type { CookieOptions } from \"./cookie\";\nexport {\n\tcookieOptions,\n\tcookieShape,\n\tdeleteCookie,\n\tgetCookie,\n\tsetCookie,\n} from \"./cookie\";\nexport type { HttpErrMeta } from \"./error\";\nexport {\n\tapplyError,\n\terr,\n\terrorStatus,\n\tkHttpErr,\n\tstatusOf,\n} from \"./error\";\nexport type { CreateHandlerContext, CreateHandlerOptions } from \"./handle\";\nexport { createHandler, handler } from \"./handle\";\nexport type { RedirectStatus } from \"./redirect\";\nexport {\n\tapplyRedirect,\n\tasResponse,\n\tRedirect,\n\tredirect,\n} from \"./redirect\";\nexport type { HttpRequest } from \"./request\";\nexport { fromRequest, req, toHttpRequest } from \"./request\";\nexport type { HttpResponse } from \"./response\";\nexport { res, toResponse } from \"./response\";\n\nexport const http = {\n\treq,\n\tres,\n\tcookieOptions,\n\tfromRequest,\n\thandler,\n\tcreateHandler,\n\tgetCookie,\n\tsetCookie,\n\tdeleteCookie,\n\terr,\n\tstatusOf,\n\terrorStatus,\n\tapplyError,\n\tredirect,\n\tapplyRedirect,\n\tasResponse,\n\ttoResponse,\n\tRedirect,\n\tserverOnly,\n\tclientSchema,\n\trejectServerOnly,\n\twireInput,\n\tfromJsonBody,\n};\n"],"mappings":";;;;;;;;;AAmDA,MAAa,OAAO;CACnB,KAAA,gBAAA;CACA,KAAA,iBAAA;CACA,eAAA,eAAA;CACA,aAAA,gBAAA;CACA,SAAA,eAAA;CACA,eAAA,eAAA;CACA,WAAA,eAAA;CACA,WAAA,eAAA;CACA,cAAA,eAAA;CACA,KAAA,cAAA;CACA,UAAA,cAAA;CACA,aAAA,cAAA;CACA,YAAA,cAAA;CACA,UAAA,iBAAA;CACA,eAAA,iBAAA;CACA,YAAA,iBAAA;CACA,YAAA,iBAAA;CACA,UAAA,iBAAA;CACA,YAAA,cAAA;CACA,cAAA,cAAA;CACA,kBAAA,cAAA;CACA,WAAA,cAAA;CACA,cAAA,cAAA;AACD"}