@ram_28/kf-ai-sdk 1.0.35 → 2.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/README.md +72 -83
- package/dist/api/client.d.ts +7 -3
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/metadata.d.ts +5 -5
- package/dist/api/metadata.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.mjs +32 -26
- package/dist/api.types.d.ts +3 -3
- package/dist/api.types.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.d.ts +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.mjs +61 -58
- package/dist/base-types.d.ts +1 -1
- package/dist/base-types.d.ts.map +1 -1
- package/dist/bdo/core/BaseBdo.d.ts +146 -0
- package/dist/bdo/core/BaseBdo.d.ts.map +1 -0
- package/dist/bdo/core/Item.d.ts +103 -0
- package/dist/bdo/core/Item.d.ts.map +1 -0
- package/dist/bdo/core/types.d.ts +68 -0
- package/dist/bdo/core/types.d.ts.map +1 -0
- package/dist/bdo/expressions/ExpressionEngine.d.ts +85 -0
- package/dist/bdo/expressions/ExpressionEngine.d.ts.map +1 -0
- package/dist/bdo/expressions/evaluator.d.ts +25 -0
- package/dist/bdo/expressions/evaluator.d.ts.map +1 -0
- package/dist/bdo/expressions/functions.d.ts +15 -0
- package/dist/bdo/expressions/functions.d.ts.map +1 -0
- package/dist/bdo/expressions/index.d.ts +5 -0
- package/dist/bdo/expressions/index.d.ts.map +1 -0
- package/dist/bdo/expressions/types.d.ts +162 -0
- package/dist/bdo/expressions/types.d.ts.map +1 -0
- package/dist/bdo/fields/ArrayField.d.ts +21 -0
- package/dist/bdo/fields/ArrayField.d.ts.map +1 -0
- package/dist/bdo/fields/BaseField.d.ts +32 -0
- package/dist/bdo/fields/BaseField.d.ts.map +1 -0
- package/dist/bdo/fields/BooleanField.d.ts +19 -0
- package/dist/bdo/fields/BooleanField.d.ts.map +1 -0
- package/dist/bdo/fields/DateField.d.ts +19 -0
- package/dist/bdo/fields/DateField.d.ts.map +1 -0
- package/dist/bdo/fields/DateTimeField.d.ts +23 -0
- package/dist/bdo/fields/DateTimeField.d.ts.map +1 -0
- package/dist/bdo/fields/NumberField.d.ts +19 -0
- package/dist/bdo/fields/NumberField.d.ts.map +1 -0
- package/dist/bdo/fields/ObjectField.d.ts +19 -0
- package/dist/bdo/fields/ObjectField.d.ts.map +1 -0
- package/dist/bdo/fields/ReferenceField.d.ts +33 -0
- package/dist/bdo/fields/ReferenceField.d.ts.map +1 -0
- package/dist/bdo/fields/SelectField.d.ts +34 -0
- package/dist/bdo/fields/SelectField.d.ts.map +1 -0
- package/dist/bdo/fields/StringField.d.ts +19 -0
- package/dist/bdo/fields/StringField.d.ts.map +1 -0
- package/dist/bdo/fields/TextAreaField.d.ts +19 -0
- package/dist/bdo/fields/TextAreaField.d.ts.map +1 -0
- package/dist/bdo/fields/index.d.ts +12 -0
- package/dist/bdo/fields/index.d.ts.map +1 -0
- package/dist/bdo/index.d.ts +5 -0
- package/dist/bdo/index.d.ts.map +1 -0
- package/dist/bdo.cjs +1 -0
- package/dist/bdo.d.ts +8 -0
- package/dist/bdo.d.ts.map +1 -0
- package/dist/bdo.mjs +925 -0
- package/dist/bdo.types.d.ts +6 -0
- package/dist/bdo.types.d.ts.map +1 -0
- package/dist/components/hooks/index.d.ts +0 -5
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +1 -1
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +2 -2
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/createItemProxy.d.ts +15 -0
- package/dist/components/hooks/useForm/createItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useForm/createResolver.d.ts +30 -0
- package/dist/components/hooks/useForm/createResolver.d.ts.map +1 -0
- package/dist/components/hooks/useForm/index.d.ts +4 -8
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +67 -434
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts +41 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/constants-C49b9Exc.cjs +1 -0
- package/dist/constants-DaX7GLgl.js +149 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.d.ts +1 -0
- package/dist/filter.d.ts.map +1 -1
- package/dist/filter.mjs +7 -3
- package/dist/filter.types.d.ts +1 -1
- package/dist/filter.types.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.d.ts +2 -2
- package/dist/form.d.ts.map +1 -1
- package/dist/form.mjs +832 -1971
- package/dist/form.types.d.ts +1 -2
- package/dist/form.types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.mjs +103 -87
- package/dist/types/base-fields.d.ts +34 -15
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +14 -8
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/constants.d.ts +385 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils.cjs +3 -3
- package/dist/utils.mjs +2832 -61
- package/docs/api.md +1 -1
- package/docs/useFilter.md +319 -117
- package/docs/useForm.md +539 -540
- package/docs/useTable.md +147 -114
- package/package.json +24 -36
- package/sdk/api/client.ts +13 -7
- package/sdk/api/index.ts +4 -4
- package/sdk/api/metadata.ts +7 -7
- package/sdk/api.ts +9 -0
- package/sdk/api.types.ts +4 -4
- package/sdk/auth.ts +6 -0
- package/sdk/base-types.ts +7 -5
- package/sdk/bdo/core/BaseBdo.ts +317 -0
- package/sdk/bdo/core/Item.ts +302 -0
- package/sdk/bdo/core/types.ts +81 -0
- package/sdk/bdo/expressions/ExpressionEngine.ts +191 -0
- package/sdk/bdo/expressions/evaluator.ts +242 -0
- package/sdk/bdo/expressions/functions.ts +241 -0
- package/sdk/bdo/expressions/index.ts +21 -0
- package/sdk/bdo/expressions/types.ts +195 -0
- package/sdk/bdo/fields/ArrayField.ts +37 -0
- package/sdk/bdo/fields/BaseField.ts +50 -0
- package/sdk/bdo/fields/BooleanField.ts +35 -0
- package/sdk/bdo/fields/DateField.ts +56 -0
- package/sdk/bdo/fields/DateTimeField.ts +52 -0
- package/sdk/bdo/fields/NumberField.ts +35 -0
- package/sdk/bdo/fields/ObjectField.ts +42 -0
- package/sdk/bdo/fields/ReferenceField.ts +87 -0
- package/sdk/bdo/fields/SelectField.ts +88 -0
- package/sdk/bdo/fields/StringField.ts +35 -0
- package/sdk/bdo/fields/TextAreaField.ts +35 -0
- package/sdk/bdo/fields/index.ts +15 -0
- package/sdk/bdo/index.ts +39 -0
- package/sdk/bdo.ts +55 -0
- package/sdk/bdo.types.ts +50 -0
- package/sdk/components/hooks/index.ts +0 -44
- package/sdk/components/hooks/useFilter/index.ts +1 -1
- package/sdk/components/hooks/useFilter/types.ts +2 -2
- package/sdk/components/hooks/useForm/createItemProxy.ts +111 -0
- package/sdk/components/hooks/useForm/createResolver.ts +82 -0
- package/sdk/components/hooks/useForm/index.ts +12 -57
- package/sdk/components/hooks/useForm/types.ts +108 -609
- package/sdk/components/hooks/useForm/useForm.ts +176 -924
- package/sdk/components/index.ts +0 -13
- package/sdk/filter.ts +7 -0
- package/sdk/filter.types.ts +1 -1
- package/sdk/form.ts +15 -12
- package/sdk/form.types.ts +10 -48
- package/sdk/index.ts +1 -38
- package/sdk/table.ts +9 -0
- package/sdk/types/base-fields.ts +41 -18
- package/sdk/types/common.ts +22 -22
- package/sdk/types/constants.ts +455 -0
- package/sdk/types/index.ts +3 -0
- package/dist/cn-Dr87sK3i.js +0 -2775
- package/dist/cn-mXUIg4vp.cjs +0 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +0 -112
- package/dist/components/hooks/useForm/apiClient.d.ts.map +0 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +0 -28
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +0 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +0 -88
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +0 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +0 -24
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +0 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +0 -29
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/apiClient.d.ts +0 -99
- package/dist/components/hooks/useKanban/apiClient.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/context.d.ts +0 -4
- package/dist/components/hooks/useKanban/context.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/dragDropManager.d.ts +0 -27
- package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/index.d.ts +0 -6
- package/dist/components/hooks/useKanban/index.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/types.d.ts +0 -380
- package/dist/components/hooks/useKanban/types.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts +0 -3
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +0 -1
- package/dist/components/hooks/useKanban/useKanbanSimple.d.ts +0 -63
- package/dist/components/hooks/useKanban/useKanbanSimple.d.ts.map +0 -1
- package/dist/components/ui/index.d.ts +0 -2
- package/dist/components/ui/index.d.ts.map +0 -1
- package/dist/components/ui/kanban/Kanban.d.ts +0 -12
- package/dist/components/ui/kanban/Kanban.d.ts.map +0 -1
- package/dist/components/ui/kanban/index.d.ts +0 -2
- package/dist/components/ui/kanban/index.d.ts.map +0 -1
- package/dist/error-handling-CAoD0Kwb.cjs +0 -1
- package/dist/error-handling-CrhTtD88.js +0 -14
- package/dist/kanban.cjs +0 -13
- package/dist/kanban.d.ts +0 -5
- package/dist/kanban.d.ts.map +0 -1
- package/dist/kanban.mjs +0 -738
- package/dist/kanban.types.d.ts +0 -2
- package/dist/kanban.types.d.ts.map +0 -1
- package/dist/kanban.ui.cjs +0 -1
- package/dist/kanban.ui.d.ts +0 -2
- package/dist/kanban.ui.d.ts.map +0 -1
- package/dist/kanban.ui.mjs +0 -104
- package/sdk/components/hooks/useForm/apiClient.ts +0 -556
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +0 -444
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +0 -482
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +0 -389
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +0 -514
- package/sdk/components/hooks/useForm/useForm.llm.txt +0 -340
- package/sdk/components/hooks/useKanban/apiClient.ts +0 -494
- package/sdk/components/hooks/useKanban/context.ts +0 -16
- package/sdk/components/hooks/useKanban/dragDropManager.ts +0 -529
- package/sdk/components/hooks/useKanban/index.ts +0 -62
- package/sdk/components/hooks/useKanban/types.ts +0 -529
- package/sdk/components/hooks/useKanban/useKanban.llm.txt +0 -482
- package/sdk/components/hooks/useKanban/useKanban.ts +0 -736
- package/sdk/components/hooks/useKanban/useKanbanSimple.ts +0 -408
- package/sdk/components/ui/index.ts +0 -2
- package/sdk/components/ui/kanban/Kanban.tsx +0 -134
- package/sdk/components/ui/kanban/index.ts +0 -11
- package/sdk/kanban.ts +0 -23
- package/sdk/kanban.types.ts +0 -50
- package/sdk/kanban.ui.ts +0 -16
- /package/dist/{kanban.types.cjs → bdo.types.cjs} +0 -0
- /package/dist/{kanban.types.mjs → bdo.types.mjs} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ram_28/kf-ai-sdk
|
|
2
2
|
|
|
3
|
-
A type-safe SDK for building modern web applications with React hooks for forms, tables,
|
|
3
|
+
A type-safe SDK for building modern web applications with React hooks for forms, tables, and filtering.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -14,10 +14,10 @@ A type-safe SDK for building modern web applications with React hooks for forms,
|
|
|
14
14
|
- [Multiple Auth Providers](#multiple-auth-providers)
|
|
15
15
|
- [Protected Routes](#protected-routes)
|
|
16
16
|
- [Hooks](#hooks)
|
|
17
|
-
- [useTable](#usetable)
|
|
18
17
|
- [useForm](#useform)
|
|
19
|
-
- [
|
|
18
|
+
- [useTable](#usetable)
|
|
20
19
|
- [useFilter](#usefilter)
|
|
20
|
+
- [BDO (Business Data Object)](#bdo-business-data-object)
|
|
21
21
|
- [API Client](#api-client)
|
|
22
22
|
- [Type System](#type-system)
|
|
23
23
|
- [Utilities](#utilities)
|
|
@@ -42,12 +42,12 @@ npm install react @tanstack/react-query
|
|
|
42
42
|
## Features
|
|
43
43
|
|
|
44
44
|
- **Authentication** - Cookie-based auth with AuthProvider and useAuth hook
|
|
45
|
-
- **useForm** -
|
|
45
|
+
- **useForm** - BDO-integrated forms with automatic validation and API calls
|
|
46
46
|
- **useTable** - Data tables with sorting, pagination, and React Query integration
|
|
47
|
-
- **useKanban** - Kanban board state management with drag-drop support
|
|
48
47
|
- **useFilter** - Advanced filtering with logical operators and payload builders
|
|
48
|
+
- **BDO Module** - Type-safe, role-based data access layer with expression validation
|
|
49
49
|
- **API Client** - Type-safe CRUD operations with structured filtering and sorting
|
|
50
|
-
- **Type System** -
|
|
50
|
+
- **Type System** - 10 semantic field types (StringField, NumberField, CurrencyField, etc.)
|
|
51
51
|
- **Utilities** - Formatting helpers for currency, dates, numbers, and more
|
|
52
52
|
|
|
53
53
|
## Quick Start
|
|
@@ -60,15 +60,16 @@ import type { UseAuthReturnType, UserDetailsType } from "@ram_28/kf-ai-sdk/auth/
|
|
|
60
60
|
// Hooks
|
|
61
61
|
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
62
62
|
import { useTable } from "@ram_28/kf-ai-sdk/table";
|
|
63
|
-
import { useKanban } from "@ram_28/kf-ai-sdk/kanban";
|
|
64
63
|
import { useFilter } from "@ram_28/kf-ai-sdk/filter";
|
|
65
64
|
|
|
66
65
|
// Types
|
|
67
66
|
import type { UseFormOptionsType, UseFormReturnType } from "@ram_28/kf-ai-sdk/form/types";
|
|
68
67
|
import type { UseTableOptionsType, UseTableReturnType } from "@ram_28/kf-ai-sdk/table/types";
|
|
69
|
-
import type { UseKanbanOptionsType, UseKanbanReturnType } from "@ram_28/kf-ai-sdk/kanban/types";
|
|
70
68
|
import type { UseFilterOptionsType, UseFilterReturnType } from "@ram_28/kf-ai-sdk/filter/types";
|
|
71
69
|
|
|
70
|
+
// BDO
|
|
71
|
+
import { BaseBdo, StringField, NumberField } from "@ram_28/kf-ai-sdk/bdo";
|
|
72
|
+
|
|
72
73
|
// API
|
|
73
74
|
import { api } from "@ram_28/kf-ai-sdk/api";
|
|
74
75
|
import type { ListResponseType, FilterType } from "@ram_28/kf-ai-sdk/api/types";
|
|
@@ -77,7 +78,7 @@ import type { ListResponseType, FilterType } from "@ram_28/kf-ai-sdk/api/types";
|
|
|
77
78
|
import { formatCurrency, formatDate } from "@ram_28/kf-ai-sdk/utils";
|
|
78
79
|
|
|
79
80
|
// Base Field Types
|
|
80
|
-
import type {
|
|
81
|
+
import type { StringFieldType, CurrencyFieldType } from "@ram_28/kf-ai-sdk/types";
|
|
81
82
|
```
|
|
82
83
|
|
|
83
84
|
## Authentication
|
|
@@ -201,6 +202,41 @@ function ProtectedRoute({ children, requiredRoles }) {
|
|
|
201
202
|
|
|
202
203
|
## Hooks
|
|
203
204
|
|
|
205
|
+
### useForm
|
|
206
|
+
|
|
207
|
+
BDO-integrated form hook with automatic validation and API calls.
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
211
|
+
import { AdminProduct } from "./bdo/admin/Product";
|
|
212
|
+
|
|
213
|
+
function ProductForm() {
|
|
214
|
+
const product = new AdminProduct();
|
|
215
|
+
|
|
216
|
+
const { register, handleSubmit, errors, isSubmitting } = useForm({
|
|
217
|
+
bdo: product,
|
|
218
|
+
defaultValues: { Title: "", Price: 0 },
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<form onSubmit={handleSubmit(
|
|
223
|
+
(result) => console.log("Created:", result),
|
|
224
|
+
(error) => console.error("Error:", error)
|
|
225
|
+
)}>
|
|
226
|
+
<input {...register("Title")} placeholder="Product Title" />
|
|
227
|
+
{errors.Title && <span>{errors.Title.message}</span>}
|
|
228
|
+
|
|
229
|
+
<input {...register("Price")} type="number" placeholder="Price" />
|
|
230
|
+
{errors.Price && <span>{errors.Price.message}</span>}
|
|
231
|
+
|
|
232
|
+
<button type="submit" disabled={isSubmitting}>
|
|
233
|
+
{isSubmitting ? "Creating..." : "Create Product"}
|
|
234
|
+
</button>
|
|
235
|
+
</form>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
204
240
|
### useTable
|
|
205
241
|
|
|
206
242
|
Data table hook with sorting, pagination, and React Query integration.
|
|
@@ -254,73 +290,6 @@ function ProductTable() {
|
|
|
254
290
|
}
|
|
255
291
|
```
|
|
256
292
|
|
|
257
|
-
### useForm
|
|
258
|
-
|
|
259
|
-
Schema-driven form hook with backend validation support.
|
|
260
|
-
|
|
261
|
-
```tsx
|
|
262
|
-
import { useForm } from "@ram_28/kf-ai-sdk/form";
|
|
263
|
-
|
|
264
|
-
function ProductForm() {
|
|
265
|
-
const form = useForm({
|
|
266
|
-
source: "products",
|
|
267
|
-
operation: "create",
|
|
268
|
-
onSuccess: (data) => {
|
|
269
|
-
console.log("Created:", data);
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
return (
|
|
274
|
-
<form onSubmit={form.handleSubmit()}>
|
|
275
|
-
<input {...form.register("name")} placeholder="Product Name" />
|
|
276
|
-
{form.errors.name && <span>{form.errors.name.message}</span>}
|
|
277
|
-
|
|
278
|
-
<input {...form.register("price")} type="number" placeholder="Price" />
|
|
279
|
-
{form.errors.price && <span>{form.errors.price.message}</span>}
|
|
280
|
-
|
|
281
|
-
<button type="submit" disabled={form.isSubmitting}>
|
|
282
|
-
{form.isSubmitting ? "Creating..." : "Create Product"}
|
|
283
|
-
</button>
|
|
284
|
-
</form>
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### useKanban
|
|
290
|
-
|
|
291
|
-
Kanban board state management with drag-drop support.
|
|
292
|
-
|
|
293
|
-
```tsx
|
|
294
|
-
import { useKanban } from "@ram_28/kf-ai-sdk/kanban";
|
|
295
|
-
import { Kanban, KanbanColumn, KanbanCard } from "@ram_28/kf-ai-sdk/kanban/ui";
|
|
296
|
-
|
|
297
|
-
function TaskBoard() {
|
|
298
|
-
const kanban = useKanban({
|
|
299
|
-
source: "tasks",
|
|
300
|
-
groupByField: "status",
|
|
301
|
-
columns: [
|
|
302
|
-
{ id: "todo", title: "To Do" },
|
|
303
|
-
{ id: "in-progress", title: "In Progress" },
|
|
304
|
-
{ id: "done", title: "Done" },
|
|
305
|
-
],
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
return (
|
|
309
|
-
<Kanban>
|
|
310
|
-
{kanban.columns.map((column) => (
|
|
311
|
-
<KanbanColumn key={column.id} column={column}>
|
|
312
|
-
{column.cards.map((card) => (
|
|
313
|
-
<KanbanCard key={card.id} card={card}>
|
|
314
|
-
{card.title}
|
|
315
|
-
</KanbanCard>
|
|
316
|
-
))}
|
|
317
|
-
</KanbanColumn>
|
|
318
|
-
))}
|
|
319
|
-
</Kanban>
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
293
|
### useFilter
|
|
325
294
|
|
|
326
295
|
Advanced filtering with logical operators.
|
|
@@ -359,6 +328,32 @@ function ProductFilter() {
|
|
|
359
328
|
}
|
|
360
329
|
```
|
|
361
330
|
|
|
331
|
+
## BDO (Business Data Object)
|
|
332
|
+
|
|
333
|
+
Type-safe, role-based data access layer:
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
import { BaseBdo, StringField, NumberField } from "@ram_28/kf-ai-sdk/bdo";
|
|
337
|
+
|
|
338
|
+
// Define your BDO class
|
|
339
|
+
class AdminProduct extends BaseBdo<ProductType> {
|
|
340
|
+
readonly boId = "BDO_Product";
|
|
341
|
+
|
|
342
|
+
readonly Title = new StringField({ id: "Title", label: "Product Title" });
|
|
343
|
+
readonly Price = new NumberField({ id: "Price", label: "Price" });
|
|
344
|
+
|
|
345
|
+
protected _getFieldDefinitions() {
|
|
346
|
+
return { Title: this.Title, Price: this.Price };
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Expose only the methods this role can use
|
|
350
|
+
public async get(id: string) { return super.get(id); }
|
|
351
|
+
public async list(options?: ListOptionsType) { return super.list(options); }
|
|
352
|
+
public async create(data: Partial<ProductType>) { return super.create(data); }
|
|
353
|
+
public async update(id: string, data: Partial<ProductType>) { return super.update(id, data); }
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
362
357
|
## API Client
|
|
363
358
|
|
|
364
359
|
Type-safe API client for CRUD operations.
|
|
@@ -419,7 +414,6 @@ The SDK provides semantic field types for type-safe data modeling:
|
|
|
419
414
|
|
|
420
415
|
```tsx
|
|
421
416
|
import type {
|
|
422
|
-
IdFieldType,
|
|
423
417
|
StringFieldType,
|
|
424
418
|
TextAreaFieldType,
|
|
425
419
|
NumberFieldType,
|
|
@@ -432,7 +426,7 @@ import type {
|
|
|
432
426
|
|
|
433
427
|
// Define your data types
|
|
434
428
|
interface Product {
|
|
435
|
-
_id:
|
|
429
|
+
_id: StringFieldType;
|
|
436
430
|
name: StringFieldType;
|
|
437
431
|
description: TextAreaFieldType;
|
|
438
432
|
price: CurrencyFieldType;
|
|
@@ -453,14 +447,12 @@ import {
|
|
|
453
447
|
formatDate,
|
|
454
448
|
formatDateTime,
|
|
455
449
|
formatNumber,
|
|
456
|
-
formatPercentage,
|
|
457
450
|
} from "@ram_28/kf-ai-sdk/utils";
|
|
458
451
|
|
|
459
452
|
formatCurrency(99.99); // "$99.99"
|
|
460
453
|
formatDate(new Date()); // "Jan 11, 2024"
|
|
461
454
|
formatDateTime(new Date()); // "Jan 11, 2024, 10:30 AM"
|
|
462
455
|
formatNumber(1234.56, 2); // "1,234.56"
|
|
463
|
-
formatPercentage(0.156); // "15.6%"
|
|
464
456
|
```
|
|
465
457
|
|
|
466
458
|
### Class Names
|
|
@@ -477,11 +469,8 @@ cn("text-red-500", condition && "text-blue-500");
|
|
|
477
469
|
|
|
478
470
|
Detailed documentation for each feature:
|
|
479
471
|
|
|
480
|
-
- [useForm Documentation](./docs/useForm.md)
|
|
481
472
|
- [useTable Documentation](./docs/useTable.md)
|
|
482
|
-
- [useKanban Documentation](./docs/useKanban.md)
|
|
483
473
|
- [useFilter Documentation](./docs/useFilter.md)
|
|
484
|
-
- [Quick Reference](./docs/QUICK_REFERENCE.md)
|
|
485
474
|
|
|
486
475
|
## Requirements
|
|
487
476
|
|
package/dist/api/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ListOptionsType, ListResponseType, CreateUpdateResponseType, Delet
|
|
|
2
2
|
/**
|
|
3
3
|
* API client interface for a specific Business Object
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface ResourceClientType<T = any> {
|
|
6
6
|
/** Get single record by ID */
|
|
7
7
|
get(id: string): Promise<T>;
|
|
8
8
|
/** Create new record */
|
|
@@ -60,8 +60,12 @@ export interface ResourceClient<T = any> {
|
|
|
60
60
|
/**
|
|
61
61
|
* Fetch reference data for a specific field (for lookup and dropdown fields)
|
|
62
62
|
* GET /{bo_id}/{instance_id}/field/{field_id}/fetch
|
|
63
|
+
*
|
|
64
|
+
* @template TResult - The type of data returned. Defaults to FetchFieldOptionType
|
|
65
|
+
* - For SelectField: FetchFieldOptionType[] (with Value/Label)
|
|
66
|
+
* - For ReferenceField: TRef[] (full entity objects)
|
|
63
67
|
*/
|
|
64
|
-
fetchField(instanceId: string, fieldId: string): Promise<
|
|
68
|
+
fetchField<TResult = FetchFieldOptionType>(instanceId: string, fieldId: string): Promise<TResult[]>;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Set the base URL for all API requests
|
|
@@ -84,5 +88,5 @@ export declare function getApiBaseUrl(): string;
|
|
|
84
88
|
* @param bo_id - Business Object identifier (e.g., "user", "leave", "vendor")
|
|
85
89
|
* @returns Resource client with CRUD operations matching API spec
|
|
86
90
|
*/
|
|
87
|
-
export declare function api<T = any>(bo_id: string):
|
|
91
|
+
export declare function api<T = any>(bo_id: string): ResourceClientType<T>;
|
|
88
92
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../sdk/api/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEhB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../sdk/api/client.ts"],"names":[],"mappings":"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"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { api, setApiBaseUrl, setDefaultHeaders, getDefaultHeaders, getApiBaseUrl, } from "./client";
|
|
2
|
-
export type {
|
|
2
|
+
export type { ResourceClientType } from "./client";
|
|
3
3
|
export { DatetimeFormat, decodeDate, decodeDateTime, formatDate, formatDateTime, parseDate, parseDateTime, } from "./datetime";
|
|
4
4
|
export { getBdoSchema, listMetadata } from "./metadata";
|
|
5
|
-
export type {
|
|
6
|
-
export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, FilterType,
|
|
5
|
+
export type { BackendSchemaType, MetadataItemType, FieldMetadataType } from "./metadata";
|
|
6
|
+
export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, FilterType, FilterRHSType, ConditionOperatorType, ListOptionsType, ListResponseType, ReadResponseType, CreateUpdateResponseType, DeleteResponseType, CountResponseType, AggregationType, MetricFieldType, MetricOptionsType, MetricResponseType, PivotHeaderItemType, PivotResponseDataType, PivotOptionsType, PivotResponseType, DraftResponseType, FieldsResponseType, } from "../types/common";
|
|
7
7
|
export type { DateEncodedType, DateTimeEncodedType, } from "../types/base-fields";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/api/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/api/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EACL,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGzF,YAAY,EAEV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAER,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,aAAa,EACb,qBAAqB,EAErB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAEjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAElB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAEjB,iBAAiB,EAEjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC"}
|
package/dist/api/metadata.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ListOptionsType, ListResponseType } from "../types/common";
|
|
|
2
2
|
/**
|
|
3
3
|
* BDO Schema Structure (Business Object Metadata)
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface BackendSchemaType {
|
|
6
6
|
[fieldName: string]: any;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
@@ -19,11 +19,11 @@ export interface BackendSchema {
|
|
|
19
19
|
* console.log(schema.Fields); // Access field definitions
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export declare function getBdoSchema(metaId: string): Promise<
|
|
22
|
+
export declare function getBdoSchema(metaId: string): Promise<BackendSchemaType>;
|
|
23
23
|
/**
|
|
24
24
|
* Metadata item structure
|
|
25
25
|
*/
|
|
26
|
-
export interface
|
|
26
|
+
export interface MetadataItemType {
|
|
27
27
|
_id: string;
|
|
28
28
|
Name: string;
|
|
29
29
|
Kind: string;
|
|
@@ -52,11 +52,11 @@ export interface MetadataItem {
|
|
|
52
52
|
* });
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
export declare function listMetadata(options?: ListOptionsType): Promise<ListResponseType<
|
|
55
|
+
export declare function listMetadata(options?: ListOptionsType): Promise<ListResponseType<MetadataItemType>>;
|
|
56
56
|
/**
|
|
57
57
|
* Field metadata structure
|
|
58
58
|
*/
|
|
59
|
-
export interface
|
|
59
|
+
export interface FieldMetadataType {
|
|
60
60
|
Id: string;
|
|
61
61
|
Name: string;
|
|
62
62
|
Type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../sdk/api/metadata.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAOzE;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../sdk/api/metadata.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAOzE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8B7E;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CA8B7C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;QAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACjD,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
package/dist/api.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-DxjRcEtN.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-DxjRcEtN.cjs"),u=require("./metadata-Bz8zJqC1.cjs"),o=require("./constants-C49b9Exc.cjs"),p={DATE:"%Y-%m-%d",TIME:"%H:%M:%S",DATE_TIME:"%Y-%m-%d %H:%M:%S"};function D(t){const[e,a,r]=t.$__d__.split("-").map(Number);return new Date(e,a-1,r)}function g(t){return new Date(t.$__dt__*1e3)}function l(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${a}-${r}`}function S(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${e}-${a}-${r} ${s}:${i}:${c}`}function y(t){const[e,a,r]=t.split("-").map(Number);return new Date(e,a-1,r)}function f(t){const[e,a]=t.split(" "),[r,s,i]=e.split("-").map(Number),[c,d,m]=a.split(":").map(Number);return new Date(r,s-1,i,c,d,m)}exports.api=n.api;exports.getApiBaseUrl=n.getApiBaseUrl;exports.getDefaultHeaders=n.getDefaultHeaders;exports.setApiBaseUrl=n.setApiBaseUrl;exports.setDefaultHeaders=n.setDefaultHeaders;exports.getBdoSchema=u.getBdoSchema;exports.listMetadata=u.listMetadata;exports.DateEncodingKey=o.DateEncodingKey;exports.DeleteStatus=o.DeleteStatus;exports.HttpMethod=o.HttpMethod;exports.MetricType=o.MetricType;exports.QueryType=o.QueryType;exports.DatetimeFormat=p;exports.decodeDate=D;exports.decodeDateTime=g;exports.formatDate=l;exports.formatDateTime=S;exports.parseDate=y;exports.parseDateTime=f;
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { api, setApiBaseUrl, setDefaultHeaders, getDefaultHeaders, getApiBaseUrl, } from './api/client';
|
|
2
2
|
export { formatDateTime, decodeDateTime, formatDate, decodeDate, parseDate, parseDateTime, DatetimeFormat, } from './api/datetime';
|
|
3
3
|
export { getBdoSchema, listMetadata } from './api/metadata';
|
|
4
|
+
export { MetricType, QueryType, HttpMethod, DateEncodingKey, DeleteStatus, } from './types/constants';
|
|
4
5
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../sdk/api.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../sdk/api.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,YAAY,GACb,MAAM,mBAAmB,CAAC"}
|
package/dist/api.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { g as
|
|
1
|
+
import { a as f, c as h, g as M, s as $, b as T } from "./client-BIkaIr2y.js";
|
|
2
|
+
import { g as H, l as b } from "./metadata-VbQzyD2C.js";
|
|
3
|
+
import { D as w, a as x, H as A, M as N, Q as Y } from "./constants-DaX7GLgl.js";
|
|
3
4
|
const m = {
|
|
4
5
|
/** Date format: "YYYY-MM-DD" */
|
|
5
6
|
DATE: "%Y-%m-%d",
|
|
@@ -8,42 +9,47 @@ const m = {
|
|
|
8
9
|
/** DateTime format: "YYYY-MM-DD HH:MM:SS" */
|
|
9
10
|
DATE_TIME: "%Y-%m-%d %H:%M:%S"
|
|
10
11
|
};
|
|
11
|
-
function u(t) {
|
|
12
|
-
const [e, a, n] = t.$__d__.split("-").map(Number);
|
|
13
|
-
return new Date(e, a - 1, n);
|
|
14
|
-
}
|
|
15
12
|
function p(t) {
|
|
13
|
+
const [e, a, r] = t.$__d__.split("-").map(Number);
|
|
14
|
+
return new Date(e, a - 1, r);
|
|
15
|
+
}
|
|
16
|
+
function u(t) {
|
|
16
17
|
return new Date(t.$__dt__ * 1e3);
|
|
17
18
|
}
|
|
18
19
|
function d(t) {
|
|
19
|
-
const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"),
|
|
20
|
-
return `${e}-${a}-${
|
|
20
|
+
const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0");
|
|
21
|
+
return `${e}-${a}-${r}`;
|
|
21
22
|
}
|
|
22
23
|
function g(t) {
|
|
23
|
-
const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"),
|
|
24
|
-
return `${e}-${a}-${
|
|
25
|
-
}
|
|
26
|
-
function S(t) {
|
|
27
|
-
const [e, a, n] = t.split("-").map(Number);
|
|
28
|
-
return new Date(e, a - 1, n);
|
|
24
|
+
const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0"), n = String(t.getHours()).padStart(2, "0"), s = String(t.getMinutes()).padStart(2, "0"), o = String(t.getSeconds()).padStart(2, "0");
|
|
25
|
+
return `${e}-${a}-${r} ${n}:${s}:${o}`;
|
|
29
26
|
}
|
|
30
27
|
function D(t) {
|
|
31
|
-
const [e, a
|
|
32
|
-
return new Date(
|
|
28
|
+
const [e, a, r] = t.split("-").map(Number);
|
|
29
|
+
return new Date(e, a - 1, r);
|
|
30
|
+
}
|
|
31
|
+
function S(t) {
|
|
32
|
+
const [e, a] = t.split(" "), [r, n, s] = e.split("-").map(Number), [o, i, c] = a.split(":").map(Number);
|
|
33
|
+
return new Date(r, n - 1, s, o, i, c);
|
|
33
34
|
}
|
|
34
35
|
export {
|
|
36
|
+
w as DateEncodingKey,
|
|
35
37
|
m as DatetimeFormat,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
x as DeleteStatus,
|
|
39
|
+
A as HttpMethod,
|
|
40
|
+
N as MetricType,
|
|
41
|
+
Y as QueryType,
|
|
42
|
+
f as api,
|
|
43
|
+
p as decodeDate,
|
|
44
|
+
u as decodeDateTime,
|
|
39
45
|
d as formatDate,
|
|
40
46
|
g as formatDateTime,
|
|
41
47
|
h as getApiBaseUrl,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
H as getBdoSchema,
|
|
49
|
+
M as getDefaultHeaders,
|
|
50
|
+
b as listMetadata,
|
|
51
|
+
D as parseDate,
|
|
52
|
+
S as parseDateTime,
|
|
53
|
+
$ as setApiBaseUrl,
|
|
54
|
+
T as setDefaultHeaders
|
|
49
55
|
};
|
package/dist/api.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
1
|
+
export type { ResourceClientType } from './api/client';
|
|
2
|
+
export type { BackendSchemaType, MetadataItemType, FieldMetadataType } from './api/metadata';
|
|
3
3
|
export type { DateTimeEncodedType, DateEncodedType } from './types/base-fields';
|
|
4
|
-
export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, ConditionOperatorType, FilterType,
|
|
4
|
+
export type { SortDirectionType, SortOptionType, SortType, ConditionType, ConditionGroupType, ConditionGroupOperatorType, ConditionOperatorType, FilterType, FilterRHSType, ListOptionsType, ListResponseType, ReadResponseType, CreateUpdateResponseType, DeleteResponseType, CountResponseType, AggregationType, MetricFieldType, MetricOptionsType, MetricResponseType, PivotHeaderItemType, PivotResponseDataType, PivotOptionsType, PivotResponseType, DraftResponseType, FieldsResponseType, FetchFieldOptionType, FetchFieldResponseType, } from './types/common';
|
|
5
5
|
//# sourceMappingURL=api.types.d.ts.map
|
package/dist/api.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../sdk/api.types.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../sdk/api.types.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG7F,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGhF,YAAY,EAEV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EAGR,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,UAAU,EACV,aAAa,EAGb,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAGjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAGlB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EAGjB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
|
package/dist/auth.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var J=Object.defineProperty;var X=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>X(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),r=require("react"),N=require("@tanstack/react-query"),L=require("./client-DxjRcEtN.cjs"),W=require("./constants-C49b9Exc.cjs"),H={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...H};function Y(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function Z(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||L.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function G(e){return h.providers[e]}function D(){h={...H}}class E extends Error{constructor(n,o){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=o}}async function ee(){const e=b(),t=k(),n=L.getDefaultHeaders(),o=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!o.ok)throw o.status===401||o.status===403?new E("Not authenticated",o.status):new E(`Session check failed: ${o.statusText}`,o.status);return await o.json()}function _(e,t){return new Promise(()=>{const n=b(),o=k();if(!o)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const u=e||n.defaultProvider,c=G(u);if(!c){const A=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${u}" is not configured. Available providers: ${A}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${u}". Configure it with: configureAuth({ providers: { ${u}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${o}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${o}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([A,v])=>{f.searchParams.set(A,v)}),window.open(f.toString(),"_blank")})}async function te(e){const t=b(),n=k(),o=L.getDefaultHeaders(),u=G(t.defaultProvider),c=u==null?void 0:u.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:o,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const V=r.createContext(null),K=["auth","session"];function re({children:e,config:t,onAuthChange:n,onError:o,loadingComponent:u,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const A=r.useRef(!1);t&&!A.current&&(Y(t),A.current=!0);const v=N.useQueryClient(),l=b(),{data:a,isLoading:g,error:U,refetch:R,isFetching:P}=N.useQuery({queryKey:K,queryFn:ee,enabled:!f,retry:(s,w)=>w instanceof E&&(w.statusCode===401||w.statusCode===403)?!1:s<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[x,S]=r.useState(null),d=r.useMemo(()=>g||P?"loading":Object.keys((a==null?void 0:a.userDetails)||{}).length>0?"authenticated":"unauthenticated",[g,P,a]),i=(a==null?void 0:a.userDetails)||null,$=(a==null?void 0:a.staticBaseUrl)||null,O=(a==null?void 0:a.buildId)||null,j=d==="authenticated",C=r.useRef(n);C.current=n;const m=r.useRef(o);m.current=o,r.useEffect(()=>{var s;g||(s=C.current)==null||s.call(C,d,i)},[d,i,g]),r.useEffect(()=>{var s;U&&(S(U),(s=m.current)==null||s.call(m,U))},[U]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&_()},[d,g,l.autoRedirect]);const p=r.useCallback((s,w)=>{_(s,w)},[]),q=r.useCallback(async s=>{v.removeQueries({queryKey:K}),await te(s)},[v]),B=r.useCallback(async()=>{if(P)return a||null;try{return(await R()).data||null}catch(s){return S(s),null}},[R,P,a]),I=r.useCallback(s=>(i==null?void 0:i.Role)===s,[i]),T=r.useCallback(s=>s.includes((i==null?void 0:i.Role)||""),[i]),F=r.useCallback(()=>{S(null)},[]),Q=r.useCallback(()=>{R()},[R]),z=r.useMemo(()=>({user:i,staticBaseUrl:$,buildId:O,status:d,isAuthenticated:j,isLoading:g,login:p,logout:q,refreshSession:B,hasRole:I,hasAnyRole:T,error:x,clearError:F,_forceCheck:Q}),[i,$,O,d,j,g,p,q,B,I,T,x,F,Q]);return d==="loading"&&u?y.jsx(y.Fragment,{children:u}):d==="unauthenticated"&&!l.autoRedirect&&c?y.jsx(y.Fragment,{children:c}):y.jsx(V.Provider,{value:z,children:e})}function ne(){const e=r.useContext(V);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function oe(){const e=ne();return r.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProviderName=W.AuthProviderName;exports.AuthStatus=W.AuthStatus;exports.AuthProvider=re;exports.AuthenticationError=E;exports.configureAuth=Y;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=D;exports.setAuthProvider=Z;exports.useAuth=oe;
|
package/dist/auth.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { AuthProvider } from './auth/AuthProvider';
|
|
|
2
2
|
export { useAuth } from './auth/useAuth';
|
|
3
3
|
export { AuthenticationError } from './auth/authClient';
|
|
4
4
|
export { configureAuth, getAuthConfig, setAuthProvider, getAuthBaseUrl, resetAuthConfig, } from './auth/authConfig';
|
|
5
|
+
export { AuthStatus, AuthProviderName, } from './types/constants';
|
|
5
6
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../sdk/auth.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../sdk/auth.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,UAAU,EACV,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|