oc-server 3.0.0 → 3.1.0
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/types.d.ts +39 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ export type Prettify<T> = {
|
|
|
2
2
|
[K in keyof T]: T[K];
|
|
3
3
|
} & {};
|
|
4
4
|
type JsonPrimitive = string | number | boolean | null | undefined;
|
|
5
|
+
type JsonObject = {
|
|
6
|
+
[key: string]: JsonPrimitive | JsonArray | JsonObject;
|
|
7
|
+
};
|
|
8
|
+
interface JsonArray extends Array<JsonPrimitive | JsonArray | JsonObject> {
|
|
9
|
+
}
|
|
10
|
+
interface JsonLike {
|
|
11
|
+
[key: string]: JsonPrimitive | JsonArray | JsonObject;
|
|
12
|
+
}
|
|
5
13
|
type CleanNeverProperties<T> = {
|
|
6
14
|
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
7
15
|
};
|
|
@@ -28,6 +36,36 @@ export interface Template {
|
|
|
28
36
|
version: string;
|
|
29
37
|
externals: External[];
|
|
30
38
|
}
|
|
39
|
+
export interface CookieOptions {
|
|
40
|
+
/** Convenient option for setting the expiry time relative to the current time in **milliseconds**. */
|
|
41
|
+
maxAge?: number | undefined;
|
|
42
|
+
/** Indicates if the cookie should be signed. */
|
|
43
|
+
signed?: boolean | undefined;
|
|
44
|
+
/** Expiry date of the cookie in GMT. If not specified (undefined), creates a session cookie. */
|
|
45
|
+
expires?: Date | undefined;
|
|
46
|
+
/** Flags the cookie to be accessible only by the web server. */
|
|
47
|
+
httpOnly?: boolean | undefined;
|
|
48
|
+
/** Path for the cookie. Defaults to “/”. */
|
|
49
|
+
path?: string | undefined;
|
|
50
|
+
/** Domain name for the cookie. Defaults to the domain name of the app. */
|
|
51
|
+
domain?: string | undefined;
|
|
52
|
+
/** Marks the cookie to be used with HTTPS only. */
|
|
53
|
+
secure?: boolean | undefined;
|
|
54
|
+
/** A synchronous function used for cookie value encoding. Defaults to encodeURIComponent. */
|
|
55
|
+
encode?: ((val: string) => string) | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Value of the “SameSite” Set-Cookie attribute.
|
|
58
|
+
* @link https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1.
|
|
59
|
+
*/
|
|
60
|
+
sameSite?: boolean | 'lax' | 'strict' | 'none' | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Value of the “Priority” Set-Cookie attribute.
|
|
63
|
+
* @link https://datatracker.ietf.org/doc/html/draft-west-cookie-priority-00#section-4.3
|
|
64
|
+
*/
|
|
65
|
+
priority?: 'low' | 'medium' | 'high';
|
|
66
|
+
/** Marks the cookie to use partioned storage. */
|
|
67
|
+
partitioned?: boolean | undefined;
|
|
68
|
+
}
|
|
31
69
|
export type DataContext<T = any, E = Env, P = any, S = unknown> = {
|
|
32
70
|
action?: string;
|
|
33
71
|
acceptLanguage: AcceptLanguage[];
|
|
@@ -39,6 +77,7 @@ export type DataContext<T = any, E = Env, P = any, S = unknown> = {
|
|
|
39
77
|
requestIp: string;
|
|
40
78
|
setEmptyResponse: () => void;
|
|
41
79
|
setHeader: (header: string, value: string) => void;
|
|
80
|
+
setCookie: (name: string, value: string | JsonLike, options?: CookieOptions) => void;
|
|
42
81
|
staticPath: string;
|
|
43
82
|
templates: Template[];
|
|
44
83
|
} & (S extends Record<string, unknown> ? {
|