@karpeleslab/klbfw 0.2.23 → 0.2.24
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/index.d.ts +153 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -29,9 +29,152 @@ declare function hasCookie(name: string): boolean;
|
|
|
29
29
|
declare function setCookie(name: string, value: string, expires?: Date | number, path?: string, domain?: string, secure?: boolean): void;
|
|
30
30
|
|
|
31
31
|
// REST API types
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
|
|
33
|
+
/** Paging information returned by list endpoints */
|
|
34
|
+
interface RestPaging {
|
|
35
|
+
/** Current page number (1-indexed) */
|
|
36
|
+
page_no: number;
|
|
37
|
+
/** Total number of results across all pages */
|
|
38
|
+
count: number;
|
|
39
|
+
/** Maximum page number available */
|
|
40
|
+
page_max: number;
|
|
41
|
+
/** Number of results per page */
|
|
42
|
+
results_per_page: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Successful REST API response wrapper
|
|
47
|
+
* @typeParam T - Type of the data field
|
|
48
|
+
*/
|
|
49
|
+
interface RestResponse<T = any> {
|
|
50
|
+
/** Result status */
|
|
51
|
+
result: 'success' | 'redirect';
|
|
52
|
+
/** Unique request identifier for debugging */
|
|
53
|
+
request_id: string;
|
|
54
|
+
/** Request processing time in seconds */
|
|
55
|
+
time: number;
|
|
56
|
+
/** Response payload */
|
|
57
|
+
data: T;
|
|
58
|
+
/** Paging information for list endpoints */
|
|
59
|
+
paging?: RestPaging;
|
|
60
|
+
/** Additional response fields */
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** REST API error object (thrown on promise rejection) */
|
|
65
|
+
interface RestError {
|
|
66
|
+
/** Always 'error' for error responses */
|
|
67
|
+
result: 'error';
|
|
68
|
+
/** Exception class name from server */
|
|
69
|
+
exception: string;
|
|
70
|
+
/** Human-readable error message */
|
|
71
|
+
error: string;
|
|
72
|
+
/** HTTP status code */
|
|
73
|
+
code: number;
|
|
74
|
+
/** Translatable error token (e.g., 'error_invalid_field') */
|
|
75
|
+
token: string;
|
|
76
|
+
/** Request ID for debugging */
|
|
77
|
+
request: string;
|
|
78
|
+
/** Structured message data for translation */
|
|
79
|
+
message: Record<string, any>;
|
|
80
|
+
/** Parameter name that caused the error, if applicable */
|
|
81
|
+
param?: string;
|
|
82
|
+
/** Request processing time in seconds */
|
|
83
|
+
time: number;
|
|
84
|
+
/** Additional error fields */
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Server DateTime object
|
|
90
|
+
* @example
|
|
91
|
+
* // Convert to JavaScript Date
|
|
92
|
+
* new Date(Number(datetime.unixms))
|
|
93
|
+
*/
|
|
94
|
+
interface DateTime {
|
|
95
|
+
/** Unix timestamp in milliseconds (use this for JS Date conversion) */
|
|
96
|
+
unixms: string | number;
|
|
97
|
+
/** Unix timestamp in seconds */
|
|
98
|
+
unix?: number;
|
|
99
|
+
/** Microseconds component */
|
|
100
|
+
us?: number;
|
|
101
|
+
/** ISO 8601 formatted string with microseconds */
|
|
102
|
+
iso?: string;
|
|
103
|
+
/** Timezone identifier (e.g., 'Asia/Tokyo') */
|
|
104
|
+
tz?: string;
|
|
105
|
+
/** Full precision timestamp as string (unix seconds + microseconds) */
|
|
106
|
+
full?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Extended integer for precise decimal arithmetic without floating-point errors.
|
|
111
|
+
* Value = v / 10^e = f
|
|
112
|
+
*
|
|
113
|
+
* When sending to API, you can provide either:
|
|
114
|
+
* - Just `f` (as string or number)
|
|
115
|
+
* - Both `v` and `e`
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* // $358.20 represented as:
|
|
119
|
+
* { v: "35820000", e: 5, f: 358.2 }
|
|
120
|
+
*/
|
|
121
|
+
interface Xint {
|
|
122
|
+
/** Integer value (multiply by 10^-e to get actual value) */
|
|
123
|
+
v?: string;
|
|
124
|
+
/** Exponent (number of decimal places) */
|
|
125
|
+
e?: number;
|
|
126
|
+
/** Float value (convenience field, may have precision loss) */
|
|
127
|
+
f?: string | number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Base price value without tax breakdown */
|
|
131
|
+
interface PriceValue {
|
|
132
|
+
/** Decimal value as string (e.g., "358.20000") */
|
|
133
|
+
value: string;
|
|
134
|
+
/** Integer representation for precise arithmetic */
|
|
135
|
+
value_int: string;
|
|
136
|
+
/** Value in cents/smallest currency unit */
|
|
137
|
+
value_cent: string;
|
|
138
|
+
/** Display-ready decimal string (e.g., "358.20") */
|
|
139
|
+
value_disp: string;
|
|
140
|
+
/** Extended integer for precise calculations */
|
|
141
|
+
value_xint: Xint;
|
|
142
|
+
/** Formatted display string with currency symbol (e.g., "$358.20") */
|
|
143
|
+
display: string;
|
|
144
|
+
/** Short formatted display string */
|
|
145
|
+
display_short: string;
|
|
146
|
+
/** ISO 4217 currency code (e.g., "USD") */
|
|
147
|
+
currency: string;
|
|
148
|
+
/** Currency unit (usually same as currency) */
|
|
149
|
+
unit: string;
|
|
150
|
+
/** Whether VAT/tax is included in this value */
|
|
151
|
+
has_vat: boolean;
|
|
152
|
+
/** Tax profile identifier or null if exempt */
|
|
153
|
+
tax_profile: string | null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Full price object with optional tax breakdown
|
|
158
|
+
* @example
|
|
159
|
+
* // Display price with tax info
|
|
160
|
+
* console.log(price.display); // "$358.20"
|
|
161
|
+
* console.log(price.tax?.display); // "$358.20" (with tax)
|
|
162
|
+
* console.log(price.tax_only?.display); // "$0.00" (tax amount only)
|
|
163
|
+
*/
|
|
164
|
+
interface Price extends PriceValue {
|
|
165
|
+
/** Original price before any tax calculations */
|
|
166
|
+
raw?: PriceValue;
|
|
167
|
+
/** Price including tax */
|
|
168
|
+
tax?: PriceValue;
|
|
169
|
+
/** Tax amount only */
|
|
170
|
+
tax_only?: PriceValue;
|
|
171
|
+
/** Tax rate as decimal (e.g., 0.1 for 10%) */
|
|
172
|
+
tax_rate?: number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
declare function rest<T = any>(name: string, verb: string, params?: Record<string, any>, context?: Record<string, any>): Promise<RestResponse<T>>;
|
|
176
|
+
declare function rest_get<T = any>(name: string, params?: Record<string, any>): Promise<RestResponse<T>>; // Backward compatibility
|
|
177
|
+
declare function restGet<T = any>(name: string, params?: Record<string, any>): Promise<RestResponse<T>>;
|
|
35
178
|
|
|
36
179
|
/** SSE message event */
|
|
37
180
|
interface SSEMessageEvent {
|
|
@@ -189,6 +332,13 @@ export {
|
|
|
189
332
|
uploadManyFiles,
|
|
190
333
|
getI18N,
|
|
191
334
|
trimPrefix,
|
|
335
|
+
RestPaging,
|
|
336
|
+
RestResponse,
|
|
337
|
+
RestError,
|
|
338
|
+
DateTime,
|
|
339
|
+
Xint,
|
|
340
|
+
PriceValue,
|
|
341
|
+
Price,
|
|
192
342
|
UploadFileInput,
|
|
193
343
|
UploadFileOptions,
|
|
194
344
|
UploadManyFilesOptions,
|