@qlover/fe-corekit 3.0.0 → 3.1.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.
- package/dist/index.cjs +2675 -3849
- package/dist/index.d.ts +45 -4
- package/dist/index.iife.min.js +8440 -2
- package/dist/index.js +2617 -3643
- package/package.json +1 -1
- package/dist/index.iife.js +0 -8277
package/dist/index.d.ts
CHANGED
|
@@ -7628,11 +7628,23 @@ declare function isRequestAdapterResponse(value: unknown): value is RequestAdapt
|
|
|
7628
7628
|
* - URL normalization: Leverages native URL API for consistent path resolution
|
|
7629
7629
|
* - Extensible design: Protected methods allow subclass customization
|
|
7630
7630
|
*
|
|
7631
|
+
* Important behaviors:
|
|
7632
|
+
* - Path preservation: When using relative paths with base URLs that contain path segments,
|
|
7633
|
+
* the relative path is appended to the base URL's path instead of replacing it
|
|
7634
|
+
* - Strict vs Non-strict mode: In strict mode, invalid base URLs cause errors;
|
|
7635
|
+
* in non-strict mode, they are handled gracefully
|
|
7636
|
+
* - Authentication info: Preserves authentication credentials in base URLs (e.g., https://user:pass@domain.com/)
|
|
7637
|
+
* - Hash fragments: Maintains hash fragments from both base URLs and relative paths
|
|
7638
|
+
* - Query parameters: Combines query parameters from base URL and config, with new parameters taking precedence
|
|
7639
|
+
*
|
|
7631
7640
|
* Design considerations:
|
|
7632
7641
|
* - Uses temporary domain (`http://temp`) for relative URL processing to leverage URL API
|
|
7633
7642
|
* - Supports strict mode for stricter baseURL validation
|
|
7634
7643
|
* - Returns path-only strings for relative URLs without valid baseURL
|
|
7635
7644
|
*
|
|
7645
|
+
* Configuration options:
|
|
7646
|
+
* - strict: Enables strict mode for stricter validation of base URLs (default: false)
|
|
7647
|
+
*
|
|
7636
7648
|
* `@since` `3.0.0`
|
|
7637
7649
|
*
|
|
7638
7650
|
* @example Basic usage with absolute baseURL
|
|
@@ -7664,6 +7676,17 @@ declare function isRequestAdapterResponse(value: unknown): value is RequestAdapt
|
|
|
7664
7676
|
* baseURL: 'invalid-url' // Will throw error in strict mode
|
|
7665
7677
|
* });
|
|
7666
7678
|
* ```
|
|
7679
|
+
*
|
|
7680
|
+
* @example Preserving path segments in baseURL
|
|
7681
|
+
* ```typescript
|
|
7682
|
+
* const urlBuilder = new SimpleUrlBuilder();
|
|
7683
|
+
* const url = urlBuilder.buildUrl({
|
|
7684
|
+
* url: '/api/token.json',
|
|
7685
|
+
* baseURL: 'https://brus-dev.api.brain.ai/v1.0/invoke/brain-user-system/method'
|
|
7686
|
+
* });
|
|
7687
|
+
* // Returns: 'https://brus-dev.api.brain.ai/v1.0/invoke/brain-user-system/method/api/token.json'
|
|
7688
|
+
* // ✅ Correctly preserves the baseURL's path segment: '/v1.0/invoke/brain-user-system/method'
|
|
7689
|
+
* ```
|
|
7667
7690
|
*/
|
|
7668
7691
|
declare class SimpleUrlBuilder implements UrlBuilderInterface {
|
|
7669
7692
|
/**
|
|
@@ -7773,6 +7796,17 @@ declare class SimpleUrlBuilder implements UrlBuilderInterface {
|
|
|
7773
7796
|
urlObject: URL;
|
|
7774
7797
|
shouldReturnPathOnly: boolean;
|
|
7775
7798
|
};
|
|
7799
|
+
/**
|
|
7800
|
+
* Joins relative URL path to a base URL that has path segments
|
|
7801
|
+
*
|
|
7802
|
+
* This method addresses the issue where using new URL('/path', 'https://domain/base/path')
|
|
7803
|
+
* would replace the entire path of the base URL instead of appending to it.
|
|
7804
|
+
*
|
|
7805
|
+
* @param relativePath - The relative path to append
|
|
7806
|
+
* @param baseURL - The base URL to append to
|
|
7807
|
+
* @returns URL object with properly joined paths
|
|
7808
|
+
*/
|
|
7809
|
+
private joinPathsToBaseURL;
|
|
7776
7810
|
/**
|
|
7777
7811
|
* Builds complete URL from request configuration
|
|
7778
7812
|
*
|
|
@@ -7786,6 +7820,11 @@ declare class SimpleUrlBuilder implements UrlBuilderInterface {
|
|
|
7786
7820
|
* - `null` and `undefined` parameter values are filtered out
|
|
7787
7821
|
* - Hash fragments are preserved in the final URL
|
|
7788
7822
|
*
|
|
7823
|
+
* **Bug Fix Note**: This implementation correctly handles baseURLs that contain
|
|
7824
|
+
* path segments. Previous versions incorrectly lost the path portion when using
|
|
7825
|
+
* `new URL(relativePath, baseURLWithPath)`. Now the relative path is properly
|
|
7826
|
+
* appended to the base URL's path instead of replacing it.
|
|
7827
|
+
*
|
|
7789
7828
|
* @override
|
|
7790
7829
|
* @param config - Request configuration containing URL components
|
|
7791
7830
|
* @param {string} [config.url=''] - The URL path (absolute or relative)
|
|
@@ -7804,13 +7843,15 @@ declare class SimpleUrlBuilder implements UrlBuilderInterface {
|
|
|
7804
7843
|
* // Returns: 'https://api.example.com/users?role=admin&page=1'
|
|
7805
7844
|
* ```
|
|
7806
7845
|
*
|
|
7807
|
-
* @example
|
|
7846
|
+
* @example Complex baseURL with path segments (Bug Fix Example)
|
|
7808
7847
|
* ```typescript
|
|
7809
7848
|
* const url = urlBuilder.buildUrl({
|
|
7810
|
-
* url: '/api/
|
|
7811
|
-
*
|
|
7849
|
+
* url: '/api/token.json',
|
|
7850
|
+
* baseURL: 'https://brus-dev.api.brain.ai/v1.0/invoke/brain-user-system/method',
|
|
7851
|
+
* params: { grant_type: 'authorization_code' }
|
|
7812
7852
|
* });
|
|
7813
|
-
* // Returns: '/api/
|
|
7853
|
+
* // Returns: 'https://brus-dev.api.brain.ai/v1.0/invoke/brain-user-system/method/api/token.json?grant_type=authorization_code'
|
|
7854
|
+
* // ✅ Correctly preserves the baseURL's path segment: '/v1.0/invoke/brain-user-system/method'
|
|
7814
7855
|
* ```
|
|
7815
7856
|
*
|
|
7816
7857
|
* @example Absolute URL ignores baseURL
|