@plyaz/api 1.5.2 → 1.5.4
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/dist/api/components/ApiInitializationError.d.ts +22 -0
- package/dist/api/components/ApiInitializationError.d.ts.map +1 -0
- package/dist/api/components/ApiInitializationLoading.d.ts +22 -0
- package/dist/api/components/ApiInitializationLoading.d.ts.map +1 -0
- package/dist/api/components/index.d.ts +11 -0
- package/dist/api/components/index.d.ts.map +1 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/providers/ApiProvider.d.ts +34 -0
- package/dist/api/providers/ApiProvider.d.ts.map +1 -0
- package/dist/api/providers/index.d.ts +10 -0
- package/dist/api/providers/index.d.ts.map +1 -0
- package/dist/api/services/featureFlags/POST/createFeatureFlag.d.ts +2 -3
- package/dist/api/services/featureFlags/POST/createFeatureFlag.d.ts.map +1 -1
- package/dist/api/services/featureFlags/POST/useCreateFeatureFlag.d.ts +2 -3
- package/dist/api/services/featureFlags/POST/useCreateFeatureFlag.d.ts.map +1 -1
- package/dist/index.cjs +156 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +153 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ApiInitializationError - Default error component for ApiProvider
|
|
3
|
+
*
|
|
4
|
+
* Displayed when API client initialization fails.
|
|
5
|
+
* Can be overridden via the `error` prop on ApiProvider.
|
|
6
|
+
*
|
|
7
|
+
* @module api/components/ApiInitializationError
|
|
8
|
+
*/
|
|
9
|
+
import { type ReactElement } from 'react';
|
|
10
|
+
import type { ApiInitializationErrorProps } from '@plyaz/types/api';
|
|
11
|
+
/**
|
|
12
|
+
* Default error component for API initialization failures.
|
|
13
|
+
*
|
|
14
|
+
* @example Override with custom component
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <ApiProvider error={(err) => <MyErrorBoundary error={err} />}>
|
|
17
|
+
* {children}
|
|
18
|
+
* </ApiProvider>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function ApiInitializationError({ error, errorComponent, }: ApiInitializationErrorProps): ReactElement;
|
|
22
|
+
//# sourceMappingURL=ApiInitializationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiInitializationError.d.ts","sourceRoot":"","sources":["../../../src/api/components/ApiInitializationError.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAc,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,cAAc,GACf,EAAE,2BAA2B,GAAG,YAAY,CAqB5C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ApiInitializationLoading - Default loading component for ApiProvider
|
|
3
|
+
*
|
|
4
|
+
* Displayed while the API client is initializing.
|
|
5
|
+
* Can be overridden via the `loading` prop on ApiProvider.
|
|
6
|
+
*
|
|
7
|
+
* @module api/components/ApiInitializationLoading
|
|
8
|
+
*/
|
|
9
|
+
import { type ReactElement } from 'react';
|
|
10
|
+
import type { ApiInitializationLoadingProps } from '@plyaz/types/api';
|
|
11
|
+
/**
|
|
12
|
+
* Default loading component for API initialization.
|
|
13
|
+
*
|
|
14
|
+
* @example Override with custom component
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <ApiProvider loading={<MyCustomSpinner />}>
|
|
17
|
+
* {children}
|
|
18
|
+
* </ApiProvider>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function ApiInitializationLoading({ loading }: ApiInitializationLoadingProps): ReactElement;
|
|
22
|
+
//# sourceMappingURL=ApiInitializationLoading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiInitializationLoading.d.ts","sourceRoot":"","sources":["../../../src/api/components/ApiInitializationLoading.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAc,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEtE;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,EAAE,6BAA6B,GAAG,YAAY,CAoBjG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Components
|
|
3
|
+
*
|
|
4
|
+
* React components for the API package.
|
|
5
|
+
* Types should be imported from @plyaz/types/api.
|
|
6
|
+
*
|
|
7
|
+
* @module api/components
|
|
8
|
+
*/
|
|
9
|
+
export { ApiInitializationLoading } from './ApiInitializationLoading';
|
|
10
|
+
export { ApiInitializationError } from './ApiInitializationError';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -25,4 +25,6 @@ export { unifiedStrategies, applyUnifiedStrategy, getUnifiedStrategy, mergeUnifi
|
|
|
25
25
|
export * from './services';
|
|
26
26
|
export { encrypt, decrypt, isCryptoAvailable, isEncryptedMetadata, generateRandomKey, exportKeyToBase64, base64ToBytes, bytesToBase64, generateIV, importKey, parseFieldPath, isWildcard, matchFieldPath, getAllFieldPaths, getFieldValue, setFieldValue, findMatchingPaths, transformFields, extractFields, hasMatchingFields, isValidFieldPath, createEncryptionInterceptor, createDecryptionInterceptor, createEncryptionInterceptors, validateEncryptionConfig, hasEncryptableFields, } from './encryption';
|
|
27
27
|
export { revalidate, revalidateAll, removeRevalidators, revalidationStrategies, genericPresets as revalidationPresets, getPresets as getRevalidationPresets, extendPresets as extendRevalidationPresets, resetPresets as resetRevalidationPresets, getPreset as getRevalidationPreset, createRevalidationStrategy, getRevalidationStrategy, applyRevalidationStrategy, isValidStrategyName as isValidRevalidationStrategyName, mergeRevalidationStrategies, getSSRSafeConfig, isRevalidationSupported, calculateCacheDuration, isDataFresh, isCacheValid, createRevalidationKey, isWithinDedupeWindow, getNetworkOptimizedConfig, toFetchffRevalidationConfig, } from './revalidation';
|
|
28
|
+
export { ApiProvider, getQueryClient, resetQueryClient } from './providers';
|
|
29
|
+
export { ApiInitializationLoading, ApiInitializationError } from './components';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC;AAEzB,cAAc,aAAa,CAAC;AAG5B,OAAO,EAEL,aAAa,EACb,OAAO,EAGP,aAAa,EACb,cAAc,EACd,SAAS,EAGT,YAAY,EACZ,wBAAwB,EACxB,2BAA2B,EAC3B,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EAGpB,yBAAyB,EACzB,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAEL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EAGX,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EAGpB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,GACd,MAA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AgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAGhB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,UAAU,EACV,aAAa,EACb,kBAAkB,EAGlB,sBAAsB,EACtB,cAAc,IAAI,mBAAmB,EACrC,UAAU,IAAI,sBAAsB,EACpC,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,EACxC,SAAS,IAAI,qBAAqB,EAClC,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,IAAI,+BAA+B,EACtD,2BAA2B,EAG3B,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG5E,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ApiProvider - React Query Provider for @plyaz/api
|
|
3
|
+
*
|
|
4
|
+
* Provides React Query context for all API hooks in the package.
|
|
5
|
+
* Optionally initializes the default API client with provided configuration.
|
|
6
|
+
*
|
|
7
|
+
* @module api/providers/ApiProvider
|
|
8
|
+
*/
|
|
9
|
+
import { type ReactElement } from 'react';
|
|
10
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
11
|
+
import type { ApiProviderProps } from '@plyaz/types/api';
|
|
12
|
+
/**
|
|
13
|
+
* Get or create the shared QueryClient instance.
|
|
14
|
+
* Ensures a single QueryClient is used across the application.
|
|
15
|
+
*
|
|
16
|
+
* @returns The shared QueryClient instance
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { getQueryClient } from '@plyaz/api';
|
|
21
|
+
*
|
|
22
|
+
* // Access query client for manual cache operations
|
|
23
|
+
* const queryClient = getQueryClient();
|
|
24
|
+
* queryClient.invalidateQueries({ queryKey: ['users'] });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getQueryClient(): QueryClient;
|
|
28
|
+
/**
|
|
29
|
+
* Reset the QueryClient instance.
|
|
30
|
+
* Useful for testing or when you need a fresh client.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resetQueryClient(): void;
|
|
33
|
+
export declare function ApiProvider({ children, queryClient, globalConfig, apiConfig, loading, error: errorComponent, onReady, onError, }: ApiProviderProps): ReactElement;
|
|
34
|
+
//# sourceMappingURL=ApiProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiProvider.d.ts","sourceRoot":"","sources":["../../../src/api/providers/ApiProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,KAAK,YAAY,EAA+B,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,WAAW,EAAuB,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA0CzD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAG5C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC;AAuFD,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,OAAO,EACP,KAAK,EAAE,cAAc,EACrB,OAAO,EACP,OAAO,GACR,EAAE,gBAAgB,GAAG,YAAY,CA+DjC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Providers
|
|
3
|
+
*
|
|
4
|
+
* React context providers for the API package.
|
|
5
|
+
* Types should be imported from @plyaz/types/api.
|
|
6
|
+
*
|
|
7
|
+
* @module api/providers
|
|
8
|
+
*/
|
|
9
|
+
export { ApiProvider, getQueryClient, resetQueryClient } from './ApiProvider';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Create Feature Flag Service
|
|
3
3
|
* Creates a new feature flag
|
|
4
4
|
*/
|
|
5
|
-
import type { ServiceOptions, CreateFlagResponse } from '@plyaz/types/api';
|
|
6
|
-
import type { CreateFlagRequest } from '@plyaz/types/features';
|
|
5
|
+
import type { ServiceOptions, CreateFlagResponse, CreateFeatureFlagRequest } from '@plyaz/types/api';
|
|
7
6
|
import type { EndpointsList } from '@/api/endpoints';
|
|
8
7
|
import type { FetchResponse } from 'fetchff';
|
|
9
8
|
/**
|
|
@@ -25,5 +24,5 @@ import type { FetchResponse } from 'fetchff';
|
|
|
25
24
|
* });
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
|
-
export declare function createFeatureFlag<TKey extends string = string, TEndpoints = EndpointsList>(data:
|
|
27
|
+
export declare function createFeatureFlag<TKey extends string = string, TEndpoints = EndpointsList>(data: CreateFeatureFlagRequest<TKey>, options?: ServiceOptions<TEndpoints>): Promise<FetchResponse<CreateFlagResponse<TKey>>>;
|
|
29
28
|
//# sourceMappingURL=createFeatureFlag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFeatureFlag.d.ts","sourceRoot":"","sources":["../../../../../src/api/services/featureFlags/POST/createFeatureFlag.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createFeatureFlag.d.ts","sourceRoot":"","sources":["../../../../../src/api/services/featureFlags/POST/createFeatureFlag.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,UAAU,GAAG,aAAa,EAC9F,IAAI,EAAE,wBAAwB,CAAC,IAAI,CAAC,EACpC,OAAO,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,GACnC,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAiBlD"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* React Query Mutation Hook for Creating Feature Flags
|
|
3
3
|
*/
|
|
4
4
|
import { createApiMutation } from '../../../hooks/factories';
|
|
5
|
-
import type { CreateFlagResponse, ServiceOptions, FeatureFlagErrorResponse } from '@plyaz/types/api';
|
|
6
|
-
import type { CreateFlagRequest } from '@plyaz/types/features';
|
|
5
|
+
import type { CreateFlagResponse, ServiceOptions, FeatureFlagErrorResponse, CreateFeatureFlagRequest } from '@plyaz/types/api';
|
|
7
6
|
import type { EndpointsList } from '@/api/endpoints';
|
|
8
7
|
/**
|
|
9
8
|
* Hook for creating feature flags
|
|
@@ -18,5 +17,5 @@ import type { EndpointsList } from '@/api/endpoints';
|
|
|
18
17
|
* });
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
|
-
export declare function useCreateFeatureFlag<TKey extends string = string, TEndpoints = EndpointsList>(serviceOptions?: ServiceOptions<TEndpoints>, mutationOptions?: Parameters<ReturnType<typeof createApiMutation<CreateFlagResponse<TKey>, FeatureFlagErrorResponse,
|
|
20
|
+
export declare function useCreateFeatureFlag<TKey extends string = string, TEndpoints = EndpointsList>(serviceOptions?: ServiceOptions<TEndpoints>, mutationOptions?: Parameters<ReturnType<typeof createApiMutation<CreateFlagResponse<TKey>, FeatureFlagErrorResponse, CreateFeatureFlagRequest<TKey>, unknown, TEndpoints>>>[1]): ReturnType<ReturnType<typeof createApiMutation<CreateFlagResponse<TKey>, FeatureFlagErrorResponse, CreateFeatureFlagRequest<TKey>, unknown, TEndpoints>>>;
|
|
22
21
|
//# sourceMappingURL=useCreateFeatureFlag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateFeatureFlag.d.ts","sourceRoot":"","sources":["../../../../../src/api/services/featureFlags/POST/useCreateFeatureFlag.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useCreateFeatureFlag.d.ts","sourceRoot":"","sources":["../../../../../src/api/services/featureFlags/POST/useCreateFeatureFlag.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,UAAU,GAAG,aAAa,EAC3F,cAAc,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,EAC3C,eAAe,CAAC,EAAE,UAAU,CAC1B,UAAU,CACR,OAAO,iBAAiB,CACtB,kBAAkB,CAAC,IAAI,CAAC,EACxB,wBAAwB,EACxB,wBAAwB,CAAC,IAAI,CAAC,EAC9B,OAAO,EACP,UAAU,CACX,CACF,CACF,CAAC,CAAC,CAAC,GACH,UAAU,CACX,UAAU,CACR,OAAO,iBAAiB,CACtB,kBAAkB,CAAC,IAAI,CAAC,EACxB,wBAAwB,EACxB,wBAAwB,CAAC,IAAI,CAAC,EAC9B,OAAO,EACP,UAAU,CACX,CACF,CACF,CAeA"}
|
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ var rxjs = require('rxjs');
|
|
|
13
13
|
var crypto2 = require('crypto');
|
|
14
14
|
var reactQuery = require('@tanstack/react-query');
|
|
15
15
|
var react = require('react');
|
|
16
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
17
|
|
|
17
18
|
function _interopNamespace(e) {
|
|
18
19
|
if (e && e.__esModule) return e;
|
|
@@ -26453,6 +26454,156 @@ __name(toFetchffRevalidationConfig, "toFetchffRevalidationConfig");
|
|
|
26453
26454
|
liveClass: revalidationStrategies.realtime,
|
|
26454
26455
|
resources: revalidationStrategies.static
|
|
26455
26456
|
});
|
|
26457
|
+
function ApiInitializationLoading({ loading }) {
|
|
26458
|
+
if (loading) {
|
|
26459
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: loading });
|
|
26460
|
+
}
|
|
26461
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
26462
|
+
"div",
|
|
26463
|
+
{
|
|
26464
|
+
role: "status",
|
|
26465
|
+
"aria-live": "polite",
|
|
26466
|
+
"aria-busy": "true",
|
|
26467
|
+
style: {
|
|
26468
|
+
display: "flex",
|
|
26469
|
+
alignItems: "center",
|
|
26470
|
+
justifyContent: "center",
|
|
26471
|
+
padding: "1rem"
|
|
26472
|
+
},
|
|
26473
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Initializing API..." })
|
|
26474
|
+
}
|
|
26475
|
+
);
|
|
26476
|
+
}
|
|
26477
|
+
__name(ApiInitializationLoading, "ApiInitializationLoading");
|
|
26478
|
+
function ApiInitializationError({
|
|
26479
|
+
error,
|
|
26480
|
+
errorComponent
|
|
26481
|
+
}) {
|
|
26482
|
+
if (errorComponent) {
|
|
26483
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: errorComponent(error) });
|
|
26484
|
+
}
|
|
26485
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
26486
|
+
"div",
|
|
26487
|
+
{
|
|
26488
|
+
role: "alert",
|
|
26489
|
+
"aria-live": "assertive",
|
|
26490
|
+
style: {
|
|
26491
|
+
padding: "1rem",
|
|
26492
|
+
backgroundColor: "#fef2f2",
|
|
26493
|
+
border: "1px solid #fecaca",
|
|
26494
|
+
borderRadius: "0.375rem",
|
|
26495
|
+
color: "#991b1b"
|
|
26496
|
+
},
|
|
26497
|
+
children: [
|
|
26498
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "API Initialization Failed" }),
|
|
26499
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0.5rem 0 0 0" }, children: error.message })
|
|
26500
|
+
]
|
|
26501
|
+
}
|
|
26502
|
+
);
|
|
26503
|
+
}
|
|
26504
|
+
__name(ApiInitializationError, "ApiInitializationError");
|
|
26505
|
+
var MS_PER_SECOND4 = 1e3;
|
|
26506
|
+
var SECONDS_PER_MINUTE3 = 60;
|
|
26507
|
+
var STALE_TIME_MINUTES = 5;
|
|
26508
|
+
var STALE_TIME_MS = MS_PER_SECOND4 * SECONDS_PER_MINUTE3 * STALE_TIME_MINUTES;
|
|
26509
|
+
var DEFAULT_RETRY_COUNT = 1;
|
|
26510
|
+
var defaultQueryOptions = {
|
|
26511
|
+
queries: {
|
|
26512
|
+
retry: DEFAULT_RETRY_COUNT,
|
|
26513
|
+
staleTime: STALE_TIME_MS,
|
|
26514
|
+
refetchOnWindowFocus: false,
|
|
26515
|
+
refetchOnReconnect: true
|
|
26516
|
+
},
|
|
26517
|
+
mutations: {
|
|
26518
|
+
retry: DEFAULT_RETRY_COUNT
|
|
26519
|
+
}
|
|
26520
|
+
};
|
|
26521
|
+
var queryClientInstance = null;
|
|
26522
|
+
function getQueryClient() {
|
|
26523
|
+
queryClientInstance ??= new reactQuery.QueryClient({ defaultOptions: defaultQueryOptions });
|
|
26524
|
+
return queryClientInstance;
|
|
26525
|
+
}
|
|
26526
|
+
__name(getQueryClient, "getQueryClient");
|
|
26527
|
+
function resetQueryClient() {
|
|
26528
|
+
if (queryClientInstance) {
|
|
26529
|
+
queryClientInstance.clear();
|
|
26530
|
+
queryClientInstance = null;
|
|
26531
|
+
}
|
|
26532
|
+
}
|
|
26533
|
+
__name(resetQueryClient, "resetQueryClient");
|
|
26534
|
+
function wrapError(err, messageKey) {
|
|
26535
|
+
if (err instanceof ApiPackageError) {
|
|
26536
|
+
return err;
|
|
26537
|
+
}
|
|
26538
|
+
const originalError = err instanceof Error ? err : new Error(String(err));
|
|
26539
|
+
return new ApiPackageError(
|
|
26540
|
+
messageKey,
|
|
26541
|
+
errors.INTERNAL_STATUS_CODES.INITIALIZATION_FAILED,
|
|
26542
|
+
errors.API_ERROR_CODES.CLIENT_INITIALIZATION_FAILED,
|
|
26543
|
+
{
|
|
26544
|
+
cause: originalError,
|
|
26545
|
+
context: {
|
|
26546
|
+
operation: errors.COMMON_OPERATIONS.INITIALIZATION,
|
|
26547
|
+
originalError: originalError.message
|
|
26548
|
+
}
|
|
26549
|
+
}
|
|
26550
|
+
);
|
|
26551
|
+
}
|
|
26552
|
+
__name(wrapError, "wrapError");
|
|
26553
|
+
function ApiProvider({
|
|
26554
|
+
children,
|
|
26555
|
+
queryClient,
|
|
26556
|
+
globalConfig,
|
|
26557
|
+
apiConfig,
|
|
26558
|
+
loading,
|
|
26559
|
+
error: errorComponent,
|
|
26560
|
+
onReady,
|
|
26561
|
+
onError
|
|
26562
|
+
}) {
|
|
26563
|
+
const client = queryClient ?? getQueryClient();
|
|
26564
|
+
const [isApiReady, setIsApiReady] = react.useState(!apiConfig);
|
|
26565
|
+
const [initError, setInitError] = react.useState(null);
|
|
26566
|
+
const initRef = react.useRef(false);
|
|
26567
|
+
const globalConfigRef = react.useRef(false);
|
|
26568
|
+
react.useEffect(() => {
|
|
26569
|
+
if (!globalConfig || globalConfigRef.current) return;
|
|
26570
|
+
globalConfigRef.current = true;
|
|
26571
|
+
try {
|
|
26572
|
+
setGlobalConfig(globalConfig);
|
|
26573
|
+
} catch (err) {
|
|
26574
|
+
const configError = wrapError(err, "provider.global_config_failed");
|
|
26575
|
+
setInitError(configError);
|
|
26576
|
+
onError?.(configError);
|
|
26577
|
+
}
|
|
26578
|
+
}, [globalConfig, onError]);
|
|
26579
|
+
react.useEffect(() => {
|
|
26580
|
+
if (!apiConfig || initRef.current) return;
|
|
26581
|
+
if (globalConfig && !globalConfigRef.current) return;
|
|
26582
|
+
initRef.current = true;
|
|
26583
|
+
async function initializeApiClient() {
|
|
26584
|
+
try {
|
|
26585
|
+
const apiClient2 = await createApiClient(apiConfig);
|
|
26586
|
+
setDefaultApiClient(apiClient2);
|
|
26587
|
+
setIsApiReady(true);
|
|
26588
|
+
onReady?.();
|
|
26589
|
+
} catch (err) {
|
|
26590
|
+
const error = wrapError(err, "provider.client_init_failed");
|
|
26591
|
+
setInitError(error);
|
|
26592
|
+
onError?.(error);
|
|
26593
|
+
}
|
|
26594
|
+
}
|
|
26595
|
+
__name(initializeApiClient, "initializeApiClient");
|
|
26596
|
+
void initializeApiClient();
|
|
26597
|
+
}, [apiConfig, globalConfig, onReady, onError]);
|
|
26598
|
+
if (apiConfig && !isApiReady && !initError) {
|
|
26599
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client, children: /* @__PURE__ */ jsxRuntime.jsx(ApiInitializationLoading, { loading }) });
|
|
26600
|
+
}
|
|
26601
|
+
if (initError) {
|
|
26602
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client, children: /* @__PURE__ */ jsxRuntime.jsx(ApiInitializationError, { error: initError, errorComponent }) });
|
|
26603
|
+
}
|
|
26604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client, children });
|
|
26605
|
+
}
|
|
26606
|
+
__name(ApiProvider, "ApiProvider");
|
|
26456
26607
|
|
|
26457
26608
|
Object.defineProperty(exports, "getErrorCategory", {
|
|
26458
26609
|
enumerable: true,
|
|
@@ -26507,7 +26658,10 @@ Object.defineProperty(exports, "STORAGE_TYPES", {
|
|
|
26507
26658
|
get: function () { return errors.COMMON_STORAGE_TYPES; }
|
|
26508
26659
|
});
|
|
26509
26660
|
exports.ALL_EVENTS = ALL_EVENTS;
|
|
26661
|
+
exports.ApiInitializationError = ApiInitializationError;
|
|
26662
|
+
exports.ApiInitializationLoading = ApiInitializationLoading;
|
|
26510
26663
|
exports.ApiPackageError = ApiPackageError;
|
|
26664
|
+
exports.ApiProvider = ApiProvider;
|
|
26511
26665
|
exports.CACHE_EVENTS = CACHE_EVENTS2;
|
|
26512
26666
|
exports.CLIENT_EVENTS = CLIENT_EVENTS2;
|
|
26513
26667
|
exports.CONFIG_EVENTS = CONFIG_EVENTS2;
|
|
@@ -26784,6 +26938,7 @@ exports.getPresetForQuality = getPresetForQuality;
|
|
|
26784
26938
|
exports.getPresetNames = getPresetNames;
|
|
26785
26939
|
exports.getProcess = getProcess;
|
|
26786
26940
|
exports.getQuarter = getQuarter;
|
|
26941
|
+
exports.getQueryClient = getQueryClient;
|
|
26787
26942
|
exports.getRelativeTime = getRelativeTime;
|
|
26788
26943
|
exports.getRetryStrategy = getRetryStrategy;
|
|
26789
26944
|
exports.getRevalidationPreset = getPreset;
|
|
@@ -26969,6 +27124,7 @@ exports.requestTracker = requestTracker;
|
|
|
26969
27124
|
exports.requestWithTimeout = requestWithTimeout;
|
|
26970
27125
|
exports.rescheduleInfobipEmails = rescheduleInfobipEmails;
|
|
26971
27126
|
exports.resetGlobalConfig = resetGlobalConfig;
|
|
27127
|
+
exports.resetQueryClient = resetQueryClient;
|
|
26972
27128
|
exports.resetRevalidationPresets = resetPresets;
|
|
26973
27129
|
exports.resolveConflict = resolveConflict;
|
|
26974
27130
|
exports.retryConditions = retryConditions;
|