@kanorio/sdk 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +66 -2
- package/dist/customer-oauth.d.ts +86 -0
- package/dist/customer-oauth.js +112 -0
- package/dist/customer.d.ts +176 -0
- package/dist/customer.js +116 -0
- package/dist/delivery.d.ts +35 -0
- package/dist/delivery.js +49 -0
- package/dist/edge.d.ts +104 -0
- package/dist/edge.js +287 -0
- package/dist/forms.d.ts +123 -0
- package/dist/forms.js +130 -0
- package/dist/generated/customer.d.ts +3157 -0
- package/dist/generated/delivery.d.ts +2380 -0
- package/dist/generated/management.d.ts +38248 -0
- package/dist/http.d.ts +73 -0
- package/dist/http.js +162 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +17 -0
- package/dist/locales.d.ts +80 -0
- package/dist/locales.js +81 -0
- package/dist/management.d.ts +19 -0
- package/dist/management.js +22 -0
- package/dist/paginate.d.ts +18 -0
- package/dist/paginate.js +27 -0
- package/dist/preview.d.ts +40 -0
- package/dist/preview.js +131 -0
- package/dist/protection.d.ts +74 -0
- package/dist/protection.js +68 -0
- package/dist/revalidate.d.ts +84 -0
- package/dist/revalidate.js +143 -0
- package/dist/seo.d.ts +120 -0
- package/dist/seo.js +125 -0
- package/dist/server-key.d.ts +71 -0
- package/dist/server-key.js +103 -0
- package/dist/shared/api/delivery/cache-tags.d.ts +142 -0
- package/dist/shared/api/delivery/cache-tags.js +212 -0
- package/dist/shared/api/server-key.d.ts +86 -0
- package/dist/shared/api/server-key.js +252 -0
- package/dist/shared/business-registry/attribution.d.ts +14 -0
- package/dist/shared/business-registry/attribution.js +28 -0
- package/dist/shared/business-registry/define.d.ts +3 -0
- package/dist/shared/business-registry/define.js +4 -0
- package/dist/shared/business-registry/formats/eu-vat.d.ts +2 -0
- package/dist/shared/business-registry/formats/eu-vat.js +54 -0
- package/dist/shared/business-registry/formats/hk-br.d.ts +5 -0
- package/dist/shared/business-registry/formats/hk-br.js +23 -0
- package/dist/shared/business-registry/formats/jp-trn.d.ts +6 -0
- package/dist/shared/business-registry/formats/jp-trn.js +23 -0
- package/dist/shared/business-registry/formats/kr-brn.d.ts +6 -0
- package/dist/shared/business-registry/formats/kr-brn.js +30 -0
- package/dist/shared/business-registry/formats/my.d.ts +7 -0
- package/dist/shared/business-registry/formats/my.js +32 -0
- package/dist/shared/business-registry/formats/sg-uen.d.ts +1 -0
- package/dist/shared/business-registry/formats/sg-uen.js +21 -0
- package/dist/shared/business-registry/formats/tw-vat.d.ts +10 -0
- package/dist/shared/business-registry/formats/tw-vat.js +32 -0
- package/dist/shared/business-registry/index.d.ts +9 -0
- package/dist/shared/business-registry/index.js +10 -0
- package/dist/shared/business-registry/lookup-wire.d.ts +33 -0
- package/dist/shared/business-registry/lookup-wire.js +8 -0
- package/dist/shared/business-registry/normalize.d.ts +7 -0
- package/dist/shared/business-registry/normalize.js +12 -0
- package/dist/shared/business-registry/registry.d.ts +26 -0
- package/dist/shared/business-registry/registry.js +67 -0
- package/dist/shared/business-registry/types.d.ts +60 -0
- package/dist/shared/business-registry/types.js +10 -0
- package/dist/shared/localization/locale-path.d.ts +38 -0
- package/dist/shared/localization/locale-path.js +76 -0
- package/dist/shared/localization/request-locale.d.ts +42 -0
- package/dist/shared/localization/request-locale.js +61 -0
- package/dist/shared/seo/alternates.d.ts +61 -0
- package/dist/shared/seo/alternates.js +71 -0
- package/dist/shared/types/forms-logic.d.ts +96 -0
- package/dist/shared/types/forms-logic.js +209 -0
- package/dist/shared/types/number-input.d.ts +5 -0
- package/dist/shared/types/number-input.js +16 -0
- package/dist/shared/utils/redirect-matching.d.ts +67 -0
- package/dist/shared/utils/redirect-matching.js +148 -0
- package/dist/tax-id.d.ts +7 -0
- package/dist/tax-id.js +6 -0
- package/dist/typed.d.ts +85 -0
- package/dist/typed.js +28 -0
- package/package.json +86 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 線上表單的條件顯示:「選了 A 才出現這一題」。
|
|
3
|
+
*
|
|
4
|
+
* 一題可以帶 `visibleWhen`:一組條件(最多 5 個),全部符合(`all`)或任一符合(`any`)時才顯示。
|
|
5
|
+
* 前台(決定畫哪些題)與伺服器(決定驗哪些題、存哪些答案)都呼叫 `resolveVisibleFieldIds`,所以兩邊一定一致:
|
|
6
|
+
* 被隱藏的題目不顯示、不驗證(必填也不擋)、答案存 null。
|
|
7
|
+
*
|
|
8
|
+
* 規則:
|
|
9
|
+
* - 條件只能參照排在前面的題目(`kind: "field"`)或表單的隱藏欄位(`kind: "hidden"`)
|
|
10
|
+
* - 來源題自己被隱藏時,當作沒有作答
|
|
11
|
+
* - Email 與電話題不能被隱藏(它們是聯絡人的識別,表單的其他規則都靠它們)
|
|
12
|
+
* - 規則無法判斷時(來源不存在、排在後面、運算子不適用)一律顯示:寧可多問一題,不要讓必填題永遠藏起來
|
|
13
|
+
*
|
|
14
|
+
* 零依賴的純函式:`@kanorio/sdk` 以複製的方式帶走,自建前端用同一份判斷。資料夾內只用相對 import。
|
|
15
|
+
* 之後要做計分時,在 `kind` 加一種來源(變數)即可,不用搬資料。
|
|
16
|
+
*/
|
|
17
|
+
export declare const FORM_CONDITION_OPS: readonly ["answered", "not_answered", "includes", "not_includes", "equals", "not_equals", "contains", "gt", "gte", "lt", "lte"];
|
|
18
|
+
export type FormConditionOp = (typeof FORM_CONDITION_OPS)[number];
|
|
19
|
+
export declare const FORM_LOGIC_LIMITS: {
|
|
20
|
+
/** 一題最多幾個條件 */
|
|
21
|
+
readonly MAX_CONDITIONS: 5;
|
|
22
|
+
/** 條件比對文字的長度上限 */
|
|
23
|
+
readonly VALUE_MAX: 200;
|
|
24
|
+
};
|
|
25
|
+
export interface FormCondition {
|
|
26
|
+
/** 來源是題目(`ref` 為題目 id)還是隱藏欄位(`ref` 為隱藏欄位 id) */
|
|
27
|
+
kind: "field" | "hidden";
|
|
28
|
+
ref: string;
|
|
29
|
+
op: FormConditionOp;
|
|
30
|
+
/** 選項 id(includes)、比對文字(equals/contains)或數字(數字比較);有無作答不用值 */
|
|
31
|
+
value?: string | number;
|
|
32
|
+
}
|
|
33
|
+
export interface FormVisibleWhen {
|
|
34
|
+
match: "all" | "any";
|
|
35
|
+
conditions: FormCondition[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 每種來源可以用哪些運算子。電話、日期、時間、Email 只能判斷有沒有作答;檔案、說明文字、地址與稅號不能當來源(空陣列)。
|
|
39
|
+
* 新增題型時要在這裡補一筆(forms.ts 有編譯期檢查)。
|
|
40
|
+
*/
|
|
41
|
+
export declare const CONDITION_OPS_BY_TYPE: {
|
|
42
|
+
readonly short_text: readonly ["answered", "not_answered", "equals", "not_equals", "contains"];
|
|
43
|
+
readonly long_text: readonly ["answered", "not_answered", "equals", "not_equals", "contains"];
|
|
44
|
+
readonly url: readonly ["answered", "not_answered", "equals", "not_equals", "contains"];
|
|
45
|
+
readonly email: readonly ["answered", "not_answered"];
|
|
46
|
+
readonly phone: readonly ["answered", "not_answered"];
|
|
47
|
+
readonly date: readonly ["answered", "not_answered"];
|
|
48
|
+
readonly time: readonly ["answered", "not_answered"];
|
|
49
|
+
readonly choice: readonly ["answered", "not_answered", "includes", "not_includes"];
|
|
50
|
+
readonly number: readonly ["answered", "not_answered", "equals", "not_equals", "gt", "gte", "lt", "lte"];
|
|
51
|
+
readonly rating: readonly ["answered", "not_answered", "equals", "not_equals", "gt", "gte", "lt", "lte"];
|
|
52
|
+
readonly file: readonly [];
|
|
53
|
+
readonly statement: readonly [];
|
|
54
|
+
readonly address: readonly [];
|
|
55
|
+
readonly tax_id: readonly [];
|
|
56
|
+
/** 隱藏欄位(網址參數帶入的字串) */
|
|
57
|
+
readonly hidden: readonly ["answered", "not_answered", "equals", "not_equals", "contains"];
|
|
58
|
+
};
|
|
59
|
+
export type FormConditionSourceType = keyof typeof CONDITION_OPS_BY_TYPE;
|
|
60
|
+
export declare function conditionOpsFor(sourceType: string): readonly FormConditionOp[];
|
|
61
|
+
/** 這個運算子要搭配哪一種值 */
|
|
62
|
+
export type FormConditionValueKind = "none" | "option" | "text" | "number";
|
|
63
|
+
export declare function conditionValueKind(sourceType: string, op: FormConditionOp): FormConditionValueKind;
|
|
64
|
+
/** 條件判斷需要的題目資訊(表單定義的子集) */
|
|
65
|
+
export interface LogicField {
|
|
66
|
+
id: string;
|
|
67
|
+
type: string;
|
|
68
|
+
visibleWhen?: FormVisibleWhen | null;
|
|
69
|
+
options?: ReadonlyArray<{
|
|
70
|
+
id: string;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
export type FormConditionIssue =
|
|
74
|
+
/** 來源不存在,或不是排在前面的題目 */
|
|
75
|
+
"missing_source" | "op_not_allowed" | "value_required" | "value_unexpected"
|
|
76
|
+
/** 值的型別不對(該填數字卻是文字,或反過來) */
|
|
77
|
+
| "value_type" | "unknown_option";
|
|
78
|
+
/**
|
|
79
|
+
* 檢查一個條件對它的來源是否成立。`source` 為 undefined 表示找不到來源。
|
|
80
|
+
* schema(存檔時擋)與編輯器(即時標示)共用。
|
|
81
|
+
*/
|
|
82
|
+
export declare function findConditionIssue(condition: FormCondition, source: {
|
|
83
|
+
type: string;
|
|
84
|
+
options?: ReadonlyArray<{
|
|
85
|
+
id: string;
|
|
86
|
+
}>;
|
|
87
|
+
} | undefined): FormConditionIssue | null;
|
|
88
|
+
/** 單一條件對一個答案是否成立;運算子不適用於這種來源時回 null(無法判斷) */
|
|
89
|
+
export declare function evaluateCondition(condition: FormCondition, sourceType: string, raw: unknown): boolean | null;
|
|
90
|
+
/**
|
|
91
|
+
* 依目前的答案算出要顯示哪些題目。`answers` 是「題目 id 或隱藏欄位 id → 值」(訪客輸入的原始值即可)。
|
|
92
|
+
* 依題目順序往下算:前面的題目被隱藏時,參照它的條件把它當作沒有作答。
|
|
93
|
+
*/
|
|
94
|
+
export declare function resolveVisibleFieldIds(fields: readonly LogicField[], answers: Readonly<Record<string, unknown>>): Set<string>;
|
|
95
|
+
/** 這張表單有沒有任何條件顯示(沒有的話前台不用每次輸入都重算) */
|
|
96
|
+
export declare function hasVisibilityRules(fields: readonly LogicField[]): boolean;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// 由 `pnpm --filter @kanorio/sdk gen` 從 packages/shared 複製,請勿手改(契約測試鎖兩份相同)。
|
|
2
|
+
/**
|
|
3
|
+
* 線上表單的條件顯示:「選了 A 才出現這一題」。
|
|
4
|
+
*
|
|
5
|
+
* 一題可以帶 `visibleWhen`:一組條件(最多 5 個),全部符合(`all`)或任一符合(`any`)時才顯示。
|
|
6
|
+
* 前台(決定畫哪些題)與伺服器(決定驗哪些題、存哪些答案)都呼叫 `resolveVisibleFieldIds`,所以兩邊一定一致:
|
|
7
|
+
* 被隱藏的題目不顯示、不驗證(必填也不擋)、答案存 null。
|
|
8
|
+
*
|
|
9
|
+
* 規則:
|
|
10
|
+
* - 條件只能參照排在前面的題目(`kind: "field"`)或表單的隱藏欄位(`kind: "hidden"`)
|
|
11
|
+
* - 來源題自己被隱藏時,當作沒有作答
|
|
12
|
+
* - Email 與電話題不能被隱藏(它們是聯絡人的識別,表單的其他規則都靠它們)
|
|
13
|
+
* - 規則無法判斷時(來源不存在、排在後面、運算子不適用)一律顯示:寧可多問一題,不要讓必填題永遠藏起來
|
|
14
|
+
*
|
|
15
|
+
* 零依賴的純函式:`@kanorio/sdk` 以複製的方式帶走,自建前端用同一份判斷。資料夾內只用相對 import。
|
|
16
|
+
* 之後要做計分時,在 `kind` 加一種來源(變數)即可,不用搬資料。
|
|
17
|
+
*/
|
|
18
|
+
import { parseNumberInput } from "./number-input.js";
|
|
19
|
+
export const FORM_CONDITION_OPS = [
|
|
20
|
+
"answered",
|
|
21
|
+
"not_answered",
|
|
22
|
+
"includes",
|
|
23
|
+
"not_includes",
|
|
24
|
+
"equals",
|
|
25
|
+
"not_equals",
|
|
26
|
+
"contains",
|
|
27
|
+
"gt",
|
|
28
|
+
"gte",
|
|
29
|
+
"lt",
|
|
30
|
+
"lte",
|
|
31
|
+
];
|
|
32
|
+
export const FORM_LOGIC_LIMITS = {
|
|
33
|
+
/** 一題最多幾個條件 */
|
|
34
|
+
MAX_CONDITIONS: 5,
|
|
35
|
+
/** 條件比對文字的長度上限 */
|
|
36
|
+
VALUE_MAX: 200,
|
|
37
|
+
};
|
|
38
|
+
const PRESENCE_OPS = ["answered", "not_answered"];
|
|
39
|
+
const TEXT_OPS = ["answered", "not_answered", "equals", "not_equals", "contains"];
|
|
40
|
+
const CHOICE_OPS = ["answered", "not_answered", "includes", "not_includes"];
|
|
41
|
+
const NUMBER_OPS = ["answered", "not_answered", "equals", "not_equals", "gt", "gte", "lt", "lte"];
|
|
42
|
+
/**
|
|
43
|
+
* 每種來源可以用哪些運算子。電話、日期、時間、Email 只能判斷有沒有作答;檔案、說明文字、地址與稅號不能當來源(空陣列)。
|
|
44
|
+
* 新增題型時要在這裡補一筆(forms.ts 有編譯期檢查)。
|
|
45
|
+
*/
|
|
46
|
+
export const CONDITION_OPS_BY_TYPE = {
|
|
47
|
+
short_text: TEXT_OPS,
|
|
48
|
+
long_text: TEXT_OPS,
|
|
49
|
+
url: TEXT_OPS,
|
|
50
|
+
email: PRESENCE_OPS,
|
|
51
|
+
phone: PRESENCE_OPS,
|
|
52
|
+
date: PRESENCE_OPS,
|
|
53
|
+
time: PRESENCE_OPS,
|
|
54
|
+
choice: CHOICE_OPS,
|
|
55
|
+
number: NUMBER_OPS,
|
|
56
|
+
rating: NUMBER_OPS,
|
|
57
|
+
file: [],
|
|
58
|
+
statement: [],
|
|
59
|
+
address: [],
|
|
60
|
+
tax_id: [],
|
|
61
|
+
/** 隱藏欄位(網址參數帶入的字串) */
|
|
62
|
+
hidden: TEXT_OPS,
|
|
63
|
+
};
|
|
64
|
+
export function conditionOpsFor(sourceType) {
|
|
65
|
+
return CONDITION_OPS_BY_TYPE[sourceType] ?? [];
|
|
66
|
+
}
|
|
67
|
+
export function conditionValueKind(sourceType, op) {
|
|
68
|
+
switch (op) {
|
|
69
|
+
case "answered":
|
|
70
|
+
case "not_answered":
|
|
71
|
+
return "none";
|
|
72
|
+
case "includes":
|
|
73
|
+
case "not_includes":
|
|
74
|
+
return "option";
|
|
75
|
+
case "contains":
|
|
76
|
+
return "text";
|
|
77
|
+
case "equals":
|
|
78
|
+
case "not_equals":
|
|
79
|
+
return sourceType === "number" || sourceType === "rating" ? "number" : "text";
|
|
80
|
+
case "gt":
|
|
81
|
+
case "gte":
|
|
82
|
+
case "lt":
|
|
83
|
+
case "lte":
|
|
84
|
+
return "number";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 檢查一個條件對它的來源是否成立。`source` 為 undefined 表示找不到來源。
|
|
89
|
+
* schema(存檔時擋)與編輯器(即時標示)共用。
|
|
90
|
+
*/
|
|
91
|
+
export function findConditionIssue(condition, source) {
|
|
92
|
+
if (!source)
|
|
93
|
+
return "missing_source";
|
|
94
|
+
if (!conditionOpsFor(source.type).includes(condition.op))
|
|
95
|
+
return "op_not_allowed";
|
|
96
|
+
const kind = conditionValueKind(source.type, condition.op);
|
|
97
|
+
const { value } = condition;
|
|
98
|
+
if (kind === "none")
|
|
99
|
+
return value === undefined ? null : "value_unexpected";
|
|
100
|
+
if (value === undefined || value === "")
|
|
101
|
+
return "value_required";
|
|
102
|
+
if (kind === "number")
|
|
103
|
+
return typeof value === "number" && Number.isFinite(value) ? null : "value_type";
|
|
104
|
+
if (typeof value !== "string")
|
|
105
|
+
return "value_type";
|
|
106
|
+
if (kind === "option" && !source.options?.some((option) => option.id === value))
|
|
107
|
+
return "unknown_option";
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function isAnswered(raw) {
|
|
111
|
+
if (raw === null || raw === undefined)
|
|
112
|
+
return false;
|
|
113
|
+
if (typeof raw === "string")
|
|
114
|
+
return raw.trim() !== "";
|
|
115
|
+
if (Array.isArray(raw))
|
|
116
|
+
return raw.length > 0;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
/** 文字比對不分大小寫、不計頭尾空白、全形半形視為相同 */
|
|
120
|
+
function foldText(value) {
|
|
121
|
+
return typeof value === "string" ? value.normalize("NFKC").trim().toLowerCase() : typeof value === "number" ? String(value) : "";
|
|
122
|
+
}
|
|
123
|
+
/** 單一條件對一個答案是否成立;運算子不適用於這種來源時回 null(無法判斷) */
|
|
124
|
+
export function evaluateCondition(condition, sourceType, raw) {
|
|
125
|
+
if (!conditionOpsFor(sourceType).includes(condition.op))
|
|
126
|
+
return null;
|
|
127
|
+
const answered = isAnswered(raw);
|
|
128
|
+
switch (condition.op) {
|
|
129
|
+
case "answered":
|
|
130
|
+
return answered;
|
|
131
|
+
case "not_answered":
|
|
132
|
+
return !answered;
|
|
133
|
+
case "includes":
|
|
134
|
+
case "not_includes": {
|
|
135
|
+
const picked = Array.isArray(raw) ? raw : typeof raw === "string" && raw ? [raw] : [];
|
|
136
|
+
const has = picked.includes(condition.value);
|
|
137
|
+
return condition.op === "includes" ? has : !has;
|
|
138
|
+
}
|
|
139
|
+
case "contains":
|
|
140
|
+
return answered && foldText(raw).includes(foldText(condition.value));
|
|
141
|
+
case "equals":
|
|
142
|
+
case "not_equals": {
|
|
143
|
+
if (conditionValueKind(sourceType, condition.op) === "number") {
|
|
144
|
+
const number = parseNumberInput(raw);
|
|
145
|
+
const same = number !== null && number === condition.value;
|
|
146
|
+
return condition.op === "equals" ? same : !same;
|
|
147
|
+
}
|
|
148
|
+
const same = answered && foldText(raw) === foldText(condition.value);
|
|
149
|
+
return condition.op === "equals" ? same : !same;
|
|
150
|
+
}
|
|
151
|
+
case "gt":
|
|
152
|
+
case "gte":
|
|
153
|
+
case "lt":
|
|
154
|
+
case "lte": {
|
|
155
|
+
const number = parseNumberInput(raw);
|
|
156
|
+
const target = typeof condition.value === "number" ? condition.value : null;
|
|
157
|
+
// 沒填或不是數字:比較不成立
|
|
158
|
+
if (number === null || target === null)
|
|
159
|
+
return false;
|
|
160
|
+
if (condition.op === "gt")
|
|
161
|
+
return number > target;
|
|
162
|
+
if (condition.op === "gte")
|
|
163
|
+
return number >= target;
|
|
164
|
+
if (condition.op === "lt")
|
|
165
|
+
return number < target;
|
|
166
|
+
return number <= target;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 依目前的答案算出要顯示哪些題目。`answers` 是「題目 id 或隱藏欄位 id → 值」(訪客輸入的原始值即可)。
|
|
172
|
+
* 依題目順序往下算:前面的題目被隱藏時,參照它的條件把它當作沒有作答。
|
|
173
|
+
*/
|
|
174
|
+
export function resolveVisibleFieldIds(fields, answers) {
|
|
175
|
+
const visible = new Set();
|
|
176
|
+
const seen = new Map();
|
|
177
|
+
for (const field of fields) {
|
|
178
|
+
const rule = field.visibleWhen;
|
|
179
|
+
const conditions = rule && Array.isArray(rule.conditions) ? rule.conditions : [];
|
|
180
|
+
// Email 與電話是聯絡人的識別,不受條件影響
|
|
181
|
+
if (conditions.length === 0 || field.type === "email" || field.type === "phone") {
|
|
182
|
+
visible.add(field.id);
|
|
183
|
+
seen.set(field.id, field.type);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
let undecidable = false;
|
|
187
|
+
const results = conditions.map((condition) => {
|
|
188
|
+
const sourceType = condition.kind === "hidden" ? "hidden" : seen.get(condition.ref);
|
|
189
|
+
if (!sourceType) {
|
|
190
|
+
undecidable = true;
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
// 來源題自己被隱藏:當作沒有作答
|
|
194
|
+
const raw = condition.kind === "hidden" || visible.has(condition.ref) ? answers[condition.ref] : null;
|
|
195
|
+
const result = evaluateCondition(condition, sourceType, raw);
|
|
196
|
+
if (result === null)
|
|
197
|
+
undecidable = true;
|
|
198
|
+
return result === true;
|
|
199
|
+
});
|
|
200
|
+
if (undecidable || (rule?.match === "any" ? results.some(Boolean) : results.every(Boolean)))
|
|
201
|
+
visible.add(field.id);
|
|
202
|
+
seen.set(field.id, field.type);
|
|
203
|
+
}
|
|
204
|
+
return visible;
|
|
205
|
+
}
|
|
206
|
+
/** 這張表單有沒有任何條件顯示(沒有的話前台不用每次輸入都重算) */
|
|
207
|
+
export function hasVisibilityRules(fields) {
|
|
208
|
+
return fields.some((field) => (field.visibleWhen?.conditions?.length ?? 0) > 0);
|
|
209
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// 由 `pnpm --filter @kanorio/sdk gen` 從 packages/shared 複製,請勿手改(契約測試鎖兩份相同)。
|
|
2
|
+
/**
|
|
3
|
+
* 訪客輸入的數字 → number。接受全形數字(中日韓輸入法常見)與千分位逗號;不是有限數字回 null。
|
|
4
|
+
* 零依賴:表單驗證、條件判斷與 `@kanorio/sdk` 用同一份。
|
|
5
|
+
*/
|
|
6
|
+
export function parseNumberInput(raw) {
|
|
7
|
+
if (typeof raw === "number")
|
|
8
|
+
return Number.isFinite(raw) ? raw : null;
|
|
9
|
+
if (typeof raw !== "string")
|
|
10
|
+
return null;
|
|
11
|
+
const cleaned = raw.normalize("NFKC").replace(/[\s,]/g, "");
|
|
12
|
+
if (!/^[+-]?(\d+\.?\d*|\.\d+)$/.test(cleaned))
|
|
13
|
+
return null;
|
|
14
|
+
const value = Number(cleaned);
|
|
15
|
+
return Number.isFinite(value) ? value : null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 網址轉址「比對 + 迴圈偵測」的單一真實來源(跨 app 契約)。
|
|
3
|
+
*
|
|
4
|
+
* - public-sites middleware 於 runtime 用 `matchRedirect` 執行實際轉址。
|
|
5
|
+
* - apps/main 於存檔前用 `isSelfLoop` / `findRedirectLoopKeys` / `hasRedirectChainLoop`
|
|
6
|
+
* 模擬同一套比對來偵測迴圈。
|
|
7
|
+
*
|
|
8
|
+
* 兩者共用此模組,比對語意(精確優先 → 最長 wildcard prefix → 相對/wildcard 目標解析)
|
|
9
|
+
* 永遠一致,不會 drift。純字串函式,無 React / node 依賴,可於 edge runtime 安全打包。
|
|
10
|
+
*/
|
|
11
|
+
export type RedirectRuleLite = {
|
|
12
|
+
sourcePath: string;
|
|
13
|
+
targetUrl: string;
|
|
14
|
+
statusCode?: number;
|
|
15
|
+
/**
|
|
16
|
+
* 規則屬於哪個語系(ADR-0010 決策 18):null/未設=各語系共用,以無語系前綴的路徑比對、站內目標再接回前綴;
|
|
17
|
+
* 有值=只屬於那個語系(翻譯代稱改名、語系停用、改前綴),來源與目標都已含前綴,以完整路徑比對、目標原樣用。
|
|
18
|
+
*/
|
|
19
|
+
locale?: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 依比對規則解析單一路徑:精確比對優先,否則最長 wildcard prefix(`sourcePath` 結尾 `/*`)。
|
|
23
|
+
* 目標結尾 `/*` 時保留剩餘子路徑;否則全部導向同一目標。
|
|
24
|
+
* 回傳命中的規則、解析後目標字串(可為站內相對路徑或完整外部網址)與狀態碼;無匹配回傳 null。
|
|
25
|
+
*/
|
|
26
|
+
export declare function matchRedirect<R extends RedirectRuleLite>(pathname: string, rules: R[]): {
|
|
27
|
+
rule: R;
|
|
28
|
+
target: string;
|
|
29
|
+
statusCode: number;
|
|
30
|
+
} | null;
|
|
31
|
+
/**
|
|
32
|
+
* 多語網站的轉址比對(ADR-0010 決策 18):先比帶語系的規則(完整路徑、目標原樣),再比共用規則(無前綴路徑)。
|
|
33
|
+
* `scoped` 為 true 時目標已含語系前綴;false 時呼叫端把站內目標接回請求語系的前綴(與既有行為相同)。
|
|
34
|
+
*/
|
|
35
|
+
export declare function matchLocalizedRedirect<R extends RedirectRuleLite>(fullPathname: string, localePathname: string, rules: R[]): {
|
|
36
|
+
rule: R;
|
|
37
|
+
target: string;
|
|
38
|
+
statusCode: number;
|
|
39
|
+
scoped: boolean;
|
|
40
|
+
} | null;
|
|
41
|
+
/** strip 結尾斜線(保留根 "/"),供自我轉址比對。 */
|
|
42
|
+
export declare function stripTrailingSlash(value: string): string;
|
|
43
|
+
/** 精確自我轉址(/foo 與 /foo/ 視為相同)。 */
|
|
44
|
+
export declare function isExactSelf(source: string, target: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* wildcard 來源,且站內相對目標落在來源涵蓋範圍內(例如 "/*" → "/"、"/blog/*" → "/blog/x")。
|
|
47
|
+
* 範圍外目標("/blog/*" → "/about")與外部網址不算。
|
|
48
|
+
*/
|
|
49
|
+
export declare function isScopeLoop(source: string, target: string): boolean;
|
|
50
|
+
/** 單條規則是否自我迴圈(精確自我轉址或 wildcard 自我涵蓋)。 */
|
|
51
|
+
export declare function isSelfLoop(source: string, target: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 找出參與跨規則轉址迴圈(例如 /a → /b 且 /b → /a)的規則 key。
|
|
54
|
+
*
|
|
55
|
+
* 從每條規則的代表路徑出發,重複套用 `matchRedirect` 逐跳解析,以 visited-set 偵測 cycle。
|
|
56
|
+
* 單條自我迴圈應由呼叫端以 `isSelfLoop` 先行處理,這裡專注多條互指。
|
|
57
|
+
*
|
|
58
|
+
* 精確化:`maxHops = 規則數 + 1`。在此 functional 結構下,非循環走訪最多經過「規則數」個
|
|
59
|
+
* 不同狀態即終止,故 `規則數 + 1` 為精確上限、零誤判;成長型鏈(永不終止)會在超過上限時被判為迴圈。
|
|
60
|
+
*/
|
|
61
|
+
export declare function findRedirectLoopKeys<R extends {
|
|
62
|
+
key: string;
|
|
63
|
+
sourcePath: string;
|
|
64
|
+
targetUrl: string;
|
|
65
|
+
}>(rules: R[]): Set<string>;
|
|
66
|
+
/** 是否存在跨規則轉址迴圈。單條自我迴圈請另以 `isSelfLoop` 檢查。 */
|
|
67
|
+
export declare function hasRedirectChainLoop(rules: RedirectRuleLite[]): boolean;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// 由 `pnpm --filter @kanorio/sdk gen` 從 packages/shared 複製,請勿手改(契約測試鎖兩份相同)。
|
|
2
|
+
/**
|
|
3
|
+
* 網址轉址「比對 + 迴圈偵測」的單一真實來源(跨 app 契約)。
|
|
4
|
+
*
|
|
5
|
+
* - public-sites middleware 於 runtime 用 `matchRedirect` 執行實際轉址。
|
|
6
|
+
* - apps/main 於存檔前用 `isSelfLoop` / `findRedirectLoopKeys` / `hasRedirectChainLoop`
|
|
7
|
+
* 模擬同一套比對來偵測迴圈。
|
|
8
|
+
*
|
|
9
|
+
* 兩者共用此模組,比對語意(精確優先 → 最長 wildcard prefix → 相對/wildcard 目標解析)
|
|
10
|
+
* 永遠一致,不會 drift。純字串函式,無 React / node 依賴,可於 edge runtime 安全打包。
|
|
11
|
+
*/
|
|
12
|
+
/** 迴圈模擬時 wildcard 來源的代表子路徑(僅內部使用,避免與真實路徑碰撞)。 */
|
|
13
|
+
const LOOP_PROBE = "__kanorio_loop_probe__";
|
|
14
|
+
/**
|
|
15
|
+
* 迴圈偵測的全域步數預算:正常輸入遠低於此值。
|
|
16
|
+
* 僅在病態輸入(大量 wildcard 規則)時觸發,避免存檔動作耗時過久;
|
|
17
|
+
* 超出後停止偵測,殘餘由 middleware runtime 保險與瀏覽器 ERR_TOO_MANY_REDIRECTS 兜底。
|
|
18
|
+
*/
|
|
19
|
+
const MAX_TOTAL_STEPS = 200_000;
|
|
20
|
+
/**
|
|
21
|
+
* 依比對規則解析單一路徑:精確比對優先,否則最長 wildcard prefix(`sourcePath` 結尾 `/*`)。
|
|
22
|
+
* 目標結尾 `/*` 時保留剩餘子路徑;否則全部導向同一目標。
|
|
23
|
+
* 回傳命中的規則、解析後目標字串(可為站內相對路徑或完整外部網址)與狀態碼;無匹配回傳 null。
|
|
24
|
+
*/
|
|
25
|
+
export function matchRedirect(pathname, rules) {
|
|
26
|
+
// 1. 精確比對 pathname(大小寫敏感,符合 URL 標準)
|
|
27
|
+
const exact = rules.find((rule) => rule.sourcePath === pathname);
|
|
28
|
+
if (exact) {
|
|
29
|
+
return { rule: exact, target: exact.targetUrl, statusCode: exact.statusCode ?? 301 };
|
|
30
|
+
}
|
|
31
|
+
// 2. wildcard prefix match(longest prefix wins)
|
|
32
|
+
let best = null;
|
|
33
|
+
for (const rule of rules) {
|
|
34
|
+
if (!rule.sourcePath.endsWith("/*"))
|
|
35
|
+
continue;
|
|
36
|
+
const prefix = rule.sourcePath.slice(0, -1); // "/blog/*" → "/blog/"
|
|
37
|
+
if (pathname.startsWith(prefix)) {
|
|
38
|
+
if (!best || prefix.length > best.prefix.length) {
|
|
39
|
+
best = { prefix, rule };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!best)
|
|
44
|
+
return null;
|
|
45
|
+
const suffix = pathname.slice(best.prefix.length); // 剩餘子路徑
|
|
46
|
+
const target = best.rule.targetUrl.endsWith("/*")
|
|
47
|
+
? best.rule.targetUrl.slice(0, -1) + suffix
|
|
48
|
+
: best.rule.targetUrl;
|
|
49
|
+
return { rule: best.rule, target, statusCode: best.rule.statusCode ?? 301 };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 多語網站的轉址比對(ADR-0010 決策 18):先比帶語系的規則(完整路徑、目標原樣),再比共用規則(無前綴路徑)。
|
|
53
|
+
* `scoped` 為 true 時目標已含語系前綴;false 時呼叫端把站內目標接回請求語系的前綴(與既有行為相同)。
|
|
54
|
+
*/
|
|
55
|
+
export function matchLocalizedRedirect(fullPathname, localePathname, rules) {
|
|
56
|
+
const scopedRules = rules.filter((rule) => rule.locale);
|
|
57
|
+
if (scopedRules.length > 0) {
|
|
58
|
+
const hit = matchRedirect(fullPathname, scopedRules);
|
|
59
|
+
if (hit)
|
|
60
|
+
return { ...hit, scoped: true };
|
|
61
|
+
}
|
|
62
|
+
const shared = scopedRules.length > 0 ? rules.filter((rule) => !rule.locale) : rules;
|
|
63
|
+
const hit = matchRedirect(localePathname, shared);
|
|
64
|
+
return hit ? { ...hit, scoped: false } : null;
|
|
65
|
+
}
|
|
66
|
+
/** strip 結尾斜線(保留根 "/"),供自我轉址比對。 */
|
|
67
|
+
export function stripTrailingSlash(value) {
|
|
68
|
+
return value.length > 1 && value.endsWith("/") ? value.slice(0, -1) : value;
|
|
69
|
+
}
|
|
70
|
+
/** 精確自我轉址(/foo 與 /foo/ 視為相同)。 */
|
|
71
|
+
export function isExactSelf(source, target) {
|
|
72
|
+
return stripTrailingSlash(source) === stripTrailingSlash(target);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* wildcard 來源,且站內相對目標落在來源涵蓋範圍內(例如 "/*" → "/"、"/blog/*" → "/blog/x")。
|
|
76
|
+
* 範圍外目標("/blog/*" → "/about")與外部網址不算。
|
|
77
|
+
*/
|
|
78
|
+
export function isScopeLoop(source, target) {
|
|
79
|
+
if (!source.endsWith("/*") || !target.startsWith("/"))
|
|
80
|
+
return false;
|
|
81
|
+
const srcPrefix = source.slice(0, -1); // "/blog/*" → "/blog/"
|
|
82
|
+
const targetBase = target.endsWith("/*") ? target.slice(0, -1) : target;
|
|
83
|
+
return targetBase.startsWith(srcPrefix);
|
|
84
|
+
}
|
|
85
|
+
/** 單條規則是否自我迴圈(精確自我轉址或 wildcard 自我涵蓋)。 */
|
|
86
|
+
export function isSelfLoop(source, target) {
|
|
87
|
+
return isExactSelf(source, target) || isScopeLoop(source, target);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 找出參與跨規則轉址迴圈(例如 /a → /b 且 /b → /a)的規則 key。
|
|
91
|
+
*
|
|
92
|
+
* 從每條規則的代表路徑出發,重複套用 `matchRedirect` 逐跳解析,以 visited-set 偵測 cycle。
|
|
93
|
+
* 單條自我迴圈應由呼叫端以 `isSelfLoop` 先行處理,這裡專注多條互指。
|
|
94
|
+
*
|
|
95
|
+
* 精確化:`maxHops = 規則數 + 1`。在此 functional 結構下,非循環走訪最多經過「規則數」個
|
|
96
|
+
* 不同狀態即終止,故 `規則數 + 1` 為精確上限、零誤判;成長型鏈(永不終止)會在超過上限時被判為迴圈。
|
|
97
|
+
*/
|
|
98
|
+
export function findRedirectLoopKeys(rules) {
|
|
99
|
+
const loopKeys = new Set();
|
|
100
|
+
const maxHops = rules.length + 1;
|
|
101
|
+
let budget = MAX_TOTAL_STEPS;
|
|
102
|
+
for (const start of rules) {
|
|
103
|
+
if (budget <= 0)
|
|
104
|
+
break; // 病態輸入:耗盡預算,停止偵測(交由 runtime 保險兜底)
|
|
105
|
+
const sample = start.sourcePath.endsWith("/*")
|
|
106
|
+
? start.sourcePath.slice(0, -1) + LOOP_PROBE
|
|
107
|
+
: start.sourcePath;
|
|
108
|
+
const seen = new Set([sample]);
|
|
109
|
+
const usedKeys = [];
|
|
110
|
+
let cur = sample;
|
|
111
|
+
for (let i = 0; i < maxHops; i++) {
|
|
112
|
+
if (budget-- <= 0 || cur === null) {
|
|
113
|
+
cur = null; // 預算耗盡,保守視為終止(不誤判為迴圈)
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
// 明確標註型別:cur 於迴圈末尾會被賦值為 matched.target,若讓 matched 走型別推斷
|
|
117
|
+
// 會與 cur 形成循環推斷(TS7022)。標註後切斷循環。
|
|
118
|
+
const matched = matchRedirect(cur, rules);
|
|
119
|
+
// 無匹配或外部網址 → 轉址鏈就此終止,無迴圈
|
|
120
|
+
if (!matched || !matched.target.startsWith("/")) {
|
|
121
|
+
cur = null;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
usedKeys.push(matched.rule.key);
|
|
125
|
+
if (seen.has(matched.target)) {
|
|
126
|
+
// 回到走過的路徑 → 迴圈,標記途經的所有規則
|
|
127
|
+
usedKeys.forEach((k) => loopKeys.add(k));
|
|
128
|
+
cur = null;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
seen.add(matched.target);
|
|
132
|
+
cur = matched.target;
|
|
133
|
+
}
|
|
134
|
+
// 走滿 maxHops 仍未終止 → 成長型無限鏈,保守視為迴圈
|
|
135
|
+
if (cur !== null)
|
|
136
|
+
usedKeys.forEach((k) => loopKeys.add(k));
|
|
137
|
+
}
|
|
138
|
+
return loopKeys;
|
|
139
|
+
}
|
|
140
|
+
/** 是否存在跨規則轉址迴圈。單條自我迴圈請另以 `isSelfLoop` 檢查。 */
|
|
141
|
+
export function hasRedirectChainLoop(rules) {
|
|
142
|
+
const keyed = rules.map((r, i) => ({
|
|
143
|
+
key: String(i),
|
|
144
|
+
sourcePath: r.sourcePath,
|
|
145
|
+
targetUrl: r.targetUrl,
|
|
146
|
+
}));
|
|
147
|
+
return findRedirectLoopKeys(keyed).size > 0;
|
|
148
|
+
}
|
package/dist/tax-id.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax id format validation (checksums included where the country publishes one), the same rules Kanorio applies on its
|
|
3
|
+
* hosted checkout and forms. Pure functions with no network access: use them to validate while the visitor types.
|
|
4
|
+
* Registry lookups (registered name, status) stay on the server.
|
|
5
|
+
*/
|
|
6
|
+
export { TAX_ID_FORMATS, cleanTaxIdInput, getTaxIdFormat, isBlockingTaxIdIssue, isTaxIdType, listTaxIdCountries, listTaxIdTypes, validateTaxIdFormat, } from "./shared/business-registry/index.js";
|
|
7
|
+
export type { RegistryAttributionWire, TaxIdEnforcement, TaxIdFormatDefinition, TaxIdFormatIssue, TaxIdFormatResult, TaxIdType, } from "./shared/business-registry/index.js";
|
package/dist/tax-id.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax id format validation (checksums included where the country publishes one), the same rules Kanorio applies on its
|
|
3
|
+
* hosted checkout and forms. Pure functions with no network access: use them to validate while the visitor types.
|
|
4
|
+
* Registry lookups (registered name, status) stay on the server.
|
|
5
|
+
*/
|
|
6
|
+
export { TAX_ID_FORMATS, cleanTaxIdInput, getTaxIdFormat, isBlockingTaxIdIssue, isTaxIdType, listTaxIdCountries, listTaxIdTypes, validateTaxIdFormat, } from "./shared/business-registry/index.js";
|
package/dist/typed.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 以 openapi-typescript 產生的 `paths` 介面推導型別的最小客戶端:
|
|
3
|
+
* `client.get("/sites/{siteId}", { params: { siteId }, query })` 會檢查路徑、路徑參數、查詢、body 與成功回應型別。
|
|
4
|
+
* 不做執行期驗證;伺服端怎麼回就怎麼給。
|
|
5
|
+
*/
|
|
6
|
+
import type { HttpClient } from "./http.js";
|
|
7
|
+
type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
8
|
+
export type PathsWithMethod<P, M extends HttpMethod> = {
|
|
9
|
+
[K in keyof P]: P[K] extends {
|
|
10
|
+
[m in M]: unknown;
|
|
11
|
+
} ? (P[K][M] extends undefined | never ? never : K) : never;
|
|
12
|
+
}[keyof P];
|
|
13
|
+
type OperationOf<P, K extends keyof P, M extends HttpMethod> = P[K] extends {
|
|
14
|
+
[m in M]: infer O;
|
|
15
|
+
} ? O : never;
|
|
16
|
+
type PathParamsOf<O> = O extends {
|
|
17
|
+
parameters: {
|
|
18
|
+
path: infer PP;
|
|
19
|
+
};
|
|
20
|
+
} ? PP : O extends {
|
|
21
|
+
parameters: {
|
|
22
|
+
path?: infer PP;
|
|
23
|
+
};
|
|
24
|
+
} ? PP : never;
|
|
25
|
+
type QueryOf<O> = O extends {
|
|
26
|
+
parameters: {
|
|
27
|
+
query?: infer Q;
|
|
28
|
+
};
|
|
29
|
+
} ? Q : O extends {
|
|
30
|
+
parameters: {
|
|
31
|
+
query: infer Q;
|
|
32
|
+
};
|
|
33
|
+
} ? Q : never;
|
|
34
|
+
type JsonBodyOf<O> = O extends {
|
|
35
|
+
requestBody: {
|
|
36
|
+
content: {
|
|
37
|
+
"application/json": infer B;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
} ? B : O extends {
|
|
41
|
+
requestBody?: {
|
|
42
|
+
content: {
|
|
43
|
+
"application/json": infer B;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
} ? B | undefined : never;
|
|
47
|
+
type SuccessStatus = 200 | 201 | 202 | 204;
|
|
48
|
+
type ResponsesOf<O> = O extends {
|
|
49
|
+
responses: infer R;
|
|
50
|
+
} ? R : never;
|
|
51
|
+
type JsonOf<R> = R extends {
|
|
52
|
+
content: {
|
|
53
|
+
"application/json": infer J;
|
|
54
|
+
};
|
|
55
|
+
} ? J : R extends {
|
|
56
|
+
content?: never;
|
|
57
|
+
} ? void : unknown;
|
|
58
|
+
export type SuccessResponseOf<O> = {
|
|
59
|
+
[S in SuccessStatus & keyof ResponsesOf<O>]: JsonOf<ResponsesOf<O>[S]>;
|
|
60
|
+
}[SuccessStatus & keyof ResponsesOf<O>];
|
|
61
|
+
/** 沒有這種參數時不收;可省略(`undefined`)或每個欄位都選填(`{}` 也合法,例如只有 `locale?` 的查詢)時不強迫呼叫端傳 */
|
|
62
|
+
type OptionalIfNever<K extends string, T> = [T] extends [never] ? {
|
|
63
|
+
[k in K]?: undefined;
|
|
64
|
+
} : undefined extends T ? {
|
|
65
|
+
[k in K]?: T;
|
|
66
|
+
} : {} extends T ? {
|
|
67
|
+
[k in K]?: T;
|
|
68
|
+
} : {
|
|
69
|
+
[k in K]: T;
|
|
70
|
+
};
|
|
71
|
+
export type TypedRequest<O> = OptionalIfNever<"params", PathParamsOf<O>> & OptionalIfNever<"query", QueryOf<O>> & OptionalIfNever<"body", JsonBodyOf<O>> & {
|
|
72
|
+
headers?: HeadersInit;
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
};
|
|
75
|
+
export interface TypedClient<P> {
|
|
76
|
+
get<K extends PathsWithMethod<P, "get">>(path: K, req?: TypedRequest<OperationOf<P, K, "get">>): Promise<SuccessResponseOf<OperationOf<P, K, "get">>>;
|
|
77
|
+
post<K extends PathsWithMethod<P, "post">>(path: K, req?: TypedRequest<OperationOf<P, K, "post">>): Promise<SuccessResponseOf<OperationOf<P, K, "post">>>;
|
|
78
|
+
put<K extends PathsWithMethod<P, "put">>(path: K, req?: TypedRequest<OperationOf<P, K, "put">>): Promise<SuccessResponseOf<OperationOf<P, K, "put">>>;
|
|
79
|
+
patch<K extends PathsWithMethod<P, "patch">>(path: K, req?: TypedRequest<OperationOf<P, K, "patch">>): Promise<SuccessResponseOf<OperationOf<P, K, "patch">>>;
|
|
80
|
+
delete<K extends PathsWithMethod<P, "delete">>(path: K, req?: TypedRequest<OperationOf<P, K, "delete">>): Promise<SuccessResponseOf<OperationOf<P, K, "delete">>>;
|
|
81
|
+
/** 底層 HTTP(未型別化) */
|
|
82
|
+
http: HttpClient;
|
|
83
|
+
}
|
|
84
|
+
export declare function createTypedClient<P>(http: HttpClient): TypedClient<P>;
|
|
85
|
+
export {};
|