@djangocfg/api 2.1.139 → 2.1.140

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 (48) hide show
  1. package/dist/auth-server.cjs +2 -199
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +2 -199
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +11 -836
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.mjs +11 -836
  8. package/dist/auth.mjs.map +1 -1
  9. package/dist/clients.cjs +40 -1077
  10. package/dist/clients.cjs.map +1 -1
  11. package/dist/clients.d.cts +209 -754
  12. package/dist/clients.d.ts +209 -754
  13. package/dist/clients.mjs +40 -1077
  14. package/dist/clients.mjs.map +1 -1
  15. package/dist/index.cjs +0 -1198
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +229 -1211
  18. package/dist/index.d.ts +229 -1211
  19. package/dist/index.mjs +0 -1198
  20. package/dist/index.mjs.map +1 -1
  21. package/package.json +2 -2
  22. package/src/clients.ts +2 -12
  23. package/src/index.ts +0 -6
  24. package/src/generated/cfg_webpush/CLAUDE.md +0 -63
  25. package/src/generated/cfg_webpush/_utils/fetchers/index.ts +0 -29
  26. package/src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts +0 -211
  27. package/src/generated/cfg_webpush/_utils/hooks/index.ts +0 -29
  28. package/src/generated/cfg_webpush/_utils/hooks/webpush__web_push.ts +0 -79
  29. package/src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts +0 -22
  30. package/src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts +0 -20
  31. package/src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts +0 -20
  32. package/src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts +0 -21
  33. package/src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts +0 -19
  34. package/src/generated/cfg_webpush/_utils/schemas/index.ts +0 -24
  35. package/src/generated/cfg_webpush/api-instance.ts +0 -180
  36. package/src/generated/cfg_webpush/client.ts +0 -322
  37. package/src/generated/cfg_webpush/errors.ts +0 -117
  38. package/src/generated/cfg_webpush/http.ts +0 -110
  39. package/src/generated/cfg_webpush/index.ts +0 -275
  40. package/src/generated/cfg_webpush/logger.ts +0 -260
  41. package/src/generated/cfg_webpush/retry.ts +0 -176
  42. package/src/generated/cfg_webpush/schema.json +0 -302
  43. package/src/generated/cfg_webpush/storage.ts +0 -162
  44. package/src/generated/cfg_webpush/validation-events.ts +0 -134
  45. package/src/generated/cfg_webpush/webpush__web_push/client.ts +0 -45
  46. package/src/generated/cfg_webpush/webpush__web_push/index.ts +0 -3
  47. package/src/generated/cfg_webpush/webpush__web_push/models.ts +0 -65
  48. package/src/hooks/webpush.ts +0 -12
package/dist/index.cjs CHANGED
@@ -72,8 +72,6 @@ __export(index_exports, {
72
72
  UserProfileTypes: () => models_exports3,
73
73
  UserProfileUpdateRequestSchema: () => UserProfileUpdateRequestSchema,
74
74
  UserSchema: () => UserSchema,
75
- WebPushAPI: () => API3,
76
- WebPushTypes: () => cfg_webpush_exports,
77
75
  api: () => api,
78
76
  clearAPITokens: () => clearAPITokens,
79
77
  configureAPI: () => configureAPI,
@@ -3498,1202 +3496,6 @@ var API2 = class {
3498
3496
  }
3499
3497
  };
3500
3498
 
3501
- // src/generated/cfg_webpush/index.ts
3502
- var cfg_webpush_exports = {};
3503
- __export(cfg_webpush_exports, {
3504
- API: () => API3,
3505
- APIClient: () => APIClient3,
3506
- APIError: () => APIError3,
3507
- APILogger: () => APILogger3,
3508
- CookieStorageAdapter: () => CookieStorageAdapter3,
3509
- DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG3,
3510
- FetchAdapter: () => FetchAdapter3,
3511
- Fetchers: () => fetchers_exports3,
3512
- LocalStorageAdapter: () => LocalStorageAdapter3,
3513
- MemoryStorageAdapter: () => MemoryStorageAdapter3,
3514
- NetworkError: () => NetworkError3,
3515
- REFRESH_TOKEN_KEY: () => REFRESH_TOKEN_KEY3,
3516
- Schemas: () => schemas_exports3,
3517
- SendPushRequestRequestSchema: () => SendPushRequestRequestSchema,
3518
- SendPushResponseSchema: () => SendPushResponseSchema,
3519
- SubscribeRequestRequestSchema: () => SubscribeRequestRequestSchema,
3520
- SubscribeResponseSchema: () => SubscribeResponseSchema,
3521
- TOKEN_KEY: () => TOKEN_KEY3,
3522
- VapidPublicKeyResponseSchema: () => VapidPublicKeyResponseSchema,
3523
- WebPushTypes: () => models_exports9,
3524
- clearAPITokens: () => clearAPITokens3,
3525
- configureAPI: () => configureAPI3,
3526
- createWebpushSendCreate: () => createWebpushSendCreate,
3527
- createWebpushSubscribeCreate: () => createWebpushSubscribeCreate,
3528
- default: () => cfg_webpush_default,
3529
- dispatchValidationError: () => dispatchValidationError3,
3530
- formatZodError: () => formatZodError3,
3531
- getAPIInstance: () => getAPIInstance3,
3532
- getWebpushVapidRetrieve: () => getWebpushVapidRetrieve,
3533
- isAPIConfigured: () => isAPIConfigured3,
3534
- onValidationError: () => onValidationError3,
3535
- reconfigureAPI: () => reconfigureAPI3,
3536
- resetAPI: () => resetAPI3,
3537
- shouldRetry: () => shouldRetry3,
3538
- withRetry: () => withRetry3
3539
- });
3540
-
3541
- // src/generated/cfg_webpush/webpush__web_push/client.ts
3542
- var WebPush = class {
3543
- static {
3544
- __name(this, "WebPush");
3545
- }
3546
- constructor(client) {
3547
- this.client = client;
3548
- }
3549
- /**
3550
- * Send push notification
3551
- *
3552
- * Send push notification to all active subscriptions for the authenticated
3553
- * user.
3554
- */
3555
- async webpushSendCreate(data) {
3556
- const response = await this.client.request("POST", "/cfg/webpush/send/", { body: data });
3557
- return response;
3558
- }
3559
- /**
3560
- * Subscribe to push notifications
3561
- *
3562
- * Save push subscription from browser for the authenticated user.
3563
- */
3564
- async webpushSubscribeCreate(data) {
3565
- const response = await this.client.request("POST", "/cfg/webpush/subscribe/", { body: data });
3566
- return response;
3567
- }
3568
- /**
3569
- * Get VAPID public key
3570
- *
3571
- * Get VAPID public key for client subscription.
3572
- */
3573
- async webpushVapidRetrieve() {
3574
- const response = await this.client.request("GET", "/cfg/webpush/vapid/");
3575
- return response;
3576
- }
3577
- };
3578
-
3579
- // src/generated/cfg_webpush/webpush__web_push/models.ts
3580
- var models_exports9 = {};
3581
-
3582
- // src/generated/cfg_webpush/http.ts
3583
- var FetchAdapter3 = class {
3584
- static {
3585
- __name(this, "FetchAdapter");
3586
- }
3587
- async request(request) {
3588
- const { method, url, headers, body, params, formData, binaryBody } = request;
3589
- let finalUrl = url;
3590
- if (params) {
3591
- const searchParams = new URLSearchParams();
3592
- Object.entries(params).forEach(([key, value]) => {
3593
- if (value !== null && value !== void 0) {
3594
- searchParams.append(key, String(value));
3595
- }
3596
- });
3597
- const queryString = searchParams.toString();
3598
- if (queryString) {
3599
- finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
3600
- }
3601
- }
3602
- const finalHeaders = { ...headers };
3603
- let requestBody;
3604
- if (formData) {
3605
- requestBody = formData;
3606
- } else if (binaryBody) {
3607
- finalHeaders["Content-Type"] = "application/octet-stream";
3608
- requestBody = binaryBody;
3609
- } else if (body) {
3610
- finalHeaders["Content-Type"] = "application/json";
3611
- requestBody = JSON.stringify(body);
3612
- }
3613
- const response = await fetch(finalUrl, {
3614
- method,
3615
- headers: finalHeaders,
3616
- body: requestBody,
3617
- credentials: "include"
3618
- // Include Django session cookies
3619
- });
3620
- let data = null;
3621
- const contentType = response.headers.get("content-type");
3622
- if (response.status !== 204 && contentType?.includes("application/json")) {
3623
- data = await response.json();
3624
- } else if (response.status !== 204) {
3625
- data = await response.text();
3626
- }
3627
- const responseHeaders = {};
3628
- response.headers.forEach((value, key) => {
3629
- responseHeaders[key] = value;
3630
- });
3631
- return {
3632
- data,
3633
- status: response.status,
3634
- statusText: response.statusText,
3635
- headers: responseHeaders
3636
- };
3637
- }
3638
- };
3639
-
3640
- // src/generated/cfg_webpush/errors.ts
3641
- var APIError3 = class extends Error {
3642
- constructor(statusCode, statusText, response, url, message) {
3643
- super(message || `HTTP ${statusCode}: ${statusText}`);
3644
- this.statusCode = statusCode;
3645
- this.statusText = statusText;
3646
- this.response = response;
3647
- this.url = url;
3648
- this.name = "APIError";
3649
- }
3650
- static {
3651
- __name(this, "APIError");
3652
- }
3653
- /**
3654
- * Get error details from response.
3655
- * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
3656
- */
3657
- get details() {
3658
- if (typeof this.response === "object" && this.response !== null) {
3659
- return this.response;
3660
- }
3661
- return null;
3662
- }
3663
- /**
3664
- * Get field-specific validation errors from DRF.
3665
- * Returns: { "field_name": ["error1", "error2"], ... }
3666
- */
3667
- get fieldErrors() {
3668
- const details = this.details;
3669
- if (!details) return null;
3670
- const fieldErrors = {};
3671
- for (const [key, value] of Object.entries(details)) {
3672
- if (Array.isArray(value)) {
3673
- fieldErrors[key] = value;
3674
- }
3675
- }
3676
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
3677
- }
3678
- /**
3679
- * Get single error message from DRF.
3680
- * Checks for "detail", "message", or first field error.
3681
- */
3682
- get errorMessage() {
3683
- const details = this.details;
3684
- if (!details) return this.message;
3685
- if (details.detail) {
3686
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
3687
- }
3688
- if (details.message) {
3689
- return String(details.message);
3690
- }
3691
- const fieldErrors = this.fieldErrors;
3692
- if (fieldErrors) {
3693
- const firstField = Object.keys(fieldErrors)[0];
3694
- if (firstField) {
3695
- return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
3696
- }
3697
- }
3698
- return this.message;
3699
- }
3700
- // Helper methods for common HTTP status codes
3701
- get isValidationError() {
3702
- return this.statusCode === 400;
3703
- }
3704
- get isAuthError() {
3705
- return this.statusCode === 401;
3706
- }
3707
- get isPermissionError() {
3708
- return this.statusCode === 403;
3709
- }
3710
- get isNotFoundError() {
3711
- return this.statusCode === 404;
3712
- }
3713
- get isServerError() {
3714
- return this.statusCode >= 500 && this.statusCode < 600;
3715
- }
3716
- };
3717
- var NetworkError3 = class extends Error {
3718
- constructor(message, url, originalError) {
3719
- super(message);
3720
- this.url = url;
3721
- this.originalError = originalError;
3722
- this.name = "NetworkError";
3723
- }
3724
- static {
3725
- __name(this, "NetworkError");
3726
- }
3727
- };
3728
-
3729
- // src/generated/cfg_webpush/logger.ts
3730
- var import_consola11 = require("consola");
3731
- var DEFAULT_CONFIG3 = {
3732
- enabled: process.env.NODE_ENV !== "production",
3733
- logRequests: true,
3734
- logResponses: true,
3735
- logErrors: true,
3736
- logBodies: true,
3737
- logHeaders: false
3738
- };
3739
- var SENSITIVE_HEADERS3 = [
3740
- "authorization",
3741
- "cookie",
3742
- "set-cookie",
3743
- "x-api-key",
3744
- "x-csrf-token"
3745
- ];
3746
- var APILogger3 = class {
3747
- static {
3748
- __name(this, "APILogger");
3749
- }
3750
- constructor(config = {}) {
3751
- this.config = { ...DEFAULT_CONFIG3, ...config };
3752
- this.consola = config.consola || (0, import_consola11.createConsola)({
3753
- level: this.config.enabled ? 4 : 0
3754
- });
3755
- }
3756
- /**
3757
- * Enable logging
3758
- */
3759
- enable() {
3760
- this.config.enabled = true;
3761
- }
3762
- /**
3763
- * Disable logging
3764
- */
3765
- disable() {
3766
- this.config.enabled = false;
3767
- }
3768
- /**
3769
- * Update configuration
3770
- */
3771
- setConfig(config) {
3772
- this.config = { ...this.config, ...config };
3773
- }
3774
- /**
3775
- * Filter sensitive headers
3776
- */
3777
- filterHeaders(headers) {
3778
- if (!headers) return {};
3779
- const filtered = {};
3780
- Object.keys(headers).forEach((key) => {
3781
- const lowerKey = key.toLowerCase();
3782
- if (SENSITIVE_HEADERS3.includes(lowerKey)) {
3783
- filtered[key] = "***";
3784
- } else {
3785
- filtered[key] = headers[key] || "";
3786
- }
3787
- });
3788
- return filtered;
3789
- }
3790
- /**
3791
- * Log request
3792
- */
3793
- logRequest(request) {
3794
- if (!this.config.enabled || !this.config.logRequests) return;
3795
- const { method, url, headers, body } = request;
3796
- this.consola.start(`${method} ${url}`);
3797
- if (this.config.logHeaders && headers) {
3798
- this.consola.debug("Headers:", this.filterHeaders(headers));
3799
- }
3800
- if (this.config.logBodies && body) {
3801
- this.consola.debug("Body:", body);
3802
- }
3803
- }
3804
- /**
3805
- * Log response
3806
- */
3807
- logResponse(request, response) {
3808
- if (!this.config.enabled || !this.config.logResponses) return;
3809
- const { method, url } = request;
3810
- const { status, statusText, data, duration } = response;
3811
- const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
3812
- this.consola.success(
3813
- `${method} ${url} ${status} ${statusText} (${duration}ms)`
3814
- );
3815
- if (this.config.logBodies && data) {
3816
- this.consola.debug("Response:", data);
3817
- }
3818
- }
3819
- /**
3820
- * Log error
3821
- */
3822
- logError(request, error) {
3823
- if (!this.config.enabled || !this.config.logErrors) return;
3824
- const { method, url } = request;
3825
- const { message, statusCode, fieldErrors, duration } = error;
3826
- this.consola.error(
3827
- `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
3828
- );
3829
- this.consola.error("Message:", message);
3830
- if (fieldErrors && Object.keys(fieldErrors).length > 0) {
3831
- this.consola.error("Field Errors:");
3832
- Object.entries(fieldErrors).forEach(([field, errors]) => {
3833
- errors.forEach((err) => {
3834
- this.consola.error(` \u2022 ${field}: ${err}`);
3835
- });
3836
- });
3837
- }
3838
- }
3839
- /**
3840
- * Log general info
3841
- */
3842
- info(message, ...args) {
3843
- if (!this.config.enabled) return;
3844
- this.consola.info(message, ...args);
3845
- }
3846
- /**
3847
- * Log warning
3848
- */
3849
- warn(message, ...args) {
3850
- if (!this.config.enabled) return;
3851
- this.consola.warn(message, ...args);
3852
- }
3853
- /**
3854
- * Log error
3855
- */
3856
- error(message, ...args) {
3857
- if (!this.config.enabled) return;
3858
- this.consola.error(message, ...args);
3859
- }
3860
- /**
3861
- * Log debug
3862
- */
3863
- debug(message, ...args) {
3864
- if (!this.config.enabled) return;
3865
- this.consola.debug(message, ...args);
3866
- }
3867
- /**
3868
- * Log success
3869
- */
3870
- success(message, ...args) {
3871
- if (!this.config.enabled) return;
3872
- this.consola.success(message, ...args);
3873
- }
3874
- /**
3875
- * Create a sub-logger with prefix
3876
- */
3877
- withTag(tag) {
3878
- return this.consola.withTag(tag);
3879
- }
3880
- };
3881
- var defaultLogger3 = new APILogger3();
3882
-
3883
- // src/generated/cfg_webpush/retry.ts
3884
- var import_p_retry3 = __toESM(require("p-retry"), 1);
3885
- var DEFAULT_RETRY_CONFIG3 = {
3886
- retries: 3,
3887
- factor: 2,
3888
- minTimeout: 1e3,
3889
- maxTimeout: 6e4,
3890
- randomize: true,
3891
- onFailedAttempt: /* @__PURE__ */ __name(() => {
3892
- }, "onFailedAttempt")
3893
- };
3894
- function shouldRetry3(error) {
3895
- if (error instanceof NetworkError3) {
3896
- return true;
3897
- }
3898
- if (error instanceof APIError3) {
3899
- const status = error.statusCode;
3900
- if (status >= 500 && status < 600) {
3901
- return true;
3902
- }
3903
- if (status === 429) {
3904
- return true;
3905
- }
3906
- return false;
3907
- }
3908
- return true;
3909
- }
3910
- __name(shouldRetry3, "shouldRetry");
3911
- async function withRetry3(fn, config) {
3912
- const finalConfig = { ...DEFAULT_RETRY_CONFIG3, ...config };
3913
- return (0, import_p_retry3.default)(
3914
- async () => {
3915
- try {
3916
- return await fn();
3917
- } catch (error) {
3918
- if (!shouldRetry3(error)) {
3919
- throw new import_p_retry3.AbortError(error);
3920
- }
3921
- throw error;
3922
- }
3923
- },
3924
- {
3925
- retries: finalConfig.retries,
3926
- factor: finalConfig.factor,
3927
- minTimeout: finalConfig.minTimeout,
3928
- maxTimeout: finalConfig.maxTimeout,
3929
- randomize: finalConfig.randomize,
3930
- onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
3931
- const pRetryError = error;
3932
- finalConfig.onFailedAttempt({
3933
- error: pRetryError,
3934
- attemptNumber: pRetryError.attemptNumber,
3935
- retriesLeft: pRetryError.retriesLeft
3936
- });
3937
- } : void 0
3938
- }
3939
- );
3940
- }
3941
- __name(withRetry3, "withRetry");
3942
-
3943
- // src/generated/cfg_webpush/client.ts
3944
- var APIClient3 = class {
3945
- constructor(baseUrl, options) {
3946
- this.logger = null;
3947
- this.retryConfig = null;
3948
- this.tokenGetter = null;
3949
- this.baseUrl = baseUrl.replace(/\/$/, "");
3950
- this.httpClient = options?.httpClient || new FetchAdapter3();
3951
- this.tokenGetter = options?.tokenGetter || null;
3952
- if (options?.loggerConfig !== void 0) {
3953
- this.logger = new APILogger3(options.loggerConfig);
3954
- }
3955
- if (options?.retryConfig !== void 0) {
3956
- this.retryConfig = options.retryConfig;
3957
- }
3958
- this.web_push = new WebPush(this);
3959
- }
3960
- static {
3961
- __name(this, "APIClient");
3962
- }
3963
- /**
3964
- * Get CSRF token from cookies (for SessionAuthentication).
3965
- *
3966
- * Returns null if cookie doesn't exist (JWT-only auth).
3967
- */
3968
- getCsrfToken() {
3969
- const name = "csrftoken";
3970
- const value = `; ${document.cookie}`;
3971
- const parts = value.split(`; ${name}=`);
3972
- if (parts.length === 2) {
3973
- return parts.pop()?.split(";").shift() || null;
3974
- }
3975
- return null;
3976
- }
3977
- /**
3978
- * Get the base URL for building streaming/download URLs.
3979
- */
3980
- getBaseUrl() {
3981
- return this.baseUrl;
3982
- }
3983
- /**
3984
- * Get JWT token for URL authentication (used in streaming endpoints).
3985
- * Returns null if no token getter is configured or no token is available.
3986
- */
3987
- getToken() {
3988
- return this.tokenGetter ? this.tokenGetter() : null;
3989
- }
3990
- /**
3991
- * Make HTTP request with Django CSRF and session handling.
3992
- * Automatically retries on network errors and 5xx server errors.
3993
- */
3994
- async request(method, path, options) {
3995
- if (this.retryConfig) {
3996
- return withRetry3(() => this._makeRequest(method, path, options), {
3997
- ...this.retryConfig,
3998
- onFailedAttempt: /* @__PURE__ */ __name((info) => {
3999
- if (this.logger) {
4000
- this.logger.warn(
4001
- `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
4002
- );
4003
- }
4004
- this.retryConfig?.onFailedAttempt?.(info);
4005
- }, "onFailedAttempt")
4006
- });
4007
- }
4008
- return this._makeRequest(method, path, options);
4009
- }
4010
- /**
4011
- * Internal request method (without retry wrapper).
4012
- * Used by request() method with optional retry logic.
4013
- */
4014
- async _makeRequest(method, path, options) {
4015
- const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
4016
- const startTime = Date.now();
4017
- const headers = {
4018
- ...options?.headers || {}
4019
- };
4020
- if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
4021
- headers["Content-Type"] = "application/json";
4022
- }
4023
- if (this.logger) {
4024
- this.logger.logRequest({
4025
- method,
4026
- url,
4027
- headers,
4028
- body: options?.formData || options?.body,
4029
- timestamp: startTime
4030
- });
4031
- }
4032
- try {
4033
- const response = await this.httpClient.request({
4034
- method,
4035
- url,
4036
- headers,
4037
- params: options?.params,
4038
- body: options?.body,
4039
- formData: options?.formData,
4040
- binaryBody: options?.binaryBody
4041
- });
4042
- const duration = Date.now() - startTime;
4043
- if (response.status >= 400) {
4044
- const error = new APIError3(
4045
- response.status,
4046
- response.statusText,
4047
- response.data,
4048
- url
4049
- );
4050
- if (this.logger) {
4051
- this.logger.logError(
4052
- {
4053
- method,
4054
- url,
4055
- headers,
4056
- body: options?.formData || options?.body,
4057
- timestamp: startTime
4058
- },
4059
- {
4060
- message: error.message,
4061
- statusCode: response.status,
4062
- duration,
4063
- timestamp: Date.now()
4064
- }
4065
- );
4066
- }
4067
- throw error;
4068
- }
4069
- if (this.logger) {
4070
- this.logger.logResponse(
4071
- {
4072
- method,
4073
- url,
4074
- headers,
4075
- body: options?.formData || options?.body,
4076
- timestamp: startTime
4077
- },
4078
- {
4079
- status: response.status,
4080
- statusText: response.statusText,
4081
- data: response.data,
4082
- duration,
4083
- timestamp: Date.now()
4084
- }
4085
- );
4086
- }
4087
- return response.data;
4088
- } catch (error) {
4089
- const duration = Date.now() - startTime;
4090
- if (error instanceof APIError3) {
4091
- throw error;
4092
- }
4093
- const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
4094
- if (this.logger) {
4095
- if (isCORSError) {
4096
- this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
4097
- this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
4098
- this.logger.error(` \u2192 Configure security_domains parameter on the server`);
4099
- } else {
4100
- this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
4101
- this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
4102
- }
4103
- }
4104
- if (typeof window !== "undefined") {
4105
- try {
4106
- if (isCORSError) {
4107
- window.dispatchEvent(new CustomEvent("cors-error", {
4108
- detail: {
4109
- url,
4110
- method,
4111
- error: error instanceof Error ? error.message : String(error),
4112
- timestamp: /* @__PURE__ */ new Date()
4113
- },
4114
- bubbles: true,
4115
- cancelable: false
4116
- }));
4117
- } else {
4118
- window.dispatchEvent(new CustomEvent("network-error", {
4119
- detail: {
4120
- url,
4121
- method,
4122
- error: error instanceof Error ? error.message : String(error),
4123
- timestamp: /* @__PURE__ */ new Date()
4124
- },
4125
- bubbles: true,
4126
- cancelable: false
4127
- }));
4128
- }
4129
- } catch (eventError) {
4130
- }
4131
- }
4132
- const networkError = error instanceof Error ? new NetworkError3(error.message, url, error) : new NetworkError3("Unknown error", url);
4133
- if (this.logger) {
4134
- this.logger.logError(
4135
- {
4136
- method,
4137
- url,
4138
- headers,
4139
- body: options?.formData || options?.body,
4140
- timestamp: startTime
4141
- },
4142
- {
4143
- message: networkError.message,
4144
- duration,
4145
- timestamp: Date.now()
4146
- }
4147
- );
4148
- }
4149
- throw networkError;
4150
- }
4151
- }
4152
- };
4153
-
4154
- // src/generated/cfg_webpush/storage.ts
4155
- var LocalStorageAdapter3 = class {
4156
- static {
4157
- __name(this, "LocalStorageAdapter");
4158
- }
4159
- constructor(logger) {
4160
- this.logger = logger;
4161
- }
4162
- getItem(key) {
4163
- try {
4164
- if (typeof window !== "undefined" && window.localStorage) {
4165
- const value = localStorage.getItem(key);
4166
- this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
4167
- return value;
4168
- }
4169
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
4170
- } catch (error) {
4171
- this.logger?.error("LocalStorage.getItem failed:", error);
4172
- }
4173
- return null;
4174
- }
4175
- setItem(key, value) {
4176
- try {
4177
- if (typeof window !== "undefined" && window.localStorage) {
4178
- localStorage.setItem(key, value);
4179
- this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
4180
- } else {
4181
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
4182
- }
4183
- } catch (error) {
4184
- this.logger?.error("LocalStorage.setItem failed:", error);
4185
- }
4186
- }
4187
- removeItem(key) {
4188
- try {
4189
- if (typeof window !== "undefined" && window.localStorage) {
4190
- localStorage.removeItem(key);
4191
- this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
4192
- } else {
4193
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
4194
- }
4195
- } catch (error) {
4196
- this.logger?.error("LocalStorage.removeItem failed:", error);
4197
- }
4198
- }
4199
- };
4200
- var CookieStorageAdapter3 = class {
4201
- static {
4202
- __name(this, "CookieStorageAdapter");
4203
- }
4204
- constructor(logger) {
4205
- this.logger = logger;
4206
- }
4207
- getItem(key) {
4208
- try {
4209
- if (typeof document === "undefined") {
4210
- this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
4211
- return null;
4212
- }
4213
- const value = `; ${document.cookie}`;
4214
- const parts = value.split(`; ${key}=`);
4215
- if (parts.length === 2) {
4216
- const result = parts.pop()?.split(";").shift() || null;
4217
- this.logger?.debug(`CookieStorage.getItem("${key}"): ${result ? "found" : "not found"}`);
4218
- return result;
4219
- }
4220
- this.logger?.debug(`CookieStorage.getItem("${key}"): not found`);
4221
- } catch (error) {
4222
- this.logger?.error("CookieStorage.getItem failed:", error);
4223
- }
4224
- return null;
4225
- }
4226
- setItem(key, value) {
4227
- try {
4228
- if (typeof document !== "undefined") {
4229
- document.cookie = `${key}=${value}; path=/; max-age=31536000`;
4230
- this.logger?.debug(`CookieStorage.setItem("${key}"): success`);
4231
- } else {
4232
- this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
4233
- }
4234
- } catch (error) {
4235
- this.logger?.error("CookieStorage.setItem failed:", error);
4236
- }
4237
- }
4238
- removeItem(key) {
4239
- try {
4240
- if (typeof document !== "undefined") {
4241
- document.cookie = `${key}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
4242
- this.logger?.debug(`CookieStorage.removeItem("${key}"): success`);
4243
- } else {
4244
- this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
4245
- }
4246
- } catch (error) {
4247
- this.logger?.error("CookieStorage.removeItem failed:", error);
4248
- }
4249
- }
4250
- };
4251
- var MemoryStorageAdapter3 = class {
4252
- constructor(logger) {
4253
- this.storage = /* @__PURE__ */ new Map();
4254
- this.logger = logger;
4255
- }
4256
- static {
4257
- __name(this, "MemoryStorageAdapter");
4258
- }
4259
- getItem(key) {
4260
- const value = this.storage.get(key) || null;
4261
- this.logger?.debug(`MemoryStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
4262
- return value;
4263
- }
4264
- setItem(key, value) {
4265
- this.storage.set(key, value);
4266
- this.logger?.debug(`MemoryStorage.setItem("${key}"): success`);
4267
- }
4268
- removeItem(key) {
4269
- this.storage.delete(key);
4270
- this.logger?.debug(`MemoryStorage.removeItem("${key}"): success`);
4271
- }
4272
- };
4273
-
4274
- // src/generated/cfg_webpush/_utils/schemas/index.ts
4275
- var schemas_exports3 = {};
4276
- __export(schemas_exports3, {
4277
- SendPushRequestRequestSchema: () => SendPushRequestRequestSchema,
4278
- SendPushResponseSchema: () => SendPushResponseSchema,
4279
- SubscribeRequestRequestSchema: () => SubscribeRequestRequestSchema,
4280
- SubscribeResponseSchema: () => SubscribeResponseSchema,
4281
- VapidPublicKeyResponseSchema: () => VapidPublicKeyResponseSchema
4282
- });
4283
-
4284
- // src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts
4285
- var import_zod57 = require("zod");
4286
- var SendPushRequestRequestSchema = import_zod57.z.object({
4287
- title: import_zod57.z.string().min(1).max(255),
4288
- body: import_zod57.z.string().min(1),
4289
- icon: import_zod57.z.union([import_zod57.z.url(), import_zod57.z.literal("")]).nullable().optional(),
4290
- url: import_zod57.z.union([import_zod57.z.url(), import_zod57.z.literal("")]).nullable().optional()
4291
- });
4292
-
4293
- // src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
4294
- var import_zod58 = require("zod");
4295
- var SendPushResponseSchema = import_zod58.z.object({
4296
- success: import_zod58.z.boolean(),
4297
- sent_to: import_zod58.z.int()
4298
- });
4299
-
4300
- // src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
4301
- var import_zod59 = require("zod");
4302
- var SubscribeRequestRequestSchema = import_zod59.z.object({
4303
- endpoint: import_zod59.z.union([import_zod59.z.url(), import_zod59.z.literal("")]),
4304
- keys: import_zod59.z.record(import_zod59.z.string(), import_zod59.z.string().min(1))
4305
- });
4306
-
4307
- // src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts
4308
- var import_zod60 = require("zod");
4309
- var SubscribeResponseSchema = import_zod60.z.object({
4310
- success: import_zod60.z.boolean(),
4311
- subscription_id: import_zod60.z.int(),
4312
- created: import_zod60.z.boolean()
4313
- });
4314
-
4315
- // src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts
4316
- var import_zod61 = require("zod");
4317
- var VapidPublicKeyResponseSchema = import_zod61.z.object({
4318
- publicKey: import_zod61.z.string()
4319
- });
4320
-
4321
- // src/generated/cfg_webpush/validation-events.ts
4322
- function dispatchValidationError3(detail) {
4323
- if (typeof window === "undefined") {
4324
- return;
4325
- }
4326
- try {
4327
- const event = new CustomEvent("zod-validation-error", {
4328
- detail,
4329
- bubbles: true,
4330
- cancelable: false
4331
- });
4332
- window.dispatchEvent(event);
4333
- } catch (error) {
4334
- console.warn("Failed to dispatch validation error event:", error);
4335
- }
4336
- }
4337
- __name(dispatchValidationError3, "dispatchValidationError");
4338
- function onValidationError3(callback) {
4339
- if (typeof window === "undefined") {
4340
- return () => {
4341
- };
4342
- }
4343
- const handler = /* @__PURE__ */ __name((event) => {
4344
- if (event instanceof CustomEvent) {
4345
- callback(event.detail);
4346
- }
4347
- }, "handler");
4348
- window.addEventListener("zod-validation-error", handler);
4349
- return () => {
4350
- window.removeEventListener("zod-validation-error", handler);
4351
- };
4352
- }
4353
- __name(onValidationError3, "onValidationError");
4354
- function formatZodError3(error) {
4355
- const issues = error.issues.map((issue, index) => {
4356
- const path = issue.path.join(".") || "root";
4357
- const parts = [`${index + 1}. ${path}: ${issue.message}`];
4358
- if ("expected" in issue && issue.expected) {
4359
- parts.push(` Expected: ${issue.expected}`);
4360
- }
4361
- if ("received" in issue && issue.received) {
4362
- parts.push(` Received: ${issue.received}`);
4363
- }
4364
- return parts.join("\n");
4365
- });
4366
- return issues.join("\n");
4367
- }
4368
- __name(formatZodError3, "formatZodError");
4369
-
4370
- // src/generated/cfg_webpush/_utils/fetchers/index.ts
4371
- var fetchers_exports3 = {};
4372
- __export(fetchers_exports3, {
4373
- createWebpushSendCreate: () => createWebpushSendCreate,
4374
- createWebpushSubscribeCreate: () => createWebpushSubscribeCreate,
4375
- getWebpushVapidRetrieve: () => getWebpushVapidRetrieve
4376
- });
4377
-
4378
- // src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
4379
- var import_consola12 = require("consola");
4380
-
4381
- // src/generated/cfg_webpush/api-instance.ts
4382
- var globalAPI3 = null;
4383
- var autoConfigAttempted3 = false;
4384
- function tryAutoConfigureFromEnv3() {
4385
- if (autoConfigAttempted3) return;
4386
- autoConfigAttempted3 = true;
4387
- if (globalAPI3) return;
4388
- if (typeof process === "undefined" || !process.env) return;
4389
- const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
4390
- if (baseUrl) {
4391
- globalAPI3 = new API3(baseUrl);
4392
- }
4393
- }
4394
- __name(tryAutoConfigureFromEnv3, "tryAutoConfigureFromEnv");
4395
- function getAPIInstance3() {
4396
- tryAutoConfigureFromEnv3();
4397
- if (!globalAPI3) {
4398
- throw new Error(
4399
- 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
4400
- );
4401
- }
4402
- return globalAPI3;
4403
- }
4404
- __name(getAPIInstance3, "getAPIInstance");
4405
- function isAPIConfigured3() {
4406
- tryAutoConfigureFromEnv3();
4407
- return globalAPI3 !== null;
4408
- }
4409
- __name(isAPIConfigured3, "isAPIConfigured");
4410
- function configureAPI3(config) {
4411
- globalAPI3 = new API3(config.baseUrl, config.options);
4412
- if (config.token) {
4413
- globalAPI3.setToken(config.token, config.refreshToken);
4414
- }
4415
- return globalAPI3;
4416
- }
4417
- __name(configureAPI3, "configureAPI");
4418
- function reconfigureAPI3(updates) {
4419
- const instance = getAPIInstance3();
4420
- if (updates.baseUrl) {
4421
- instance.setBaseUrl(updates.baseUrl);
4422
- }
4423
- if (updates.token) {
4424
- instance.setToken(updates.token, updates.refreshToken);
4425
- }
4426
- return instance;
4427
- }
4428
- __name(reconfigureAPI3, "reconfigureAPI");
4429
- function clearAPITokens3() {
4430
- const instance = getAPIInstance3();
4431
- instance.clearTokens();
4432
- }
4433
- __name(clearAPITokens3, "clearAPITokens");
4434
- function resetAPI3() {
4435
- if (globalAPI3) {
4436
- globalAPI3.clearTokens();
4437
- }
4438
- globalAPI3 = null;
4439
- }
4440
- __name(resetAPI3, "resetAPI");
4441
-
4442
- // src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
4443
- async function createWebpushSendCreate(data, client) {
4444
- const api2 = client || getAPIInstance3();
4445
- const response = await api2.web_push.webpushSendCreate(data);
4446
- try {
4447
- return SendPushResponseSchema.parse(response);
4448
- } catch (error) {
4449
- import_consola12.consola.error("\u274C Zod Validation Failed");
4450
- import_consola12.consola.box(`createWebpushSendCreate
4451
- Path: /cfg/webpush/send/
4452
- Method: POST`);
4453
- if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
4454
- import_consola12.consola.error("Validation Issues:");
4455
- error.issues.forEach((issue, index) => {
4456
- import_consola12.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
4457
- import_consola12.consola.error(` \u251C\u2500 Message: ${issue.message}`);
4458
- if (issue.expected) import_consola12.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
4459
- if (issue.received) import_consola12.consola.error(` \u2514\u2500 Received: ${issue.received}`);
4460
- });
4461
- }
4462
- import_consola12.consola.error("Response data:", response);
4463
- if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
4464
- try {
4465
- const event = new CustomEvent("zod-validation-error", {
4466
- detail: {
4467
- operation: "createWebpushSendCreate",
4468
- path: "/cfg/webpush/send/",
4469
- method: "POST",
4470
- error,
4471
- response,
4472
- timestamp: /* @__PURE__ */ new Date()
4473
- },
4474
- bubbles: true,
4475
- cancelable: false
4476
- });
4477
- window.dispatchEvent(event);
4478
- } catch (eventError) {
4479
- import_consola12.consola.warn("Failed to dispatch validation error event:", eventError);
4480
- }
4481
- }
4482
- throw error;
4483
- }
4484
- }
4485
- __name(createWebpushSendCreate, "createWebpushSendCreate");
4486
- async function createWebpushSubscribeCreate(data, client) {
4487
- const api2 = client || getAPIInstance3();
4488
- const response = await api2.web_push.webpushSubscribeCreate(data);
4489
- try {
4490
- return SubscribeResponseSchema.parse(response);
4491
- } catch (error) {
4492
- import_consola12.consola.error("\u274C Zod Validation Failed");
4493
- import_consola12.consola.box(`createWebpushSubscribeCreate
4494
- Path: /cfg/webpush/subscribe/
4495
- Method: POST`);
4496
- if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
4497
- import_consola12.consola.error("Validation Issues:");
4498
- error.issues.forEach((issue, index) => {
4499
- import_consola12.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
4500
- import_consola12.consola.error(` \u251C\u2500 Message: ${issue.message}`);
4501
- if (issue.expected) import_consola12.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
4502
- if (issue.received) import_consola12.consola.error(` \u2514\u2500 Received: ${issue.received}`);
4503
- });
4504
- }
4505
- import_consola12.consola.error("Response data:", response);
4506
- if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
4507
- try {
4508
- const event = new CustomEvent("zod-validation-error", {
4509
- detail: {
4510
- operation: "createWebpushSubscribeCreate",
4511
- path: "/cfg/webpush/subscribe/",
4512
- method: "POST",
4513
- error,
4514
- response,
4515
- timestamp: /* @__PURE__ */ new Date()
4516
- },
4517
- bubbles: true,
4518
- cancelable: false
4519
- });
4520
- window.dispatchEvent(event);
4521
- } catch (eventError) {
4522
- import_consola12.consola.warn("Failed to dispatch validation error event:", eventError);
4523
- }
4524
- }
4525
- throw error;
4526
- }
4527
- }
4528
- __name(createWebpushSubscribeCreate, "createWebpushSubscribeCreate");
4529
- async function getWebpushVapidRetrieve(client) {
4530
- const api2 = client || getAPIInstance3();
4531
- const response = await api2.web_push.webpushVapidRetrieve();
4532
- try {
4533
- return VapidPublicKeyResponseSchema.parse(response);
4534
- } catch (error) {
4535
- import_consola12.consola.error("\u274C Zod Validation Failed");
4536
- import_consola12.consola.box(`getWebpushVapidRetrieve
4537
- Path: /cfg/webpush/vapid/
4538
- Method: GET`);
4539
- if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
4540
- import_consola12.consola.error("Validation Issues:");
4541
- error.issues.forEach((issue, index) => {
4542
- import_consola12.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
4543
- import_consola12.consola.error(` \u251C\u2500 Message: ${issue.message}`);
4544
- if (issue.expected) import_consola12.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
4545
- if (issue.received) import_consola12.consola.error(` \u2514\u2500 Received: ${issue.received}`);
4546
- });
4547
- }
4548
- import_consola12.consola.error("Response data:", response);
4549
- if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
4550
- try {
4551
- const event = new CustomEvent("zod-validation-error", {
4552
- detail: {
4553
- operation: "getWebpushVapidRetrieve",
4554
- path: "/cfg/webpush/vapid/",
4555
- method: "GET",
4556
- error,
4557
- response,
4558
- timestamp: /* @__PURE__ */ new Date()
4559
- },
4560
- bubbles: true,
4561
- cancelable: false
4562
- });
4563
- window.dispatchEvent(event);
4564
- } catch (eventError) {
4565
- import_consola12.consola.warn("Failed to dispatch validation error event:", eventError);
4566
- }
4567
- }
4568
- throw error;
4569
- }
4570
- }
4571
- __name(getWebpushVapidRetrieve, "getWebpushVapidRetrieve");
4572
-
4573
- // src/generated/cfg_webpush/index.ts
4574
- var TOKEN_KEY3 = "auth_token";
4575
- var REFRESH_TOKEN_KEY3 = "refresh_token";
4576
- var API3 = class {
4577
- constructor(baseUrl, options) {
4578
- this._token = null;
4579
- this._refreshToken = null;
4580
- this.baseUrl = baseUrl;
4581
- this.options = options;
4582
- const logger = options?.loggerConfig ? new APILogger3(options.loggerConfig) : void 0;
4583
- this.storage = options?.storage || new LocalStorageAdapter3(logger);
4584
- this._loadTokensFromStorage();
4585
- this._client = new APIClient3(this.baseUrl, {
4586
- retryConfig: this.options?.retryConfig,
4587
- loggerConfig: this.options?.loggerConfig,
4588
- tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
4589
- });
4590
- this._injectAuthHeader();
4591
- this.web_push = this._client.web_push;
4592
- }
4593
- static {
4594
- __name(this, "API");
4595
- }
4596
- _loadTokensFromStorage() {
4597
- this._token = this.storage.getItem(TOKEN_KEY3);
4598
- this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY3);
4599
- }
4600
- _reinitClients() {
4601
- this._client = new APIClient3(this.baseUrl, {
4602
- retryConfig: this.options?.retryConfig,
4603
- loggerConfig: this.options?.loggerConfig,
4604
- tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
4605
- });
4606
- this._injectAuthHeader();
4607
- this.web_push = this._client.web_push;
4608
- }
4609
- _injectAuthHeader() {
4610
- const originalRequest = this._client.request.bind(this._client);
4611
- this._client.request = async (method, path, options) => {
4612
- const token = this.getToken();
4613
- const mergedOptions = {
4614
- ...options,
4615
- headers: {
4616
- ...options?.headers || {},
4617
- ...token ? { "Authorization": `Bearer ${token}` } : {}
4618
- }
4619
- };
4620
- return originalRequest(method, path, mergedOptions);
4621
- };
4622
- }
4623
- /**
4624
- * Get current JWT token
4625
- */
4626
- getToken() {
4627
- return this.storage.getItem(TOKEN_KEY3);
4628
- }
4629
- /**
4630
- * Get current refresh token
4631
- */
4632
- getRefreshToken() {
4633
- return this.storage.getItem(REFRESH_TOKEN_KEY3);
4634
- }
4635
- /**
4636
- * Set JWT token and refresh token
4637
- * @param token - JWT access token
4638
- * @param refreshToken - JWT refresh token (optional)
4639
- */
4640
- setToken(token, refreshToken) {
4641
- this._token = token;
4642
- this.storage.setItem(TOKEN_KEY3, token);
4643
- if (refreshToken) {
4644
- this._refreshToken = refreshToken;
4645
- this.storage.setItem(REFRESH_TOKEN_KEY3, refreshToken);
4646
- }
4647
- this._reinitClients();
4648
- }
4649
- /**
4650
- * Clear all tokens
4651
- */
4652
- clearTokens() {
4653
- this._token = null;
4654
- this._refreshToken = null;
4655
- this.storage.removeItem(TOKEN_KEY3);
4656
- this.storage.removeItem(REFRESH_TOKEN_KEY3);
4657
- this._reinitClients();
4658
- }
4659
- /**
4660
- * Check if user is authenticated
4661
- */
4662
- isAuthenticated() {
4663
- return !!this.getToken();
4664
- }
4665
- /**
4666
- * Update base URL and reinitialize clients
4667
- * @param url - New base URL
4668
- */
4669
- setBaseUrl(url) {
4670
- this.baseUrl = url;
4671
- this._reinitClients();
4672
- }
4673
- /**
4674
- * Get current base URL
4675
- */
4676
- getBaseUrl() {
4677
- return this.baseUrl;
4678
- }
4679
- /**
4680
- * Get OpenAPI schema path
4681
- * @returns Path to the OpenAPI schema JSON file
4682
- *
4683
- * Note: The OpenAPI schema is available in the schema.json file.
4684
- * You can load it dynamically using:
4685
- * ```typescript
4686
- * const schema = await fetch('./schema.json').then(r => r.json());
4687
- * // or using fs in Node.js:
4688
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
4689
- * ```
4690
- */
4691
- getSchemaPath() {
4692
- return "./schema.json";
4693
- }
4694
- };
4695
- var cfg_webpush_default = API3;
4696
-
4697
3499
  // src/index.ts
4698
3500
  var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
4699
3501
  var apiUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";