fastapi-rtk 2.4.2 → 2.5.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.
Files changed (37) 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/cjs/ApiContext/ApiContext.cjs +4 -1
  22. package/dist/contexts/esm/ApiContext/ApiContext.mjs +4 -1
  23. package/dist/contexts/lib/ApiContext/ApiContext.d.ts +6 -4
  24. package/dist/contexts/lib/ApiContext/types.d.ts +50 -25
  25. package/dist/core/cjs/Wrappers/ApiProvider/hooks/useProvideApi.cjs +1 -1
  26. package/dist/core/esm/Wrappers/ApiProvider/hooks/useProvideApi.mjs +1 -1
  27. package/dist/core/lib/Dialogs/types.d.ts +2 -2
  28. package/dist/core/lib/Wrappers/ApiProvider/hooks/utils/useApiActions.d.ts +2 -2
  29. package/dist/core/lib/Wrappers/ApiProvider/utils/api/deleteItem.d.ts +1 -1
  30. package/dist/core/lib/Wrappers/ApiProvider/utils/api/getInfo.d.ts +1 -1
  31. package/dist/core/lib/Wrappers/ApiProvider/utils/api/getItems.d.ts +1 -1
  32. package/dist/core/lib/Wrappers/ApiProvider/utils/api/types.d.ts +2 -2
  33. package/dist/core/lib/fab-react-toolkit-patch/api/utils/api/getItems.d.ts +1 -1
  34. package/dist/utils/cjs/parseResponse/parseResponse.cjs +3 -0
  35. package/dist/utils/esm/parseResponse/parseResponse.mjs +3 -0
  36. package/dist/utils/lib/parseResponse/parseResponse.d.ts +2 -1
  37. package/package.json +1 -1
@@ -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 format = {};
4
+ exports.__exports = format;
@@ -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 compile = {};
4
+ exports.__exports = compile;
@@ -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 core = {};
4
+ exports.__exports = core;
@@ -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 validation = {};
4
+ exports.__exports = validation;
@@ -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 applicator = {};
4
+ exports.__exports = applicator;
@@ -1,4 +1,4 @@
1
- var compile = {};
1
+ var format = {};
2
2
  export {
3
- compile as __exports
3
+ format as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var core = {};
1
+ var compile = {};
2
2
  export {
3
- core as __exports
3
+ compile as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var validation = {};
1
+ var core = {};
2
2
  export {
3
- validation as __exports
3
+ core as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var applicator = {};
1
+ var validation = {};
2
2
  export {
3
- applicator as __exports
3
+ validation as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var format = {};
1
+ var applicator = {};
2
2
  export {
3
- format as __exports
3
+ applicator 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/index10.cjs");
3
+ const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/index6.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/index8.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index9.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/index6.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index7.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/index9.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index10.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/index7.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index8.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/index10.mjs";
1
+ import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/index6.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/index8.mjs";
1
+ import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index9.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/index6.mjs";
1
+ import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index7.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/index9.mjs";
1
+ import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index10.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/index7.mjs";
1
+ import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index8.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";
@@ -4,7 +4,10 @@ const utils = require("fastapi-rtk/utils");
4
4
  const [ApiContextProvider, useApiProvider] = utils.createSafeContext(
5
5
  "useApi must be used within an ApiProvider"
6
6
  );
7
- const useApi = (options) => useApiProvider(options);
7
+ const useApi = (options) => (
8
+ // #MUSTASSERT #MUSTUNKNOWN the provider stores one untyped runtime value; the per-operation type params are a compile-time view of the same rows, so the resolved conditional types don't structurally overlap the fixed provider type
9
+ useApiProvider(options)
10
+ );
8
11
  exports.ApiContextProvider = ApiContextProvider;
9
12
  exports.useApi = useApi;
10
13
  exports.useApiProvider = useApiProvider;
@@ -2,7 +2,10 @@ import { createSafeContext } from "fastapi-rtk/utils";
2
2
  const [ApiContextProvider, useApiProvider] = createSafeContext(
3
3
  "useApi must be used within an ApiProvider"
4
4
  );
5
- const useApi = (options) => useApiProvider(options);
5
+ const useApi = (options) => (
6
+ // #MUSTASSERT #MUSTUNKNOWN the provider stores one untyped runtime value; the per-operation type params are a compile-time view of the same rows, so the resolved conditional types don't structurally overlap the fixed provider type
7
+ useApiProvider(options)
8
+ );
6
9
  export {
7
10
  ApiContextProvider,
8
11
  useApi,
@@ -1,10 +1,12 @@
1
1
  import { SafeContextOptions } from 'fastapi-rtk/utils';
2
- import { ApiContextValue } from './types';
3
- export declare const ApiContextProvider: import('react').Provider<ApiContextValue | null>, useApiProvider: (options?: SafeContextOptions<ApiContextValue>) => ApiContextValue;
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>;
4
4
  /**
5
5
  * Access the API context.
6
6
  *
7
+ * @typeParam TDefault - Uniform row/payload type applied to every operation. Defaults to the dynamic `EntryRow`.
8
+ * @typeParam TOverrides - Per-operation overrides (`list` / `get` / `add` / `edit`); each replaces `TDefault` for that operation only.
7
9
  * @param options - Options for the context hook.
8
- * @returns The API context object.
10
+ * @returns The API context object, with `data`, `getEntry`, `addEntry`, `updateEntry`, etc. typed per operation.
9
11
  */
10
- export declare const useApi: (options?: SafeContextOptions<ApiContextValue>) => ApiContextValue;
12
+ export declare const useApi: <TDefault = EntryRow, TOverrides extends ApiTypeOverrides = ApiTypeOverrides>(options?: SafeContextOptions<UseApiResult<TDefault, TOverrides>>) => UseApiResult<TDefault, TOverrides>;
@@ -1,8 +1,8 @@
1
1
  import { BaseResponseMany, BaseResponseSingle, ColumnFilterOperator, ColumnInfo, ColumnRelationInfo, ConvertedInfo, FilterInfo, InfoResponse, JsonSchema, Layout, PrimaryKey, QueryFilter, QueryParams } from 'fastapi-rtk/api-types';
2
2
  import { InfiniteData, UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
3
3
  import { Schema as ValidationSchema } from '../../../.external/lib/yup';
4
- /** A non-null CRUD result row, mirroring the unwrapped `BaseResponseSingle.result`. */
5
- type EntryRow = NonNullable<BaseResponseSingle['result']>;
4
+ /** A non-null CRUD result row, mirroring the unwrapped `BaseResponseSingle.result`. Default row type for the API generics. */
5
+ export type EntryRow = NonNullable<BaseResponseSingle['result']>;
6
6
  export type APIColumnInfo = ColumnInfo;
7
7
  export type APIColumnRelationInfo = ColumnRelationInfo;
8
8
  export type APIColumnFilter = ColumnFilterOperator;
@@ -40,11 +40,11 @@ export type APIQueryParams = Required<Pick<QueryParams, 'page' | 'page_size' | '
40
40
  * `BaseResponseMany`: `count` / `result` are guaranteed non-null after a successful fetch, and
41
41
  * `path` / `queryParams` (the resolved `APIQueryParams`) are always present.
42
42
  */
43
- export interface APIData extends Omit<BaseResponseMany, 'count' | 'result'> {
43
+ export interface APIData<TData = EntryRow> extends Omit<BaseResponseMany, 'count' | 'result'> {
44
44
  /** The total count of items existing in the database for the given query parameters. */
45
45
  count: number;
46
46
  /** An array of objects representing the API response data. */
47
- result: EntryRow[];
47
+ result: TData[];
48
48
  /** The API path. */
49
49
  path: string;
50
50
  /** The query parameters used in the API request. */
@@ -56,10 +56,10 @@ export interface APISpecialKey {
56
56
  /** The key to be used when retrieving actions for `NextGenDataGrid`. Typically `actions`, but can be `_actions` if `actions` is in the list of columns. */
57
57
  actions: string;
58
58
  }
59
- export interface APIStreaming {
59
+ export interface APIStreaming<TData = EntryRow> {
60
60
  /** The streaming data, organized by the page number. */
61
61
  data: {
62
- [pageNumber: string]: EntryRow[];
62
+ [pageNumber: string]: TData[];
63
63
  };
64
64
  /** Indicates whether the streaming has ended. */
65
65
  isEnd: boolean;
@@ -86,10 +86,10 @@ export interface APIError {
86
86
  message: string;
87
87
  originalError: Error;
88
88
  }
89
- export interface APISetErrorPayload {
89
+ export interface APISetErrorPayload<TData = EntryRow> {
90
90
  message: string;
91
91
  originalError: Error;
92
- data?: EntryRow;
92
+ data?: TData;
93
93
  }
94
94
  /**
95
95
  * `APIInfo` augmented with the normalized add/edit form blocks produced by
@@ -101,13 +101,34 @@ export interface APISetErrorPayload {
101
101
  export type APIInfoCanonical = ConvertedInfo<ValidationSchema> & {
102
102
  path?: string;
103
103
  };
104
- export interface ApiContextValue {
104
+ /**
105
+ * Per-operation type overrides for `useApi`. Each key maps to a backend column projection and,
106
+ * when set, replaces the uniform default for that operation only: `list` (list response rows,
107
+ * `list_columns`), `get` (a single fetched entry and the record returned by `addEntry` / `updateEntry`,
108
+ * `show_columns`), `add` (the `addEntry` payload, `add_columns`), `edit` (the `updateEntry` payload,
109
+ * `edit_columns`). `upload` (`EntryRow[]`, loosely-typed import rows) and `deleteEntry` (`null`, the 204 no-content response) are not parameterized.
110
+ */
111
+ export interface ApiTypeOverrides {
112
+ list?: unknown;
113
+ get?: unknown;
114
+ add?: unknown;
115
+ edit?: unknown;
116
+ }
117
+ /** Resolve one operation's type from the override map, falling back to `TDefault`. */
118
+ export type OpType<TOverrides extends ApiTypeOverrides, K extends keyof ApiTypeOverrides, TDefault> = TOverrides extends Record<K, infer T> ? T : TDefault;
119
+ /**
120
+ * @typeParam TList - Row shape of the list response (`data.result`).
121
+ * @typeParam TGet - Shape of a single fetched/affected record (`getEntry`, and the record returned by `addEntry` / `updateEntry`).
122
+ * @typeParam TAdd - Payload accepted by `addEntry`.
123
+ * @typeParam TEdit - Payload accepted by `updateEntry`.
124
+ */
125
+ export interface ApiContextValue<TList = EntryRow, TGet = EntryRow, TAdd = EntryRow, TEdit = EntryRow> {
105
126
  /** The API path. */
106
127
  path: string;
107
128
  /** Information about the API, including schemas, UI schemas, and the normalized add/edit form blocks. */
108
129
  info?: APIInfoCanonical;
109
130
  /** The data returned by the API. */
110
- data?: APIData;
131
+ data?: APIData<TList>;
111
132
  /** The query parameters used in the API request. */
112
133
  queryParams?: APIQueryParams;
113
134
  /** Indicates whether the API request is currently loading. */
@@ -125,11 +146,11 @@ export interface ApiContextValue {
125
146
  /** The raw React Query object for the info request. */
126
147
  infoQuery: UseQueryResult<APIInfoCanonical | undefined>;
127
148
  /** The raw React Query object for the data request. */
128
- dataQuery: UseQueryResult<APIData | null>;
149
+ dataQuery: UseQueryResult<APIData<TList> | null>;
129
150
  /** The raw React Query infinite query object for streaming requests. */
130
- streamingQuery: UseInfiniteQueryResult<InfiniteData<APIData | null>>;
151
+ streamingQuery: UseInfiniteQueryResult<InfiniteData<APIData<TList> | null>>;
131
152
  /** Streaming (infinite-scroll) controller. Present only when the `ApiProvider` is configured for streaming; its presence is the streaming-mode signal. When set, `data.result` carries every row fetched so far (all pages) and `streaming.data` is the page-number-keyed breakdown. */
132
- streaming?: APIStreaming;
153
+ streaming?: APIStreaming<TList>;
133
154
  /** An object containing special keys for the API query, such as 'all' and 'actions'. */
134
155
  specialKey: APISpecialKey;
135
156
  /** A function to update the query parameters. */
@@ -142,25 +163,29 @@ export interface ApiContextValue {
142
163
  refetchInfo: (options?: {
143
164
  force?: boolean;
144
165
  }) => Promise<void>;
145
- /** A function to retrieve a specific entry by ID. */
146
- getEntry: (id: PrimaryKey) => Promise<EntryRow>;
147
- /** A function to add a new entry to the API. */
148
- addEntry: (item: EntryRow) => Promise<EntryRow>;
149
- /** A function to edit an existing entry in the API. */
150
- updateEntry: (id: PrimaryKey, item: EntryRow) => Promise<EntryRow>;
151
- /** A function to delete an entry from the API. */
152
- deleteEntry: (id: PrimaryKey) => Promise<EntryRow>;
166
+ /** Retrieve a specific entry by ID. Return defaults to the resolved `get` type; override per call (e.g. `getEntry<Custom>(id)`) when the route is customized. */
167
+ getEntry: <R = TGet>(id: PrimaryKey) => Promise<R>;
168
+ /** Add a new entry. Return defaults to the resolved `get` type; override per call for custom routes. */
169
+ addEntry: <R = TGet>(item: TAdd) => Promise<R>;
170
+ /** Edit an existing entry. Return defaults to the resolved `get` type; override per call for custom routes. */
171
+ updateEntry: <R = TGet>(id: PrimaryKey, item: TEdit) => Promise<R>;
172
+ /** Delete an entry. The stock endpoint responds 204 (no body), parsed to `null`, so the return defaults to `null`; override per call for custom `post_delete` payloads. */
173
+ deleteEntry: <R = null>(id: PrimaryKey) => Promise<R>;
153
174
  /** A function to download data from the API. */
154
175
  download: (label?: string, options?: APIDownloadOptions) => Promise<void>;
155
- /** A function to upload a file to the API. */
156
- upload: (file: File, options?: APIUploadOptions) => Promise<EntryRow>;
176
+ /** Upload a CSV. The importer returns `list[dict[str, Any]]` (no response_model), so the default is `EntryRow[]` (loosely-typed rows), NOT the model/`TGet` shape; override per call if your route is typed. */
177
+ upload: <R = EntryRow[]>(file: File, options?: APIUploadOptions) => Promise<R>;
157
178
  /** A function to get the URL for a file item (file name or File object). */
158
179
  getFileURL: (item: string | File) => string;
159
180
  /** A function to get the URL for an image item (image name or File object). */
160
181
  getImageURL: (item: string | File) => string;
161
182
  /** A function to set the error state, surfacing errors thrown by the action functions (`addEntry`, `updateEntry`, ...) through the shared `ErrorDialog`. */
162
- setError: (error: APISetErrorPayload | undefined) => void;
183
+ setError: (error: APISetErrorPayload<TGet> | undefined) => void;
163
184
  /** A function to reset the error state. */
164
185
  resetError: () => void;
165
186
  }
166
- export {};
187
+ /**
188
+ * The `ApiContextValue` returned by `useApi<TDefault, TOverrides>`: the uniform `TDefault` applied to
189
+ * every operation, with any `TOverrides` keys replacing it per operation.
190
+ */
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>>;
@@ -298,7 +298,7 @@ function useProvideApi(params, api = defaultApi) {
298
298
  getImageURL: (item) => getItemURL("image", item),
299
299
  setError,
300
300
  resetError
301
- // #MUSTASSERT useProvideApi holds raw react-query state (DataPage/StreamingPage data, raw QueryParams, null errors); this is the resolved ApiContextValue surface consumers read, normalized at runtime
301
+ // #MUSTASSERT #MUSTUNKNOWN useProvideApi holds raw react-query state (DataPage/StreamingPage data, raw QueryParams, null errors) and concrete (non-generic) action fns; this is the resolved ApiContextValue surface consumers read, normalized at runtime
302
302
  };
303
303
  }
304
304
  exports.useProvideApi = useProvideApi;
@@ -296,7 +296,7 @@ function useProvideApi(params, api = defaultApi) {
296
296
  getImageURL: (item) => getItemURL("image", item),
297
297
  setError,
298
298
  resetError
299
- // #MUSTASSERT useProvideApi holds raw react-query state (DataPage/StreamingPage data, raw QueryParams, null errors); this is the resolved ApiContextValue surface consumers read, normalized at runtime
299
+ // #MUSTASSERT #MUSTUNKNOWN useProvideApi holds raw react-query state (DataPage/StreamingPage data, raw QueryParams, null errors) and concrete (non-generic) action fns; this is the resolved ApiContextValue surface consumers read, normalized at runtime
300
300
  };
301
301
  }
302
302
  export {
@@ -31,8 +31,8 @@ export type EditDialogProps = AddDialogOwnProps & DialogModalProps;
31
31
  export interface DeleteDialogOwnProps {
32
32
  /** Custom text or component to display in the delete confirmation dialog. */
33
33
  deleteText?: ReactNode;
34
- /** Callback function triggered on successful form submission. */
35
- onSuccess?: (result: MRT_RowData | null) => void;
34
+ /** Callback function triggered on successful deletion. Delete responds 204 (no body), parsed to `null`. */
35
+ onSuccess?: (result: null) => void;
36
36
  /** Callback function triggered on form submission error. */
37
37
  onError?: (error: unknown) => void;
38
38
  }
@@ -4,8 +4,8 @@ export declare const useApiActions: (params: UseApiActionsParams) => {
4
4
  getEntry: (id: EntryId) => Promise<MRT_RowData>;
5
5
  addEntry: (item: MRT_RowData) => Promise<MRT_RowData>;
6
6
  updateEntry: (id: EntryId, item: MRT_RowData) => Promise<MRT_RowData>;
7
- deleteEntry: (id: EntryId) => Promise<MRT_RowData>;
7
+ deleteEntry: (id: EntryId) => Promise<MRT_RowData | null>;
8
8
  download: (label?: string, { export_mode, delimiter, quotechar }?: DownloadActionOptions) => Promise<void>;
9
- upload: (file: File, { delimiter, quotechar }?: UploadActionOptions) => Promise<MRT_RowData>;
9
+ upload: (file: File, { delimiter, quotechar }?: UploadActionOptions) => Promise<import('../../utils/api/types').UploadResponse>;
10
10
  getItemURL: (type: string, item: string | File) => string;
11
11
  };
@@ -1,3 +1,3 @@
1
1
  import { MRT_RowData } from '../../../../../../.external/lib/mantine-react-table';
2
2
  import { FetchOptions, ItemId } from './types';
3
- export declare const deleteItem: (path: string, id: ItemId, options?: FetchOptions) => Promise<MRT_RowData>;
3
+ export declare const deleteItem: (path: string, id: ItemId, options?: FetchOptions) => Promise<MRT_RowData | null>;
@@ -7,4 +7,4 @@ import { FetchOptions } from './types';
7
7
  * @returns The data fetched from the given path.
8
8
  * @throws {Error} If the response is not ok, throws an error with the response detail.
9
9
  */
10
- export declare const getInfo: (path: string, options?: FetchOptions) => Promise<string | object>;
10
+ export declare const getInfo: (path: string, options?: FetchOptions) => Promise<string | object | null>;
@@ -9,4 +9,4 @@ import { FetchOptions } from './types';
9
9
  * @returns A promise that resolves to the fetched data, either as a JSON object or a text string.
10
10
  * @throws {Error} - Throws an error if the response is not ok or if there is an issue with the fetch request.
11
11
  */
12
- export declare const getItems: (path: string, queryParams?: QueryParams, options?: FetchOptions) => Promise<string | object>;
12
+ export declare const getItems: (path: string, queryParams?: QueryParams, options?: FetchOptions) => Promise<string | object | null>;
@@ -19,5 +19,5 @@ export interface UploadOptions {
19
19
  delimiter?: string;
20
20
  quotechar?: string;
21
21
  }
22
- /** The CRUD row returned by the upload endpoint; model-driven at runtime. */
23
- export type UploadResponse = MRT_RowData;
22
+ /** The rows returned by the upload (CSV import) endpoint; a list of model-driven rows at runtime. */
23
+ export type UploadResponse = MRT_RowData[];
@@ -9,4 +9,4 @@ import { FetchOptions } from '../../../../Wrappers/ApiProvider/utils/api/types';
9
9
  * @returns A promise that resolves to the fetched data, either as a JSON object or a text string.
10
10
  * @throws {Error} - Throws an error if the response is not ok or if there is an issue with the fetch request.
11
11
  */
12
- export declare const getItems: (path: string, queryParams?: QueryParams, options?: FetchOptions) => Promise<string | object>;
12
+ export declare const getItems: (path: string, queryParams?: QueryParams, options?: FetchOptions) => Promise<string | object | null>;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const parseResponse = async (response) => {
4
+ if (response.status === 204) {
5
+ return null;
6
+ }
4
7
  let newData = void 0;
5
8
  const contentType = response.headers.get("content-type");
6
9
  if (contentType && contentType.includes("application/json")) {
@@ -1,4 +1,7 @@
1
1
  const parseResponse = async (response) => {
2
+ if (response.status === 204) {
3
+ return null;
4
+ }
2
5
  let newData = void 0;
3
6
  const contentType = response.headers.get("content-type");
4
7
  if (contentType && contentType.includes("application/json")) {
@@ -1,5 +1,6 @@
1
1
  interface ParseableResponse {
2
2
  ok: boolean;
3
+ status: number;
3
4
  headers: {
4
5
  get(name: string): string | null | undefined;
5
6
  };
@@ -14,5 +15,5 @@ interface ParseableResponse {
14
15
  * @throws Throws an error if the response is not ok. The error message is derived from the parsed data,
15
16
  * using the "detail" or "message" property if available on an object, or by stringifying the object or using the text directly.
16
17
  */
17
- export declare const parseResponse: (response: ParseableResponse) => Promise<object | string>;
18
+ export declare const parseResponse: (response: ParseableResponse) => Promise<object | string | null>;
18
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastapi-rtk",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
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",