fastapi-rtk 2.5.1 → 2.6.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.
Files changed (29) hide show
  1. package/dist/.bundled/jsonforms/cjs/_virtual/index10.cjs +2 -2
  2. package/dist/.bundled/jsonforms/cjs/_virtual/index6.cjs +2 -2
  3. package/dist/.bundled/jsonforms/cjs/_virtual/index7.cjs +2 -2
  4. package/dist/.bundled/jsonforms/cjs/_virtual/index8.cjs +2 -2
  5. package/dist/.bundled/jsonforms/cjs/_virtual/index9.cjs +2 -2
  6. package/dist/.bundled/jsonforms/esm/_virtual/index10.mjs +2 -2
  7. package/dist/.bundled/jsonforms/esm/_virtual/index6.mjs +2 -2
  8. package/dist/.bundled/jsonforms/esm/_virtual/index7.mjs +2 -2
  9. package/dist/.bundled/jsonforms/esm/_virtual/index8.mjs +2 -2
  10. package/dist/.bundled/jsonforms/esm/_virtual/index9.mjs +2 -2
  11. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/compile/index.cjs +1 -1
  12. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.cjs +1 -1
  13. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/core/index.cjs +1 -1
  14. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/format/index.cjs +1 -1
  15. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/validation/index.cjs +1 -1
  16. package/dist/.external/esm/ajv@8.17.1/ajv/dist/compile/index.mjs +1 -1
  17. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.mjs +1 -1
  18. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/core/index.mjs +1 -1
  19. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/format/index.mjs +1 -1
  20. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/validation/index.mjs +1 -1
  21. package/dist/contexts/lib/ApiContext/ApiContext.d.ts +3 -2
  22. package/dist/contexts/lib/ApiContext/types.d.ts +7 -6
  23. package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/useColumns.cjs +3 -2
  24. package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/useColumns.mjs +3 -2
  25. package/dist/core/lib/Tables/NextGenDataGrid/hooks/useColumns/useColumns.d.ts +1 -1
  26. package/dist/core/lib/Tables/NextGenDataGrid/hooks/useColumns/useColumns.test.d.ts +1 -0
  27. package/dist/core/lib/Wrappers/ApiProvider/ApiProvider.d.ts +1 -1
  28. package/dist/core/lib/Wrappers/ApiProvider/types.d.ts +10 -4
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var format = {};
4
- exports.__exports = format;
3
+ var compile = {};
4
+ exports.__exports = compile;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var compile = {};
4
- exports.__exports = compile;
3
+ var core = {};
4
+ exports.__exports = core;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var core = {};
4
- exports.__exports = core;
3
+ var validation = {};
4
+ exports.__exports = validation;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var validation = {};
4
- exports.__exports = validation;
3
+ var applicator = {};
4
+ exports.__exports = applicator;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var applicator = {};
4
- exports.__exports = applicator;
3
+ var format = {};
4
+ exports.__exports = format;
@@ -1,4 +1,4 @@
1
- var format = {};
1
+ var compile = {};
2
2
  export {
3
- format as __exports
3
+ compile as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var compile = {};
1
+ var core = {};
2
2
  export {
3
- compile as __exports
3
+ core as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var core = {};
1
+ var validation = {};
2
2
  export {
3
- core as __exports
3
+ validation as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var validation = {};
1
+ var applicator = {};
2
2
  export {
3
- validation as __exports
3
+ applicator as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var applicator = {};
1
+ var format = {};
2
2
  export {
3
- applicator as __exports
3
+ format as __exports
4
4
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/index6.cjs");
3
+ const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/index10.cjs");
4
4
  const index$1 = require("./codegen/index.cjs");
5
5
  const validation_error = require("../runtime/validation_error.cjs");
6
6
  const names = require("./names.cjs");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index9.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index8.cjs");
4
4
  const additionalItems = require("./additionalItems.cjs");
5
5
  const prefixItems = require("./prefixItems.cjs");
6
6
  const items = require("./items.cjs");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index7.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index6.cjs");
4
4
  const id = require("./id.cjs");
5
5
  const ref = require("./ref.cjs");
6
6
  var hasRequiredCore;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index10.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index9.cjs");
4
4
  const format = require("./format.cjs");
5
5
  var hasRequiredFormat;
6
6
  function requireFormat() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index8.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index7.cjs");
4
4
  const limitNumber = require("./limitNumber.cjs");
5
5
  const multipleOf = require("./multipleOf.cjs");
6
6
  const limitLength = require("./limitLength.cjs");
@@ -1,4 +1,4 @@
1
- import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/index6.mjs";
1
+ import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/index10.mjs";
2
2
  import { __require as requireCodegen } from "./codegen/index.mjs";
3
3
  import { __require as requireValidation_error } from "../runtime/validation_error.mjs";
4
4
  import { __require as requireNames } from "./names.mjs";
@@ -1,4 +1,4 @@
1
- import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index9.mjs";
1
+ import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index8.mjs";
2
2
  import { __require as requireAdditionalItems } from "./additionalItems.mjs";
3
3
  import { __require as requirePrefixItems } from "./prefixItems.mjs";
4
4
  import { __require as requireItems } from "./items.mjs";
@@ -1,4 +1,4 @@
1
- import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index7.mjs";
1
+ import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index6.mjs";
2
2
  import { __require as requireId } from "./id.mjs";
3
3
  import { __require as requireRef } from "./ref.mjs";
4
4
  var hasRequiredCore;
@@ -1,4 +1,4 @@
1
- import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index10.mjs";
1
+ import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index9.mjs";
2
2
  import { __require as requireFormat$1 } from "./format.mjs";
3
3
  var hasRequiredFormat;
4
4
  function requireFormat() {
@@ -1,4 +1,4 @@
1
- import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index8.mjs";
1
+ import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index7.mjs";
2
2
  import { __require as requireLimitNumber } from "./limitNumber.mjs";
3
3
  import { __require as requireMultipleOf } from "./multipleOf.mjs";
4
4
  import { __require as requireLimitLength } from "./limitLength.mjs";
@@ -1,12 +1,13 @@
1
1
  import { SafeContextOptions } from 'fastapi-rtk/utils';
2
2
  import { ApiContextValue, ApiTypeOverrides, EntryRow, UseApiResult } from './types';
3
- export declare const ApiContextProvider: import('react').Provider<ApiContextValue<import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow> | null>, useApiProvider: (options?: SafeContextOptions<ApiContextValue<import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow>>) => ApiContextValue<import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow>;
3
+ export declare const ApiContextProvider: import('react').Provider<ApiContextValue<import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, object> | null>, useApiProvider: (options?: SafeContextOptions<ApiContextValue<import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, object>>) => ApiContextValue<import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, import('fastapi-rtk/api-types').ResultRow, object>;
4
4
  /**
5
5
  * Access the API context.
6
6
  *
7
7
  * @typeParam TDefault - Uniform row/payload type applied to every operation. Defaults to the dynamic `EntryRow`.
8
8
  * @typeParam TOverrides - Per-operation overrides (`list` / `get` / `add` / `edit`); each replaces `TDefault` for that operation only.
9
+ * @typeParam TQuery - Custom query-param keys forwarded to the backend, surfaced typed on `queryParams` / `setQueryParams`.
9
10
  * @param options - Options for the context hook.
10
11
  * @returns The API context object, with `data`, `getEntry`, `addEntry`, `updateEntry`, etc. typed per operation.
11
12
  */
12
- export declare const useApi: <TDefault = EntryRow, TOverrides extends ApiTypeOverrides = ApiTypeOverrides>(options?: SafeContextOptions<UseApiResult<TDefault, TOverrides>>) => UseApiResult<TDefault, TOverrides>;
13
+ export declare const useApi: <TDefault = EntryRow, TOverrides extends ApiTypeOverrides = ApiTypeOverrides, TQuery extends object = object>(options?: SafeContextOptions<UseApiResult<TDefault, TOverrides, TQuery>>) => UseApiResult<TDefault, TOverrides, TQuery>;
@@ -121,8 +121,9 @@ export type OpType<TOverrides extends ApiTypeOverrides, K extends keyof ApiTypeO
121
121
  * @typeParam TGet - Shape of a single fetched/affected record (`getEntry`, and the record returned by `addEntry` / `updateEntry`).
122
122
  * @typeParam TAdd - Payload accepted by `addEntry`.
123
123
  * @typeParam TEdit - Payload accepted by `updateEntry`.
124
+ * @typeParam TQuery - Custom query-param keys forwarded to the backend, intersected onto `queryParams` and `setQueryParams`.
124
125
  */
125
- export interface ApiContextValue<TList = EntryRow, TGet = EntryRow, TAdd = EntryRow, TEdit = EntryRow> {
126
+ export interface ApiContextValue<TList = EntryRow, TGet = EntryRow, TAdd = EntryRow, TEdit = EntryRow, TQuery extends object = object> {
126
127
  /** The API path. */
127
128
  path: string;
128
129
  /** Information about the API, including schemas, UI schemas, and the normalized add/edit form blocks. */
@@ -130,7 +131,7 @@ export interface ApiContextValue<TList = EntryRow, TGet = EntryRow, TAdd = Entry
130
131
  /** The data returned by the API. */
131
132
  data?: APIData<TList>;
132
133
  /** The query parameters used in the API request. */
133
- queryParams?: APIQueryParams;
134
+ queryParams?: APIQueryParams & TQuery;
134
135
  /** Indicates whether the API request is currently loading. */
135
136
  loading: boolean;
136
137
  /** Indicates whether the API info request is currently loading. */
@@ -154,7 +155,7 @@ export interface ApiContextValue<TList = EntryRow, TGet = EntryRow, TAdd = Entry
154
155
  /** An object containing special keys for the API query, such as 'all' and 'actions'. */
155
156
  specialKey: APISpecialKey;
156
157
  /** A function to update the query parameters. */
157
- setQueryParams: (partialQueryParams: Partial<APIQueryParams> | ((prev: APIQueryParams) => Partial<APIQueryParams>)) => void;
158
+ setQueryParams: (partialQueryParams: Partial<APIQueryParams & TQuery> | ((prev: APIQueryParams & TQuery) => Partial<APIQueryParams & TQuery>)) => void;
158
159
  /** A function to refetch the data from the API. */
159
160
  refetch: (options?: {
160
161
  force?: boolean;
@@ -185,7 +186,7 @@ export interface ApiContextValue<TList = EntryRow, TGet = EntryRow, TAdd = Entry
185
186
  resetError: () => void;
186
187
  }
187
188
  /**
188
- * The `ApiContextValue` returned by `useApi<TDefault, TOverrides>`: the uniform `TDefault` applied to
189
- * every operation, with any `TOverrides` keys replacing it per operation.
189
+ * The `ApiContextValue` returned by `useApi<TDefault, TOverrides, TQuery>`: the uniform `TDefault` applied to
190
+ * every operation, with any `TOverrides` keys replacing it per operation, and `TQuery` adding custom query-param keys.
190
191
  */
191
- export type UseApiResult<TDefault = EntryRow, TOverrides extends ApiTypeOverrides = ApiTypeOverrides> = ApiContextValue<OpType<TOverrides, 'list', TDefault>, OpType<TOverrides, 'get', TDefault>, OpType<TOverrides, 'add', TDefault>, OpType<TOverrides, 'edit', TDefault>>;
192
+ export type UseApiResult<TDefault = EntryRow, TOverrides extends ApiTypeOverrides = ApiTypeOverrides, TQuery extends object = object> = ApiContextValue<OpType<TOverrides, 'list', TDefault>, OpType<TOverrides, 'get', TDefault>, OpType<TOverrides, 'add', TDefault>, OpType<TOverrides, 'edit', TDefault>, TQuery>;
@@ -23,7 +23,7 @@ function useColumns(columnProps = {}, header = {}, body = {}, textFilterSeparato
23
23
  idValueMap.set(`${infoPath}-${key}-${filter.id}`, filter.value);
24
24
  }
25
25
  });
26
- }, [idValueMap, info == null ? void 0 : info.filters, infoPath]);
26
+ }, [info == null ? void 0 : info.filters, infoPath]);
27
27
  const columns = React.useMemo(
28
28
  () => (data == null ? void 0 : data.list_columns.map((col) => {
29
29
  var _a, _b, _c, _d, _e, _f, _g;
@@ -127,6 +127,8 @@ function useColumns(columnProps = {}, header = {}, body = {}, textFilterSeparato
127
127
  };
128
128
  return { ...result, ...utils.parseFromValuesOrFunc(utils.mergeProps(columnProps, specialKey.all, col), result) };
129
129
  })) || [],
130
+ // idValueMap excluded: new identity on every .set, and its contents track info?.filters (already a dep).
131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
130
132
  [
131
133
  data == null ? void 0 : data.list_columns,
132
134
  data == null ? void 0 : data.label_columns,
@@ -139,7 +141,6 @@ function useColumns(columnProps = {}, header = {}, body = {}, textFilterSeparato
139
141
  columnProps,
140
142
  api,
141
143
  auth,
142
- idValueMap,
143
144
  memo,
144
145
  queryParams == null ? void 0 : queryParams.filters,
145
146
  body,
@@ -21,7 +21,7 @@ function useColumns(columnProps = {}, header = {}, body = {}, textFilterSeparato
21
21
  idValueMap.set(`${infoPath}-${key}-${filter.id}`, filter.value);
22
22
  }
23
23
  });
24
- }, [idValueMap, info == null ? void 0 : info.filters, infoPath]);
24
+ }, [info == null ? void 0 : info.filters, infoPath]);
25
25
  const columns = useMemo(
26
26
  () => (data == null ? void 0 : data.list_columns.map((col) => {
27
27
  var _a, _b, _c, _d, _e, _f, _g;
@@ -125,6 +125,8 @@ function useColumns(columnProps = {}, header = {}, body = {}, textFilterSeparato
125
125
  };
126
126
  return { ...result, ...parseFromValuesOrFunc(mergeProps(columnProps, specialKey.all, col), result) };
127
127
  })) || [],
128
+ // idValueMap excluded: new identity on every .set, and its contents track info?.filters (already a dep).
129
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
130
  [
129
131
  data == null ? void 0 : data.list_columns,
130
132
  data == null ? void 0 : data.label_columns,
@@ -137,7 +139,6 @@ function useColumns(columnProps = {}, header = {}, body = {}, textFilterSeparato
137
139
  columnProps,
138
140
  api,
139
141
  auth,
140
- idValueMap,
141
142
  memo,
142
143
  queryParams == null ? void 0 : queryParams.filters,
143
144
  body,
@@ -11,7 +11,7 @@ export declare function useColumns(columnProps: NonNullable<NextGenDataGridProps
11
11
  accessorKey: string;
12
12
  accessorFn: (row: MRT_RowData) => unknown;
13
13
  header: string | undefined;
14
- filterTooltipValueFn: (value: string) => {};
14
+ filterTooltipValueFn: (value: string) => string;
15
15
  Filter: (props: NextGenDataGridMRTProps) => import("react/jsx-runtime").JSX.Element | null;
16
16
  enableSorting: boolean;
17
17
  filterFn: string | undefined;
@@ -3,7 +3,7 @@ import { ApiProviderProps, WithApiProviderOptions } from './types';
3
3
  /**
4
4
  * Provides the API context, bulk actions context, and form contexts to its children.
5
5
  */
6
- export declare function ApiProvider(props: ApiProviderProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ApiProvider<TQuery extends object = object>(props: ApiProviderProps<TQuery>): import("react/jsx-runtime").JSX.Element;
7
7
  /**
8
8
  * Higher-order component to wrap a component with ApiProvider.
9
9
  *
@@ -3,12 +3,18 @@ import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseQueryOptions } from
3
3
  import { PropsWithChildren } from 'react';
4
4
  import { InfoQueryData, RelationParam } from './hooks/types';
5
5
  import { QueryParams } from './utils/types';
6
- /** Props accepted by the `ApiProvider` component. */
7
- export type ApiProviderProps = PropsWithChildren<{
6
+ /**
7
+ * Props accepted by the `ApiProvider` component.
8
+ *
9
+ * @typeParam TQuery - Custom query-param keys forwarded to the backend (read off `request.query_params`).
10
+ * Surfaced typed on `initialQueryParams`; pass the same shape to `useApi<…, TQuery>()` to type `queryParams` /
11
+ * `setQueryParams` (React context cannot carry the Provider's type param to a distant `useApi` call).
12
+ */
13
+ export type ApiProviderProps<TQuery extends object = object> = PropsWithChildren<{
8
14
  /** The name of the resource to be used in the API path. */
9
15
  resource_name?: string;
10
- /** The initial query parameters to be used in the API requests. */
11
- initialQueryParams?: QueryParams;
16
+ /** The initial query parameters to be used in the API requests. May include custom keys (typed via `TQuery`) forwarded to the backend. */
17
+ initialQueryParams?: QueryParams & Partial<TQuery>;
12
18
  /** The relation to be used in the API requests. */
13
19
  relation?: RelationParam;
14
20
  /** Whether to fetch the `info` for the API requests when the component mounts. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastapi-rtk",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "private": false,
5
5
  "description": "A React component library for FastAPI in combination with FastAPI React Toolkit backend, built with Mantine, JsonForms, and Zustand.",
6
6
  "license": "MIT",