zupost 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -21,10 +21,32 @@ var __spreadValues = (a, b) => {
21
21
  return a;
22
22
  };
23
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
24
36
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
25
37
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
38
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
26
39
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
40
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
27
41
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
42
+ var __privateWrapper = (obj, member, setter, getter) => ({
43
+ set _(value) {
44
+ __privateSet(obj, member, value, setter);
45
+ },
46
+ get _() {
47
+ return __privateGet(obj, member, getter);
48
+ }
49
+ });
28
50
  var __async = (__this, __arguments, generator) => {
29
51
  return new Promise((resolve, reject) => {
30
52
  var fulfilled = (value) => {
@@ -47,9 +69,9 @@ var __async = (__this, __arguments, generator) => {
47
69
  };
48
70
 
49
71
  // package.json
50
- var version = "0.0.0";
72
+ var version = "0.1.1";
51
73
 
52
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/errors/HTTPError.js
74
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/HTTPError.js
53
75
  var HTTPError = class extends Error {
54
76
  constructor(response, request, options) {
55
77
  var _a;
@@ -68,17 +90,41 @@ var HTTPError = class extends Error {
68
90
  }
69
91
  };
70
92
 
71
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/errors/TimeoutError.js
72
- var TimeoutError = class extends Error {
73
- constructor(request) {
74
- super(`Request timed out: ${request.method} ${request.url}`);
75
- __publicField(this, "request");
76
- this.name = "TimeoutError";
77
- this.request = request;
93
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/NonError.js
94
+ var NonError = class extends Error {
95
+ constructor(value) {
96
+ let message = "Non-error value was thrown";
97
+ try {
98
+ if (typeof value === "string") {
99
+ message = value;
100
+ } else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
101
+ message = value.message;
102
+ }
103
+ } catch (e) {
104
+ }
105
+ super(message);
106
+ __publicField(this, "name", "NonError");
107
+ __publicField(this, "value");
108
+ this.value = value;
78
109
  }
79
110
  };
80
111
 
81
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/core/constants.js
112
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/ForceRetryError.js
113
+ var ForceRetryError = class extends Error {
114
+ constructor(options) {
115
+ const cause = (options == null ? void 0 : options.cause) ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : void 0;
116
+ super((options == null ? void 0 : options.code) ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : void 0);
117
+ __publicField(this, "name", "ForceRetryError");
118
+ __publicField(this, "customDelay");
119
+ __publicField(this, "code");
120
+ __publicField(this, "customRequest");
121
+ this.customDelay = options == null ? void 0 : options.delay;
122
+ this.code = options == null ? void 0 : options.code;
123
+ this.customRequest = options == null ? void 0 : options.request;
124
+ }
125
+ };
126
+
127
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/core/constants.js
82
128
  var supportsRequestStreams = (() => {
83
129
  let duplexAccessed = false;
84
130
  let hasContentType = false;
@@ -123,7 +169,14 @@ var responseTypes = {
123
169
  };
124
170
  var maxSafeTimeout = 2147483647;
125
171
  var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
126
- var stop = Symbol("stop");
172
+ var stop = /* @__PURE__ */ Symbol("stop");
173
+ var RetryMarker = class {
174
+ constructor(options) {
175
+ __publicField(this, "options");
176
+ this.options = options;
177
+ }
178
+ };
179
+ var retry = (options) => new RetryMarker(options);
127
180
  var kyOptionKeys = {
128
181
  json: true,
129
182
  parseJson: true,
@@ -136,7 +189,12 @@ var kyOptionKeys = {
136
189
  throwHttpErrors: true,
137
190
  onDownloadProgress: true,
138
191
  onUploadProgress: true,
139
- fetch: true
192
+ fetch: true,
193
+ context: true
194
+ };
195
+ var vendorSpecificOptions = {
196
+ next: true
197
+ // Next.js cache revalidation (revalidate, tags)
140
198
  };
141
199
  var requestOptionsRegistry = {
142
200
  method: true,
@@ -152,12 +210,10 @@ var requestOptionsRegistry = {
152
210
  keepalive: true,
153
211
  signal: true,
154
212
  window: true,
155
- dispatcher: true,
156
- duplex: true,
157
- priority: true
213
+ duplex: true
158
214
  };
159
215
 
160
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/body.js
216
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/body.js
161
217
  var getBodySize = (body) => {
162
218
  if (!body) {
163
219
  return 0;
@@ -231,7 +287,7 @@ var streamResponse = (response, onDownloadProgress) => {
231
287
  headers: response.headers
232
288
  });
233
289
  }
234
- const totalBytes = Number(response.headers.get("content-length")) || 0;
290
+ const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
235
291
  return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
236
292
  status: response.status,
237
293
  statusText: response.statusText,
@@ -250,10 +306,10 @@ var streamRequest = (request, onUploadProgress, originalBody) => {
250
306
  });
251
307
  };
252
308
 
253
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/is.js
309
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/is.js
254
310
  var isObject = (value) => value !== null && typeof value === "object";
255
311
 
256
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/merge.js
312
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/merge.js
257
313
  var validateAndMerge = (...sources) => {
258
314
  for (const source of sources) {
259
315
  if ((!isObject(source) || Array.isArray(source)) && source !== void 0) {
@@ -285,10 +341,44 @@ var mergeHooks = (original = {}, incoming = {}) => ({
285
341
  afterResponse: newHookValue(original, incoming, "afterResponse"),
286
342
  beforeError: newHookValue(original, incoming, "beforeError")
287
343
  });
344
+ var appendSearchParameters = (target, source) => {
345
+ const result = new URLSearchParams();
346
+ for (const input of [target, source]) {
347
+ if (input === void 0) {
348
+ continue;
349
+ }
350
+ if (input instanceof URLSearchParams) {
351
+ for (const [key, value] of input.entries()) {
352
+ result.append(key, value);
353
+ }
354
+ } else if (Array.isArray(input)) {
355
+ for (const pair of input) {
356
+ if (!Array.isArray(pair) || pair.length !== 2) {
357
+ throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
358
+ }
359
+ result.append(String(pair[0]), String(pair[1]));
360
+ }
361
+ } else if (isObject(input)) {
362
+ for (const [key, value] of Object.entries(input)) {
363
+ if (value !== void 0) {
364
+ result.append(key, String(value));
365
+ }
366
+ }
367
+ } else {
368
+ const parameters = new URLSearchParams(input);
369
+ for (const [key, value] of parameters.entries()) {
370
+ result.append(key, value);
371
+ }
372
+ }
373
+ }
374
+ return result;
375
+ };
288
376
  var deepMerge = (...sources) => {
289
377
  let returnValue = {};
290
378
  let headers = {};
291
379
  let hooks = {};
380
+ let searchParameters;
381
+ const signals = [];
292
382
  for (const source of sources) {
293
383
  if (Array.isArray(source)) {
294
384
  if (!Array.isArray(returnValue)) {
@@ -297,6 +387,27 @@ var deepMerge = (...sources) => {
297
387
  returnValue = [...returnValue, ...source];
298
388
  } else if (isObject(source)) {
299
389
  for (let [key, value] of Object.entries(source)) {
390
+ if (key === "signal" && value instanceof globalThis.AbortSignal) {
391
+ signals.push(value);
392
+ continue;
393
+ }
394
+ if (key === "context") {
395
+ if (value !== void 0 && value !== null && (!isObject(value) || Array.isArray(value))) {
396
+ throw new TypeError("The `context` option must be an object");
397
+ }
398
+ returnValue = __spreadProps(__spreadValues({}, returnValue), {
399
+ context: value === void 0 || value === null ? {} : __spreadValues(__spreadValues({}, returnValue.context), value)
400
+ });
401
+ continue;
402
+ }
403
+ if (key === "searchParams") {
404
+ if (value === void 0 || value === null) {
405
+ searchParameters = void 0;
406
+ } else {
407
+ searchParameters = searchParameters === void 0 ? value : appendSearchParameters(searchParameters, value);
408
+ }
409
+ continue;
410
+ }
300
411
  if (isObject(value) && key in returnValue) {
301
412
  value = deepMerge(returnValue[key], value);
302
413
  }
@@ -312,10 +423,22 @@ var deepMerge = (...sources) => {
312
423
  }
313
424
  }
314
425
  }
426
+ if (searchParameters !== void 0) {
427
+ returnValue.searchParams = searchParameters;
428
+ }
429
+ if (signals.length > 0) {
430
+ if (signals.length === 1) {
431
+ returnValue.signal = signals[0];
432
+ } else if (supportsAbortSignal) {
433
+ returnValue.signal = AbortSignal.any(signals);
434
+ } else {
435
+ returnValue.signal = signals.at(-1);
436
+ }
437
+ }
315
438
  return returnValue;
316
439
  };
317
440
 
318
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/normalize.js
441
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/normalize.js
319
442
  var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
320
443
  var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
321
444
  var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
@@ -327,24 +450,38 @@ var defaultRetryOptions = {
327
450
  afterStatusCodes: retryAfterStatusCodes,
328
451
  maxRetryAfter: Number.POSITIVE_INFINITY,
329
452
  backoffLimit: Number.POSITIVE_INFINITY,
330
- delay: (attemptCount) => 0.3 * __pow(2, attemptCount - 1) * 1e3
453
+ delay: (attemptCount) => 0.3 * __pow(2, attemptCount - 1) * 1e3,
454
+ jitter: void 0,
455
+ retryOnTimeout: false
331
456
  };
332
- var normalizeRetryOptions = (retry = {}) => {
333
- if (typeof retry === "number") {
457
+ var normalizeRetryOptions = (retry2 = {}) => {
458
+ if (typeof retry2 === "number") {
334
459
  return __spreadProps(__spreadValues({}, defaultRetryOptions), {
335
- limit: retry
460
+ limit: retry2
336
461
  });
337
462
  }
338
- if (retry.methods && !Array.isArray(retry.methods)) {
463
+ if (retry2.methods && !Array.isArray(retry2.methods)) {
339
464
  throw new Error("retry.methods must be an array");
340
465
  }
341
- if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {
466
+ retry2.methods && (retry2.methods = retry2.methods.map((method) => method.toLowerCase()));
467
+ if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
342
468
  throw new Error("retry.statusCodes must be an array");
343
469
  }
344
- return __spreadValues(__spreadValues({}, defaultRetryOptions), retry);
470
+ const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== void 0));
471
+ return __spreadValues(__spreadValues({}, defaultRetryOptions), normalizedRetry);
345
472
  };
346
473
 
347
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/timeout.js
474
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/TimeoutError.js
475
+ var TimeoutError = class extends Error {
476
+ constructor(request) {
477
+ super(`Request timed out: ${request.method} ${request.url}`);
478
+ __publicField(this, "request");
479
+ this.name = "TimeoutError";
480
+ this.request = request;
481
+ }
482
+ };
483
+
484
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/timeout.js
348
485
  function timeout(request, init, abortController, options) {
349
486
  return __async(this, null, function* () {
350
487
  return new Promise((resolve, reject) => {
@@ -361,7 +498,7 @@ function timeout(request, init, abortController, options) {
361
498
  });
362
499
  }
363
500
 
364
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/delay.js
501
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/delay.js
365
502
  function delay(_0, _1) {
366
503
  return __async(this, arguments, function* (ms, { signal }) {
367
504
  return new Promise((resolve, reject) => {
@@ -381,11 +518,14 @@ function delay(_0, _1) {
381
518
  });
382
519
  }
383
520
 
384
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/utils/options.js
521
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/options.js
385
522
  var findUnknownOptions = (request, options) => {
386
523
  const unknownOptions = {};
387
524
  for (const key in options) {
388
- if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {
525
+ if (!Object.hasOwn(options, key)) {
526
+ continue;
527
+ }
528
+ if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || key in vendorSpecificOptions)) {
389
529
  unknownOptions[key] = options[key];
390
530
  }
391
531
  }
@@ -410,131 +550,156 @@ var hasSearchParameters = (search) => {
410
550
  return Boolean(search);
411
551
  };
412
552
 
413
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/core/Ky.js
414
- var _Ky_static, normalizeSearchParams_fn;
553
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/type-guards.js
554
+ function isHTTPError(error) {
555
+ return error instanceof HTTPError || (error == null ? void 0 : error.name) === HTTPError.name;
556
+ }
557
+ function isTimeoutError(error) {
558
+ return error instanceof TimeoutError || (error == null ? void 0 : error.name) === TimeoutError.name;
559
+ }
560
+
561
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/core/Ky.js
562
+ var _Ky_static, normalizeSearchParams_fn, _abortController, _retryCount, _input, _options, _originalRequest, _userProvidedAbortSignal, _cachedNormalizedOptions, _Ky_instances, calculateDelay_fn, calculateRetryDelay_fn, decorateResponse_fn, cancelBody_fn, cancelResponseBody_fn, retry_fn, fetch_fn, getNormalizedOptions_fn, assignRequest_fn, wrapRequestWithUploadProgress_fn;
415
563
  var _Ky = class _Ky {
416
564
  // eslint-disable-next-line complexity
417
565
  constructor(input, options = {}) {
566
+ __privateAdd(this, _Ky_instances);
418
567
  __publicField(this, "request");
419
- __publicField(this, "abortController");
420
- __publicField(this, "_retryCount", 0);
421
- __publicField(this, "_input");
422
- __publicField(this, "_options");
423
- __publicField(this, "_originalRequest");
424
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
425
- this._input = input;
426
- this._options = __spreadProps(__spreadValues({}, options), {
427
- headers: mergeHeaders(this._input.headers, options.headers),
568
+ __privateAdd(this, _abortController);
569
+ __privateAdd(this, _retryCount, 0);
570
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly -- False positive: #input is reassigned on line 202
571
+ __privateAdd(this, _input);
572
+ __privateAdd(this, _options);
573
+ __privateAdd(this, _originalRequest);
574
+ __privateAdd(this, _userProvidedAbortSignal);
575
+ __privateAdd(this, _cachedNormalizedOptions);
576
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
577
+ __privateSet(this, _input, input);
578
+ __privateSet(this, _options, __spreadProps(__spreadValues({}, options), {
579
+ headers: mergeHeaders(__privateGet(this, _input).headers, options.headers),
428
580
  hooks: mergeHooks({
429
581
  beforeRequest: [],
430
582
  beforeRetry: [],
431
583
  beforeError: [],
432
584
  afterResponse: []
433
585
  }, options.hooks),
434
- method: normalizeRequestMethod((_b = (_a = options.method) != null ? _a : this._input.method) != null ? _b : "GET"),
586
+ method: normalizeRequestMethod((_b = (_a = options.method) != null ? _a : __privateGet(this, _input).method) != null ? _b : "GET"),
435
587
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
436
588
  prefixUrl: String(options.prefixUrl || ""),
437
589
  retry: normalizeRetryOptions(options.retry),
438
- throwHttpErrors: options.throwHttpErrors !== false,
439
- timeout: (_c = options.timeout) != null ? _c : 1e4,
440
- fetch: (_d = options.fetch) != null ? _d : globalThis.fetch.bind(globalThis)
441
- });
442
- if (typeof this._input !== "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
590
+ throwHttpErrors: (_c = options.throwHttpErrors) != null ? _c : true,
591
+ timeout: (_d = options.timeout) != null ? _d : 1e4,
592
+ fetch: (_e = options.fetch) != null ? _e : globalThis.fetch.bind(globalThis),
593
+ context: (_f = options.context) != null ? _f : {}
594
+ }));
595
+ if (typeof __privateGet(this, _input) !== "string" && !(__privateGet(this, _input) instanceof URL || __privateGet(this, _input) instanceof globalThis.Request)) {
443
596
  throw new TypeError("`input` must be a string, URL, or Request");
444
597
  }
445
- if (this._options.prefixUrl && typeof this._input === "string") {
446
- if (this._input.startsWith("/")) {
598
+ if (__privateGet(this, _options).prefixUrl && typeof __privateGet(this, _input) === "string") {
599
+ if (__privateGet(this, _input).startsWith("/")) {
447
600
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
448
601
  }
449
- if (!this._options.prefixUrl.endsWith("/")) {
450
- this._options.prefixUrl += "/";
602
+ if (!__privateGet(this, _options).prefixUrl.endsWith("/")) {
603
+ __privateGet(this, _options).prefixUrl += "/";
451
604
  }
452
- this._input = this._options.prefixUrl + this._input;
605
+ __privateSet(this, _input, __privateGet(this, _options).prefixUrl + __privateGet(this, _input));
453
606
  }
454
607
  if (supportsAbortController && supportsAbortSignal) {
455
- const originalSignal = (_e = this._options.signal) != null ? _e : this._input.signal;
456
- this.abortController = new globalThis.AbortController();
457
- this._options.signal = originalSignal ? AbortSignal.any([originalSignal, this.abortController.signal]) : this.abortController.signal;
608
+ __privateSet(this, _userProvidedAbortSignal, (_g = __privateGet(this, _options).signal) != null ? _g : __privateGet(this, _input).signal);
609
+ __privateSet(this, _abortController, new globalThis.AbortController());
610
+ __privateGet(this, _options).signal = __privateGet(this, _userProvidedAbortSignal) ? AbortSignal.any([__privateGet(this, _userProvidedAbortSignal), __privateGet(this, _abortController).signal]) : __privateGet(this, _abortController).signal;
458
611
  }
459
612
  if (supportsRequestStreams) {
460
- this._options.duplex = "half";
613
+ __privateGet(this, _options).duplex = "half";
614
+ }
615
+ if (__privateGet(this, _options).json !== void 0) {
616
+ __privateGet(this, _options).body = (_j = (_i = (_h = __privateGet(this, _options)).stringifyJson) == null ? void 0 : _i.call(_h, __privateGet(this, _options).json)) != null ? _j : JSON.stringify(__privateGet(this, _options).json);
617
+ __privateGet(this, _options).headers.set("content-type", (_k = __privateGet(this, _options).headers.get("content-type")) != null ? _k : "application/json");
461
618
  }
462
- if (this._options.json !== void 0) {
463
- this._options.body = (_h = (_g = (_f = this._options).stringifyJson) == null ? void 0 : _g.call(_f, this._options.json)) != null ? _h : JSON.stringify(this._options.json);
464
- this._options.headers.set("content-type", (_i = this._options.headers.get("content-type")) != null ? _i : "application/json");
619
+ const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
620
+ if (__privateGet(this, _input) instanceof globalThis.Request && (supportsFormData && __privateGet(this, _options).body instanceof globalThis.FormData || __privateGet(this, _options).body instanceof URLSearchParams) && !userProvidedContentType) {
621
+ __privateGet(this, _options).headers.delete("content-type");
465
622
  }
466
- this.request = new globalThis.Request(this._input, this._options);
467
- if (hasSearchParameters(this._options.searchParams)) {
468
- const textSearchParams = typeof this._options.searchParams === "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(__privateMethod(_j = _Ky, _Ky_static, normalizeSearchParams_fn).call(_j, this._options.searchParams)).toString();
623
+ this.request = new globalThis.Request(__privateGet(this, _input), __privateGet(this, _options));
624
+ if (hasSearchParameters(__privateGet(this, _options).searchParams)) {
625
+ const textSearchParams = typeof __privateGet(this, _options).searchParams === "string" ? __privateGet(this, _options).searchParams.replace(/^\?/, "") : new URLSearchParams(__privateMethod(_l = _Ky, _Ky_static, normalizeSearchParams_fn).call(_l, __privateGet(this, _options).searchParams)).toString();
469
626
  const searchParams = "?" + textSearchParams;
470
627
  const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
471
- if ((supportsFormData && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"])) {
472
- this.request.headers.delete("content-type");
473
- }
474
- this.request = new globalThis.Request(new globalThis.Request(url, __spreadValues({}, this.request)), this._options);
628
+ this.request = new globalThis.Request(url, __privateGet(this, _options));
475
629
  }
476
- if (this._options.onUploadProgress) {
477
- if (typeof this._options.onUploadProgress !== "function") {
630
+ if (__privateGet(this, _options).onUploadProgress) {
631
+ if (typeof __privateGet(this, _options).onUploadProgress !== "function") {
478
632
  throw new TypeError("The `onUploadProgress` option must be a function");
479
633
  }
480
634
  if (!supportsRequestStreams) {
481
635
  throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
482
636
  }
483
- const originalBody = this.request.body;
484
- if (originalBody) {
485
- this.request = streamRequest(this.request, this._options.onUploadProgress, this._options.body);
486
- }
637
+ this.request = __privateMethod(this, _Ky_instances, wrapRequestWithUploadProgress_fn).call(this, this.request, (_m = __privateGet(this, _options).body) != null ? _m : void 0);
487
638
  }
488
639
  }
489
640
  static create(input, options) {
490
- var _a, _b;
641
+ var _a, _b, _c;
491
642
  const ky2 = new _Ky(input, options);
492
643
  const function_ = () => __async(null, null, function* () {
493
- if (typeof ky2._options.timeout === "number" && ky2._options.timeout > maxSafeTimeout) {
644
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l;
645
+ if (typeof __privateGet(ky2, _options).timeout === "number" && __privateGet(ky2, _options).timeout > maxSafeTimeout) {
494
646
  throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
495
647
  }
496
648
  yield Promise.resolve();
497
- let response = yield ky2._fetch();
498
- for (const hook of ky2._options.hooks.afterResponse) {
499
- const modifiedResponse = yield hook(ky2.request, ky2._options, ky2._decorateResponse(response.clone()));
500
- if (modifiedResponse instanceof globalThis.Response) {
501
- response = modifiedResponse;
649
+ let response = yield __privateMethod(_a2 = ky2, _Ky_instances, fetch_fn).call(_a2);
650
+ for (const hook of __privateGet(ky2, _options).hooks.afterResponse) {
651
+ const clonedResponse = __privateMethod(_b2 = ky2, _Ky_instances, decorateResponse_fn).call(_b2, response.clone());
652
+ let modifiedResponse;
653
+ try {
654
+ modifiedResponse = yield hook(ky2.request, __privateMethod(_c2 = ky2, _Ky_instances, getNormalizedOptions_fn).call(_c2), clonedResponse, { retryCount: __privateGet(ky2, _retryCount) });
655
+ } catch (error) {
656
+ __privateMethod(_d = ky2, _Ky_instances, cancelResponseBody_fn).call(_d, clonedResponse);
657
+ __privateMethod(_e = ky2, _Ky_instances, cancelResponseBody_fn).call(_e, response);
658
+ throw error;
659
+ }
660
+ if (modifiedResponse instanceof RetryMarker) {
661
+ __privateMethod(_f = ky2, _Ky_instances, cancelResponseBody_fn).call(_f, clonedResponse);
662
+ __privateMethod(_g = ky2, _Ky_instances, cancelResponseBody_fn).call(_g, response);
663
+ throw new ForceRetryError(modifiedResponse.options);
664
+ }
665
+ const nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;
666
+ if (clonedResponse !== nextResponse) {
667
+ __privateMethod(_h = ky2, _Ky_instances, cancelResponseBody_fn).call(_h, clonedResponse);
668
+ }
669
+ if (response !== nextResponse) {
670
+ __privateMethod(_i = ky2, _Ky_instances, cancelResponseBody_fn).call(_i, response);
502
671
  }
672
+ response = nextResponse;
503
673
  }
504
- ky2._decorateResponse(response);
505
- if (!response.ok && ky2._options.throwHttpErrors) {
506
- let error = new HTTPError(response, ky2.request, ky2._options);
507
- for (const hook of ky2._options.hooks.beforeError) {
508
- error = yield hook(error);
674
+ __privateMethod(_j = ky2, _Ky_instances, decorateResponse_fn).call(_j, response);
675
+ if (!response.ok && (typeof __privateGet(ky2, _options).throwHttpErrors === "function" ? __privateGet(ky2, _options).throwHttpErrors(response.status) : __privateGet(ky2, _options).throwHttpErrors)) {
676
+ let error = new HTTPError(response, ky2.request, __privateMethod(_k = ky2, _Ky_instances, getNormalizedOptions_fn).call(_k));
677
+ for (const hook of __privateGet(ky2, _options).hooks.beforeError) {
678
+ error = yield hook(error, { retryCount: __privateGet(ky2, _retryCount) });
509
679
  }
510
680
  throw error;
511
681
  }
512
- if (ky2._options.onDownloadProgress) {
513
- if (typeof ky2._options.onDownloadProgress !== "function") {
682
+ if (__privateGet(ky2, _options).onDownloadProgress) {
683
+ if (typeof __privateGet(ky2, _options).onDownloadProgress !== "function") {
514
684
  throw new TypeError("The `onDownloadProgress` option must be a function");
515
685
  }
516
686
  if (!supportsResponseStreams) {
517
687
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
518
688
  }
519
- return streamResponse(response.clone(), ky2._options.onDownloadProgress);
689
+ const progressResponse = response.clone();
690
+ __privateMethod(_l = ky2, _Ky_instances, cancelResponseBody_fn).call(_l, response);
691
+ return streamResponse(progressResponse, __privateGet(ky2, _options).onDownloadProgress);
520
692
  }
521
693
  return response;
522
694
  });
523
- const isRetriableMethod = ky2._options.retry.methods.includes(ky2.request.method.toLowerCase());
524
- const result = (isRetriableMethod ? ky2._retry(function_) : function_()).finally(() => __async(null, null, function* () {
525
- var _a2, _b2;
526
- const originalRequest = ky2._originalRequest;
527
- const cleanupPromises = [];
528
- if (originalRequest && !originalRequest.bodyUsed) {
529
- cleanupPromises.push((_a2 = originalRequest.body) == null ? void 0 : _a2.cancel());
530
- }
531
- if (!ky2.request.bodyUsed) {
532
- cleanupPromises.push((_b2 = ky2.request.body) == null ? void 0 : _b2.cancel());
533
- }
534
- yield Promise.all(cleanupPromises);
535
- }));
695
+ const result = __privateMethod(_a = ky2, _Ky_instances, retry_fn).call(_a, function_).finally(() => {
696
+ var _a2, _b2, _c2, _d;
697
+ const originalRequest = __privateGet(ky2, _originalRequest);
698
+ __privateMethod(_b2 = ky2, _Ky_instances, cancelBody_fn).call(_b2, (_a2 = originalRequest == null ? void 0 : originalRequest.body) != null ? _a2 : void 0);
699
+ __privateMethod(_d = ky2, _Ky_instances, cancelBody_fn).call(_d, (_c2 = ky2.request.body) != null ? _c2 : void 0);
700
+ });
536
701
  for (const [type, mimeType] of Object.entries(responseTypes)) {
537
- if (type === "bytes" && typeof ((_b = (_a = globalThis.Response) == null ? void 0 : _a.prototype) == null ? void 0 : _b.bytes) !== "function") {
702
+ if (type === "bytes" && typeof ((_c = (_b = globalThis.Response) == null ? void 0 : _b.prototype) == null ? void 0 : _c.bytes) !== "function") {
538
703
  continue;
539
704
  }
540
705
  result[type] = () => __async(null, null, function* () {
@@ -558,100 +723,188 @@ var _Ky = class _Ky {
558
723
  }
559
724
  return result;
560
725
  }
561
- _calculateRetryDelay(error) {
562
- var _a, _b, _c, _d;
563
- this._retryCount++;
564
- if (this._retryCount > this._options.retry.limit || error instanceof TimeoutError) {
726
+ };
727
+ _Ky_static = new WeakSet();
728
+ normalizeSearchParams_fn = function(searchParams) {
729
+ if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
730
+ return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== void 0));
731
+ }
732
+ return searchParams;
733
+ };
734
+ _abortController = new WeakMap();
735
+ _retryCount = new WeakMap();
736
+ _input = new WeakMap();
737
+ _options = new WeakMap();
738
+ _originalRequest = new WeakMap();
739
+ _userProvidedAbortSignal = new WeakMap();
740
+ _cachedNormalizedOptions = new WeakMap();
741
+ _Ky_instances = new WeakSet();
742
+ calculateDelay_fn = function() {
743
+ var _a;
744
+ const retryDelay = __privateGet(this, _options).retry.delay(__privateGet(this, _retryCount));
745
+ let jitteredDelay = retryDelay;
746
+ if (__privateGet(this, _options).retry.jitter === true) {
747
+ jitteredDelay = Math.random() * retryDelay;
748
+ } else if (typeof __privateGet(this, _options).retry.jitter === "function") {
749
+ jitteredDelay = __privateGet(this, _options).retry.jitter(retryDelay);
750
+ if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
751
+ jitteredDelay = retryDelay;
752
+ }
753
+ }
754
+ const backoffLimit = (_a = __privateGet(this, _options).retry.backoffLimit) != null ? _a : Number.POSITIVE_INFINITY;
755
+ return Math.min(backoffLimit, jitteredDelay);
756
+ };
757
+ calculateRetryDelay_fn = function(error) {
758
+ return __async(this, null, function* () {
759
+ var _a, _b, _c, _d, _e, _f;
760
+ __privateWrapper(this, _retryCount)._++;
761
+ if (__privateGet(this, _retryCount) > __privateGet(this, _options).retry.limit) {
565
762
  throw error;
566
763
  }
567
- if (error instanceof HTTPError) {
568
- if (!this._options.retry.statusCodes.includes(error.response.status)) {
764
+ const errorObject = error instanceof Error ? error : new NonError(error);
765
+ if (errorObject instanceof ForceRetryError) {
766
+ return (_a = errorObject.customDelay) != null ? _a : __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
767
+ }
768
+ if (!__privateGet(this, _options).retry.methods.includes(this.request.method.toLowerCase())) {
769
+ throw error;
770
+ }
771
+ if (__privateGet(this, _options).retry.shouldRetry !== void 0) {
772
+ const result = yield __privateGet(this, _options).retry.shouldRetry({ error: errorObject, retryCount: __privateGet(this, _retryCount) });
773
+ if (result === false) {
569
774
  throw error;
570
775
  }
571
- const retryAfter = (_c = (_b = (_a = error.response.headers.get("Retry-After")) != null ? _a : error.response.headers.get("RateLimit-Reset")) != null ? _b : error.response.headers.get("X-RateLimit-Reset")) != null ? _c : error.response.headers.get("X-Rate-Limit-Reset");
572
- if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {
776
+ if (result === true) {
777
+ return __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
778
+ }
779
+ }
780
+ if (isTimeoutError(error) && !__privateGet(this, _options).retry.retryOnTimeout) {
781
+ throw error;
782
+ }
783
+ if (isHTTPError(error)) {
784
+ if (!__privateGet(this, _options).retry.statusCodes.includes(error.response.status)) {
785
+ throw error;
786
+ }
787
+ const retryAfter = (_e = (_d = (_c = (_b = error.response.headers.get("Retry-After")) != null ? _b : error.response.headers.get("RateLimit-Reset")) != null ? _c : error.response.headers.get("X-RateLimit-Retry-After")) != null ? _d : error.response.headers.get("X-RateLimit-Reset")) != null ? _e : error.response.headers.get("X-Rate-Limit-Reset");
788
+ if (retryAfter && __privateGet(this, _options).retry.afterStatusCodes.includes(error.response.status)) {
573
789
  let after = Number(retryAfter) * 1e3;
574
790
  if (Number.isNaN(after)) {
575
791
  after = Date.parse(retryAfter) - Date.now();
576
792
  } else if (after >= Date.parse("2024-01-01")) {
577
793
  after -= Date.now();
578
794
  }
579
- const max = (_d = this._options.retry.maxRetryAfter) != null ? _d : after;
795
+ const max = (_f = __privateGet(this, _options).retry.maxRetryAfter) != null ? _f : after;
580
796
  return after < max ? after : max;
581
797
  }
582
798
  if (error.response.status === 413) {
583
799
  throw error;
584
800
  }
585
801
  }
586
- const retryDelay = this._options.retry.delay(this._retryCount);
587
- return Math.min(this._options.retry.backoffLimit, retryDelay);
802
+ return __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
803
+ });
804
+ };
805
+ decorateResponse_fn = function(response) {
806
+ if (__privateGet(this, _options).parseJson) {
807
+ response.json = () => __async(this, null, function* () {
808
+ return __privateGet(this, _options).parseJson(yield response.text());
809
+ });
588
810
  }
589
- _decorateResponse(response) {
590
- if (this._options.parseJson) {
591
- response.json = () => __async(this, null, function* () {
592
- return this._options.parseJson(yield response.text());
593
- });
594
- }
595
- return response;
811
+ return response;
812
+ };
813
+ cancelBody_fn = function(body) {
814
+ if (!body) {
815
+ return;
596
816
  }
597
- _retry(function_) {
598
- return __async(this, null, function* () {
599
- try {
600
- return yield function_();
601
- } catch (error) {
602
- const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);
603
- if (this._retryCount < 1) {
604
- throw error;
605
- }
606
- yield delay(ms, { signal: this._options.signal });
607
- for (const hook of this._options.hooks.beforeRetry) {
608
- const hookResult = yield hook({
609
- request: this.request,
610
- options: this._options,
611
- error,
612
- retryCount: this._retryCount
613
- });
614
- if (hookResult === stop) {
615
- return;
616
- }
617
- }
618
- return this._retry(function_);
817
+ void body.cancel().catch(() => void 0);
818
+ };
819
+ cancelResponseBody_fn = function(response) {
820
+ var _a;
821
+ __privateMethod(this, _Ky_instances, cancelBody_fn).call(this, (_a = response.body) != null ? _a : void 0);
822
+ };
823
+ retry_fn = function(function_) {
824
+ return __async(this, null, function* () {
825
+ try {
826
+ return yield function_();
827
+ } catch (error) {
828
+ const ms = Math.min(yield __privateMethod(this, _Ky_instances, calculateRetryDelay_fn).call(this, error), maxSafeTimeout);
829
+ if (__privateGet(this, _retryCount) < 1) {
830
+ throw error;
619
831
  }
620
- });
621
- }
622
- _fetch() {
623
- return __async(this, null, function* () {
624
- for (const hook of this._options.hooks.beforeRequest) {
625
- const result = yield hook(this.request, this._options);
626
- if (result instanceof Request) {
627
- this.request = result;
832
+ yield delay(ms, __privateGet(this, _userProvidedAbortSignal) ? { signal: __privateGet(this, _userProvidedAbortSignal) } : {});
833
+ if (error instanceof ForceRetryError && error.customRequest) {
834
+ const managedRequest = __privateGet(this, _options).signal ? new globalThis.Request(error.customRequest, { signal: __privateGet(this, _options).signal }) : new globalThis.Request(error.customRequest);
835
+ __privateMethod(this, _Ky_instances, assignRequest_fn).call(this, managedRequest);
836
+ }
837
+ for (const hook of __privateGet(this, _options).hooks.beforeRetry) {
838
+ const hookResult = yield hook({
839
+ request: this.request,
840
+ options: __privateMethod(this, _Ky_instances, getNormalizedOptions_fn).call(this),
841
+ error,
842
+ retryCount: __privateGet(this, _retryCount)
843
+ });
844
+ if (hookResult instanceof globalThis.Request) {
845
+ __privateMethod(this, _Ky_instances, assignRequest_fn).call(this, hookResult);
628
846
  break;
629
847
  }
630
- if (result instanceof Response) {
631
- return result;
848
+ if (hookResult instanceof globalThis.Response) {
849
+ return hookResult;
850
+ }
851
+ if (hookResult === stop) {
852
+ return;
632
853
  }
633
854
  }
634
- const nonRequestOptions = findUnknownOptions(this.request, this._options);
635
- this._originalRequest = this.request;
636
- this.request = this._originalRequest.clone();
637
- if (this._options.timeout === false) {
638
- return this._options.fetch(this._originalRequest, nonRequestOptions);
855
+ return __privateMethod(this, _Ky_instances, retry_fn).call(this, function_);
856
+ }
857
+ });
858
+ };
859
+ fetch_fn = function() {
860
+ return __async(this, null, function* () {
861
+ var _a;
862
+ if ((_a = __privateGet(this, _abortController)) == null ? void 0 : _a.signal.aborted) {
863
+ __privateSet(this, _abortController, new globalThis.AbortController());
864
+ __privateGet(this, _options).signal = __privateGet(this, _userProvidedAbortSignal) ? AbortSignal.any([__privateGet(this, _userProvidedAbortSignal), __privateGet(this, _abortController).signal]) : __privateGet(this, _abortController).signal;
865
+ this.request = new globalThis.Request(this.request, { signal: __privateGet(this, _options).signal });
866
+ }
867
+ for (const hook of __privateGet(this, _options).hooks.beforeRequest) {
868
+ const result = yield hook(this.request, __privateMethod(this, _Ky_instances, getNormalizedOptions_fn).call(this), { retryCount: __privateGet(this, _retryCount) });
869
+ if (result instanceof Response) {
870
+ return result;
871
+ }
872
+ if (result instanceof globalThis.Request) {
873
+ __privateMethod(this, _Ky_instances, assignRequest_fn).call(this, result);
874
+ break;
639
875
  }
640
- return timeout(this._originalRequest, nonRequestOptions, this.abortController, this._options);
641
- });
876
+ }
877
+ const nonRequestOptions = findUnknownOptions(this.request, __privateGet(this, _options));
878
+ __privateSet(this, _originalRequest, this.request);
879
+ this.request = __privateGet(this, _originalRequest).clone();
880
+ if (__privateGet(this, _options).timeout === false) {
881
+ return __privateGet(this, _options).fetch(__privateGet(this, _originalRequest), nonRequestOptions);
882
+ }
883
+ return timeout(__privateGet(this, _originalRequest), nonRequestOptions, __privateGet(this, _abortController), __privateGet(this, _options));
884
+ });
885
+ };
886
+ getNormalizedOptions_fn = function() {
887
+ if (!__privateGet(this, _cachedNormalizedOptions)) {
888
+ const _a = __privateGet(this, _options), { hooks } = _a, normalizedOptions = __objRest(_a, ["hooks"]);
889
+ __privateSet(this, _cachedNormalizedOptions, Object.freeze(normalizedOptions));
642
890
  }
891
+ return __privateGet(this, _cachedNormalizedOptions);
643
892
  };
644
- _Ky_static = new WeakSet();
645
- normalizeSearchParams_fn = function(searchParams) {
646
- if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
647
- return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== void 0));
893
+ assignRequest_fn = function(request) {
894
+ __privateSet(this, _cachedNormalizedOptions, void 0);
895
+ this.request = __privateMethod(this, _Ky_instances, wrapRequestWithUploadProgress_fn).call(this, request);
896
+ };
897
+ wrapRequestWithUploadProgress_fn = function(request, originalBody) {
898
+ var _a;
899
+ if (!__privateGet(this, _options).onUploadProgress || !request.body) {
900
+ return request;
648
901
  }
649
- return searchParams;
902
+ return streamRequest(request, __privateGet(this, _options).onUploadProgress, (_a = originalBody != null ? originalBody : __privateGet(this, _options).body) != null ? _a : void 0);
650
903
  };
651
904
  __privateAdd(_Ky, _Ky_static);
652
905
  var Ky = _Ky;
653
906
 
654
- // node_modules/.pnpm/ky@1.11.0/node_modules/ky/distribution/index.js
907
+ // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/index.js
655
908
  var createInstance = (defaults) => {
656
909
  const ky2 = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
657
910
  for (const method of requestMethods) {
@@ -665,29 +918,128 @@ var createInstance = (defaults) => {
665
918
  return createInstance(validateAndMerge(defaults, newDefaults));
666
919
  };
667
920
  ky2.stop = stop;
921
+ ky2.retry = retry;
668
922
  return ky2;
669
923
  };
670
924
  var ky = createInstance();
671
925
  var distribution_default = ky;
672
926
 
927
+ // src/email/emails.ts
928
+ import { render } from "@react-email/render";
929
+ var Emails = class {
930
+ constructor(zupost) {
931
+ this.zupost = zupost;
932
+ }
933
+ /**
934
+ * Send an email using template, markdown or HTML content.
935
+ *
936
+ * @param options - Email options including recipient, sender, and content.
937
+ * @returns A promise that resolves to the email response containing emailId.
938
+ *
939
+ * @example
940
+ * ```typescript
941
+ * const zupost = new Zupost('your-api-key');
942
+ *
943
+ * // Send with HTML content
944
+ * const { emailId } = await zupost.emails.send({
945
+ * from: 'sender@example.com',
946
+ * to: 'recipient@example.com',
947
+ * subject: 'Hello World',
948
+ * html: '<h1>Hello!</h1>',
949
+ * });
950
+ *
951
+ * // Send with a template
952
+ * await zupost.emails.send({
953
+ * from: 'sender@example.com',
954
+ * to: ['user1@example.com', 'user2@example.com'],
955
+ * subject: 'Welcome!',
956
+ * templateId: 'welcome-template',
957
+ * variables: { name: 'John' },
958
+ * });
959
+ *
960
+ * // Send with markdown
961
+ * await zupost.emails.send({
962
+ * from: 'sender@example.com',
963
+ * to: 'recipient@example.com',
964
+ * subject: 'Newsletter',
965
+ * markdown: '# Hello\n\nThis is **markdown** content.',
966
+ * });
967
+ * ```
968
+ */
969
+ send(options) {
970
+ return __async(this, null, function* () {
971
+ if (options.react) {
972
+ options.html = yield render(options.react, options.reactOptions);
973
+ delete options.react;
974
+ delete options.reactOptions;
975
+ }
976
+ if (!options.html && !options.markdown && !options.react && !options.templateId) {
977
+ throw new Error("Either html, markdown, react or templateId must be provided");
978
+ }
979
+ if (options.html && options.markdown) {
980
+ throw new Error("Either html or markdown must be provided");
981
+ }
982
+ if (options.react && options.html) {
983
+ throw new Error("Either react or html must be provided");
984
+ }
985
+ return this.zupost.post("email/send", options);
986
+ });
987
+ }
988
+ };
989
+
990
+ // src/campaign/campaigns.ts
991
+ var Campaigns = class {
992
+ constructor(zupost) {
993
+ this.zupost = zupost;
994
+ }
995
+ /**
996
+ * Send a campaign to selected audiences.
997
+ *
998
+ * @param options - Campaign options including the campaign ID.
999
+ * @returns A promise that resolves to the campaign response.
1000
+ *
1001
+ * @example
1002
+ * ```typescript
1003
+ * const zupost = new Zupost('your-api-key');
1004
+ *
1005
+ * const { success, message } = await zupost.campaigns.send({
1006
+ * campaignId: 'campaign_123',
1007
+ * });
1008
+ *
1009
+ * if (success) {
1010
+ * console.log('Campaign sent:', message);
1011
+ * }
1012
+ * ```
1013
+ */
1014
+ send(options) {
1015
+ return __async(this, null, function* () {
1016
+ return this.zupost.post("campaign/send", options);
1017
+ });
1018
+ }
1019
+ };
1020
+
673
1021
  // src/zupost.ts
674
1022
  var Zupost = class {
675
- constructor(apiKey, apiUrl) {
676
- this.apiKey = apiKey;
677
- this.apiUrl = apiUrl;
1023
+ constructor(apiKey, options) {
678
1024
  this.baseUrl = "https://api.zupost.com";
679
1025
  if (!apiKey) {
680
1026
  throw new Error("API key is required");
681
1027
  }
682
- if (apiUrl) {
683
- this.baseUrl = apiUrl;
1028
+ if (options == null ? void 0 : options.baseUrl) {
1029
+ this.baseUrl = options.baseUrl;
684
1030
  }
685
1031
  this.headers = new Headers({
686
1032
  "Authorization": `Bearer ${apiKey}`,
687
1033
  "Content-Type": "application/json",
688
1034
  "User-Agent": `node-sdk@${version}`
689
1035
  });
1036
+ this.emails = new Emails(this);
1037
+ this.campaigns = new Campaigns(this);
690
1038
  }
1039
+ /**
1040
+ * @internal
1041
+ * Makes a request to the Zupost API.
1042
+ */
691
1043
  request(path, method, body) {
692
1044
  return __async(this, null, function* () {
693
1045
  return distribution_default(path, {
@@ -695,15 +1047,23 @@ var Zupost = class {
695
1047
  method,
696
1048
  retry: 3,
697
1049
  prefixUrl: this.baseUrl,
698
- body
1050
+ json: body
699
1051
  }).json();
700
1052
  });
701
1053
  }
1054
+ /**
1055
+ * @internal
1056
+ * Makes a GET request to the Zupost API.
1057
+ */
702
1058
  get(path) {
703
1059
  return __async(this, null, function* () {
704
1060
  return this.request(path, "GET");
705
1061
  });
706
1062
  }
1063
+ /**
1064
+ * @internal
1065
+ * Makes a POST request to the Zupost API.
1066
+ */
707
1067
  post(path, body) {
708
1068
  return __async(this, null, function* () {
709
1069
  return this.request(path, "POST", body);