@akanjs/client 0.9.56 → 0.9.57
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/cjs/src/cookie.js +0 -27
- package/cjs/src/makePageProto.js +1 -48
- package/esm/src/cookie.js +0 -27
- package/esm/src/makePageProto.js +1 -48
- package/package.json +1 -1
- package/src/cookie.d.ts +2 -4
- package/src/makePageProto.d.ts +13 -26
- package/src/types.d.ts +2 -3
- package/src/useClient.d.ts +19 -1156
package/cjs/src/cookie.js
CHANGED
|
@@ -31,8 +31,6 @@ __export(cookie_exports, {
|
|
|
31
31
|
getAccount: () => getAccount,
|
|
32
32
|
getCookie: () => getCookie,
|
|
33
33
|
getHeader: () => getHeader,
|
|
34
|
-
getMe: () => getMe,
|
|
35
|
-
getSelf: () => getSelf,
|
|
36
34
|
headers: () => headers,
|
|
37
35
|
initAuth: () => initAuth,
|
|
38
36
|
removeCookie: () => removeCookie,
|
|
@@ -49,7 +47,6 @@ var import_core = require("@capacitor/core");
|
|
|
49
47
|
var import_js_cookie = __toESM(require("js-cookie"));
|
|
50
48
|
var import_jwt_decode = require("jwt-decode");
|
|
51
49
|
var import_react = __toESM(require("react"));
|
|
52
|
-
var import_router = require("./router");
|
|
53
50
|
var import_storage = require("./storage");
|
|
54
51
|
const cookies = import_base.baseClientEnv.side === "server" ? () => {
|
|
55
52
|
const nextHeaders = require("next/headers");
|
|
@@ -99,30 +96,6 @@ const getAccount = () => {
|
|
|
99
96
|
return import_signal2.defaultAccount;
|
|
100
97
|
return account;
|
|
101
98
|
};
|
|
102
|
-
function getMe(option) {
|
|
103
|
-
const me = getAccount().me;
|
|
104
|
-
if (!me && option) {
|
|
105
|
-
if (option.unauthorize === "notFound")
|
|
106
|
-
import_router.router.notFound();
|
|
107
|
-
else if (import_base.baseClientEnv.side === "client")
|
|
108
|
-
import_router.router.replace(option.unauthorize);
|
|
109
|
-
else
|
|
110
|
-
import_react.default.use(import_router.router.redirect(option.unauthorize));
|
|
111
|
-
}
|
|
112
|
-
return me;
|
|
113
|
-
}
|
|
114
|
-
function getSelf(option) {
|
|
115
|
-
const self = getAccount().self;
|
|
116
|
-
if (!self && option) {
|
|
117
|
-
if (option.unauthorize === "notFound")
|
|
118
|
-
import_router.router.notFound();
|
|
119
|
-
else if (import_base.baseClientEnv.side === "client")
|
|
120
|
-
import_router.router.replace(option.unauthorize);
|
|
121
|
-
else
|
|
122
|
-
import_react.default.use(import_router.router.redirect(option.unauthorize));
|
|
123
|
-
}
|
|
124
|
-
return self;
|
|
125
|
-
}
|
|
126
99
|
const setAuth = ({ jwt }) => {
|
|
127
100
|
import_signal.client.setJwt(jwt);
|
|
128
101
|
setCookie("jwt", jwt);
|
package/cjs/src/makePageProto.js
CHANGED
|
@@ -60,6 +60,7 @@ const makePageProto = (cnst) => {
|
|
|
60
60
|
const { locale, path } = getPageInfo();
|
|
61
61
|
const lang = locale;
|
|
62
62
|
const l = (key, param) => clientTranslate({ lang, dictKey: key, param });
|
|
63
|
+
l._ = (key, param) => clientTranslate({ lang, dictKey: key, param });
|
|
63
64
|
l.rich = (key, param) => /* @__PURE__ */ React.createElement(
|
|
64
65
|
"span",
|
|
65
66
|
{
|
|
@@ -78,54 +79,6 @@ const makePageProto = (cnst) => {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
);
|
|
81
|
-
l.field = (model, field) => {
|
|
82
|
-
const key = `${model}.${field}`;
|
|
83
|
-
return l(key);
|
|
84
|
-
};
|
|
85
|
-
l.desc = (model, field) => {
|
|
86
|
-
const key = `${model}.desc-${field}`;
|
|
87
|
-
return l(key);
|
|
88
|
-
};
|
|
89
|
-
l.enum = (model, field, value) => {
|
|
90
|
-
const key = `${model}.enum-${field}-${value}`;
|
|
91
|
-
return l(key);
|
|
92
|
-
};
|
|
93
|
-
l.enumdesc = (model, field, value) => {
|
|
94
|
-
const key = `${model}.enumdesc-${field}-${value}`;
|
|
95
|
-
return l(key);
|
|
96
|
-
};
|
|
97
|
-
l.api = (model, endpoint) => {
|
|
98
|
-
const key = `${model}.api-${endpoint}`;
|
|
99
|
-
return l(key);
|
|
100
|
-
};
|
|
101
|
-
l.apidesc = (model, endpoint) => {
|
|
102
|
-
const key = `${model}.apidesc-${endpoint}`;
|
|
103
|
-
return l(key);
|
|
104
|
-
};
|
|
105
|
-
l.arg = (model, endpoint, arg) => {
|
|
106
|
-
const key = `${model}.arg-${endpoint}-${arg}`;
|
|
107
|
-
return l(key);
|
|
108
|
-
};
|
|
109
|
-
l.argdesc = (model, endpoint, arg) => {
|
|
110
|
-
const key = `${model}.argdesc-${endpoint}-${arg}`;
|
|
111
|
-
return l(key);
|
|
112
|
-
};
|
|
113
|
-
l.qry = (model, queryKey) => {
|
|
114
|
-
const key = `${model}.qry-${queryKey}`;
|
|
115
|
-
return l(key);
|
|
116
|
-
};
|
|
117
|
-
l.qrydesc = (model, queryKey) => {
|
|
118
|
-
const key = `${model}.qrydesc-${queryKey}`;
|
|
119
|
-
return l(key);
|
|
120
|
-
};
|
|
121
|
-
l.qarg = (model, queryKey, arg) => {
|
|
122
|
-
const key = `${model}.qarg-${queryKey}-${arg}`;
|
|
123
|
-
return l(key);
|
|
124
|
-
};
|
|
125
|
-
l.qargdesc = (model, queryKey, arg) => {
|
|
126
|
-
const key = `${model}.qargdesc-${queryKey}-${arg}`;
|
|
127
|
-
return l(key);
|
|
128
|
-
};
|
|
129
82
|
l.trans = (translation) => {
|
|
130
83
|
return translation[lang] ?? "unknown translation";
|
|
131
84
|
};
|
package/esm/src/cookie.js
CHANGED
|
@@ -6,7 +6,6 @@ import { CapacitorCookies } from "@capacitor/core";
|
|
|
6
6
|
import Cookies from "js-cookie";
|
|
7
7
|
import { jwtDecode } from "jwt-decode";
|
|
8
8
|
import React from "react";
|
|
9
|
-
import { router } from "./router";
|
|
10
9
|
import { storage } from "./storage";
|
|
11
10
|
const cookies = baseClientEnv.side === "server" ? () => {
|
|
12
11
|
const nextHeaders = require("next/headers");
|
|
@@ -56,30 +55,6 @@ const getAccount = () => {
|
|
|
56
55
|
return defaultAccount;
|
|
57
56
|
return account;
|
|
58
57
|
};
|
|
59
|
-
function getMe(option) {
|
|
60
|
-
const me = getAccount().me;
|
|
61
|
-
if (!me && option) {
|
|
62
|
-
if (option.unauthorize === "notFound")
|
|
63
|
-
router.notFound();
|
|
64
|
-
else if (baseClientEnv.side === "client")
|
|
65
|
-
router.replace(option.unauthorize);
|
|
66
|
-
else
|
|
67
|
-
React.use(router.redirect(option.unauthorize));
|
|
68
|
-
}
|
|
69
|
-
return me;
|
|
70
|
-
}
|
|
71
|
-
function getSelf(option) {
|
|
72
|
-
const self = getAccount().self;
|
|
73
|
-
if (!self && option) {
|
|
74
|
-
if (option.unauthorize === "notFound")
|
|
75
|
-
router.notFound();
|
|
76
|
-
else if (baseClientEnv.side === "client")
|
|
77
|
-
router.replace(option.unauthorize);
|
|
78
|
-
else
|
|
79
|
-
React.use(router.redirect(option.unauthorize));
|
|
80
|
-
}
|
|
81
|
-
return self;
|
|
82
|
-
}
|
|
83
58
|
const setAuth = ({ jwt }) => {
|
|
84
59
|
client.setJwt(jwt);
|
|
85
60
|
setCookie("jwt", jwt);
|
|
@@ -102,8 +77,6 @@ export {
|
|
|
102
77
|
getAccount,
|
|
103
78
|
getCookie,
|
|
104
79
|
getHeader,
|
|
105
|
-
getMe,
|
|
106
|
-
getSelf,
|
|
107
80
|
headers,
|
|
108
81
|
initAuth,
|
|
109
82
|
removeCookie,
|
package/esm/src/makePageProto.js
CHANGED
|
@@ -38,6 +38,7 @@ const makePageProto = (cnst) => {
|
|
|
38
38
|
const { locale, path } = getPageInfo();
|
|
39
39
|
const lang = locale;
|
|
40
40
|
const l = (key, param) => clientTranslate({ lang, dictKey: key, param });
|
|
41
|
+
l._ = (key, param) => clientTranslate({ lang, dictKey: key, param });
|
|
41
42
|
l.rich = (key, param) => /* @__PURE__ */ React.createElement(
|
|
42
43
|
"span",
|
|
43
44
|
{
|
|
@@ -56,54 +57,6 @@ const makePageProto = (cnst) => {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
);
|
|
59
|
-
l.field = (model, field) => {
|
|
60
|
-
const key = `${model}.${field}`;
|
|
61
|
-
return l(key);
|
|
62
|
-
};
|
|
63
|
-
l.desc = (model, field) => {
|
|
64
|
-
const key = `${model}.desc-${field}`;
|
|
65
|
-
return l(key);
|
|
66
|
-
};
|
|
67
|
-
l.enum = (model, field, value) => {
|
|
68
|
-
const key = `${model}.enum-${field}-${value}`;
|
|
69
|
-
return l(key);
|
|
70
|
-
};
|
|
71
|
-
l.enumdesc = (model, field, value) => {
|
|
72
|
-
const key = `${model}.enumdesc-${field}-${value}`;
|
|
73
|
-
return l(key);
|
|
74
|
-
};
|
|
75
|
-
l.api = (model, endpoint) => {
|
|
76
|
-
const key = `${model}.api-${endpoint}`;
|
|
77
|
-
return l(key);
|
|
78
|
-
};
|
|
79
|
-
l.apidesc = (model, endpoint) => {
|
|
80
|
-
const key = `${model}.apidesc-${endpoint}`;
|
|
81
|
-
return l(key);
|
|
82
|
-
};
|
|
83
|
-
l.arg = (model, endpoint, arg) => {
|
|
84
|
-
const key = `${model}.arg-${endpoint}-${arg}`;
|
|
85
|
-
return l(key);
|
|
86
|
-
};
|
|
87
|
-
l.argdesc = (model, endpoint, arg) => {
|
|
88
|
-
const key = `${model}.argdesc-${endpoint}-${arg}`;
|
|
89
|
-
return l(key);
|
|
90
|
-
};
|
|
91
|
-
l.qry = (model, queryKey) => {
|
|
92
|
-
const key = `${model}.qry-${queryKey}`;
|
|
93
|
-
return l(key);
|
|
94
|
-
};
|
|
95
|
-
l.qrydesc = (model, queryKey) => {
|
|
96
|
-
const key = `${model}.qrydesc-${queryKey}`;
|
|
97
|
-
return l(key);
|
|
98
|
-
};
|
|
99
|
-
l.qarg = (model, queryKey, arg) => {
|
|
100
|
-
const key = `${model}.qarg-${queryKey}-${arg}`;
|
|
101
|
-
return l(key);
|
|
102
|
-
};
|
|
103
|
-
l.qargdesc = (model, queryKey, arg) => {
|
|
104
|
-
const key = `${model}.qargdesc-${queryKey}-${arg}`;
|
|
105
|
-
return l(key);
|
|
106
|
-
};
|
|
107
60
|
l.trans = (translation) => {
|
|
108
61
|
return translation[lang] ?? "unknown translation";
|
|
109
62
|
};
|
package/package.json
CHANGED
package/src/cookie.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Account
|
|
1
|
+
import { type Account } from "@akanjs/signal";
|
|
2
2
|
export declare const cookies: () => Map<string, {
|
|
3
3
|
name: string;
|
|
4
4
|
value: string;
|
|
@@ -10,12 +10,10 @@ export declare const removeCookie: (key: string, options?: {
|
|
|
10
10
|
}) => boolean | undefined;
|
|
11
11
|
export declare const headers: () => Map<string, string>;
|
|
12
12
|
export declare const getHeader: (key: string) => string | undefined;
|
|
13
|
-
export declare const getAccount: () => Account
|
|
13
|
+
export declare const getAccount: <AddData = unknown>() => Account<AddData>;
|
|
14
14
|
export interface GetOption {
|
|
15
15
|
unauthorize: string;
|
|
16
16
|
}
|
|
17
|
-
export declare function getMe<O extends GetOption | undefined>(option?: O): O extends GetOption ? Me : Me | undefined;
|
|
18
|
-
export declare function getSelf<O extends GetOption | undefined>(option?: O): O extends GetOption ? Self : Self | undefined;
|
|
19
17
|
interface SetAuthOption {
|
|
20
18
|
jwt: string;
|
|
21
19
|
}
|
package/src/makePageProto.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AllDictionary
|
|
1
|
+
import { AllDictionary } from "@akanjs/dictionary";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
export interface TransMessageOption {
|
|
4
4
|
key?: string;
|
|
@@ -7,13 +7,9 @@ export interface TransMessageOption {
|
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export declare const makePageProto: <
|
|
11
|
-
[key: string]: {
|
|
12
|
-
[key: string]: Translation;
|
|
13
|
-
};
|
|
14
|
-
}, Fetch, Sig>(cnst: any) => {
|
|
10
|
+
export declare const makePageProto: <DictKey extends string, ErrorKey extends string, Fetch, Sig>(cnst: any) => {
|
|
15
11
|
Revert: {
|
|
16
|
-
new (key:
|
|
12
|
+
new (key: ErrorKey, data?: any): {
|
|
17
13
|
name: string;
|
|
18
14
|
message: string;
|
|
19
15
|
stack?: string;
|
|
@@ -23,33 +19,24 @@ export declare const makePageProto: <Locale extends {
|
|
|
23
19
|
stackTraceLimit: number;
|
|
24
20
|
};
|
|
25
21
|
msg: {
|
|
26
|
-
info: (key:
|
|
27
|
-
success: (key:
|
|
28
|
-
error: (key:
|
|
29
|
-
warning: (key:
|
|
30
|
-
loading: (key:
|
|
22
|
+
info: (key: DictKey, option?: TransMessageOption) => void;
|
|
23
|
+
success: (key: DictKey, option?: TransMessageOption) => void;
|
|
24
|
+
error: (key: DictKey | ErrorKey, option?: TransMessageOption) => void;
|
|
25
|
+
warning: (key: DictKey, option?: TransMessageOption) => void;
|
|
26
|
+
loading: (key: DictKey, option?: TransMessageOption) => void;
|
|
31
27
|
};
|
|
32
28
|
usePage: () => {
|
|
33
29
|
path: string;
|
|
34
30
|
l: {
|
|
35
|
-
(key:
|
|
31
|
+
(key: DictKey, param?: {
|
|
32
|
+
[key: string]: string | number;
|
|
33
|
+
}): string;
|
|
34
|
+
_(key: string, param?: {
|
|
36
35
|
[key: string]: string | number;
|
|
37
36
|
}): string;
|
|
38
|
-
rich(key:
|
|
37
|
+
rich(key: DictKey, param?: {
|
|
39
38
|
[key: string]: string | number;
|
|
40
39
|
}): ReactNode;
|
|
41
|
-
field<ModelKey extends keyof Locale>(model: ModelKey, field: keyof Locale[ModelKey]): string;
|
|
42
|
-
desc<ModelKey extends keyof Locale>(model: ModelKey, field: keyof Locale[ModelKey]): string;
|
|
43
|
-
enum<ModelKey extends keyof Locale>(model: ModelKey, field: keyof Locale[ModelKey], value: string): string;
|
|
44
|
-
enumdesc<ModelKey extends keyof Locale>(model: ModelKey, field: keyof Locale[ModelKey], value: string): string;
|
|
45
|
-
api<ModelKey extends keyof Locale>(model: ModelKey, endpoint: keyof Locale[ModelKey]): string;
|
|
46
|
-
apidesc<ModelKey extends keyof Locale>(model: ModelKey, endpoint: keyof Locale[ModelKey]): string;
|
|
47
|
-
arg<ModelKey extends keyof Locale>(model: ModelKey, endpoint: keyof Locale[ModelKey], arg: string): string;
|
|
48
|
-
argdesc<ModelKey extends keyof Locale>(model: ModelKey, endpoint: keyof Locale[ModelKey], arg: string): string;
|
|
49
|
-
qry<ModelKey extends keyof Locale>(model: ModelKey, queryKey: keyof Locale[ModelKey]): string;
|
|
50
|
-
qrydesc<ModelKey extends keyof Locale>(model: ModelKey, queryKey: keyof Locale[ModelKey]): string;
|
|
51
|
-
qarg<ModelKey extends keyof Locale>(model: ModelKey, queryKey: keyof Locale[ModelKey], arg: string): string;
|
|
52
|
-
qargdesc<ModelKey extends keyof Locale>(model: ModelKey, queryKey: keyof Locale[ModelKey], arg: string): string;
|
|
53
40
|
trans<Returns extends ReactNode>(translation: Record<"en" | "ko" | (string & {}), Returns>): Returns extends string ? string : Returns;
|
|
54
41
|
};
|
|
55
42
|
lang: string;
|
package/src/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseInsight } from "@akanjs/base";
|
|
1
2
|
import type { FetchInitForm } from "@akanjs/signal";
|
|
2
3
|
import { type ClassValue } from "clsx";
|
|
3
4
|
import type { ReactElement, ReactNode } from "react";
|
|
@@ -43,9 +44,7 @@ export interface ModelDashboardProps<Summary> {
|
|
|
43
44
|
hidePresents?: boolean;
|
|
44
45
|
sliceName?: string;
|
|
45
46
|
}
|
|
46
|
-
export interface ModelInsightProps<Insight = {
|
|
47
|
-
count: number;
|
|
48
|
-
}> {
|
|
47
|
+
export interface ModelInsightProps<Insight = BaseInsight> {
|
|
49
48
|
className?: string;
|
|
50
49
|
insight: Insight;
|
|
51
50
|
sliceName?: string;
|