@taruvi/refine-providers 1.3.3 → 1.3.4-beta.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 +23 -8
- package/dist/index.cjs +342 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -8
- package/dist/index.d.ts +77 -8
- package/dist/index.js +332 -97
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataProvider, AuthProvider, AccessControlProvider, MetaQuery, CrudFilter, CrudSort, Pagination } from '@refinedev/core';
|
|
2
|
-
import { Client, GraphFormat, GraphInclude } from '@taruvi/sdk';
|
|
2
|
+
import { Client, GraphFormat, GraphInclude, Database, BackendFilterTreeRoot } from '@taruvi/sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a Refine DataProvider for Taruvi database operations.
|
|
@@ -94,11 +94,16 @@ declare function functionsDataProvider(client: Client): DataProvider;
|
|
|
94
94
|
declare function analyticsDataProvider(client: Client): DataProvider;
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* Login params
|
|
97
|
+
* Login params - supports both redirect flow and credentials flow
|
|
98
98
|
*/
|
|
99
99
|
interface LoginParams {
|
|
100
|
-
/** URL to redirect after successful login */
|
|
100
|
+
/** For redirect-based login - URL to redirect after successful login */
|
|
101
101
|
callbackUrl?: string;
|
|
102
|
+
/** For credentials-based login (if supported) */
|
|
103
|
+
username?: string;
|
|
104
|
+
password?: string;
|
|
105
|
+
/** Whether to use redirect flow (default: true) */
|
|
106
|
+
redirect?: boolean;
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
109
|
* Logout params
|
|
@@ -118,10 +123,11 @@ declare let _cachedUser: Record<string, any> | null;
|
|
|
118
123
|
/**
|
|
119
124
|
* Creates a Refine AuthProvider for Taruvi authentication.
|
|
120
125
|
*
|
|
121
|
-
*
|
|
126
|
+
* Supports redirect-based authentication flow (Web UI Flow):
|
|
122
127
|
* 1. User calls login() → Redirects to backend /accounts/login/
|
|
123
128
|
* 2. User authenticates on backend
|
|
124
|
-
* 3. Backend redirects back
|
|
129
|
+
* 3. Backend redirects back with tokens in URL hash
|
|
130
|
+
* 4. Client extracts and stores tokens automatically
|
|
125
131
|
*/
|
|
126
132
|
declare function authProvider(client: Client): AuthProvider;
|
|
127
133
|
|
|
@@ -229,11 +235,74 @@ interface TaruviListResponse<T> {
|
|
|
229
235
|
* Example: { field: "age", operator: "gte", value: 18 } → "age__gte=18"
|
|
230
236
|
*/
|
|
231
237
|
declare const REFINE_OPERATOR_MAP: Record<string, string>;
|
|
238
|
+
type ConvertRefineFiltersOptions = {
|
|
239
|
+
/**
|
|
240
|
+
* `bracket` (default): logical `and` / `or` use Taruvi CrudFilters bracket query keys.
|
|
241
|
+
* `flatten`: legacy merge (OR becomes AND) — only for Storage list filters that do not support CrudFilters.
|
|
242
|
+
*/
|
|
243
|
+
logicalEncoding?: "bracket" | "flatten";
|
|
244
|
+
};
|
|
245
|
+
/** One leaf filter ready for flat `field__op=value` query encoding. */
|
|
246
|
+
type FlatFilterLeaf = {
|
|
247
|
+
field: string;
|
|
248
|
+
operator: string;
|
|
249
|
+
value: unknown;
|
|
250
|
+
};
|
|
251
|
+
/** Root logical filter for JSON `filters` query param (not wrapped in an array). */
|
|
252
|
+
type LogicalCrudFilter = {
|
|
253
|
+
operator: "and" | "or";
|
|
254
|
+
value: CrudFilter[];
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Taruvi list filter payload: leaf array → flat query params; logical object → JSON tree.
|
|
258
|
+
*/
|
|
259
|
+
type TaruviListFilters = FlatFilterLeaf[] | LogicalCrudFilter;
|
|
260
|
+
/** True when `filters` is a non-logical array of field leaves (may be empty). */
|
|
261
|
+
declare function isFlatFilterList(filters: unknown): filters is FlatFilterLeaf[];
|
|
262
|
+
/** True when `filters` is a single logical object (and / or), not an array. */
|
|
263
|
+
declare function isLogicalCrudFilter(filters: unknown): filters is LogicalCrudFilter;
|
|
264
|
+
/**
|
|
265
|
+
* Normalize Refine `CrudFilter[]` or Taruvi payloads for `applyFilters`.
|
|
266
|
+
* Legacy: all field leaves → flat array; single root logical → logical object.
|
|
267
|
+
*/
|
|
268
|
+
declare function normalizeTaruviListFilters(filters: unknown): TaruviListFilters | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Collect field filters that can be sent as top-level query params (implicit AND).
|
|
271
|
+
*
|
|
272
|
+
* Returns `null` when the list contains `or` or other shapes that require the JSON
|
|
273
|
+
* `filters` tree. FK-traversal fields (`department_id.name`, etc.) must use flat
|
|
274
|
+
* params on the current platform — nesting them under JSON `and` breaks traversal.
|
|
275
|
+
*/
|
|
276
|
+
declare function collectFlatLeaves(filters?: CrudFilter[]): FlatFilterLeaf[] | null;
|
|
277
|
+
/** Backend operator token for CrudFilters bracket payloads (suffix or `eq`). */
|
|
278
|
+
declare function refineOperatorToBackendKey(operator: string): string;
|
|
279
|
+
/** String value for a leaf filter (flat or bracket). */
|
|
280
|
+
declare function formatRefineLeafValue(operator: string, value: unknown): string;
|
|
281
|
+
/** Encode one CrudFilter node (logical or leaf) into bracket-style flat query keys. */
|
|
282
|
+
declare function encodeCrudFilterBracket(filter: CrudFilter, path: string, out: Record<string, string>): void;
|
|
283
|
+
/**
|
|
284
|
+
* Converts Refine `CrudFilter[]` into the backend JSON `filters` query param tree
|
|
285
|
+
* (root array of `{ operator: "and"|"or", value: [...] }` nodes).
|
|
286
|
+
*
|
|
287
|
+
* Leaf `operator` values are **Taruvi / platform** tokens after `refineOperatorToBackendKey`.
|
|
288
|
+
* Leaf `operator` values use Taruvi / platform tokens from `refineOperatorToBackendKey`.
|
|
289
|
+
*/
|
|
290
|
+
declare function convertRefineFiltersToBackendTree(filters?: CrudFilter[]): BackendFilterTreeRoot | null;
|
|
291
|
+
/**
|
|
292
|
+
* Converts one logical CrudFilter object into the backend JSON `filters` tree root.
|
|
293
|
+
*/
|
|
294
|
+
declare function convertLogicalFilterToBackendTree(filter: LogicalCrudFilter): BackendFilterTreeRoot | null;
|
|
295
|
+
/** Encode leaf filters as flat `field__op` query param keys. */
|
|
296
|
+
declare function encodeFlatFilterListToParams(leaves: FlatFilterLeaf[]): Record<string, string>;
|
|
232
297
|
/**
|
|
233
298
|
* Converts Refine CrudFilter[] to Taruvi query parameters.
|
|
234
|
-
*
|
|
299
|
+
* Logical `and` / `or` use CrudFilters bracket notation unless `logicalEncoding: 'flatten'`.
|
|
300
|
+
*/
|
|
301
|
+
declare function convertRefineFilters(filters?: CrudFilter[], options?: ConvertRefineFiltersOptions): Record<string, string>;
|
|
302
|
+
/**
|
|
303
|
+
* Applies flat query param entries (including bracket keys) onto a Database query.
|
|
235
304
|
*/
|
|
236
|
-
declare function
|
|
305
|
+
declare function applyRefineQueryParamsToDatabase<T>(query: Database<T>, params: Record<string, string>): Database<T>;
|
|
237
306
|
/**
|
|
238
307
|
* Converts Refine CrudSort[] to Taruvi ordering parameter.
|
|
239
308
|
* Uses DRF convention: "-field" for DESC, "field" for ASC.
|
|
@@ -264,4 +333,4 @@ declare function buildQueryString(params?: Record<string, unknown>): string;
|
|
|
264
333
|
*/
|
|
265
334
|
declare function handleError(error: unknown): never;
|
|
266
335
|
|
|
267
|
-
export { type AllowedAction, type AnalyticsMeta, type AppCustomMeta, type FunctionMeta, type LoginParams, type LogoutParams, REFINE_OPERATOR_MAP, type RegisterParams, type StorageDownloadResponse, type StorageUploadVariables, type TaruviListResponse, type TaruviMeta, _cachedUser, accessControlProvider, analyticsDataProvider, appDataProvider, authProvider, buildQueryString, buildRefineQueryParams, convertRefineFilters, convertRefinePagination, convertRefineSorters, dataProvider, functionsDataProvider, handleError, storageDataProvider, userDataProvider };
|
|
336
|
+
export { type AllowedAction, type AnalyticsMeta, type AppCustomMeta, type ConvertRefineFiltersOptions, type FlatFilterLeaf, type FunctionMeta, type LogicalCrudFilter, type LoginParams, type LogoutParams, REFINE_OPERATOR_MAP, type RegisterParams, type StorageDownloadResponse, type StorageUploadVariables, type TaruviListFilters, type TaruviListResponse, type TaruviMeta, _cachedUser, accessControlProvider, analyticsDataProvider, appDataProvider, applyRefineQueryParamsToDatabase, authProvider, buildQueryString, buildRefineQueryParams, collectFlatLeaves, convertLogicalFilterToBackendTree, convertRefineFilters, convertRefineFiltersToBackendTree, convertRefinePagination, convertRefineSorters, dataProvider, encodeCrudFilterBracket, encodeFlatFilterListToParams, formatRefineLeafValue, functionsDataProvider, handleError, isFlatFilterList, isLogicalCrudFilter, normalizeTaruviListFilters, refineOperatorToBackendKey, storageDataProvider, userDataProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataProvider, AuthProvider, AccessControlProvider, MetaQuery, CrudFilter, CrudSort, Pagination } from '@refinedev/core';
|
|
2
|
-
import { Client, GraphFormat, GraphInclude } from '@taruvi/sdk';
|
|
2
|
+
import { Client, GraphFormat, GraphInclude, Database, BackendFilterTreeRoot } from '@taruvi/sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a Refine DataProvider for Taruvi database operations.
|
|
@@ -94,11 +94,16 @@ declare function functionsDataProvider(client: Client): DataProvider;
|
|
|
94
94
|
declare function analyticsDataProvider(client: Client): DataProvider;
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* Login params
|
|
97
|
+
* Login params - supports both redirect flow and credentials flow
|
|
98
98
|
*/
|
|
99
99
|
interface LoginParams {
|
|
100
|
-
/** URL to redirect after successful login */
|
|
100
|
+
/** For redirect-based login - URL to redirect after successful login */
|
|
101
101
|
callbackUrl?: string;
|
|
102
|
+
/** For credentials-based login (if supported) */
|
|
103
|
+
username?: string;
|
|
104
|
+
password?: string;
|
|
105
|
+
/** Whether to use redirect flow (default: true) */
|
|
106
|
+
redirect?: boolean;
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
109
|
* Logout params
|
|
@@ -118,10 +123,11 @@ declare let _cachedUser: Record<string, any> | null;
|
|
|
118
123
|
/**
|
|
119
124
|
* Creates a Refine AuthProvider for Taruvi authentication.
|
|
120
125
|
*
|
|
121
|
-
*
|
|
126
|
+
* Supports redirect-based authentication flow (Web UI Flow):
|
|
122
127
|
* 1. User calls login() → Redirects to backend /accounts/login/
|
|
123
128
|
* 2. User authenticates on backend
|
|
124
|
-
* 3. Backend redirects back
|
|
129
|
+
* 3. Backend redirects back with tokens in URL hash
|
|
130
|
+
* 4. Client extracts and stores tokens automatically
|
|
125
131
|
*/
|
|
126
132
|
declare function authProvider(client: Client): AuthProvider;
|
|
127
133
|
|
|
@@ -229,11 +235,74 @@ interface TaruviListResponse<T> {
|
|
|
229
235
|
* Example: { field: "age", operator: "gte", value: 18 } → "age__gte=18"
|
|
230
236
|
*/
|
|
231
237
|
declare const REFINE_OPERATOR_MAP: Record<string, string>;
|
|
238
|
+
type ConvertRefineFiltersOptions = {
|
|
239
|
+
/**
|
|
240
|
+
* `bracket` (default): logical `and` / `or` use Taruvi CrudFilters bracket query keys.
|
|
241
|
+
* `flatten`: legacy merge (OR becomes AND) — only for Storage list filters that do not support CrudFilters.
|
|
242
|
+
*/
|
|
243
|
+
logicalEncoding?: "bracket" | "flatten";
|
|
244
|
+
};
|
|
245
|
+
/** One leaf filter ready for flat `field__op=value` query encoding. */
|
|
246
|
+
type FlatFilterLeaf = {
|
|
247
|
+
field: string;
|
|
248
|
+
operator: string;
|
|
249
|
+
value: unknown;
|
|
250
|
+
};
|
|
251
|
+
/** Root logical filter for JSON `filters` query param (not wrapped in an array). */
|
|
252
|
+
type LogicalCrudFilter = {
|
|
253
|
+
operator: "and" | "or";
|
|
254
|
+
value: CrudFilter[];
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Taruvi list filter payload: leaf array → flat query params; logical object → JSON tree.
|
|
258
|
+
*/
|
|
259
|
+
type TaruviListFilters = FlatFilterLeaf[] | LogicalCrudFilter;
|
|
260
|
+
/** True when `filters` is a non-logical array of field leaves (may be empty). */
|
|
261
|
+
declare function isFlatFilterList(filters: unknown): filters is FlatFilterLeaf[];
|
|
262
|
+
/** True when `filters` is a single logical object (and / or), not an array. */
|
|
263
|
+
declare function isLogicalCrudFilter(filters: unknown): filters is LogicalCrudFilter;
|
|
264
|
+
/**
|
|
265
|
+
* Normalize Refine `CrudFilter[]` or Taruvi payloads for `applyFilters`.
|
|
266
|
+
* Legacy: all field leaves → flat array; single root logical → logical object.
|
|
267
|
+
*/
|
|
268
|
+
declare function normalizeTaruviListFilters(filters: unknown): TaruviListFilters | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Collect field filters that can be sent as top-level query params (implicit AND).
|
|
271
|
+
*
|
|
272
|
+
* Returns `null` when the list contains `or` or other shapes that require the JSON
|
|
273
|
+
* `filters` tree. FK-traversal fields (`department_id.name`, etc.) must use flat
|
|
274
|
+
* params on the current platform — nesting them under JSON `and` breaks traversal.
|
|
275
|
+
*/
|
|
276
|
+
declare function collectFlatLeaves(filters?: CrudFilter[]): FlatFilterLeaf[] | null;
|
|
277
|
+
/** Backend operator token for CrudFilters bracket payloads (suffix or `eq`). */
|
|
278
|
+
declare function refineOperatorToBackendKey(operator: string): string;
|
|
279
|
+
/** String value for a leaf filter (flat or bracket). */
|
|
280
|
+
declare function formatRefineLeafValue(operator: string, value: unknown): string;
|
|
281
|
+
/** Encode one CrudFilter node (logical or leaf) into bracket-style flat query keys. */
|
|
282
|
+
declare function encodeCrudFilterBracket(filter: CrudFilter, path: string, out: Record<string, string>): void;
|
|
283
|
+
/**
|
|
284
|
+
* Converts Refine `CrudFilter[]` into the backend JSON `filters` query param tree
|
|
285
|
+
* (root array of `{ operator: "and"|"or", value: [...] }` nodes).
|
|
286
|
+
*
|
|
287
|
+
* Leaf `operator` values are **Taruvi / platform** tokens after `refineOperatorToBackendKey`.
|
|
288
|
+
* Leaf `operator` values use Taruvi / platform tokens from `refineOperatorToBackendKey`.
|
|
289
|
+
*/
|
|
290
|
+
declare function convertRefineFiltersToBackendTree(filters?: CrudFilter[]): BackendFilterTreeRoot | null;
|
|
291
|
+
/**
|
|
292
|
+
* Converts one logical CrudFilter object into the backend JSON `filters` tree root.
|
|
293
|
+
*/
|
|
294
|
+
declare function convertLogicalFilterToBackendTree(filter: LogicalCrudFilter): BackendFilterTreeRoot | null;
|
|
295
|
+
/** Encode leaf filters as flat `field__op` query param keys. */
|
|
296
|
+
declare function encodeFlatFilterListToParams(leaves: FlatFilterLeaf[]): Record<string, string>;
|
|
232
297
|
/**
|
|
233
298
|
* Converts Refine CrudFilter[] to Taruvi query parameters.
|
|
234
|
-
*
|
|
299
|
+
* Logical `and` / `or` use CrudFilters bracket notation unless `logicalEncoding: 'flatten'`.
|
|
300
|
+
*/
|
|
301
|
+
declare function convertRefineFilters(filters?: CrudFilter[], options?: ConvertRefineFiltersOptions): Record<string, string>;
|
|
302
|
+
/**
|
|
303
|
+
* Applies flat query param entries (including bracket keys) onto a Database query.
|
|
235
304
|
*/
|
|
236
|
-
declare function
|
|
305
|
+
declare function applyRefineQueryParamsToDatabase<T>(query: Database<T>, params: Record<string, string>): Database<T>;
|
|
237
306
|
/**
|
|
238
307
|
* Converts Refine CrudSort[] to Taruvi ordering parameter.
|
|
239
308
|
* Uses DRF convention: "-field" for DESC, "field" for ASC.
|
|
@@ -264,4 +333,4 @@ declare function buildQueryString(params?: Record<string, unknown>): string;
|
|
|
264
333
|
*/
|
|
265
334
|
declare function handleError(error: unknown): never;
|
|
266
335
|
|
|
267
|
-
export { type AllowedAction, type AnalyticsMeta, type AppCustomMeta, type FunctionMeta, type LoginParams, type LogoutParams, REFINE_OPERATOR_MAP, type RegisterParams, type StorageDownloadResponse, type StorageUploadVariables, type TaruviListResponse, type TaruviMeta, _cachedUser, accessControlProvider, analyticsDataProvider, appDataProvider, authProvider, buildQueryString, buildRefineQueryParams, convertRefineFilters, convertRefinePagination, convertRefineSorters, dataProvider, functionsDataProvider, handleError, storageDataProvider, userDataProvider };
|
|
336
|
+
export { type AllowedAction, type AnalyticsMeta, type AppCustomMeta, type ConvertRefineFiltersOptions, type FlatFilterLeaf, type FunctionMeta, type LogicalCrudFilter, type LoginParams, type LogoutParams, REFINE_OPERATOR_MAP, type RegisterParams, type StorageDownloadResponse, type StorageUploadVariables, type TaruviListFilters, type TaruviListResponse, type TaruviMeta, _cachedUser, accessControlProvider, analyticsDataProvider, appDataProvider, applyRefineQueryParamsToDatabase, authProvider, buildQueryString, buildRefineQueryParams, collectFlatLeaves, convertLogicalFilterToBackendTree, convertRefineFilters, convertRefineFiltersToBackendTree, convertRefinePagination, convertRefineSorters, dataProvider, encodeCrudFilterBracket, encodeFlatFilterListToParams, formatRefineLeafValue, functionsDataProvider, handleError, isFlatFilterList, isLogicalCrudFilter, normalizeTaruviListFilters, refineOperatorToBackendKey, storageDataProvider, userDataProvider };
|