@mono-lit/utility 0.0.0-stage → 0.0.1
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/LICENSE.md +54 -0
- package/README.md +156 -2
- package/dist/app-roots-BJsIxzjk.d.ts +91 -0
- package/dist/app-roots-CvJnmXcs.js +128 -0
- package/dist/config-node-UzJrXg0Z.js +76 -0
- package/dist/config-node.d.ts +977 -0
- package/dist/config-node.js +7 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +3 -0
- package/dist/create-config-D3m6xTaQ.d.ts +733 -0
- package/dist/create-config-DdL3Fh6T.js +357 -0
- package/dist/fetching.d.ts +239 -0
- package/dist/fetching.js +867 -0
- package/dist/generate-CJ7MtcDd.js +291 -0
- package/dist/index-C2hZeNkq.d.ts +365 -0
- package/dist/index-ClrZbU7n.d.ts +518 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +939 -0
- package/dist/merge-file-C5nzi_MY.d.ts +122 -0
- package/dist/merge-file-CtyKTu5L.js +133 -0
- package/dist/mock-db-5mJTObSC.js +1282 -0
- package/dist/mock-db.d.ts +2 -0
- package/dist/mock-db.js +4 -0
- package/dist/mono-alias-DNDm-jB_.js +508 -0
- package/dist/mono-clone.mjs +958 -0
- package/dist/mono-db.d.ts +1 -0
- package/dist/mono-db.js +151 -0
- package/dist/mono-env.mjs +231 -0
- package/dist/mono-git.mjs +798 -0
- package/dist/mono-link-YlOQ2PVS.js +488 -0
- package/dist/mono-prepare.d.ts +1 -0
- package/dist/mono-prepare.js +27 -0
- package/dist/mono-skills.d.ts +1 -0
- package/dist/mono-skills.js +830 -0
- package/dist/mono-tsconfig-D2qRL9_R.js +204 -0
- package/dist/mono.mjs +34 -0
- package/dist/nuxt-layers-DP1m7f1-.js +176 -0
- package/dist/nuxt-layers.d.ts +34 -0
- package/dist/nuxt-layers.js +3 -0
- package/dist/nuxt-runtime.d.ts +18 -0
- package/dist/nuxt-runtime.js +102 -0
- package/dist/nuxt.d.ts +386 -0
- package/dist/nuxt.js +590 -0
- package/dist/runtime-C_IWNrAG.js +5817 -0
- package/dist/runtime.d.ts +2583 -0
- package/dist/runtime.js +4 -0
- package/dist/session-Bk985AIM.js +1721 -0
- package/dist/types-B6FdB7LJ.d.ts +57 -0
- package/dist/universal-B2eD9xho.d.ts +97 -0
- package/dist/universal-BNTo_83u.js +599 -0
- package/dist/virtual-mono-apps.d.ts +16 -0
- package/dist/vite.d.ts +940 -0
- package/dist/vite.js +1132 -0
- package/package.json +141 -3
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/token/types.d.ts
|
|
2
|
+
interface CookieParams {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
days?: number;
|
|
6
|
+
milis?: number;
|
|
7
|
+
split?: boolean | string;
|
|
8
|
+
splitEvery?: number;
|
|
9
|
+
}
|
|
10
|
+
type MonoFetchCookieOptions = {
|
|
11
|
+
name?: CookieTokenParams['name'];
|
|
12
|
+
path?: CookieTokenParams['path'];
|
|
13
|
+
fetchParams?: CookieTokenParams['fetchParams'];
|
|
14
|
+
splitCookie?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type JWTPayload<T extends object> = T & {
|
|
17
|
+
nbf: string;
|
|
18
|
+
exp: string;
|
|
19
|
+
iat: string;
|
|
20
|
+
};
|
|
21
|
+
interface LocalStorageParams {
|
|
22
|
+
name?: string | string[] | RegExp;
|
|
23
|
+
value?: any;
|
|
24
|
+
items?: LocalStorageParams[];
|
|
25
|
+
type?: 'local' | 'session';
|
|
26
|
+
}
|
|
27
|
+
type NormalFetchOptions = RequestInit & {
|
|
28
|
+
token?: string;
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
unauthCall?: () => void;
|
|
31
|
+
callback?: (item: NormalFetchResult<Record<string, any>>) => void;
|
|
32
|
+
};
|
|
33
|
+
interface CookieTokenParams {
|
|
34
|
+
name?: string;
|
|
35
|
+
value?: string;
|
|
36
|
+
days?: number;
|
|
37
|
+
milis?: number;
|
|
38
|
+
path?: {
|
|
39
|
+
milis?: string;
|
|
40
|
+
days?: string;
|
|
41
|
+
value?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
};
|
|
44
|
+
fetchParams?: {
|
|
45
|
+
url?: string;
|
|
46
|
+
options?: NormalFetchOptions | undefined;
|
|
47
|
+
};
|
|
48
|
+
splitCookie?: boolean;
|
|
49
|
+
}
|
|
50
|
+
type NormalFetchResult<T> = {
|
|
51
|
+
statusCode: number;
|
|
52
|
+
data: T | null;
|
|
53
|
+
message: string | null;
|
|
54
|
+
all: any;
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { MonoFetchCookieOptions as a, LocalStorageParams as i, CookieTokenParams as n, NormalFetchOptions as o, JWTPayload as r, NormalFetchResult as s, CookieParams as t };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { a as MonoFetchCookieOptions, i as LocalStorageParams, n as CookieTokenParams, r as JWTPayload, t as CookieParams } from "./types-B6FdB7LJ.js";
|
|
2
|
+
|
|
3
|
+
//#region src/token/cookie-core.d.ts
|
|
4
|
+
interface CookieApi {
|
|
5
|
+
get(name: string, split?: boolean | string): string | null;
|
|
6
|
+
add(params: CookieParams): string | null | undefined;
|
|
7
|
+
remove(name: string, split?: boolean | string): boolean;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/composables/universal.d.ts
|
|
11
|
+
/** Minimal shape of an h3/Nuxt request event we rely on (kept loose on purpose). */
|
|
12
|
+
type MonoRequestEvent = any;
|
|
13
|
+
/**
|
|
14
|
+
* Wire how the SSR cookie utils find the current request event. Call once from a
|
|
15
|
+
* Nuxt plugin: `setMonoEventResolver(() => useRequestEvent())`. Without it (and
|
|
16
|
+
* without an explicit `event` argument) the server utils degrade to empty reads.
|
|
17
|
+
*/
|
|
18
|
+
declare function setMonoEventResolver(fn: (() => MonoRequestEvent | undefined) | undefined): void;
|
|
19
|
+
/** Cookie util. Client: document.cookie. Server: the h3 request event (sync). */
|
|
20
|
+
declare function monoCookie(event?: MonoRequestEvent): CookieApi;
|
|
21
|
+
/** Token util. Client: document.cookie. Server: the h3 request event (sync). */
|
|
22
|
+
declare function monoToken(options?: CookieTokenParams, event?: MonoRequestEvent): {
|
|
23
|
+
decode: <T extends object>(name?: CookieTokenParams["name"], split?: boolean) => JWTPayload<T> | null;
|
|
24
|
+
add: ({
|
|
25
|
+
name,
|
|
26
|
+
value,
|
|
27
|
+
days,
|
|
28
|
+
milis,
|
|
29
|
+
splitCookie
|
|
30
|
+
}: Pick<CookieTokenParams, "name" | "value" | "days" | "milis" | "splitCookie">) => string | null | undefined;
|
|
31
|
+
get: (name?: CookieTokenParams["name"], split?: boolean) => CookieTokenParams["value"] | null;
|
|
32
|
+
replace: ({
|
|
33
|
+
name,
|
|
34
|
+
value,
|
|
35
|
+
days,
|
|
36
|
+
milis,
|
|
37
|
+
splitCookie
|
|
38
|
+
}: Pick<CookieTokenParams, "name" | "value" | "days" | "milis" | "splitCookie">) => boolean;
|
|
39
|
+
fetch: <T = Record<string, any>>({
|
|
40
|
+
fetchParams,
|
|
41
|
+
name,
|
|
42
|
+
path,
|
|
43
|
+
splitCookie
|
|
44
|
+
}?: MonoFetchCookieOptions) => Promise<{
|
|
45
|
+
response: T | null;
|
|
46
|
+
cookie: string | null | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
validate: (name?: CookieTokenParams["name"], split?: boolean) => boolean;
|
|
49
|
+
wrap: <T = any>({
|
|
50
|
+
name,
|
|
51
|
+
fetchParams,
|
|
52
|
+
path,
|
|
53
|
+
splitCookie
|
|
54
|
+
}?: Pick<CookieTokenParams, "name" | "splitCookie" | "fetchParams" | "path">, callback?: (value?: string | null) => T | undefined | Promise<T | undefined>) => Promise<T | undefined>;
|
|
55
|
+
};
|
|
56
|
+
/** JWT util. `cookieDecode({ cookie })` reads via the isomorphic cookie util. */
|
|
57
|
+
declare function monoJwt(event?: MonoRequestEvent): {
|
|
58
|
+
isJwt: (jwt: string) => boolean;
|
|
59
|
+
cookieDecode: <T extends object>({
|
|
60
|
+
cookie,
|
|
61
|
+
token,
|
|
62
|
+
splitCookie
|
|
63
|
+
}: {
|
|
64
|
+
splitCookie?: CookieParams["split"];
|
|
65
|
+
cookie?: CookieParams["name"];
|
|
66
|
+
token?: CookieParams["value"];
|
|
67
|
+
}) => JWTPayload<T> | null;
|
|
68
|
+
};
|
|
69
|
+
/** Storage util. Client: localStorage/sessionStorage. Server: safe no-op. */
|
|
70
|
+
declare function monoStorage(options?: LocalStorageParams): {
|
|
71
|
+
get: (name: LocalStorageParams["name"]) => LocalStorageParams["value"] | LocalStorageParams[] | null;
|
|
72
|
+
add: ({
|
|
73
|
+
name,
|
|
74
|
+
value,
|
|
75
|
+
items
|
|
76
|
+
}: Pick<LocalStorageParams, "name" | "value" | "items">) => string | null;
|
|
77
|
+
remove: (name: LocalStorageParams["name"]) => boolean;
|
|
78
|
+
change: ({
|
|
79
|
+
name,
|
|
80
|
+
value
|
|
81
|
+
}: Pick<LocalStorageParams, "name" | "value">) => string | null;
|
|
82
|
+
pull: (name: LocalStorageParams["name"]) => LocalStorageParams["value"] | null;
|
|
83
|
+
redirect: (url: string, {
|
|
84
|
+
name,
|
|
85
|
+
value,
|
|
86
|
+
items
|
|
87
|
+
}: Pick<LocalStorageParams, "name" | "value" | "items">) => void;
|
|
88
|
+
} | {
|
|
89
|
+
get: () => null;
|
|
90
|
+
add: (_: Pick<LocalStorageParams, "name" | "value" | "items">) => null;
|
|
91
|
+
remove: (_?: LocalStorageParams["name"]) => boolean;
|
|
92
|
+
change: (_: Pick<LocalStorageParams, "name" | "value">) => null;
|
|
93
|
+
pull: (_?: LocalStorageParams["name"]) => null;
|
|
94
|
+
redirect: () => void;
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { monoToken as a, monoStorage as i, monoCookie as n, setMonoEventResolver as o, monoJwt as r, CookieApi as s, MonoRequestEvent as t };
|