api-core-lib 16.12.136 → 16.12.138

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.
@@ -233,6 +233,7 @@ interface UseApiModuleOptions<TExtra = {}> {
233
233
  enabled?: boolean;
234
234
  hydratedState?: string;
235
235
  extraContextData?: TExtra;
236
+ initialQueryOptions?: Partial<QueryOptions>;
236
237
  }
237
238
  /** A utility type to infer the Input type (`TInput`) from an ActionConfigModule. */
238
239
  type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
@@ -233,6 +233,7 @@ interface UseApiModuleOptions<TExtra = {}> {
233
233
  enabled?: boolean;
234
234
  hydratedState?: string;
235
235
  extraContextData?: TExtra;
236
+ initialQueryOptions?: Partial<QueryOptions>;
236
237
  }
237
238
  /** A utility type to infer the Input type (`TInput`) from an ActionConfigModule. */
238
239
  type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
package/dist/client.cjs CHANGED
@@ -327,7 +327,20 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
327
327
  extraContextData
328
328
  } = options;
329
329
  const pathParamsString = _react.useMemo.call(void 0, () => JSON.stringify(modulePathParams || {}), [modulePathParams]);
330
- const [queryOptions, setQueryOptions] = _react.useState.call(void 0, {});
330
+ const initialQueryOptionsState = _react.useMemo.call(void 0, () => {
331
+ const defaults = {};
332
+ for (const key in moduleConfig.actions) {
333
+ const action = moduleConfig.actions[key];
334
+ if (action._input) {
335
+ defaults[key] = action._input;
336
+ }
337
+ }
338
+ if (options.initialQueryOptions) {
339
+ return { ...defaults, ...options.initialQueryOptions };
340
+ }
341
+ return defaults;
342
+ }, [moduleConfig.actions, options.initialQueryOptions]);
343
+ const [queryOptions, setQueryOptions] = _react.useState.call(void 0, initialQueryOptionsState);
331
344
  const savedCallbacks = _react.useRef.call(void 0, { onSuccess, onError });
332
345
  _react.useEffect.call(void 0, () => {
333
346
  savedCallbacks.current = { onSuccess, onError };
package/dist/client.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, M as ModuleStates, d as ModuleActions, e as ModuleQueries } from './apiModule.types-hGWAkTwf.cjs';
3
- import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-V-4fiB7L.cjs';
2
+ import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, M as ModuleStates, d as ModuleActions, e as ModuleQueries } from './apiModule.types-yrNKmdKs.cjs';
3
+ import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-DB_MyuFk.cjs';
4
4
  import * as react from 'react';
5
5
  import { ReactNode } from 'react';
6
6
 
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, M as ModuleStates, d as ModuleActions, e as ModuleQueries } from './apiModule.types-hGWAkTwf.js';
3
- import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-BJop2XPB.js';
2
+ import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, M as ModuleStates, d as ModuleActions, e as ModuleQueries } from './apiModule.types-yrNKmdKs.js';
3
+ import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-C_kV2hKC.js';
4
4
  import * as react from 'react';
5
5
  import { ReactNode } from 'react';
6
6
 
package/dist/client.js CHANGED
@@ -327,7 +327,20 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
327
327
  extraContextData
328
328
  } = options;
329
329
  const pathParamsString = useMemo3(() => JSON.stringify(modulePathParams || {}), [modulePathParams]);
330
- const [queryOptions, setQueryOptions] = useState3({});
330
+ const initialQueryOptionsState = useMemo3(() => {
331
+ const defaults = {};
332
+ for (const key in moduleConfig.actions) {
333
+ const action = moduleConfig.actions[key];
334
+ if (action._input) {
335
+ defaults[key] = action._input;
336
+ }
337
+ }
338
+ if (options.initialQueryOptions) {
339
+ return { ...defaults, ...options.initialQueryOptions };
340
+ }
341
+ return defaults;
342
+ }, [moduleConfig.actions, options.initialQueryOptions]);
343
+ const [queryOptions, setQueryOptions] = useState3(initialQueryOptionsState);
331
344
  const savedCallbacks = useRef4({ onSuccess, onError });
332
345
  useEffect4(() => {
333
346
  savedCallbacks.current = { onSuccess, onError };
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
2
- import { f as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, g as ActionOptions, R as RequestConfig, h as ActionStateModule, Q as QueryOptions, i as UseApiQuery, j as ApiError, L as LogLevel } from './apiModule.types-hGWAkTwf.cjs';
3
- export { o as ActionConfig, u as ActionMethods, q as ActionState, s as ActionsWithQuery, a as ApiModuleConfig, E as ExecutableAction, r as ExecuteOptions, I as InputOf, m as Middleware, l as MiddlewareContext, d as ModuleActions, e as ModuleQueries, M as ModuleStates, O as OutputOf, P as PaginationMeta, n as RefreshTokenConfig, k as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, p as UseApiState, V as ValidationError, t } from './apiModule.types-hGWAkTwf.cjs';
4
- export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-V-4fiB7L.cjs';
2
+ import { f as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, g as ActionOptions, R as RequestConfig, h as ActionStateModule, Q as QueryOptions, i as UseApiQuery, j as ApiError, L as LogLevel } from './apiModule.types-yrNKmdKs.cjs';
3
+ export { o as ActionConfig, u as ActionMethods, q as ActionState, s as ActionsWithQuery, a as ApiModuleConfig, E as ExecutableAction, r as ExecuteOptions, I as InputOf, m as Middleware, l as MiddlewareContext, d as ModuleActions, e as ModuleQueries, M as ModuleStates, O as OutputOf, P as PaginationMeta, n as RefreshTokenConfig, k as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, p as UseApiState, V as ValidationError, t } from './apiModule.types-yrNKmdKs.cjs';
4
+ export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-DB_MyuFk.cjs';
5
5
  import 'react';
6
6
 
7
7
  declare function createApiClient(config: ApiClientConfig): AxiosInstance;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
2
- import { f as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, g as ActionOptions, R as RequestConfig, h as ActionStateModule, Q as QueryOptions, i as UseApiQuery, j as ApiError, L as LogLevel } from './apiModule.types-hGWAkTwf.js';
3
- export { o as ActionConfig, u as ActionMethods, q as ActionState, s as ActionsWithQuery, a as ApiModuleConfig, E as ExecutableAction, r as ExecuteOptions, I as InputOf, m as Middleware, l as MiddlewareContext, d as ModuleActions, e as ModuleQueries, M as ModuleStates, O as OutputOf, P as PaginationMeta, n as RefreshTokenConfig, k as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, p as UseApiState, V as ValidationError, t } from './apiModule.types-hGWAkTwf.js';
4
- export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-BJop2XPB.js';
2
+ import { f as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, g as ActionOptions, R as RequestConfig, h as ActionStateModule, Q as QueryOptions, i as UseApiQuery, j as ApiError, L as LogLevel } from './apiModule.types-yrNKmdKs.js';
3
+ export { o as ActionConfig, u as ActionMethods, q as ActionState, s as ActionsWithQuery, a as ApiModuleConfig, E as ExecutableAction, r as ExecuteOptions, I as InputOf, m as Middleware, l as MiddlewareContext, d as ModuleActions, e as ModuleQueries, M as ModuleStates, O as OutputOf, P as PaginationMeta, n as RefreshTokenConfig, k as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, p as UseApiState, V as ValidationError, t } from './apiModule.types-yrNKmdKs.js';
4
+ export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-C_kV2hKC.js';
5
5
  import 'react';
6
6
 
7
7
  declare function createApiClient(config: ApiClientConfig): AxiosInstance;
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-hGWAkTwf.cjs';
2
+ import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-yrNKmdKs.cjs';
3
3
  import 'react';
4
4
 
5
5
  /**
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-hGWAkTwf.js';
2
+ import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-yrNKmdKs.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { R as RequestConfig, j as ApiError, S as StandardResponse, g as ActionOptions } from './apiModule.types-hGWAkTwf.js';
2
+ import { R as RequestConfig, j as ApiError, S as StandardResponse, g as ActionOptions } from './apiModule.types-yrNKmdKs.js';
3
3
 
4
4
  /**
5
5
  * Represents the internal state of the `useApiRecord` hook.
@@ -1,5 +1,5 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { R as RequestConfig, j as ApiError, S as StandardResponse, g as ActionOptions } from './apiModule.types-hGWAkTwf.cjs';
2
+ import { R as RequestConfig, j as ApiError, S as StandardResponse, g as ActionOptions } from './apiModule.types-yrNKmdKs.cjs';
3
3
 
4
4
  /**
5
5
  * Represents the internal state of the `useApiRecord` hook.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "16.12.136",
3
+ "version": "16.12.138",
4
4
  "description": "A flexible and powerful API client library for modern web applications.",
5
5
  "type": "module",
6
6
  "exports": {