@djangocfg/ext-newsletter 1.0.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/README.md +140 -0
- package/dist/chunk-LQLPNWHR.js +2075 -0
- package/dist/hooks.cjs +2539 -0
- package/dist/hooks.d.cts +267 -0
- package/dist/hooks.d.ts +267 -0
- package/dist/hooks.js +370 -0
- package/dist/index.cjs +2153 -0
- package/dist/index.d.cts +2084 -0
- package/dist/index.d.ts +2084 -0
- package/dist/index.js +1 -0
- package/package.json +80 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter.ts +210 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter__bulk_email.ts +93 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter__campaigns.ts +338 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter__logs.ts +92 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter__newsletters.ts +150 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter__subscriptions.ts +210 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter__testing.ts +93 -0
- package/src/api/generated/ext_newsletter/_utils/fetchers/index.ts +34 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter.ts +81 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter__bulk_email.ts +42 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter__campaigns.ts +130 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter__logs.ts +37 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter__newsletters.ts +52 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter__subscriptions.ts +78 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/ext_newsletter__newsletter__testing.ts +42 -0
- package/src/api/generated/ext_newsletter/_utils/hooks/index.ts +34 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/BulkEmailRequest.schema.ts +26 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/BulkEmailResponse.schema.ts +23 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/EmailLog.schema.ts +31 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/ErrorResponse.schema.ts +20 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/Newsletter.schema.ts +26 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/NewsletterCampaign.schema.ts +33 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/NewsletterCampaignRequest.schema.ts +26 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/NewsletterSubscription.schema.ts +27 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/PaginatedEmailLogList.schema.ts +24 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/PaginatedNewsletterCampaignList.schema.ts +24 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/PaginatedNewsletterList.schema.ts +24 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/PaginatedNewsletterSubscriptionList.schema.ts +24 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/PatchedNewsletterCampaignRequest.schema.ts +26 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/PatchedUnsubscribeRequest.schema.ts +19 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/SendCampaignRequest.schema.ts +19 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/SendCampaignResponse.schema.ts +22 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/SubscribeRequest.schema.ts +20 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/SubscribeResponse.schema.ts +21 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/SuccessResponse.schema.ts +20 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/TestEmailRequest.schema.ts +21 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/Unsubscribe.schema.ts +19 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/UnsubscribeRequest.schema.ts +19 -0
- package/src/api/generated/ext_newsletter/_utils/schemas/index.ts +40 -0
- package/src/api/generated/ext_newsletter/api-instance.ts +131 -0
- package/src/api/generated/ext_newsletter/client.ts +319 -0
- package/src/api/generated/ext_newsletter/enums.ts +24 -0
- package/src/api/generated/ext_newsletter/errors.ts +116 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter/client.ts +38 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter/models.ts +71 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__bulk_email/client.ts +24 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__bulk_email/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__bulk_email/models.ts +29 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__campaigns/client.ts +85 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__campaigns/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__campaigns/models.ts +100 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__logs/client.ts +35 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__logs/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__logs/models.ts +51 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__newsletters/client.ts +45 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__newsletters/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__newsletters/models.ts +42 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__subscriptions/client.ts +55 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__subscriptions/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__subscriptions/models.ts +92 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__testing/client.ts +24 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__testing/index.ts +2 -0
- package/src/api/generated/ext_newsletter/ext_newsletter__newsletter__testing/models.ts +24 -0
- package/src/api/generated/ext_newsletter/http.ts +103 -0
- package/src/api/generated/ext_newsletter/index.ts +315 -0
- package/src/api/generated/ext_newsletter/logger.ts +259 -0
- package/src/api/generated/ext_newsletter/retry.ts +175 -0
- package/src/api/generated/ext_newsletter/schema.json +1739 -0
- package/src/api/generated/ext_newsletter/storage.ts +161 -0
- package/src/api/generated/ext_newsletter/validation-events.ts +133 -0
- package/src/api/index.ts +9 -0
- package/src/components/Hero/index.tsx +160 -0
- package/src/components/Hero/types.ts +37 -0
- package/src/config.ts +20 -0
- package/src/contexts/newsletter/NewsletterContext.tsx +264 -0
- package/src/contexts/newsletter/types.ts +32 -0
- package/src/hooks/index.ts +21 -0
- package/src/index.ts +14 -0
- package/src/utils/logger.ts +9 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2153 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var consola = require('consola');
|
|
4
|
+
var pRetry = require('p-retry');
|
|
5
|
+
var zod = require('zod');
|
|
6
|
+
var api = require('@djangocfg/ext-base/api');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var pRetry__default = /*#__PURE__*/_interopDefault(pRetry);
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__bulk_email/client.ts
|
|
19
|
+
var ExtNewsletterBulkEmail = class {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Send Bulk Email
|
|
26
|
+
*
|
|
27
|
+
* Send bulk emails to multiple recipients using base email template.
|
|
28
|
+
*/
|
|
29
|
+
async newsletterBulkCreate(data) {
|
|
30
|
+
const response = await this.client.request("POST", "/cfg/newsletter/bulk/", { body: data });
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__bulk_email/models.ts
|
|
36
|
+
var models_exports = {};
|
|
37
|
+
|
|
38
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__campaigns/client.ts
|
|
39
|
+
var ExtNewsletterCampaigns = class {
|
|
40
|
+
client;
|
|
41
|
+
constructor(client) {
|
|
42
|
+
this.client = client;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* List Newsletter Campaigns
|
|
46
|
+
*
|
|
47
|
+
* Get a list of all newsletter campaigns.
|
|
48
|
+
*/
|
|
49
|
+
async newsletterCampaignsList(...args) {
|
|
50
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
51
|
+
let params;
|
|
52
|
+
if (isParamsObject) {
|
|
53
|
+
params = args[0];
|
|
54
|
+
} else {
|
|
55
|
+
params = { page: args[0], page_size: args[1] };
|
|
56
|
+
}
|
|
57
|
+
const response = await this.client.request("GET", "/cfg/newsletter/campaigns/", { params });
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create Newsletter Campaign
|
|
62
|
+
*
|
|
63
|
+
* Create a new newsletter campaign.
|
|
64
|
+
*/
|
|
65
|
+
async newsletterCampaignsCreate(data) {
|
|
66
|
+
const response = await this.client.request("POST", "/cfg/newsletter/campaigns/", { body: data });
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get Campaign Details
|
|
71
|
+
*
|
|
72
|
+
* Retrieve details of a specific newsletter campaign.
|
|
73
|
+
*/
|
|
74
|
+
async newsletterCampaignsRetrieve(id) {
|
|
75
|
+
const response = await this.client.request("GET", `/cfg/newsletter/campaigns/${id}/`);
|
|
76
|
+
return response;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Update Campaign
|
|
80
|
+
*
|
|
81
|
+
* Update a newsletter campaign.
|
|
82
|
+
*/
|
|
83
|
+
async newsletterCampaignsUpdate(id, data) {
|
|
84
|
+
const response = await this.client.request("PUT", `/cfg/newsletter/campaigns/${id}/`, { body: data });
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Delete Campaign
|
|
89
|
+
*
|
|
90
|
+
* Delete a newsletter campaign.
|
|
91
|
+
*/
|
|
92
|
+
async newsletterCampaignsDestroy(id) {
|
|
93
|
+
await this.client.request("DELETE", `/cfg/newsletter/campaigns/${id}/`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Send Newsletter Campaign
|
|
98
|
+
*
|
|
99
|
+
* Send a newsletter campaign to all subscribers.
|
|
100
|
+
*/
|
|
101
|
+
async newsletterCampaignsSendCreate(data) {
|
|
102
|
+
const response = await this.client.request("POST", "/cfg/newsletter/campaigns/send/", { body: data });
|
|
103
|
+
return response;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__campaigns/models.ts
|
|
108
|
+
var models_exports2 = {};
|
|
109
|
+
|
|
110
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__logs/client.ts
|
|
111
|
+
var ExtNewsletterLogs = class {
|
|
112
|
+
client;
|
|
113
|
+
constructor(client) {
|
|
114
|
+
this.client = client;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List Email Logs
|
|
118
|
+
*
|
|
119
|
+
* Get a list of email sending logs.
|
|
120
|
+
*/
|
|
121
|
+
async newsletterLogsList(...args) {
|
|
122
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
123
|
+
let params;
|
|
124
|
+
if (isParamsObject) {
|
|
125
|
+
params = args[0];
|
|
126
|
+
} else {
|
|
127
|
+
params = { page: args[0], page_size: args[1] };
|
|
128
|
+
}
|
|
129
|
+
const response = await this.client.request("GET", "/cfg/newsletter/logs/", { params });
|
|
130
|
+
return response;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__logs/models.ts
|
|
135
|
+
var models_exports3 = {};
|
|
136
|
+
|
|
137
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__newsletters/client.ts
|
|
138
|
+
var ExtNewsletterNewsletters = class {
|
|
139
|
+
client;
|
|
140
|
+
constructor(client) {
|
|
141
|
+
this.client = client;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* List Active Newsletters
|
|
145
|
+
*
|
|
146
|
+
* Get a list of all active newsletters available for subscription.
|
|
147
|
+
*/
|
|
148
|
+
async newsletterNewslettersList(...args) {
|
|
149
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
150
|
+
let params;
|
|
151
|
+
if (isParamsObject) {
|
|
152
|
+
params = args[0];
|
|
153
|
+
} else {
|
|
154
|
+
params = { page: args[0], page_size: args[1] };
|
|
155
|
+
}
|
|
156
|
+
const response = await this.client.request("GET", "/cfg/newsletter/newsletters/", { params });
|
|
157
|
+
return response;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get Newsletter Details
|
|
161
|
+
*
|
|
162
|
+
* Retrieve details of a specific newsletter.
|
|
163
|
+
*/
|
|
164
|
+
async newsletterNewslettersRetrieve(id) {
|
|
165
|
+
const response = await this.client.request("GET", `/cfg/newsletter/newsletters/${id}/`);
|
|
166
|
+
return response;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__newsletters/models.ts
|
|
171
|
+
var models_exports4 = {};
|
|
172
|
+
|
|
173
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__subscriptions/client.ts
|
|
174
|
+
var ExtNewsletterSubscriptions = class {
|
|
175
|
+
client;
|
|
176
|
+
constructor(client) {
|
|
177
|
+
this.client = client;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Subscribe to Newsletter
|
|
181
|
+
*
|
|
182
|
+
* Subscribe an email address to a newsletter.
|
|
183
|
+
*/
|
|
184
|
+
async newsletterSubscribeCreate(data) {
|
|
185
|
+
const response = await this.client.request("POST", "/cfg/newsletter/subscribe/", { body: data });
|
|
186
|
+
return response;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* List User Subscriptions
|
|
190
|
+
*
|
|
191
|
+
* Get a list of current user's active newsletter subscriptions.
|
|
192
|
+
*/
|
|
193
|
+
async newsletterSubscriptionsList(...args) {
|
|
194
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
195
|
+
let params;
|
|
196
|
+
if (isParamsObject) {
|
|
197
|
+
params = args[0];
|
|
198
|
+
} else {
|
|
199
|
+
params = { page: args[0], page_size: args[1] };
|
|
200
|
+
}
|
|
201
|
+
const response = await this.client.request("GET", "/cfg/newsletter/subscriptions/", { params });
|
|
202
|
+
return response;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Unsubscribe from Newsletter
|
|
206
|
+
*
|
|
207
|
+
* Unsubscribe from a newsletter using subscription ID.
|
|
208
|
+
*/
|
|
209
|
+
async newsletterUnsubscribeCreate(data) {
|
|
210
|
+
const response = await this.client.request("POST", "/cfg/newsletter/unsubscribe/", { body: data });
|
|
211
|
+
return response;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__subscriptions/models.ts
|
|
216
|
+
var models_exports5 = {};
|
|
217
|
+
|
|
218
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__testing/client.ts
|
|
219
|
+
var ExtNewsletterTesting = class {
|
|
220
|
+
client;
|
|
221
|
+
constructor(client) {
|
|
222
|
+
this.client = client;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Test Email Sending
|
|
226
|
+
*
|
|
227
|
+
* Send a test email to verify mailer configuration.
|
|
228
|
+
*/
|
|
229
|
+
async newsletterTestCreate(data) {
|
|
230
|
+
const response = await this.client.request("POST", "/cfg/newsletter/test/", { body: data });
|
|
231
|
+
return response;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter__testing/models.ts
|
|
236
|
+
var models_exports6 = {};
|
|
237
|
+
|
|
238
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter/client.ts
|
|
239
|
+
var ExtNewsletterNewsletter = class {
|
|
240
|
+
client;
|
|
241
|
+
constructor(client) {
|
|
242
|
+
this.client = client;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Retrieve, update, or delete a newsletter campaign.
|
|
246
|
+
*/
|
|
247
|
+
async campaignsPartialUpdate(id, data) {
|
|
248
|
+
const response = await this.client.request("PATCH", `/cfg/newsletter/campaigns/${id}/`, { body: data });
|
|
249
|
+
return response;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Handle newsletter unsubscriptions.
|
|
253
|
+
*/
|
|
254
|
+
async unsubscribeUpdate(data) {
|
|
255
|
+
const response = await this.client.request("PUT", "/cfg/newsletter/unsubscribe/", { body: data });
|
|
256
|
+
return response;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Handle newsletter unsubscriptions.
|
|
260
|
+
*/
|
|
261
|
+
async unsubscribePartialUpdate(data) {
|
|
262
|
+
const response = await this.client.request("PATCH", "/cfg/newsletter/unsubscribe/", { body: data });
|
|
263
|
+
return response;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/api/generated/ext_newsletter/ext_newsletter__newsletter/models.ts
|
|
268
|
+
var models_exports7 = {};
|
|
269
|
+
|
|
270
|
+
// src/api/generated/ext_newsletter/http.ts
|
|
271
|
+
var FetchAdapter = class {
|
|
272
|
+
async request(request) {
|
|
273
|
+
const { method, url, headers, body, params, formData } = request;
|
|
274
|
+
let finalUrl = url;
|
|
275
|
+
if (params) {
|
|
276
|
+
const searchParams = new URLSearchParams();
|
|
277
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
278
|
+
if (value !== null && value !== void 0) {
|
|
279
|
+
searchParams.append(key, String(value));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
const queryString = searchParams.toString();
|
|
283
|
+
if (queryString) {
|
|
284
|
+
finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const finalHeaders = { ...headers };
|
|
288
|
+
let requestBody;
|
|
289
|
+
if (formData) {
|
|
290
|
+
requestBody = formData;
|
|
291
|
+
} else if (body) {
|
|
292
|
+
finalHeaders["Content-Type"] = "application/json";
|
|
293
|
+
requestBody = JSON.stringify(body);
|
|
294
|
+
}
|
|
295
|
+
const response = await fetch(finalUrl, {
|
|
296
|
+
method,
|
|
297
|
+
headers: finalHeaders,
|
|
298
|
+
body: requestBody,
|
|
299
|
+
credentials: "include"
|
|
300
|
+
// Include Django session cookies
|
|
301
|
+
});
|
|
302
|
+
let data = null;
|
|
303
|
+
const contentType = response.headers.get("content-type");
|
|
304
|
+
if (response.status !== 204 && contentType?.includes("application/json")) {
|
|
305
|
+
data = await response.json();
|
|
306
|
+
} else if (response.status !== 204) {
|
|
307
|
+
data = await response.text();
|
|
308
|
+
}
|
|
309
|
+
const responseHeaders = {};
|
|
310
|
+
response.headers.forEach((value, key) => {
|
|
311
|
+
responseHeaders[key] = value;
|
|
312
|
+
});
|
|
313
|
+
return {
|
|
314
|
+
data,
|
|
315
|
+
status: response.status,
|
|
316
|
+
statusText: response.statusText,
|
|
317
|
+
headers: responseHeaders
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/api/generated/ext_newsletter/errors.ts
|
|
323
|
+
var APIError = class extends Error {
|
|
324
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
325
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
326
|
+
this.statusCode = statusCode;
|
|
327
|
+
this.statusText = statusText;
|
|
328
|
+
this.response = response;
|
|
329
|
+
this.url = url;
|
|
330
|
+
this.name = "APIError";
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Get error details from response.
|
|
334
|
+
* DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
|
|
335
|
+
*/
|
|
336
|
+
get details() {
|
|
337
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
338
|
+
return this.response;
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Get field-specific validation errors from DRF.
|
|
344
|
+
* Returns: { "field_name": ["error1", "error2"], ... }
|
|
345
|
+
*/
|
|
346
|
+
get fieldErrors() {
|
|
347
|
+
const details = this.details;
|
|
348
|
+
if (!details) return null;
|
|
349
|
+
const fieldErrors = {};
|
|
350
|
+
for (const [key, value] of Object.entries(details)) {
|
|
351
|
+
if (Array.isArray(value)) {
|
|
352
|
+
fieldErrors[key] = value;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get single error message from DRF.
|
|
359
|
+
* Checks for "detail", "message", or first field error.
|
|
360
|
+
*/
|
|
361
|
+
get errorMessage() {
|
|
362
|
+
const details = this.details;
|
|
363
|
+
if (!details) return this.message;
|
|
364
|
+
if (details.detail) {
|
|
365
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
366
|
+
}
|
|
367
|
+
if (details.message) {
|
|
368
|
+
return String(details.message);
|
|
369
|
+
}
|
|
370
|
+
const fieldErrors = this.fieldErrors;
|
|
371
|
+
if (fieldErrors) {
|
|
372
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
373
|
+
if (firstField) {
|
|
374
|
+
return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return this.message;
|
|
378
|
+
}
|
|
379
|
+
// Helper methods for common HTTP status codes
|
|
380
|
+
get isValidationError() {
|
|
381
|
+
return this.statusCode === 400;
|
|
382
|
+
}
|
|
383
|
+
get isAuthError() {
|
|
384
|
+
return this.statusCode === 401;
|
|
385
|
+
}
|
|
386
|
+
get isPermissionError() {
|
|
387
|
+
return this.statusCode === 403;
|
|
388
|
+
}
|
|
389
|
+
get isNotFoundError() {
|
|
390
|
+
return this.statusCode === 404;
|
|
391
|
+
}
|
|
392
|
+
get isServerError() {
|
|
393
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var NetworkError = class extends Error {
|
|
397
|
+
constructor(message, url, originalError) {
|
|
398
|
+
super(message);
|
|
399
|
+
this.url = url;
|
|
400
|
+
this.originalError = originalError;
|
|
401
|
+
this.name = "NetworkError";
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var DEFAULT_CONFIG = {
|
|
405
|
+
enabled: process.env.NODE_ENV !== "production",
|
|
406
|
+
logRequests: true,
|
|
407
|
+
logResponses: true,
|
|
408
|
+
logErrors: true,
|
|
409
|
+
logBodies: true,
|
|
410
|
+
logHeaders: false
|
|
411
|
+
};
|
|
412
|
+
var SENSITIVE_HEADERS = [
|
|
413
|
+
"authorization",
|
|
414
|
+
"cookie",
|
|
415
|
+
"set-cookie",
|
|
416
|
+
"x-api-key",
|
|
417
|
+
"x-csrf-token"
|
|
418
|
+
];
|
|
419
|
+
var APILogger = class {
|
|
420
|
+
config;
|
|
421
|
+
consola;
|
|
422
|
+
constructor(config = {}) {
|
|
423
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
424
|
+
this.consola = config.consola || consola.createConsola({
|
|
425
|
+
level: this.config.enabled ? 4 : 0
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Enable logging
|
|
430
|
+
*/
|
|
431
|
+
enable() {
|
|
432
|
+
this.config.enabled = true;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Disable logging
|
|
436
|
+
*/
|
|
437
|
+
disable() {
|
|
438
|
+
this.config.enabled = false;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Update configuration
|
|
442
|
+
*/
|
|
443
|
+
setConfig(config) {
|
|
444
|
+
this.config = { ...this.config, ...config };
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Filter sensitive headers
|
|
448
|
+
*/
|
|
449
|
+
filterHeaders(headers) {
|
|
450
|
+
if (!headers) return {};
|
|
451
|
+
const filtered = {};
|
|
452
|
+
Object.keys(headers).forEach((key) => {
|
|
453
|
+
const lowerKey = key.toLowerCase();
|
|
454
|
+
if (SENSITIVE_HEADERS.includes(lowerKey)) {
|
|
455
|
+
filtered[key] = "***";
|
|
456
|
+
} else {
|
|
457
|
+
filtered[key] = headers[key] || "";
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
return filtered;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Log request
|
|
464
|
+
*/
|
|
465
|
+
logRequest(request) {
|
|
466
|
+
if (!this.config.enabled || !this.config.logRequests) return;
|
|
467
|
+
const { method, url, headers, body } = request;
|
|
468
|
+
this.consola.start(`${method} ${url}`);
|
|
469
|
+
if (this.config.logHeaders && headers) {
|
|
470
|
+
this.consola.debug("Headers:", this.filterHeaders(headers));
|
|
471
|
+
}
|
|
472
|
+
if (this.config.logBodies && body) {
|
|
473
|
+
this.consola.debug("Body:", body);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Log response
|
|
478
|
+
*/
|
|
479
|
+
logResponse(request, response) {
|
|
480
|
+
if (!this.config.enabled || !this.config.logResponses) return;
|
|
481
|
+
const { method, url } = request;
|
|
482
|
+
const { status, statusText, data, duration } = response;
|
|
483
|
+
this.consola.success(
|
|
484
|
+
`${method} ${url} ${status} ${statusText} (${duration}ms)`
|
|
485
|
+
);
|
|
486
|
+
if (this.config.logBodies && data) {
|
|
487
|
+
this.consola.debug("Response:", data);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Log error
|
|
492
|
+
*/
|
|
493
|
+
logError(request, error) {
|
|
494
|
+
if (!this.config.enabled || !this.config.logErrors) return;
|
|
495
|
+
const { method, url } = request;
|
|
496
|
+
const { message, statusCode, fieldErrors, duration } = error;
|
|
497
|
+
this.consola.error(
|
|
498
|
+
`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
|
|
499
|
+
);
|
|
500
|
+
this.consola.error("Message:", message);
|
|
501
|
+
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
502
|
+
this.consola.error("Field Errors:");
|
|
503
|
+
Object.entries(fieldErrors).forEach(([field, errors]) => {
|
|
504
|
+
errors.forEach((err) => {
|
|
505
|
+
this.consola.error(` \u2022 ${field}: ${err}`);
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Log general info
|
|
512
|
+
*/
|
|
513
|
+
info(message, ...args) {
|
|
514
|
+
if (!this.config.enabled) return;
|
|
515
|
+
this.consola.info(message, ...args);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Log warning
|
|
519
|
+
*/
|
|
520
|
+
warn(message, ...args) {
|
|
521
|
+
if (!this.config.enabled) return;
|
|
522
|
+
this.consola.warn(message, ...args);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Log error
|
|
526
|
+
*/
|
|
527
|
+
error(message, ...args) {
|
|
528
|
+
if (!this.config.enabled) return;
|
|
529
|
+
this.consola.error(message, ...args);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Log debug
|
|
533
|
+
*/
|
|
534
|
+
debug(message, ...args) {
|
|
535
|
+
if (!this.config.enabled) return;
|
|
536
|
+
this.consola.debug(message, ...args);
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Log success
|
|
540
|
+
*/
|
|
541
|
+
success(message, ...args) {
|
|
542
|
+
if (!this.config.enabled) return;
|
|
543
|
+
this.consola.success(message, ...args);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Create a sub-logger with prefix
|
|
547
|
+
*/
|
|
548
|
+
withTag(tag) {
|
|
549
|
+
return this.consola.withTag(tag);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
new APILogger();
|
|
553
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
554
|
+
retries: 3,
|
|
555
|
+
factor: 2,
|
|
556
|
+
minTimeout: 1e3,
|
|
557
|
+
maxTimeout: 6e4,
|
|
558
|
+
randomize: true,
|
|
559
|
+
onFailedAttempt: () => {
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
function shouldRetry(error) {
|
|
563
|
+
if (error instanceof NetworkError) {
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
if (error instanceof APIError) {
|
|
567
|
+
const status = error.statusCode;
|
|
568
|
+
if (status >= 500 && status < 600) {
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
if (status === 429) {
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
async function withRetry(fn, config) {
|
|
579
|
+
const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
580
|
+
return pRetry__default.default(
|
|
581
|
+
async () => {
|
|
582
|
+
try {
|
|
583
|
+
return await fn();
|
|
584
|
+
} catch (error) {
|
|
585
|
+
if (!shouldRetry(error)) {
|
|
586
|
+
throw new pRetry.AbortError(error);
|
|
587
|
+
}
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
retries: finalConfig.retries,
|
|
593
|
+
factor: finalConfig.factor,
|
|
594
|
+
minTimeout: finalConfig.minTimeout,
|
|
595
|
+
maxTimeout: finalConfig.maxTimeout,
|
|
596
|
+
randomize: finalConfig.randomize,
|
|
597
|
+
onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
|
|
598
|
+
const pRetryError = error;
|
|
599
|
+
finalConfig.onFailedAttempt({
|
|
600
|
+
error: pRetryError,
|
|
601
|
+
attemptNumber: pRetryError.attemptNumber,
|
|
602
|
+
retriesLeft: pRetryError.retriesLeft
|
|
603
|
+
});
|
|
604
|
+
} : void 0
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/api/generated/ext_newsletter/client.ts
|
|
610
|
+
var APIClient = class {
|
|
611
|
+
baseUrl;
|
|
612
|
+
httpClient;
|
|
613
|
+
logger = null;
|
|
614
|
+
retryConfig = null;
|
|
615
|
+
// Sub-clients
|
|
616
|
+
ext_newsletter_bulk_email;
|
|
617
|
+
ext_newsletter_campaigns;
|
|
618
|
+
ext_newsletter_logs;
|
|
619
|
+
ext_newsletter_newsletters;
|
|
620
|
+
ext_newsletter_subscriptions;
|
|
621
|
+
ext_newsletter_testing;
|
|
622
|
+
ext_newsletter_newsletter;
|
|
623
|
+
constructor(baseUrl, options) {
|
|
624
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
625
|
+
this.httpClient = options?.httpClient || new FetchAdapter();
|
|
626
|
+
if (options?.loggerConfig !== void 0) {
|
|
627
|
+
this.logger = new APILogger(options.loggerConfig);
|
|
628
|
+
}
|
|
629
|
+
if (options?.retryConfig !== void 0) {
|
|
630
|
+
this.retryConfig = options.retryConfig;
|
|
631
|
+
}
|
|
632
|
+
this.ext_newsletter_bulk_email = new ExtNewsletterBulkEmail(this);
|
|
633
|
+
this.ext_newsletter_campaigns = new ExtNewsletterCampaigns(this);
|
|
634
|
+
this.ext_newsletter_logs = new ExtNewsletterLogs(this);
|
|
635
|
+
this.ext_newsletter_newsletters = new ExtNewsletterNewsletters(this);
|
|
636
|
+
this.ext_newsletter_subscriptions = new ExtNewsletterSubscriptions(this);
|
|
637
|
+
this.ext_newsletter_testing = new ExtNewsletterTesting(this);
|
|
638
|
+
this.ext_newsletter_newsletter = new ExtNewsletterNewsletter(this);
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Get CSRF token from cookies (for SessionAuthentication).
|
|
642
|
+
*
|
|
643
|
+
* Returns null if cookie doesn't exist (JWT-only auth).
|
|
644
|
+
*/
|
|
645
|
+
getCsrfToken() {
|
|
646
|
+
const name = "csrftoken";
|
|
647
|
+
const value = `; ${document.cookie}`;
|
|
648
|
+
const parts = value.split(`; ${name}=`);
|
|
649
|
+
if (parts.length === 2) {
|
|
650
|
+
return parts.pop()?.split(";").shift() || null;
|
|
651
|
+
}
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Make HTTP request with Django CSRF and session handling.
|
|
656
|
+
* Automatically retries on network errors and 5xx server errors.
|
|
657
|
+
*/
|
|
658
|
+
async request(method, path, options) {
|
|
659
|
+
if (this.retryConfig) {
|
|
660
|
+
return withRetry(() => this._makeRequest(method, path, options), {
|
|
661
|
+
...this.retryConfig,
|
|
662
|
+
onFailedAttempt: (info) => {
|
|
663
|
+
if (this.logger) {
|
|
664
|
+
this.logger.warn(
|
|
665
|
+
`Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
this.retryConfig?.onFailedAttempt?.(info);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
return this._makeRequest(method, path, options);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Internal request method (without retry wrapper).
|
|
676
|
+
* Used by request() method with optional retry logic.
|
|
677
|
+
*/
|
|
678
|
+
async _makeRequest(method, path, options) {
|
|
679
|
+
const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
|
|
680
|
+
const startTime = Date.now();
|
|
681
|
+
const headers = {
|
|
682
|
+
...options?.headers || {}
|
|
683
|
+
};
|
|
684
|
+
if (!options?.formData && !headers["Content-Type"]) {
|
|
685
|
+
headers["Content-Type"] = "application/json";
|
|
686
|
+
}
|
|
687
|
+
if (this.logger) {
|
|
688
|
+
this.logger.logRequest({
|
|
689
|
+
method,
|
|
690
|
+
url,
|
|
691
|
+
headers,
|
|
692
|
+
body: options?.formData || options?.body,
|
|
693
|
+
timestamp: startTime
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
try {
|
|
697
|
+
const response = await this.httpClient.request({
|
|
698
|
+
method,
|
|
699
|
+
url,
|
|
700
|
+
headers,
|
|
701
|
+
params: options?.params,
|
|
702
|
+
body: options?.body,
|
|
703
|
+
formData: options?.formData
|
|
704
|
+
});
|
|
705
|
+
const duration = Date.now() - startTime;
|
|
706
|
+
if (response.status >= 400) {
|
|
707
|
+
const error = new APIError(
|
|
708
|
+
response.status,
|
|
709
|
+
response.statusText,
|
|
710
|
+
response.data,
|
|
711
|
+
url
|
|
712
|
+
);
|
|
713
|
+
if (this.logger) {
|
|
714
|
+
this.logger.logError(
|
|
715
|
+
{
|
|
716
|
+
method,
|
|
717
|
+
url,
|
|
718
|
+
headers,
|
|
719
|
+
body: options?.formData || options?.body,
|
|
720
|
+
timestamp: startTime
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
message: error.message,
|
|
724
|
+
statusCode: response.status,
|
|
725
|
+
duration,
|
|
726
|
+
timestamp: Date.now()
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
throw error;
|
|
731
|
+
}
|
|
732
|
+
if (this.logger) {
|
|
733
|
+
this.logger.logResponse(
|
|
734
|
+
{
|
|
735
|
+
method,
|
|
736
|
+
url,
|
|
737
|
+
headers,
|
|
738
|
+
body: options?.formData || options?.body,
|
|
739
|
+
timestamp: startTime
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
status: response.status,
|
|
743
|
+
statusText: response.statusText,
|
|
744
|
+
data: response.data,
|
|
745
|
+
duration,
|
|
746
|
+
timestamp: Date.now()
|
|
747
|
+
}
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
return response.data;
|
|
751
|
+
} catch (error) {
|
|
752
|
+
const duration = Date.now() - startTime;
|
|
753
|
+
if (error instanceof APIError) {
|
|
754
|
+
throw error;
|
|
755
|
+
}
|
|
756
|
+
const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
|
|
757
|
+
if (this.logger) {
|
|
758
|
+
if (isCORSError) {
|
|
759
|
+
this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
|
|
760
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
761
|
+
this.logger.error(` \u2192 Configure security_domains parameter on the server`);
|
|
762
|
+
} else {
|
|
763
|
+
this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
|
|
764
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (typeof window !== "undefined") {
|
|
768
|
+
try {
|
|
769
|
+
if (isCORSError) {
|
|
770
|
+
window.dispatchEvent(new CustomEvent("cors-error", {
|
|
771
|
+
detail: {
|
|
772
|
+
url,
|
|
773
|
+
method,
|
|
774
|
+
error: error instanceof Error ? error.message : String(error),
|
|
775
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
776
|
+
},
|
|
777
|
+
bubbles: true,
|
|
778
|
+
cancelable: false
|
|
779
|
+
}));
|
|
780
|
+
} else {
|
|
781
|
+
window.dispatchEvent(new CustomEvent("network-error", {
|
|
782
|
+
detail: {
|
|
783
|
+
url,
|
|
784
|
+
method,
|
|
785
|
+
error: error instanceof Error ? error.message : String(error),
|
|
786
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
787
|
+
},
|
|
788
|
+
bubbles: true,
|
|
789
|
+
cancelable: false
|
|
790
|
+
}));
|
|
791
|
+
}
|
|
792
|
+
} catch (eventError) {
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
|
|
796
|
+
if (this.logger) {
|
|
797
|
+
this.logger.logError(
|
|
798
|
+
{
|
|
799
|
+
method,
|
|
800
|
+
url,
|
|
801
|
+
headers,
|
|
802
|
+
body: options?.formData || options?.body,
|
|
803
|
+
timestamp: startTime
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
message: networkError.message,
|
|
807
|
+
duration,
|
|
808
|
+
timestamp: Date.now()
|
|
809
|
+
}
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
throw networkError;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
// src/api/generated/ext_newsletter/storage.ts
|
|
818
|
+
var LocalStorageAdapter = class {
|
|
819
|
+
logger;
|
|
820
|
+
constructor(logger) {
|
|
821
|
+
this.logger = logger;
|
|
822
|
+
}
|
|
823
|
+
getItem(key) {
|
|
824
|
+
try {
|
|
825
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
826
|
+
const value = localStorage.getItem(key);
|
|
827
|
+
this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
828
|
+
return value;
|
|
829
|
+
}
|
|
830
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
831
|
+
} catch (error) {
|
|
832
|
+
this.logger?.error("LocalStorage.getItem failed:", error);
|
|
833
|
+
}
|
|
834
|
+
return null;
|
|
835
|
+
}
|
|
836
|
+
setItem(key, value) {
|
|
837
|
+
try {
|
|
838
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
839
|
+
localStorage.setItem(key, value);
|
|
840
|
+
this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
|
|
841
|
+
} else {
|
|
842
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
843
|
+
}
|
|
844
|
+
} catch (error) {
|
|
845
|
+
this.logger?.error("LocalStorage.setItem failed:", error);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
removeItem(key) {
|
|
849
|
+
try {
|
|
850
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
851
|
+
localStorage.removeItem(key);
|
|
852
|
+
this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
|
|
853
|
+
} else {
|
|
854
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
855
|
+
}
|
|
856
|
+
} catch (error) {
|
|
857
|
+
this.logger?.error("LocalStorage.removeItem failed:", error);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
var CookieStorageAdapter = class {
|
|
862
|
+
logger;
|
|
863
|
+
constructor(logger) {
|
|
864
|
+
this.logger = logger;
|
|
865
|
+
}
|
|
866
|
+
getItem(key) {
|
|
867
|
+
try {
|
|
868
|
+
if (typeof document === "undefined") {
|
|
869
|
+
this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
const value = `; ${document.cookie}`;
|
|
873
|
+
const parts = value.split(`; ${key}=`);
|
|
874
|
+
if (parts.length === 2) {
|
|
875
|
+
const result = parts.pop()?.split(";").shift() || null;
|
|
876
|
+
this.logger?.debug(`CookieStorage.getItem("${key}"): ${result ? "found" : "not found"}`);
|
|
877
|
+
return result;
|
|
878
|
+
}
|
|
879
|
+
this.logger?.debug(`CookieStorage.getItem("${key}"): not found`);
|
|
880
|
+
} catch (error) {
|
|
881
|
+
this.logger?.error("CookieStorage.getItem failed:", error);
|
|
882
|
+
}
|
|
883
|
+
return null;
|
|
884
|
+
}
|
|
885
|
+
setItem(key, value) {
|
|
886
|
+
try {
|
|
887
|
+
if (typeof document !== "undefined") {
|
|
888
|
+
document.cookie = `${key}=${value}; path=/; max-age=31536000`;
|
|
889
|
+
this.logger?.debug(`CookieStorage.setItem("${key}"): success`);
|
|
890
|
+
} else {
|
|
891
|
+
this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
|
|
892
|
+
}
|
|
893
|
+
} catch (error) {
|
|
894
|
+
this.logger?.error("CookieStorage.setItem failed:", error);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
removeItem(key) {
|
|
898
|
+
try {
|
|
899
|
+
if (typeof document !== "undefined") {
|
|
900
|
+
document.cookie = `${key}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
|
901
|
+
this.logger?.debug(`CookieStorage.removeItem("${key}"): success`);
|
|
902
|
+
} else {
|
|
903
|
+
this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
|
|
904
|
+
}
|
|
905
|
+
} catch (error) {
|
|
906
|
+
this.logger?.error("CookieStorage.removeItem failed:", error);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
var MemoryStorageAdapter = class {
|
|
911
|
+
storage = /* @__PURE__ */ new Map();
|
|
912
|
+
logger;
|
|
913
|
+
constructor(logger) {
|
|
914
|
+
this.logger = logger;
|
|
915
|
+
}
|
|
916
|
+
getItem(key) {
|
|
917
|
+
const value = this.storage.get(key) || null;
|
|
918
|
+
this.logger?.debug(`MemoryStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
919
|
+
return value;
|
|
920
|
+
}
|
|
921
|
+
setItem(key, value) {
|
|
922
|
+
this.storage.set(key, value);
|
|
923
|
+
this.logger?.debug(`MemoryStorage.setItem("${key}"): success`);
|
|
924
|
+
}
|
|
925
|
+
removeItem(key) {
|
|
926
|
+
this.storage.delete(key);
|
|
927
|
+
this.logger?.debug(`MemoryStorage.removeItem("${key}"): success`);
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
// src/api/generated/ext_newsletter/enums.ts
|
|
932
|
+
var enums_exports = {};
|
|
933
|
+
__export(enums_exports, {
|
|
934
|
+
EmailLogStatus: () => EmailLogStatus,
|
|
935
|
+
NewsletterCampaignStatus: () => NewsletterCampaignStatus
|
|
936
|
+
});
|
|
937
|
+
var EmailLogStatus = /* @__PURE__ */ ((EmailLogStatus2) => {
|
|
938
|
+
EmailLogStatus2["PENDING"] = "pending";
|
|
939
|
+
EmailLogStatus2["SENT"] = "sent";
|
|
940
|
+
EmailLogStatus2["FAILED"] = "failed";
|
|
941
|
+
return EmailLogStatus2;
|
|
942
|
+
})(EmailLogStatus || {});
|
|
943
|
+
var NewsletterCampaignStatus = /* @__PURE__ */ ((NewsletterCampaignStatus2) => {
|
|
944
|
+
NewsletterCampaignStatus2["DRAFT"] = "draft";
|
|
945
|
+
NewsletterCampaignStatus2["SENDING"] = "sending";
|
|
946
|
+
NewsletterCampaignStatus2["SENT"] = "sent";
|
|
947
|
+
NewsletterCampaignStatus2["FAILED"] = "failed";
|
|
948
|
+
return NewsletterCampaignStatus2;
|
|
949
|
+
})(NewsletterCampaignStatus || {});
|
|
950
|
+
|
|
951
|
+
// src/api/generated/ext_newsletter/_utils/schemas/index.ts
|
|
952
|
+
var schemas_exports = {};
|
|
953
|
+
__export(schemas_exports, {
|
|
954
|
+
BulkEmailRequestSchema: () => BulkEmailRequestSchema,
|
|
955
|
+
BulkEmailResponseSchema: () => BulkEmailResponseSchema,
|
|
956
|
+
EmailLogSchema: () => EmailLogSchema,
|
|
957
|
+
ErrorResponseSchema: () => ErrorResponseSchema,
|
|
958
|
+
NewsletterCampaignRequestSchema: () => NewsletterCampaignRequestSchema,
|
|
959
|
+
NewsletterCampaignSchema: () => NewsletterCampaignSchema,
|
|
960
|
+
NewsletterSchema: () => NewsletterSchema,
|
|
961
|
+
NewsletterSubscriptionSchema: () => NewsletterSubscriptionSchema,
|
|
962
|
+
PaginatedEmailLogListSchema: () => PaginatedEmailLogListSchema,
|
|
963
|
+
PaginatedNewsletterCampaignListSchema: () => PaginatedNewsletterCampaignListSchema,
|
|
964
|
+
PaginatedNewsletterListSchema: () => PaginatedNewsletterListSchema,
|
|
965
|
+
PaginatedNewsletterSubscriptionListSchema: () => PaginatedNewsletterSubscriptionListSchema,
|
|
966
|
+
PatchedNewsletterCampaignRequestSchema: () => PatchedNewsletterCampaignRequestSchema,
|
|
967
|
+
PatchedUnsubscribeRequestSchema: () => PatchedUnsubscribeRequestSchema,
|
|
968
|
+
SendCampaignRequestSchema: () => SendCampaignRequestSchema,
|
|
969
|
+
SendCampaignResponseSchema: () => SendCampaignResponseSchema,
|
|
970
|
+
SubscribeRequestSchema: () => SubscribeRequestSchema,
|
|
971
|
+
SubscribeResponseSchema: () => SubscribeResponseSchema,
|
|
972
|
+
SuccessResponseSchema: () => SuccessResponseSchema,
|
|
973
|
+
TestEmailRequestSchema: () => TestEmailRequestSchema,
|
|
974
|
+
UnsubscribeRequestSchema: () => UnsubscribeRequestSchema,
|
|
975
|
+
UnsubscribeSchema: () => UnsubscribeSchema
|
|
976
|
+
});
|
|
977
|
+
var BulkEmailRequestSchema = zod.z.object({
|
|
978
|
+
recipients: zod.z.array(zod.z.email()),
|
|
979
|
+
subject: zod.z.string().min(1).max(255),
|
|
980
|
+
email_title: zod.z.string().min(1).max(255),
|
|
981
|
+
main_text: zod.z.string().min(1),
|
|
982
|
+
main_html_content: zod.z.string().optional(),
|
|
983
|
+
button_text: zod.z.string().max(100).optional(),
|
|
984
|
+
button_url: zod.z.url().optional(),
|
|
985
|
+
secondary_text: zod.z.string().optional()
|
|
986
|
+
});
|
|
987
|
+
var BulkEmailResponseSchema = zod.z.object({
|
|
988
|
+
success: zod.z.boolean(),
|
|
989
|
+
sent_count: zod.z.int(),
|
|
990
|
+
failed_count: zod.z.int(),
|
|
991
|
+
total_recipients: zod.z.int(),
|
|
992
|
+
error: zod.z.string().optional()
|
|
993
|
+
});
|
|
994
|
+
var EmailLogSchema = zod.z.object({
|
|
995
|
+
id: zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
996
|
+
user: zod.z.int().nullable(),
|
|
997
|
+
user_email: zod.z.string(),
|
|
998
|
+
newsletter: zod.z.int().nullable(),
|
|
999
|
+
newsletter_title: zod.z.string(),
|
|
1000
|
+
recipient: zod.z.string(),
|
|
1001
|
+
subject: zod.z.string(),
|
|
1002
|
+
body: zod.z.string(),
|
|
1003
|
+
status: zod.z.nativeEnum(EmailLogStatus),
|
|
1004
|
+
created_at: zod.z.iso.datetime(),
|
|
1005
|
+
sent_at: zod.z.iso.datetime().nullable(),
|
|
1006
|
+
error_message: zod.z.string().nullable()
|
|
1007
|
+
});
|
|
1008
|
+
var ErrorResponseSchema = zod.z.object({
|
|
1009
|
+
success: zod.z.boolean().optional(),
|
|
1010
|
+
message: zod.z.string()
|
|
1011
|
+
});
|
|
1012
|
+
var NewsletterSchema = zod.z.object({
|
|
1013
|
+
id: zod.z.int(),
|
|
1014
|
+
title: zod.z.string().max(255),
|
|
1015
|
+
description: zod.z.string().optional(),
|
|
1016
|
+
is_active: zod.z.boolean().optional(),
|
|
1017
|
+
auto_subscribe: zod.z.boolean().optional(),
|
|
1018
|
+
created_at: zod.z.iso.datetime(),
|
|
1019
|
+
updated_at: zod.z.iso.datetime(),
|
|
1020
|
+
subscribers_count: zod.z.int()
|
|
1021
|
+
});
|
|
1022
|
+
var NewsletterCampaignSchema = zod.z.object({
|
|
1023
|
+
id: zod.z.int(),
|
|
1024
|
+
newsletter: zod.z.int(),
|
|
1025
|
+
newsletter_title: zod.z.string(),
|
|
1026
|
+
subject: zod.z.string().max(255),
|
|
1027
|
+
email_title: zod.z.string().max(255),
|
|
1028
|
+
main_text: zod.z.string(),
|
|
1029
|
+
main_html_content: zod.z.string().optional(),
|
|
1030
|
+
button_text: zod.z.string().max(100).optional(),
|
|
1031
|
+
button_url: zod.z.url().optional(),
|
|
1032
|
+
secondary_text: zod.z.string().optional(),
|
|
1033
|
+
status: zod.z.nativeEnum(NewsletterCampaignStatus),
|
|
1034
|
+
created_at: zod.z.iso.datetime(),
|
|
1035
|
+
sent_at: zod.z.iso.datetime().nullable(),
|
|
1036
|
+
recipient_count: zod.z.int()
|
|
1037
|
+
});
|
|
1038
|
+
var NewsletterCampaignRequestSchema = zod.z.object({
|
|
1039
|
+
newsletter: zod.z.int(),
|
|
1040
|
+
subject: zod.z.string().min(1).max(255),
|
|
1041
|
+
email_title: zod.z.string().min(1).max(255),
|
|
1042
|
+
main_text: zod.z.string().min(1),
|
|
1043
|
+
main_html_content: zod.z.string().optional(),
|
|
1044
|
+
button_text: zod.z.string().max(100).optional(),
|
|
1045
|
+
button_url: zod.z.url().optional(),
|
|
1046
|
+
secondary_text: zod.z.string().optional()
|
|
1047
|
+
});
|
|
1048
|
+
var NewsletterSubscriptionSchema = zod.z.object({
|
|
1049
|
+
id: zod.z.int(),
|
|
1050
|
+
newsletter: zod.z.int(),
|
|
1051
|
+
newsletter_title: zod.z.string(),
|
|
1052
|
+
user: zod.z.int().nullable().optional(),
|
|
1053
|
+
user_email: zod.z.string(),
|
|
1054
|
+
email: zod.z.email(),
|
|
1055
|
+
is_active: zod.z.boolean().optional(),
|
|
1056
|
+
subscribed_at: zod.z.iso.datetime(),
|
|
1057
|
+
unsubscribed_at: zod.z.iso.datetime().nullable()
|
|
1058
|
+
});
|
|
1059
|
+
var PaginatedEmailLogListSchema = zod.z.object({
|
|
1060
|
+
count: zod.z.int(),
|
|
1061
|
+
page: zod.z.int(),
|
|
1062
|
+
pages: zod.z.int(),
|
|
1063
|
+
page_size: zod.z.int(),
|
|
1064
|
+
has_next: zod.z.boolean(),
|
|
1065
|
+
has_previous: zod.z.boolean(),
|
|
1066
|
+
next_page: zod.z.int().nullable().optional(),
|
|
1067
|
+
previous_page: zod.z.int().nullable().optional(),
|
|
1068
|
+
results: zod.z.array(EmailLogSchema)
|
|
1069
|
+
});
|
|
1070
|
+
var PaginatedNewsletterCampaignListSchema = zod.z.object({
|
|
1071
|
+
count: zod.z.int(),
|
|
1072
|
+
page: zod.z.int(),
|
|
1073
|
+
pages: zod.z.int(),
|
|
1074
|
+
page_size: zod.z.int(),
|
|
1075
|
+
has_next: zod.z.boolean(),
|
|
1076
|
+
has_previous: zod.z.boolean(),
|
|
1077
|
+
next_page: zod.z.int().nullable().optional(),
|
|
1078
|
+
previous_page: zod.z.int().nullable().optional(),
|
|
1079
|
+
results: zod.z.array(NewsletterCampaignSchema)
|
|
1080
|
+
});
|
|
1081
|
+
var PaginatedNewsletterListSchema = zod.z.object({
|
|
1082
|
+
count: zod.z.int(),
|
|
1083
|
+
page: zod.z.int(),
|
|
1084
|
+
pages: zod.z.int(),
|
|
1085
|
+
page_size: zod.z.int(),
|
|
1086
|
+
has_next: zod.z.boolean(),
|
|
1087
|
+
has_previous: zod.z.boolean(),
|
|
1088
|
+
next_page: zod.z.int().nullable().optional(),
|
|
1089
|
+
previous_page: zod.z.int().nullable().optional(),
|
|
1090
|
+
results: zod.z.array(NewsletterSchema)
|
|
1091
|
+
});
|
|
1092
|
+
var PaginatedNewsletterSubscriptionListSchema = zod.z.object({
|
|
1093
|
+
count: zod.z.int(),
|
|
1094
|
+
page: zod.z.int(),
|
|
1095
|
+
pages: zod.z.int(),
|
|
1096
|
+
page_size: zod.z.int(),
|
|
1097
|
+
has_next: zod.z.boolean(),
|
|
1098
|
+
has_previous: zod.z.boolean(),
|
|
1099
|
+
next_page: zod.z.int().nullable().optional(),
|
|
1100
|
+
previous_page: zod.z.int().nullable().optional(),
|
|
1101
|
+
results: zod.z.array(NewsletterSubscriptionSchema)
|
|
1102
|
+
});
|
|
1103
|
+
var PatchedNewsletterCampaignRequestSchema = zod.z.object({
|
|
1104
|
+
newsletter: zod.z.int().optional(),
|
|
1105
|
+
subject: zod.z.string().min(1).max(255).optional(),
|
|
1106
|
+
email_title: zod.z.string().min(1).max(255).optional(),
|
|
1107
|
+
main_text: zod.z.string().min(1).optional(),
|
|
1108
|
+
main_html_content: zod.z.string().optional(),
|
|
1109
|
+
button_text: zod.z.string().max(100).optional(),
|
|
1110
|
+
button_url: zod.z.url().optional(),
|
|
1111
|
+
secondary_text: zod.z.string().optional()
|
|
1112
|
+
});
|
|
1113
|
+
var PatchedUnsubscribeRequestSchema = zod.z.object({
|
|
1114
|
+
subscription_id: zod.z.int().optional()
|
|
1115
|
+
});
|
|
1116
|
+
var SendCampaignRequestSchema = zod.z.object({
|
|
1117
|
+
campaign_id: zod.z.int()
|
|
1118
|
+
});
|
|
1119
|
+
var SendCampaignResponseSchema = zod.z.object({
|
|
1120
|
+
success: zod.z.boolean(),
|
|
1121
|
+
message: zod.z.string().optional(),
|
|
1122
|
+
sent_count: zod.z.int().optional(),
|
|
1123
|
+
error: zod.z.string().optional()
|
|
1124
|
+
});
|
|
1125
|
+
var SubscribeRequestSchema = zod.z.object({
|
|
1126
|
+
newsletter_id: zod.z.int(),
|
|
1127
|
+
email: zod.z.email()
|
|
1128
|
+
});
|
|
1129
|
+
var SubscribeResponseSchema = zod.z.object({
|
|
1130
|
+
success: zod.z.boolean(),
|
|
1131
|
+
message: zod.z.string(),
|
|
1132
|
+
subscription_id: zod.z.int().optional()
|
|
1133
|
+
});
|
|
1134
|
+
var SuccessResponseSchema = zod.z.object({
|
|
1135
|
+
success: zod.z.boolean(),
|
|
1136
|
+
message: zod.z.string()
|
|
1137
|
+
});
|
|
1138
|
+
var TestEmailRequestSchema = zod.z.object({
|
|
1139
|
+
email: zod.z.email(),
|
|
1140
|
+
subject: zod.z.string().min(1).max(255).optional(),
|
|
1141
|
+
message: zod.z.string().min(1).optional()
|
|
1142
|
+
});
|
|
1143
|
+
var UnsubscribeSchema = zod.z.object({
|
|
1144
|
+
subscription_id: zod.z.int()
|
|
1145
|
+
});
|
|
1146
|
+
var UnsubscribeRequestSchema = zod.z.object({
|
|
1147
|
+
subscription_id: zod.z.int()
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// src/api/generated/ext_newsletter/validation-events.ts
|
|
1151
|
+
function dispatchValidationError(detail) {
|
|
1152
|
+
if (typeof window === "undefined") {
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
try {
|
|
1156
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1157
|
+
detail,
|
|
1158
|
+
bubbles: true,
|
|
1159
|
+
cancelable: false
|
|
1160
|
+
});
|
|
1161
|
+
window.dispatchEvent(event);
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
console.warn("Failed to dispatch validation error event:", error);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
function onValidationError(callback) {
|
|
1167
|
+
if (typeof window === "undefined") {
|
|
1168
|
+
return () => {
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
const handler = (event) => {
|
|
1172
|
+
if (event instanceof CustomEvent) {
|
|
1173
|
+
callback(event.detail);
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
window.addEventListener("zod-validation-error", handler);
|
|
1177
|
+
return () => {
|
|
1178
|
+
window.removeEventListener("zod-validation-error", handler);
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
function formatZodError(error) {
|
|
1182
|
+
const issues = error.issues.map((issue, index) => {
|
|
1183
|
+
const path = issue.path.join(".") || "root";
|
|
1184
|
+
const parts = [`${index + 1}. ${path}: ${issue.message}`];
|
|
1185
|
+
if ("expected" in issue && issue.expected) {
|
|
1186
|
+
parts.push(` Expected: ${issue.expected}`);
|
|
1187
|
+
}
|
|
1188
|
+
if ("received" in issue && issue.received) {
|
|
1189
|
+
parts.push(` Received: ${issue.received}`);
|
|
1190
|
+
}
|
|
1191
|
+
return parts.join("\n");
|
|
1192
|
+
});
|
|
1193
|
+
return issues.join("\n");
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// src/api/generated/ext_newsletter/_utils/fetchers/index.ts
|
|
1197
|
+
var fetchers_exports = {};
|
|
1198
|
+
__export(fetchers_exports, {
|
|
1199
|
+
createNewsletterBulkCreate: () => createNewsletterBulkCreate,
|
|
1200
|
+
createNewsletterCampaignsCreate: () => createNewsletterCampaignsCreate,
|
|
1201
|
+
createNewsletterCampaignsSendCreate: () => createNewsletterCampaignsSendCreate,
|
|
1202
|
+
createNewsletterSubscribeCreate: () => createNewsletterSubscribeCreate,
|
|
1203
|
+
createNewsletterTestCreate: () => createNewsletterTestCreate,
|
|
1204
|
+
createNewsletterUnsubscribeCreate: () => createNewsletterUnsubscribeCreate,
|
|
1205
|
+
deleteNewsletterCampaignsDestroy: () => deleteNewsletterCampaignsDestroy,
|
|
1206
|
+
getNewsletterCampaignsList: () => getNewsletterCampaignsList,
|
|
1207
|
+
getNewsletterCampaignsRetrieve: () => getNewsletterCampaignsRetrieve,
|
|
1208
|
+
getNewsletterLogsList: () => getNewsletterLogsList,
|
|
1209
|
+
getNewsletterNewslettersList: () => getNewsletterNewslettersList,
|
|
1210
|
+
getNewsletterNewslettersRetrieve: () => getNewsletterNewslettersRetrieve,
|
|
1211
|
+
getNewsletterSubscriptionsList: () => getNewsletterSubscriptionsList,
|
|
1212
|
+
partialUpdateNewsletterCampaignsPartialUpdate: () => partialUpdateNewsletterCampaignsPartialUpdate,
|
|
1213
|
+
partialUpdateNewsletterUnsubscribePartialUpdate: () => partialUpdateNewsletterUnsubscribePartialUpdate,
|
|
1214
|
+
updateNewsletterCampaignsUpdate: () => updateNewsletterCampaignsUpdate,
|
|
1215
|
+
updateNewsletterUnsubscribeUpdate: () => updateNewsletterUnsubscribeUpdate
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1218
|
+
// src/api/generated/ext_newsletter/api-instance.ts
|
|
1219
|
+
var globalAPI = null;
|
|
1220
|
+
function getAPIInstance() {
|
|
1221
|
+
if (!globalAPI) {
|
|
1222
|
+
throw new Error(
|
|
1223
|
+
'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" })'
|
|
1224
|
+
);
|
|
1225
|
+
}
|
|
1226
|
+
return globalAPI;
|
|
1227
|
+
}
|
|
1228
|
+
function isAPIConfigured() {
|
|
1229
|
+
return globalAPI !== null;
|
|
1230
|
+
}
|
|
1231
|
+
function configureAPI(config) {
|
|
1232
|
+
globalAPI = new API(config.baseUrl, config.options);
|
|
1233
|
+
if (config.token) {
|
|
1234
|
+
globalAPI.setToken(config.token, config.refreshToken);
|
|
1235
|
+
}
|
|
1236
|
+
return globalAPI;
|
|
1237
|
+
}
|
|
1238
|
+
function reconfigureAPI(updates) {
|
|
1239
|
+
const instance = getAPIInstance();
|
|
1240
|
+
if (updates.baseUrl) {
|
|
1241
|
+
instance.setBaseUrl(updates.baseUrl);
|
|
1242
|
+
}
|
|
1243
|
+
if (updates.token) {
|
|
1244
|
+
instance.setToken(updates.token, updates.refreshToken);
|
|
1245
|
+
}
|
|
1246
|
+
return instance;
|
|
1247
|
+
}
|
|
1248
|
+
function clearAPITokens() {
|
|
1249
|
+
const instance = getAPIInstance();
|
|
1250
|
+
instance.clearTokens();
|
|
1251
|
+
}
|
|
1252
|
+
function resetAPI() {
|
|
1253
|
+
if (globalAPI) {
|
|
1254
|
+
globalAPI.clearTokens();
|
|
1255
|
+
}
|
|
1256
|
+
globalAPI = null;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// src/api/generated/ext_newsletter/_utils/fetchers/ext_newsletter__newsletter.ts
|
|
1260
|
+
async function partialUpdateNewsletterCampaignsPartialUpdate(id, data, client) {
|
|
1261
|
+
const api = client || getAPIInstance();
|
|
1262
|
+
const response = await api.ext_newsletter_newsletter.campaignsPartialUpdate(id, data);
|
|
1263
|
+
try {
|
|
1264
|
+
return NewsletterCampaignSchema.parse(response);
|
|
1265
|
+
} catch (error) {
|
|
1266
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1267
|
+
consola.consola.box(`partialUpdateNewsletterCampaignsPartialUpdate
|
|
1268
|
+
Path: /cfg/newsletter/campaigns/{id}/
|
|
1269
|
+
Method: PATCH`);
|
|
1270
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1271
|
+
consola.consola.error("Validation Issues:");
|
|
1272
|
+
error.issues.forEach((issue, index) => {
|
|
1273
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1274
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1275
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1276
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
consola.consola.error("Response data:", response);
|
|
1280
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1281
|
+
try {
|
|
1282
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1283
|
+
detail: {
|
|
1284
|
+
operation: "partialUpdateNewsletterCampaignsPartialUpdate",
|
|
1285
|
+
path: "/cfg/newsletter/campaigns/{id}/",
|
|
1286
|
+
method: "PATCH",
|
|
1287
|
+
error,
|
|
1288
|
+
response,
|
|
1289
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1290
|
+
},
|
|
1291
|
+
bubbles: true,
|
|
1292
|
+
cancelable: false
|
|
1293
|
+
});
|
|
1294
|
+
window.dispatchEvent(event);
|
|
1295
|
+
} catch (eventError) {
|
|
1296
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
throw error;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
async function updateNewsletterUnsubscribeUpdate(data, client) {
|
|
1303
|
+
const api = client || getAPIInstance();
|
|
1304
|
+
const response = await api.ext_newsletter_newsletter.unsubscribeUpdate(data);
|
|
1305
|
+
try {
|
|
1306
|
+
return UnsubscribeSchema.parse(response);
|
|
1307
|
+
} catch (error) {
|
|
1308
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1309
|
+
consola.consola.box(`updateNewsletterUnsubscribeUpdate
|
|
1310
|
+
Path: /cfg/newsletter/unsubscribe/
|
|
1311
|
+
Method: PUT`);
|
|
1312
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1313
|
+
consola.consola.error("Validation Issues:");
|
|
1314
|
+
error.issues.forEach((issue, index) => {
|
|
1315
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1316
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1317
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1318
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
consola.consola.error("Response data:", response);
|
|
1322
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1323
|
+
try {
|
|
1324
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1325
|
+
detail: {
|
|
1326
|
+
operation: "updateNewsletterUnsubscribeUpdate",
|
|
1327
|
+
path: "/cfg/newsletter/unsubscribe/",
|
|
1328
|
+
method: "PUT",
|
|
1329
|
+
error,
|
|
1330
|
+
response,
|
|
1331
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1332
|
+
},
|
|
1333
|
+
bubbles: true,
|
|
1334
|
+
cancelable: false
|
|
1335
|
+
});
|
|
1336
|
+
window.dispatchEvent(event);
|
|
1337
|
+
} catch (eventError) {
|
|
1338
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
throw error;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
async function partialUpdateNewsletterUnsubscribePartialUpdate(data, client) {
|
|
1345
|
+
const api = client || getAPIInstance();
|
|
1346
|
+
const response = await api.ext_newsletter_newsletter.unsubscribePartialUpdate(data);
|
|
1347
|
+
try {
|
|
1348
|
+
return UnsubscribeSchema.parse(response);
|
|
1349
|
+
} catch (error) {
|
|
1350
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1351
|
+
consola.consola.box(`partialUpdateNewsletterUnsubscribePartialUpdate
|
|
1352
|
+
Path: /cfg/newsletter/unsubscribe/
|
|
1353
|
+
Method: PATCH`);
|
|
1354
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1355
|
+
consola.consola.error("Validation Issues:");
|
|
1356
|
+
error.issues.forEach((issue, index) => {
|
|
1357
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1358
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1359
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1360
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
consola.consola.error("Response data:", response);
|
|
1364
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1365
|
+
try {
|
|
1366
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1367
|
+
detail: {
|
|
1368
|
+
operation: "partialUpdateNewsletterUnsubscribePartialUpdate",
|
|
1369
|
+
path: "/cfg/newsletter/unsubscribe/",
|
|
1370
|
+
method: "PATCH",
|
|
1371
|
+
error,
|
|
1372
|
+
response,
|
|
1373
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1374
|
+
},
|
|
1375
|
+
bubbles: true,
|
|
1376
|
+
cancelable: false
|
|
1377
|
+
});
|
|
1378
|
+
window.dispatchEvent(event);
|
|
1379
|
+
} catch (eventError) {
|
|
1380
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
throw error;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
async function createNewsletterBulkCreate(data, client) {
|
|
1387
|
+
const api = client || getAPIInstance();
|
|
1388
|
+
const response = await api.ext_newsletter_bulk_email.newsletterBulkCreate(data);
|
|
1389
|
+
try {
|
|
1390
|
+
return BulkEmailResponseSchema.parse(response);
|
|
1391
|
+
} catch (error) {
|
|
1392
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1393
|
+
consola.consola.box(`createNewsletterBulkCreate
|
|
1394
|
+
Path: /cfg/newsletter/bulk/
|
|
1395
|
+
Method: POST`);
|
|
1396
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1397
|
+
consola.consola.error("Validation Issues:");
|
|
1398
|
+
error.issues.forEach((issue, index) => {
|
|
1399
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1400
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1401
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1402
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
consola.consola.error("Response data:", response);
|
|
1406
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1407
|
+
try {
|
|
1408
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1409
|
+
detail: {
|
|
1410
|
+
operation: "createNewsletterBulkCreate",
|
|
1411
|
+
path: "/cfg/newsletter/bulk/",
|
|
1412
|
+
method: "POST",
|
|
1413
|
+
error,
|
|
1414
|
+
response,
|
|
1415
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1416
|
+
},
|
|
1417
|
+
bubbles: true,
|
|
1418
|
+
cancelable: false
|
|
1419
|
+
});
|
|
1420
|
+
window.dispatchEvent(event);
|
|
1421
|
+
} catch (eventError) {
|
|
1422
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
throw error;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
async function getNewsletterCampaignsList(params, client) {
|
|
1429
|
+
const api = client || getAPIInstance();
|
|
1430
|
+
const response = await api.ext_newsletter_campaigns.newsletterCampaignsList(params?.page, params?.page_size);
|
|
1431
|
+
try {
|
|
1432
|
+
return PaginatedNewsletterCampaignListSchema.parse(response);
|
|
1433
|
+
} catch (error) {
|
|
1434
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1435
|
+
consola.consola.box(`getNewsletterCampaignsList
|
|
1436
|
+
Path: /cfg/newsletter/campaigns/
|
|
1437
|
+
Method: GET`);
|
|
1438
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1439
|
+
consola.consola.error("Validation Issues:");
|
|
1440
|
+
error.issues.forEach((issue, index) => {
|
|
1441
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1442
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1443
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1444
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
consola.consola.error("Response data:", response);
|
|
1448
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1449
|
+
try {
|
|
1450
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1451
|
+
detail: {
|
|
1452
|
+
operation: "getNewsletterCampaignsList",
|
|
1453
|
+
path: "/cfg/newsletter/campaigns/",
|
|
1454
|
+
method: "GET",
|
|
1455
|
+
error,
|
|
1456
|
+
response,
|
|
1457
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1458
|
+
},
|
|
1459
|
+
bubbles: true,
|
|
1460
|
+
cancelable: false
|
|
1461
|
+
});
|
|
1462
|
+
window.dispatchEvent(event);
|
|
1463
|
+
} catch (eventError) {
|
|
1464
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
throw error;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
async function createNewsletterCampaignsCreate(data, client) {
|
|
1471
|
+
const api = client || getAPIInstance();
|
|
1472
|
+
const response = await api.ext_newsletter_campaigns.newsletterCampaignsCreate(data);
|
|
1473
|
+
try {
|
|
1474
|
+
return NewsletterCampaignSchema.parse(response);
|
|
1475
|
+
} catch (error) {
|
|
1476
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1477
|
+
consola.consola.box(`createNewsletterCampaignsCreate
|
|
1478
|
+
Path: /cfg/newsletter/campaigns/
|
|
1479
|
+
Method: POST`);
|
|
1480
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1481
|
+
consola.consola.error("Validation Issues:");
|
|
1482
|
+
error.issues.forEach((issue, index) => {
|
|
1483
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1484
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1485
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1486
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
consola.consola.error("Response data:", response);
|
|
1490
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1491
|
+
try {
|
|
1492
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1493
|
+
detail: {
|
|
1494
|
+
operation: "createNewsletterCampaignsCreate",
|
|
1495
|
+
path: "/cfg/newsletter/campaigns/",
|
|
1496
|
+
method: "POST",
|
|
1497
|
+
error,
|
|
1498
|
+
response,
|
|
1499
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1500
|
+
},
|
|
1501
|
+
bubbles: true,
|
|
1502
|
+
cancelable: false
|
|
1503
|
+
});
|
|
1504
|
+
window.dispatchEvent(event);
|
|
1505
|
+
} catch (eventError) {
|
|
1506
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
throw error;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
async function getNewsletterCampaignsRetrieve(id, client) {
|
|
1513
|
+
const api = client || getAPIInstance();
|
|
1514
|
+
const response = await api.ext_newsletter_campaigns.newsletterCampaignsRetrieve(id);
|
|
1515
|
+
try {
|
|
1516
|
+
return NewsletterCampaignSchema.parse(response);
|
|
1517
|
+
} catch (error) {
|
|
1518
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1519
|
+
consola.consola.box(`getNewsletterCampaignsRetrieve
|
|
1520
|
+
Path: /cfg/newsletter/campaigns/{id}/
|
|
1521
|
+
Method: GET`);
|
|
1522
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1523
|
+
consola.consola.error("Validation Issues:");
|
|
1524
|
+
error.issues.forEach((issue, index) => {
|
|
1525
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1526
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1527
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1528
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
consola.consola.error("Response data:", response);
|
|
1532
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1533
|
+
try {
|
|
1534
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1535
|
+
detail: {
|
|
1536
|
+
operation: "getNewsletterCampaignsRetrieve",
|
|
1537
|
+
path: "/cfg/newsletter/campaigns/{id}/",
|
|
1538
|
+
method: "GET",
|
|
1539
|
+
error,
|
|
1540
|
+
response,
|
|
1541
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1542
|
+
},
|
|
1543
|
+
bubbles: true,
|
|
1544
|
+
cancelable: false
|
|
1545
|
+
});
|
|
1546
|
+
window.dispatchEvent(event);
|
|
1547
|
+
} catch (eventError) {
|
|
1548
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
throw error;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
async function updateNewsletterCampaignsUpdate(id, data, client) {
|
|
1555
|
+
const api = client || getAPIInstance();
|
|
1556
|
+
const response = await api.ext_newsletter_campaigns.newsletterCampaignsUpdate(id, data);
|
|
1557
|
+
try {
|
|
1558
|
+
return NewsletterCampaignSchema.parse(response);
|
|
1559
|
+
} catch (error) {
|
|
1560
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1561
|
+
consola.consola.box(`updateNewsletterCampaignsUpdate
|
|
1562
|
+
Path: /cfg/newsletter/campaigns/{id}/
|
|
1563
|
+
Method: PUT`);
|
|
1564
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1565
|
+
consola.consola.error("Validation Issues:");
|
|
1566
|
+
error.issues.forEach((issue, index) => {
|
|
1567
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1568
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1569
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1570
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
consola.consola.error("Response data:", response);
|
|
1574
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1575
|
+
try {
|
|
1576
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1577
|
+
detail: {
|
|
1578
|
+
operation: "updateNewsletterCampaignsUpdate",
|
|
1579
|
+
path: "/cfg/newsletter/campaigns/{id}/",
|
|
1580
|
+
method: "PUT",
|
|
1581
|
+
error,
|
|
1582
|
+
response,
|
|
1583
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1584
|
+
},
|
|
1585
|
+
bubbles: true,
|
|
1586
|
+
cancelable: false
|
|
1587
|
+
});
|
|
1588
|
+
window.dispatchEvent(event);
|
|
1589
|
+
} catch (eventError) {
|
|
1590
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
throw error;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
async function deleteNewsletterCampaignsDestroy(id, client) {
|
|
1597
|
+
const api = client || getAPIInstance();
|
|
1598
|
+
const response = await api.ext_newsletter_campaigns.newsletterCampaignsDestroy(id);
|
|
1599
|
+
return response;
|
|
1600
|
+
}
|
|
1601
|
+
async function createNewsletterCampaignsSendCreate(data, client) {
|
|
1602
|
+
const api = client || getAPIInstance();
|
|
1603
|
+
const response = await api.ext_newsletter_campaigns.newsletterCampaignsSendCreate(data);
|
|
1604
|
+
try {
|
|
1605
|
+
return SendCampaignResponseSchema.parse(response);
|
|
1606
|
+
} catch (error) {
|
|
1607
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1608
|
+
consola.consola.box(`createNewsletterCampaignsSendCreate
|
|
1609
|
+
Path: /cfg/newsletter/campaigns/send/
|
|
1610
|
+
Method: POST`);
|
|
1611
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1612
|
+
consola.consola.error("Validation Issues:");
|
|
1613
|
+
error.issues.forEach((issue, index) => {
|
|
1614
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1615
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1616
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1617
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
consola.consola.error("Response data:", response);
|
|
1621
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1622
|
+
try {
|
|
1623
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1624
|
+
detail: {
|
|
1625
|
+
operation: "createNewsletterCampaignsSendCreate",
|
|
1626
|
+
path: "/cfg/newsletter/campaigns/send/",
|
|
1627
|
+
method: "POST",
|
|
1628
|
+
error,
|
|
1629
|
+
response,
|
|
1630
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1631
|
+
},
|
|
1632
|
+
bubbles: true,
|
|
1633
|
+
cancelable: false
|
|
1634
|
+
});
|
|
1635
|
+
window.dispatchEvent(event);
|
|
1636
|
+
} catch (eventError) {
|
|
1637
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
throw error;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
async function getNewsletterLogsList(params, client) {
|
|
1644
|
+
const api = client || getAPIInstance();
|
|
1645
|
+
const response = await api.ext_newsletter_logs.newsletterLogsList(params?.page, params?.page_size);
|
|
1646
|
+
try {
|
|
1647
|
+
return PaginatedEmailLogListSchema.parse(response);
|
|
1648
|
+
} catch (error) {
|
|
1649
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1650
|
+
consola.consola.box(`getNewsletterLogsList
|
|
1651
|
+
Path: /cfg/newsletter/logs/
|
|
1652
|
+
Method: GET`);
|
|
1653
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1654
|
+
consola.consola.error("Validation Issues:");
|
|
1655
|
+
error.issues.forEach((issue, index) => {
|
|
1656
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1657
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1658
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1659
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
consola.consola.error("Response data:", response);
|
|
1663
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1664
|
+
try {
|
|
1665
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1666
|
+
detail: {
|
|
1667
|
+
operation: "getNewsletterLogsList",
|
|
1668
|
+
path: "/cfg/newsletter/logs/",
|
|
1669
|
+
method: "GET",
|
|
1670
|
+
error,
|
|
1671
|
+
response,
|
|
1672
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1673
|
+
},
|
|
1674
|
+
bubbles: true,
|
|
1675
|
+
cancelable: false
|
|
1676
|
+
});
|
|
1677
|
+
window.dispatchEvent(event);
|
|
1678
|
+
} catch (eventError) {
|
|
1679
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
throw error;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
async function getNewsletterNewslettersList(params, client) {
|
|
1686
|
+
const api = client || getAPIInstance();
|
|
1687
|
+
const response = await api.ext_newsletter_newsletters.newsletterNewslettersList(params?.page, params?.page_size);
|
|
1688
|
+
try {
|
|
1689
|
+
return PaginatedNewsletterListSchema.parse(response);
|
|
1690
|
+
} catch (error) {
|
|
1691
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1692
|
+
consola.consola.box(`getNewsletterNewslettersList
|
|
1693
|
+
Path: /cfg/newsletter/newsletters/
|
|
1694
|
+
Method: GET`);
|
|
1695
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1696
|
+
consola.consola.error("Validation Issues:");
|
|
1697
|
+
error.issues.forEach((issue, index) => {
|
|
1698
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1699
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1700
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1701
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
consola.consola.error("Response data:", response);
|
|
1705
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1706
|
+
try {
|
|
1707
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1708
|
+
detail: {
|
|
1709
|
+
operation: "getNewsletterNewslettersList",
|
|
1710
|
+
path: "/cfg/newsletter/newsletters/",
|
|
1711
|
+
method: "GET",
|
|
1712
|
+
error,
|
|
1713
|
+
response,
|
|
1714
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1715
|
+
},
|
|
1716
|
+
bubbles: true,
|
|
1717
|
+
cancelable: false
|
|
1718
|
+
});
|
|
1719
|
+
window.dispatchEvent(event);
|
|
1720
|
+
} catch (eventError) {
|
|
1721
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
throw error;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
async function getNewsletterNewslettersRetrieve(id, client) {
|
|
1728
|
+
const api = client || getAPIInstance();
|
|
1729
|
+
const response = await api.ext_newsletter_newsletters.newsletterNewslettersRetrieve(id);
|
|
1730
|
+
try {
|
|
1731
|
+
return NewsletterSchema.parse(response);
|
|
1732
|
+
} catch (error) {
|
|
1733
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1734
|
+
consola.consola.box(`getNewsletterNewslettersRetrieve
|
|
1735
|
+
Path: /cfg/newsletter/newsletters/{id}/
|
|
1736
|
+
Method: GET`);
|
|
1737
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1738
|
+
consola.consola.error("Validation Issues:");
|
|
1739
|
+
error.issues.forEach((issue, index) => {
|
|
1740
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1741
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1742
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1743
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
consola.consola.error("Response data:", response);
|
|
1747
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1748
|
+
try {
|
|
1749
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1750
|
+
detail: {
|
|
1751
|
+
operation: "getNewsletterNewslettersRetrieve",
|
|
1752
|
+
path: "/cfg/newsletter/newsletters/{id}/",
|
|
1753
|
+
method: "GET",
|
|
1754
|
+
error,
|
|
1755
|
+
response,
|
|
1756
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1757
|
+
},
|
|
1758
|
+
bubbles: true,
|
|
1759
|
+
cancelable: false
|
|
1760
|
+
});
|
|
1761
|
+
window.dispatchEvent(event);
|
|
1762
|
+
} catch (eventError) {
|
|
1763
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
throw error;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
async function createNewsletterSubscribeCreate(data, client) {
|
|
1770
|
+
const api = client || getAPIInstance();
|
|
1771
|
+
const response = await api.ext_newsletter_subscriptions.newsletterSubscribeCreate(data);
|
|
1772
|
+
try {
|
|
1773
|
+
return SubscribeResponseSchema.parse(response);
|
|
1774
|
+
} catch (error) {
|
|
1775
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1776
|
+
consola.consola.box(`createNewsletterSubscribeCreate
|
|
1777
|
+
Path: /cfg/newsletter/subscribe/
|
|
1778
|
+
Method: POST`);
|
|
1779
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1780
|
+
consola.consola.error("Validation Issues:");
|
|
1781
|
+
error.issues.forEach((issue, index) => {
|
|
1782
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1783
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1784
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1785
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
consola.consola.error("Response data:", response);
|
|
1789
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1790
|
+
try {
|
|
1791
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1792
|
+
detail: {
|
|
1793
|
+
operation: "createNewsletterSubscribeCreate",
|
|
1794
|
+
path: "/cfg/newsletter/subscribe/",
|
|
1795
|
+
method: "POST",
|
|
1796
|
+
error,
|
|
1797
|
+
response,
|
|
1798
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1799
|
+
},
|
|
1800
|
+
bubbles: true,
|
|
1801
|
+
cancelable: false
|
|
1802
|
+
});
|
|
1803
|
+
window.dispatchEvent(event);
|
|
1804
|
+
} catch (eventError) {
|
|
1805
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
throw error;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
async function getNewsletterSubscriptionsList(params, client) {
|
|
1812
|
+
const api = client || getAPIInstance();
|
|
1813
|
+
const response = await api.ext_newsletter_subscriptions.newsletterSubscriptionsList(params?.page, params?.page_size);
|
|
1814
|
+
try {
|
|
1815
|
+
return PaginatedNewsletterSubscriptionListSchema.parse(response);
|
|
1816
|
+
} catch (error) {
|
|
1817
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1818
|
+
consola.consola.box(`getNewsletterSubscriptionsList
|
|
1819
|
+
Path: /cfg/newsletter/subscriptions/
|
|
1820
|
+
Method: GET`);
|
|
1821
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1822
|
+
consola.consola.error("Validation Issues:");
|
|
1823
|
+
error.issues.forEach((issue, index) => {
|
|
1824
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1825
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1826
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1827
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
consola.consola.error("Response data:", response);
|
|
1831
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1832
|
+
try {
|
|
1833
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1834
|
+
detail: {
|
|
1835
|
+
operation: "getNewsletterSubscriptionsList",
|
|
1836
|
+
path: "/cfg/newsletter/subscriptions/",
|
|
1837
|
+
method: "GET",
|
|
1838
|
+
error,
|
|
1839
|
+
response,
|
|
1840
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1841
|
+
},
|
|
1842
|
+
bubbles: true,
|
|
1843
|
+
cancelable: false
|
|
1844
|
+
});
|
|
1845
|
+
window.dispatchEvent(event);
|
|
1846
|
+
} catch (eventError) {
|
|
1847
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
throw error;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
async function createNewsletterUnsubscribeCreate(data, client) {
|
|
1854
|
+
const api = client || getAPIInstance();
|
|
1855
|
+
const response = await api.ext_newsletter_subscriptions.newsletterUnsubscribeCreate(data);
|
|
1856
|
+
try {
|
|
1857
|
+
return SuccessResponseSchema.parse(response);
|
|
1858
|
+
} catch (error) {
|
|
1859
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1860
|
+
consola.consola.box(`createNewsletterUnsubscribeCreate
|
|
1861
|
+
Path: /cfg/newsletter/unsubscribe/
|
|
1862
|
+
Method: POST`);
|
|
1863
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1864
|
+
consola.consola.error("Validation Issues:");
|
|
1865
|
+
error.issues.forEach((issue, index) => {
|
|
1866
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1867
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1868
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1869
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
consola.consola.error("Response data:", response);
|
|
1873
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1874
|
+
try {
|
|
1875
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1876
|
+
detail: {
|
|
1877
|
+
operation: "createNewsletterUnsubscribeCreate",
|
|
1878
|
+
path: "/cfg/newsletter/unsubscribe/",
|
|
1879
|
+
method: "POST",
|
|
1880
|
+
error,
|
|
1881
|
+
response,
|
|
1882
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1883
|
+
},
|
|
1884
|
+
bubbles: true,
|
|
1885
|
+
cancelable: false
|
|
1886
|
+
});
|
|
1887
|
+
window.dispatchEvent(event);
|
|
1888
|
+
} catch (eventError) {
|
|
1889
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
throw error;
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
async function createNewsletterTestCreate(data, client) {
|
|
1896
|
+
const api = client || getAPIInstance();
|
|
1897
|
+
const response = await api.ext_newsletter_testing.newsletterTestCreate(data);
|
|
1898
|
+
try {
|
|
1899
|
+
return BulkEmailResponseSchema.parse(response);
|
|
1900
|
+
} catch (error) {
|
|
1901
|
+
consola.consola.error("\u274C Zod Validation Failed");
|
|
1902
|
+
consola.consola.box(`createNewsletterTestCreate
|
|
1903
|
+
Path: /cfg/newsletter/test/
|
|
1904
|
+
Method: POST`);
|
|
1905
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
1906
|
+
consola.consola.error("Validation Issues:");
|
|
1907
|
+
error.issues.forEach((issue, index) => {
|
|
1908
|
+
consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
1909
|
+
consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
1910
|
+
if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
1911
|
+
if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
consola.consola.error("Response data:", response);
|
|
1915
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
1916
|
+
try {
|
|
1917
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
1918
|
+
detail: {
|
|
1919
|
+
operation: "createNewsletterTestCreate",
|
|
1920
|
+
path: "/cfg/newsletter/test/",
|
|
1921
|
+
method: "POST",
|
|
1922
|
+
error,
|
|
1923
|
+
response,
|
|
1924
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1925
|
+
},
|
|
1926
|
+
bubbles: true,
|
|
1927
|
+
cancelable: false
|
|
1928
|
+
});
|
|
1929
|
+
window.dispatchEvent(event);
|
|
1930
|
+
} catch (eventError) {
|
|
1931
|
+
consola.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
throw error;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
// src/api/generated/ext_newsletter/index.ts
|
|
1939
|
+
var TOKEN_KEY = "auth_token";
|
|
1940
|
+
var REFRESH_TOKEN_KEY = "refresh_token";
|
|
1941
|
+
var API = class {
|
|
1942
|
+
baseUrl;
|
|
1943
|
+
_client;
|
|
1944
|
+
_token = null;
|
|
1945
|
+
_refreshToken = null;
|
|
1946
|
+
storage;
|
|
1947
|
+
options;
|
|
1948
|
+
// Sub-clients
|
|
1949
|
+
ext_newsletter_bulk_email;
|
|
1950
|
+
ext_newsletter_campaigns;
|
|
1951
|
+
ext_newsletter_logs;
|
|
1952
|
+
ext_newsletter_newsletters;
|
|
1953
|
+
ext_newsletter_subscriptions;
|
|
1954
|
+
ext_newsletter_testing;
|
|
1955
|
+
ext_newsletter_newsletter;
|
|
1956
|
+
constructor(baseUrl, options) {
|
|
1957
|
+
this.baseUrl = baseUrl;
|
|
1958
|
+
this.options = options;
|
|
1959
|
+
const logger = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
|
|
1960
|
+
this.storage = options?.storage || new LocalStorageAdapter(logger);
|
|
1961
|
+
this._loadTokensFromStorage();
|
|
1962
|
+
this._client = new APIClient(this.baseUrl, {
|
|
1963
|
+
retryConfig: this.options?.retryConfig,
|
|
1964
|
+
loggerConfig: this.options?.loggerConfig
|
|
1965
|
+
});
|
|
1966
|
+
this._injectAuthHeader();
|
|
1967
|
+
this.ext_newsletter_bulk_email = this._client.ext_newsletter_bulk_email;
|
|
1968
|
+
this.ext_newsletter_campaigns = this._client.ext_newsletter_campaigns;
|
|
1969
|
+
this.ext_newsletter_logs = this._client.ext_newsletter_logs;
|
|
1970
|
+
this.ext_newsletter_newsletters = this._client.ext_newsletter_newsletters;
|
|
1971
|
+
this.ext_newsletter_subscriptions = this._client.ext_newsletter_subscriptions;
|
|
1972
|
+
this.ext_newsletter_testing = this._client.ext_newsletter_testing;
|
|
1973
|
+
this.ext_newsletter_newsletter = this._client.ext_newsletter_newsletter;
|
|
1974
|
+
}
|
|
1975
|
+
_loadTokensFromStorage() {
|
|
1976
|
+
this._token = this.storage.getItem(TOKEN_KEY);
|
|
1977
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
|
|
1978
|
+
}
|
|
1979
|
+
_reinitClients() {
|
|
1980
|
+
this._client = new APIClient(this.baseUrl, {
|
|
1981
|
+
retryConfig: this.options?.retryConfig,
|
|
1982
|
+
loggerConfig: this.options?.loggerConfig
|
|
1983
|
+
});
|
|
1984
|
+
this._injectAuthHeader();
|
|
1985
|
+
this.ext_newsletter_bulk_email = this._client.ext_newsletter_bulk_email;
|
|
1986
|
+
this.ext_newsletter_campaigns = this._client.ext_newsletter_campaigns;
|
|
1987
|
+
this.ext_newsletter_logs = this._client.ext_newsletter_logs;
|
|
1988
|
+
this.ext_newsletter_newsletters = this._client.ext_newsletter_newsletters;
|
|
1989
|
+
this.ext_newsletter_subscriptions = this._client.ext_newsletter_subscriptions;
|
|
1990
|
+
this.ext_newsletter_testing = this._client.ext_newsletter_testing;
|
|
1991
|
+
this.ext_newsletter_newsletter = this._client.ext_newsletter_newsletter;
|
|
1992
|
+
}
|
|
1993
|
+
_injectAuthHeader() {
|
|
1994
|
+
const originalRequest = this._client.request.bind(this._client);
|
|
1995
|
+
this._client.request = async (method, path, options) => {
|
|
1996
|
+
const token = this.getToken();
|
|
1997
|
+
const mergedOptions = {
|
|
1998
|
+
...options,
|
|
1999
|
+
headers: {
|
|
2000
|
+
...options?.headers || {},
|
|
2001
|
+
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
return originalRequest(method, path, mergedOptions);
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Get current JWT token
|
|
2009
|
+
*/
|
|
2010
|
+
getToken() {
|
|
2011
|
+
return this.storage.getItem(TOKEN_KEY);
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Get current refresh token
|
|
2015
|
+
*/
|
|
2016
|
+
getRefreshToken() {
|
|
2017
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY);
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Set JWT token and refresh token
|
|
2021
|
+
* @param token - JWT access token
|
|
2022
|
+
* @param refreshToken - JWT refresh token (optional)
|
|
2023
|
+
*/
|
|
2024
|
+
setToken(token, refreshToken) {
|
|
2025
|
+
this._token = token;
|
|
2026
|
+
this.storage.setItem(TOKEN_KEY, token);
|
|
2027
|
+
if (refreshToken) {
|
|
2028
|
+
this._refreshToken = refreshToken;
|
|
2029
|
+
this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
|
|
2030
|
+
}
|
|
2031
|
+
this._reinitClients();
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Clear all tokens
|
|
2035
|
+
*/
|
|
2036
|
+
clearTokens() {
|
|
2037
|
+
this._token = null;
|
|
2038
|
+
this._refreshToken = null;
|
|
2039
|
+
this.storage.removeItem(TOKEN_KEY);
|
|
2040
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY);
|
|
2041
|
+
this._reinitClients();
|
|
2042
|
+
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Check if user is authenticated
|
|
2045
|
+
*/
|
|
2046
|
+
isAuthenticated() {
|
|
2047
|
+
return !!this.getToken();
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Update base URL and reinitialize clients
|
|
2051
|
+
* @param url - New base URL
|
|
2052
|
+
*/
|
|
2053
|
+
setBaseUrl(url) {
|
|
2054
|
+
this.baseUrl = url;
|
|
2055
|
+
this._reinitClients();
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Get current base URL
|
|
2059
|
+
*/
|
|
2060
|
+
getBaseUrl() {
|
|
2061
|
+
return this.baseUrl;
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* Get OpenAPI schema path
|
|
2065
|
+
* @returns Path to the OpenAPI schema JSON file
|
|
2066
|
+
*
|
|
2067
|
+
* Note: The OpenAPI schema is available in the schema.json file.
|
|
2068
|
+
* You can load it dynamically using:
|
|
2069
|
+
* ```typescript
|
|
2070
|
+
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
2071
|
+
* // or using fs in Node.js:
|
|
2072
|
+
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
2073
|
+
* ```
|
|
2074
|
+
*/
|
|
2075
|
+
getSchemaPath() {
|
|
2076
|
+
return "./schema.json";
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
var apiNewsletter = api.createExtensionAPI(API);
|
|
2080
|
+
|
|
2081
|
+
exports.API = API;
|
|
2082
|
+
exports.APIClient = APIClient;
|
|
2083
|
+
exports.APIError = APIError;
|
|
2084
|
+
exports.APILogger = APILogger;
|
|
2085
|
+
exports.BulkEmailRequestSchema = BulkEmailRequestSchema;
|
|
2086
|
+
exports.BulkEmailResponseSchema = BulkEmailResponseSchema;
|
|
2087
|
+
exports.CookieStorageAdapter = CookieStorageAdapter;
|
|
2088
|
+
exports.DEFAULT_RETRY_CONFIG = DEFAULT_RETRY_CONFIG;
|
|
2089
|
+
exports.EmailLogSchema = EmailLogSchema;
|
|
2090
|
+
exports.Enums = enums_exports;
|
|
2091
|
+
exports.ErrorResponseSchema = ErrorResponseSchema;
|
|
2092
|
+
exports.ExtNewsletterBulkEmailTypes = models_exports;
|
|
2093
|
+
exports.ExtNewsletterCampaignsTypes = models_exports2;
|
|
2094
|
+
exports.ExtNewsletterLogsTypes = models_exports3;
|
|
2095
|
+
exports.ExtNewsletterNewsletterTypes = models_exports7;
|
|
2096
|
+
exports.ExtNewsletterNewslettersTypes = models_exports4;
|
|
2097
|
+
exports.ExtNewsletterSubscriptionsTypes = models_exports5;
|
|
2098
|
+
exports.ExtNewsletterTestingTypes = models_exports6;
|
|
2099
|
+
exports.FetchAdapter = FetchAdapter;
|
|
2100
|
+
exports.Fetchers = fetchers_exports;
|
|
2101
|
+
exports.LocalStorageAdapter = LocalStorageAdapter;
|
|
2102
|
+
exports.MemoryStorageAdapter = MemoryStorageAdapter;
|
|
2103
|
+
exports.NetworkError = NetworkError;
|
|
2104
|
+
exports.NewsletterCampaignRequestSchema = NewsletterCampaignRequestSchema;
|
|
2105
|
+
exports.NewsletterCampaignSchema = NewsletterCampaignSchema;
|
|
2106
|
+
exports.NewsletterSchema = NewsletterSchema;
|
|
2107
|
+
exports.NewsletterSubscriptionSchema = NewsletterSubscriptionSchema;
|
|
2108
|
+
exports.PaginatedEmailLogListSchema = PaginatedEmailLogListSchema;
|
|
2109
|
+
exports.PaginatedNewsletterCampaignListSchema = PaginatedNewsletterCampaignListSchema;
|
|
2110
|
+
exports.PaginatedNewsletterListSchema = PaginatedNewsletterListSchema;
|
|
2111
|
+
exports.PaginatedNewsletterSubscriptionListSchema = PaginatedNewsletterSubscriptionListSchema;
|
|
2112
|
+
exports.PatchedNewsletterCampaignRequestSchema = PatchedNewsletterCampaignRequestSchema;
|
|
2113
|
+
exports.PatchedUnsubscribeRequestSchema = PatchedUnsubscribeRequestSchema;
|
|
2114
|
+
exports.REFRESH_TOKEN_KEY = REFRESH_TOKEN_KEY;
|
|
2115
|
+
exports.Schemas = schemas_exports;
|
|
2116
|
+
exports.SendCampaignRequestSchema = SendCampaignRequestSchema;
|
|
2117
|
+
exports.SendCampaignResponseSchema = SendCampaignResponseSchema;
|
|
2118
|
+
exports.SubscribeRequestSchema = SubscribeRequestSchema;
|
|
2119
|
+
exports.SubscribeResponseSchema = SubscribeResponseSchema;
|
|
2120
|
+
exports.SuccessResponseSchema = SuccessResponseSchema;
|
|
2121
|
+
exports.TOKEN_KEY = TOKEN_KEY;
|
|
2122
|
+
exports.TestEmailRequestSchema = TestEmailRequestSchema;
|
|
2123
|
+
exports.UnsubscribeRequestSchema = UnsubscribeRequestSchema;
|
|
2124
|
+
exports.UnsubscribeSchema = UnsubscribeSchema;
|
|
2125
|
+
exports.apiNewsletter = apiNewsletter;
|
|
2126
|
+
exports.clearAPITokens = clearAPITokens;
|
|
2127
|
+
exports.configureAPI = configureAPI;
|
|
2128
|
+
exports.createNewsletterBulkCreate = createNewsletterBulkCreate;
|
|
2129
|
+
exports.createNewsletterCampaignsCreate = createNewsletterCampaignsCreate;
|
|
2130
|
+
exports.createNewsletterCampaignsSendCreate = createNewsletterCampaignsSendCreate;
|
|
2131
|
+
exports.createNewsletterSubscribeCreate = createNewsletterSubscribeCreate;
|
|
2132
|
+
exports.createNewsletterTestCreate = createNewsletterTestCreate;
|
|
2133
|
+
exports.createNewsletterUnsubscribeCreate = createNewsletterUnsubscribeCreate;
|
|
2134
|
+
exports.deleteNewsletterCampaignsDestroy = deleteNewsletterCampaignsDestroy;
|
|
2135
|
+
exports.dispatchValidationError = dispatchValidationError;
|
|
2136
|
+
exports.formatZodError = formatZodError;
|
|
2137
|
+
exports.getAPIInstance = getAPIInstance;
|
|
2138
|
+
exports.getNewsletterCampaignsList = getNewsletterCampaignsList;
|
|
2139
|
+
exports.getNewsletterCampaignsRetrieve = getNewsletterCampaignsRetrieve;
|
|
2140
|
+
exports.getNewsletterLogsList = getNewsletterLogsList;
|
|
2141
|
+
exports.getNewsletterNewslettersList = getNewsletterNewslettersList;
|
|
2142
|
+
exports.getNewsletterNewslettersRetrieve = getNewsletterNewslettersRetrieve;
|
|
2143
|
+
exports.getNewsletterSubscriptionsList = getNewsletterSubscriptionsList;
|
|
2144
|
+
exports.isAPIConfigured = isAPIConfigured;
|
|
2145
|
+
exports.onValidationError = onValidationError;
|
|
2146
|
+
exports.partialUpdateNewsletterCampaignsPartialUpdate = partialUpdateNewsletterCampaignsPartialUpdate;
|
|
2147
|
+
exports.partialUpdateNewsletterUnsubscribePartialUpdate = partialUpdateNewsletterUnsubscribePartialUpdate;
|
|
2148
|
+
exports.reconfigureAPI = reconfigureAPI;
|
|
2149
|
+
exports.resetAPI = resetAPI;
|
|
2150
|
+
exports.shouldRetry = shouldRetry;
|
|
2151
|
+
exports.updateNewsletterCampaignsUpdate = updateNewsletterCampaignsUpdate;
|
|
2152
|
+
exports.updateNewsletterUnsubscribeUpdate = updateNewsletterUnsubscribeUpdate;
|
|
2153
|
+
exports.withRetry = withRetry;
|