@arkstack/http 0.12.6 → 0.12.8
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/{index-BfxuYaPt.d.ts → index-DM79pxEy.d.ts} +126 -0
- package/dist/index.d.ts +1 -1
- package/dist/setup.d.ts +1 -2
- package/dist/setup.js +1 -0
- package/package.json +3 -2
|
@@ -4,6 +4,11 @@ import * as _$kanun from "kanun";
|
|
|
4
4
|
import { RequestData } from "clear-router/types/basic";
|
|
5
5
|
|
|
6
6
|
//#region src/Response.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Represents an HTTP response, providing a consistent interface for accessing response data.
|
|
9
|
+
*
|
|
10
|
+
* @author 3m1n3nc3
|
|
11
|
+
*/
|
|
7
12
|
declare class Response$1<TBody = unknown> extends Response {
|
|
8
13
|
body: TBody;
|
|
9
14
|
readonly source?: unknown;
|
|
@@ -164,27 +169,130 @@ declare class Session {
|
|
|
164
169
|
private queuePersist;
|
|
165
170
|
save(): Promise<this>;
|
|
166
171
|
destroy(): Promise<this>;
|
|
172
|
+
/**
|
|
173
|
+
* Get an item from the session bag
|
|
174
|
+
*
|
|
175
|
+
* @param key
|
|
176
|
+
* @param defaultValue
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
167
179
|
get<T = any>(key: string, defaultValue?: T): T;
|
|
180
|
+
/**
|
|
181
|
+
* Add an item to the session bag
|
|
182
|
+
*
|
|
183
|
+
* @param key
|
|
184
|
+
* @param defaultValue
|
|
185
|
+
* @returns
|
|
186
|
+
*/
|
|
168
187
|
put<T = any>(key: string, value: T): this;
|
|
188
|
+
/**
|
|
189
|
+
* Add an item to the session bag
|
|
190
|
+
*
|
|
191
|
+
* @param key
|
|
192
|
+
* @param defaultValue
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
169
195
|
set<T = any>(key: string, value: T): this;
|
|
196
|
+
/**
|
|
197
|
+
* Check if an item exist in the session bag
|
|
198
|
+
*
|
|
199
|
+
* @param key
|
|
200
|
+
* @returns
|
|
201
|
+
*/
|
|
170
202
|
has(key: string): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Remove an item from the session bag
|
|
205
|
+
*
|
|
206
|
+
* @param key
|
|
207
|
+
* @returns
|
|
208
|
+
*/
|
|
171
209
|
forget(key: string): this;
|
|
210
|
+
/**
|
|
211
|
+
* Clear the session bag
|
|
212
|
+
*
|
|
213
|
+
* @returns
|
|
214
|
+
*/
|
|
172
215
|
clear(): this;
|
|
216
|
+
/**
|
|
217
|
+
* Get all items in the session bag
|
|
218
|
+
*
|
|
219
|
+
* @returns
|
|
220
|
+
*/
|
|
173
221
|
all(): {
|
|
174
222
|
[x: string]: any;
|
|
175
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* Add a flash item for the next request
|
|
226
|
+
*
|
|
227
|
+
* @param key
|
|
228
|
+
* @param value
|
|
229
|
+
* @returns
|
|
230
|
+
*/
|
|
176
231
|
flash<T = any>(key: string, value: T): this;
|
|
232
|
+
/**
|
|
233
|
+
* Get a flash item
|
|
234
|
+
*
|
|
235
|
+
* @param key
|
|
236
|
+
* @param defaultValue
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
177
239
|
getFlash<T = any>(key: string, defaultValue?: T): T;
|
|
240
|
+
/**
|
|
241
|
+
* Sweep flashed data that was loaded for this request
|
|
242
|
+
*
|
|
243
|
+
* @returns
|
|
244
|
+
*/
|
|
178
245
|
sweepFlash(): Promise<this>;
|
|
246
|
+
/**
|
|
247
|
+
* Add an error to the session error bag
|
|
248
|
+
*
|
|
249
|
+
* @param field
|
|
250
|
+
* @param message
|
|
251
|
+
* @returns
|
|
252
|
+
*/
|
|
179
253
|
addError(field: string, message: SessionErrorValue): this;
|
|
254
|
+
/**
|
|
255
|
+
* Add multiple errors to the session error bag
|
|
256
|
+
*
|
|
257
|
+
* @param errors
|
|
258
|
+
* @returns
|
|
259
|
+
*/
|
|
180
260
|
addErrors(errors: SessionErrorRecord | ErrorBag): this;
|
|
261
|
+
/**
|
|
262
|
+
* Add a validation error to the session error bag
|
|
263
|
+
*
|
|
264
|
+
* @param error
|
|
265
|
+
* @returns
|
|
266
|
+
*/
|
|
181
267
|
addValidationErrors(error: unknown): this;
|
|
268
|
+
/**
|
|
269
|
+
* Check if the session error bag has any errors
|
|
270
|
+
*
|
|
271
|
+
* @param field
|
|
272
|
+
* @returns
|
|
273
|
+
*/
|
|
182
274
|
hasErrors(field?: string): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Clear all errors in the session error bag
|
|
277
|
+
*
|
|
278
|
+
* @param field
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
183
281
|
clearErrors(field?: string): this;
|
|
282
|
+
/**
|
|
283
|
+
* Parse session for views
|
|
284
|
+
*
|
|
285
|
+
* @returns
|
|
286
|
+
*/
|
|
184
287
|
forView(): {
|
|
185
288
|
errors: ErrorBag;
|
|
186
289
|
flash: FlashBag<unknown>;
|
|
187
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* Return session as json
|
|
293
|
+
*
|
|
294
|
+
* @returns
|
|
295
|
+
*/
|
|
188
296
|
toJSON(): {
|
|
189
297
|
errors: Record<string, string[]>;
|
|
190
298
|
flash: {
|
|
@@ -200,7 +308,20 @@ declare const kanunSessionPlugin: _$kanun.ValidatorPlugin;
|
|
|
200
308
|
//#region src/session/helpers.d.ts
|
|
201
309
|
declare const registerResponseFlashSweep: (target: unknown, session?: Session) => void;
|
|
202
310
|
declare const attachViewState: (target: Record<PropertyKey, any>, session: Session) => void;
|
|
311
|
+
/**
|
|
312
|
+
* Ensure a valid session exists
|
|
313
|
+
*
|
|
314
|
+
* @param ctx
|
|
315
|
+
* @param initial
|
|
316
|
+
* @returns
|
|
317
|
+
*/
|
|
203
318
|
declare const ensureSession: (ctx: unknown, initial?: SessionInitialState | Record<string, any>, persistent?: SessionDriverResult) => Session;
|
|
319
|
+
/**
|
|
320
|
+
* Get the current session
|
|
321
|
+
*
|
|
322
|
+
* @param ctx
|
|
323
|
+
* @returns
|
|
324
|
+
*/
|
|
204
325
|
declare const getSession: (ctx: unknown) => Session | undefined;
|
|
205
326
|
//#endregion
|
|
206
327
|
//#region src/session/config.d.ts
|
|
@@ -325,6 +446,11 @@ interface OldHelper {
|
|
|
325
446
|
}
|
|
326
447
|
//#endregion
|
|
327
448
|
//#region src/Request.d.ts
|
|
449
|
+
/**
|
|
450
|
+
* Represents an HTTP request, providing a consistent interface for accessing request data.
|
|
451
|
+
*
|
|
452
|
+
* @author 3m1n3nc3
|
|
453
|
+
*/
|
|
328
454
|
declare class Request$1<TUser = unknown> extends Request {
|
|
329
455
|
readonly headers: HeaderMap;
|
|
330
456
|
readonly ip: string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="./app.d.ts" />
|
|
2
|
-
import { $ as ErrorBag, A as encodeSessionPayload, B as serializeCookie, C as ResponseSource, D as CookieSessionDriver, E as DatabaseSessionDriver, F as encodeJson, G as getSessionDriver, H as signValue, I as encodeSignedValue, J as getSession, K as attachViewState, L as generateSessionId, M as encryptSessionValue, N as decodeJson, O as BaseSessionDriver, P as decodeSignedValue, Q as Session, R as getCookie, S as RequestSource, T as FileSessionDriver, U as configureSession, V as setCookie, W as createSessionDriver, X as arkstackHttpPlugin, Y as registerResponseFlashSweep, Z as kanunSessionPlugin, _ as HeaderValue, a as redirect, at as SessionDriver, b as RequestHelper, c as isHeaders, ct as SessionErrorRecord, d as normalizeHeaderValue, dt as SessionInitialState, et as BaseSessionDriverOptions, f as normalizeHeaders, ft as SessionMessageProvider, g as HeaderSource, gt as Response, h as HeaderMap, ht as FlashBag, i as old, it as SessionConfig, j as decryptSessionValue, k as decodeSessionPayload, l as isRecord, lt as SessionErrorSource, m as Request, mt as cookie_options, n as web, nt as HttpContextLike, o as redirectBackTarget, ot as SessionDriverResult, p as unwrapRequestSource, pt as SessionPayload, q as ensureSession, r as webMiddlewareKey, rt as PersistentSessionConfig, s as resolveRedirectTarget, st as SessionDriverType, t as isWebRequest, tt as DatabaseSessionDriverOptions, u as makeHeaders, ut as SessionErrorValue, v as OldHelper, w as SessionHelper, x as RequestOptions, y as RedirectHelper, z as parseCookies } from "./index-
|
|
2
|
+
import { $ as ErrorBag, A as encodeSessionPayload, B as serializeCookie, C as ResponseSource, D as CookieSessionDriver, E as DatabaseSessionDriver, F as encodeJson, G as getSessionDriver, H as signValue, I as encodeSignedValue, J as getSession, K as attachViewState, L as generateSessionId, M as encryptSessionValue, N as decodeJson, O as BaseSessionDriver, P as decodeSignedValue, Q as Session, R as getCookie, S as RequestSource, T as FileSessionDriver, U as configureSession, V as setCookie, W as createSessionDriver, X as arkstackHttpPlugin, Y as registerResponseFlashSweep, Z as kanunSessionPlugin, _ as HeaderValue, a as redirect, at as SessionDriver, b as RequestHelper, c as isHeaders, ct as SessionErrorRecord, d as normalizeHeaderValue, dt as SessionInitialState, et as BaseSessionDriverOptions, f as normalizeHeaders, ft as SessionMessageProvider, g as HeaderSource, gt as Response, h as HeaderMap, ht as FlashBag, i as old, it as SessionConfig, j as decryptSessionValue, k as decodeSessionPayload, l as isRecord, lt as SessionErrorSource, m as Request, mt as cookie_options, n as web, nt as HttpContextLike, o as redirectBackTarget, ot as SessionDriverResult, p as unwrapRequestSource, pt as SessionPayload, q as ensureSession, r as webMiddlewareKey, rt as PersistentSessionConfig, s as resolveRedirectTarget, st as SessionDriverType, t as isWebRequest, tt as DatabaseSessionDriverOptions, u as makeHeaders, ut as SessionErrorValue, v as OldHelper, w as SessionHelper, x as RequestOptions, y as RedirectHelper, z as parseCookies } from "./index-DM79pxEy.js";
|
|
3
3
|
export { BaseSessionDriver, BaseSessionDriverOptions, CookieSessionDriver, DatabaseSessionDriver, DatabaseSessionDriverOptions, ErrorBag, FileSessionDriver, FlashBag, HeaderMap, HeaderSource, HeaderValue, HttpContextLike, OldHelper, PersistentSessionConfig, RedirectHelper, Request, RequestHelper, RequestOptions, RequestSource, Response, ResponseSource, Session, SessionConfig, SessionDriver, SessionDriverResult, SessionDriverType, SessionErrorRecord, SessionErrorSource, SessionErrorValue, SessionHelper, SessionInitialState, SessionMessageProvider, SessionPayload, arkstackHttpPlugin, attachViewState, configureSession, cookie_options, createSessionDriver, decodeJson, decodeSessionPayload, decodeSignedValue, decryptSessionValue, encodeJson, encodeSessionPayload, encodeSignedValue, encryptSessionValue, ensureSession, generateSessionId, getCookie, getSession, getSessionDriver, isHeaders, isRecord, isWebRequest, kanunSessionPlugin, makeHeaders, normalizeHeaderValue, normalizeHeaders, old, parseCookies, redirect, redirectBackTarget, registerResponseFlashSweep, resolveRedirectTarget, serializeCookie, setCookie, signValue, unwrapRequestSource, web, webMiddlewareKey };
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { b as RequestHelper, gt as Response, v as OldHelper, w as SessionHelper, y as RedirectHelper } from "./index-
|
|
2
|
-
|
|
1
|
+
import { b as RequestHelper, gt as Response, v as OldHelper, w as SessionHelper, y as RedirectHelper } from "./index-DM79pxEy.js";
|
|
3
2
|
//#region src/setup.d.ts
|
|
4
3
|
declare global {
|
|
5
4
|
var session: SessionHelper;
|
package/dist/setup.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { F as Response$1, I as Request$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect } from "./redirect-Bt3re8Qq.js";
|
|
2
2
|
import { CoreRouter } from "clear-router";
|
|
3
3
|
import { Validator } from "kanun";
|
|
4
|
+
import "dotenv/config";
|
|
4
5
|
//#region src/setup.ts
|
|
5
6
|
CoreRouter.setRequestProvider(Request$1);
|
|
6
7
|
CoreRouter.setResponseProvider(Response$1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/http",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "HTTP module for Arkstack, providing framework-agnostic request and response primitives.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net/guide/http",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"clear-router": "^2.8.0",
|
|
32
|
-
"
|
|
32
|
+
"dotenv": "17.3.1",
|
|
33
|
+
"@arkstack/contract": "^0.12.8"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"arkormx": "^2.4.1",
|