@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.
Files changed (54) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +156 -2
  3. package/dist/app-roots-BJsIxzjk.d.ts +91 -0
  4. package/dist/app-roots-CvJnmXcs.js +128 -0
  5. package/dist/config-node-UzJrXg0Z.js +76 -0
  6. package/dist/config-node.d.ts +977 -0
  7. package/dist/config-node.js +7 -0
  8. package/dist/config.d.ts +2 -0
  9. package/dist/config.js +3 -0
  10. package/dist/create-config-D3m6xTaQ.d.ts +733 -0
  11. package/dist/create-config-DdL3Fh6T.js +357 -0
  12. package/dist/fetching.d.ts +239 -0
  13. package/dist/fetching.js +867 -0
  14. package/dist/generate-CJ7MtcDd.js +291 -0
  15. package/dist/index-C2hZeNkq.d.ts +365 -0
  16. package/dist/index-ClrZbU7n.d.ts +518 -0
  17. package/dist/index.d.ts +29 -0
  18. package/dist/index.js +939 -0
  19. package/dist/merge-file-C5nzi_MY.d.ts +122 -0
  20. package/dist/merge-file-CtyKTu5L.js +133 -0
  21. package/dist/mock-db-5mJTObSC.js +1282 -0
  22. package/dist/mock-db.d.ts +2 -0
  23. package/dist/mock-db.js +4 -0
  24. package/dist/mono-alias-DNDm-jB_.js +508 -0
  25. package/dist/mono-clone.mjs +958 -0
  26. package/dist/mono-db.d.ts +1 -0
  27. package/dist/mono-db.js +151 -0
  28. package/dist/mono-env.mjs +231 -0
  29. package/dist/mono-git.mjs +798 -0
  30. package/dist/mono-link-YlOQ2PVS.js +488 -0
  31. package/dist/mono-prepare.d.ts +1 -0
  32. package/dist/mono-prepare.js +27 -0
  33. package/dist/mono-skills.d.ts +1 -0
  34. package/dist/mono-skills.js +830 -0
  35. package/dist/mono-tsconfig-D2qRL9_R.js +204 -0
  36. package/dist/mono.mjs +34 -0
  37. package/dist/nuxt-layers-DP1m7f1-.js +176 -0
  38. package/dist/nuxt-layers.d.ts +34 -0
  39. package/dist/nuxt-layers.js +3 -0
  40. package/dist/nuxt-runtime.d.ts +18 -0
  41. package/dist/nuxt-runtime.js +102 -0
  42. package/dist/nuxt.d.ts +386 -0
  43. package/dist/nuxt.js +590 -0
  44. package/dist/runtime-C_IWNrAG.js +5817 -0
  45. package/dist/runtime.d.ts +2583 -0
  46. package/dist/runtime.js +4 -0
  47. package/dist/session-Bk985AIM.js +1721 -0
  48. package/dist/types-B6FdB7LJ.d.ts +57 -0
  49. package/dist/universal-B2eD9xho.d.ts +97 -0
  50. package/dist/universal-BNTo_83u.js +599 -0
  51. package/dist/virtual-mono-apps.d.ts +16 -0
  52. package/dist/vite.d.ts +940 -0
  53. package/dist/vite.js +1132 -0
  54. 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 };