@postrun/js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2023 @@
1
+ import { zErrorCode } from './chunk-IMU3SG45.js';
2
+ import * as z from 'zod';
3
+
4
+ var ProblemSchema = z.object({
5
+ type: z.string().optional(),
6
+ title: z.string().optional(),
7
+ status: z.number().optional(),
8
+ code: z.string().optional(),
9
+ detail: z.string().optional(),
10
+ // RFC 9457 calls the occurrence id `instance`; our bodies emit it as
11
+ // `request_id`. Tolerate both, preferring `request_id`.
12
+ request_id: z.string().optional(),
13
+ instance: z.string().optional(),
14
+ errors: z.array(z.object({ field: z.string(), code: z.string(), detail: z.string() })).optional()
15
+ });
16
+ var PostrunError = class extends Error {
17
+ status;
18
+ /** The machine-readable code to branch on (closed union), if the body had one. */
19
+ code;
20
+ /** The request id for support/debugging (our `request_id`, or RFC `instance`). */
21
+ request_id;
22
+ /** Per-field validation problems on a 422, surfaced for convenience. */
23
+ fieldErrors;
24
+ problem;
25
+ constructor(status, rawProblem) {
26
+ const problem = ProblemSchema.safeParse(rawProblem).data;
27
+ super(problem?.detail ?? problem?.title ?? `Postrun API error (${status})`);
28
+ this.name = "PostrunError";
29
+ this.status = status;
30
+ this.code = zErrorCode.safeParse(problem?.code).data;
31
+ this.request_id = problem?.request_id ?? problem?.instance;
32
+ this.fieldErrors = problem?.errors ?? [];
33
+ this.problem = problem;
34
+ }
35
+ };
36
+
37
+ // src/client/core/bodySerializer.gen.ts
38
+ var jsonBodySerializer = {
39
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
40
+ };
41
+
42
+ // src/client/core/serverSentEvents.gen.ts
43
+ function createSseClient({
44
+ onRequest,
45
+ onSseError,
46
+ onSseEvent,
47
+ responseTransformer,
48
+ responseValidator,
49
+ sseDefaultRetryDelay,
50
+ sseMaxRetryAttempts,
51
+ sseMaxRetryDelay,
52
+ sseSleepFn,
53
+ url,
54
+ ...options
55
+ }) {
56
+ let lastEventId;
57
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
58
+ const createStream = async function* () {
59
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
60
+ let attempt = 0;
61
+ const signal = options.signal ?? new AbortController().signal;
62
+ while (true) {
63
+ if (signal.aborted) break;
64
+ attempt++;
65
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
66
+ if (lastEventId !== void 0) {
67
+ headers.set("Last-Event-ID", lastEventId);
68
+ }
69
+ try {
70
+ const requestInit = {
71
+ redirect: "follow",
72
+ ...options,
73
+ body: options.serializedBody,
74
+ headers,
75
+ signal
76
+ };
77
+ let request = new Request(url, requestInit);
78
+ if (onRequest) {
79
+ request = await onRequest(url, requestInit);
80
+ }
81
+ const _fetch = options.fetch ?? globalThis.fetch;
82
+ const response = await _fetch(request);
83
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
84
+ if (!response.body) throw new Error("No body in SSE response");
85
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
86
+ let buffer = "";
87
+ const abortHandler = () => {
88
+ try {
89
+ reader.cancel();
90
+ } catch {
91
+ }
92
+ };
93
+ signal.addEventListener("abort", abortHandler);
94
+ try {
95
+ while (true) {
96
+ const { done, value } = await reader.read();
97
+ if (done) break;
98
+ buffer += value;
99
+ buffer = buffer.replace(/\r\n?/g, "\n");
100
+ const chunks = buffer.split("\n\n");
101
+ buffer = chunks.pop() ?? "";
102
+ for (const chunk of chunks) {
103
+ const lines = chunk.split("\n");
104
+ const dataLines = [];
105
+ let eventName;
106
+ for (const line of lines) {
107
+ if (line.startsWith("data:")) {
108
+ dataLines.push(line.replace(/^data:\s*/, ""));
109
+ } else if (line.startsWith("event:")) {
110
+ eventName = line.replace(/^event:\s*/, "");
111
+ } else if (line.startsWith("id:")) {
112
+ lastEventId = line.replace(/^id:\s*/, "");
113
+ } else if (line.startsWith("retry:")) {
114
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
115
+ if (!Number.isNaN(parsed)) {
116
+ retryDelay = parsed;
117
+ }
118
+ }
119
+ }
120
+ let data;
121
+ let parsedJson = false;
122
+ if (dataLines.length) {
123
+ const rawData = dataLines.join("\n");
124
+ try {
125
+ data = JSON.parse(rawData);
126
+ parsedJson = true;
127
+ } catch {
128
+ data = rawData;
129
+ }
130
+ }
131
+ if (parsedJson) {
132
+ if (responseValidator) {
133
+ await responseValidator(data);
134
+ }
135
+ if (responseTransformer) {
136
+ data = await responseTransformer(data);
137
+ }
138
+ }
139
+ onSseEvent?.({
140
+ data,
141
+ event: eventName,
142
+ id: lastEventId,
143
+ retry: retryDelay
144
+ });
145
+ if (dataLines.length) {
146
+ yield data;
147
+ }
148
+ }
149
+ }
150
+ } finally {
151
+ signal.removeEventListener("abort", abortHandler);
152
+ reader.releaseLock();
153
+ }
154
+ break;
155
+ } catch (error) {
156
+ onSseError?.(error);
157
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
158
+ break;
159
+ }
160
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
161
+ await sleep(backoff);
162
+ }
163
+ }
164
+ };
165
+ const stream = createStream();
166
+ return { stream };
167
+ }
168
+
169
+ // src/client/core/pathSerializer.gen.ts
170
+ var separatorArrayExplode = (style) => {
171
+ switch (style) {
172
+ case "label":
173
+ return ".";
174
+ case "matrix":
175
+ return ";";
176
+ case "simple":
177
+ return ",";
178
+ default:
179
+ return "&";
180
+ }
181
+ };
182
+ var separatorArrayNoExplode = (style) => {
183
+ switch (style) {
184
+ case "form":
185
+ return ",";
186
+ case "pipeDelimited":
187
+ return "|";
188
+ case "spaceDelimited":
189
+ return "%20";
190
+ default:
191
+ return ",";
192
+ }
193
+ };
194
+ var separatorObjectExplode = (style) => {
195
+ switch (style) {
196
+ case "label":
197
+ return ".";
198
+ case "matrix":
199
+ return ";";
200
+ case "simple":
201
+ return ",";
202
+ default:
203
+ return "&";
204
+ }
205
+ };
206
+ var serializeArrayParam = ({
207
+ allowReserved,
208
+ explode,
209
+ name,
210
+ style,
211
+ value
212
+ }) => {
213
+ if (!explode) {
214
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
215
+ switch (style) {
216
+ case "label":
217
+ return `.${joinedValues2}`;
218
+ case "matrix":
219
+ return `;${name}=${joinedValues2}`;
220
+ case "simple":
221
+ return joinedValues2;
222
+ default:
223
+ return `${name}=${joinedValues2}`;
224
+ }
225
+ }
226
+ const separator = separatorArrayExplode(style);
227
+ const joinedValues = value.map((v) => {
228
+ if (style === "label" || style === "simple") {
229
+ return allowReserved ? v : encodeURIComponent(v);
230
+ }
231
+ return serializePrimitiveParam({
232
+ allowReserved,
233
+ name,
234
+ value: v
235
+ });
236
+ }).join(separator);
237
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
238
+ };
239
+ var serializePrimitiveParam = ({
240
+ allowReserved,
241
+ name,
242
+ value
243
+ }) => {
244
+ if (value === void 0 || value === null) {
245
+ return "";
246
+ }
247
+ if (typeof value === "object") {
248
+ throw new Error(
249
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
250
+ );
251
+ }
252
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
253
+ };
254
+ var serializeObjectParam = ({
255
+ allowReserved,
256
+ explode,
257
+ name,
258
+ style,
259
+ value,
260
+ valueOnly
261
+ }) => {
262
+ if (value instanceof Date) {
263
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
264
+ }
265
+ if (style !== "deepObject" && !explode) {
266
+ let values = [];
267
+ Object.entries(value).forEach(([key, v]) => {
268
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
269
+ });
270
+ const joinedValues2 = values.join(",");
271
+ switch (style) {
272
+ case "form":
273
+ return `${name}=${joinedValues2}`;
274
+ case "label":
275
+ return `.${joinedValues2}`;
276
+ case "matrix":
277
+ return `;${name}=${joinedValues2}`;
278
+ default:
279
+ return joinedValues2;
280
+ }
281
+ }
282
+ const separator = separatorObjectExplode(style);
283
+ const joinedValues = Object.entries(value).map(
284
+ ([key, v]) => serializePrimitiveParam({
285
+ allowReserved,
286
+ name: style === "deepObject" ? `${name}[${key}]` : key,
287
+ value: v
288
+ })
289
+ ).join(separator);
290
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
291
+ };
292
+
293
+ // src/client/core/utils.gen.ts
294
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
295
+ var defaultPathSerializer = ({ path, url: _url }) => {
296
+ let url = _url;
297
+ const matches = _url.match(PATH_PARAM_RE);
298
+ if (matches) {
299
+ for (const match of matches) {
300
+ let explode = false;
301
+ let name = match.substring(1, match.length - 1);
302
+ let style = "simple";
303
+ if (name.endsWith("*")) {
304
+ explode = true;
305
+ name = name.substring(0, name.length - 1);
306
+ }
307
+ if (name.startsWith(".")) {
308
+ name = name.substring(1);
309
+ style = "label";
310
+ } else if (name.startsWith(";")) {
311
+ name = name.substring(1);
312
+ style = "matrix";
313
+ }
314
+ const value = path[name];
315
+ if (value === void 0 || value === null) {
316
+ continue;
317
+ }
318
+ if (Array.isArray(value)) {
319
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
320
+ continue;
321
+ }
322
+ if (typeof value === "object") {
323
+ url = url.replace(
324
+ match,
325
+ serializeObjectParam({
326
+ explode,
327
+ name,
328
+ style,
329
+ value,
330
+ valueOnly: true
331
+ })
332
+ );
333
+ continue;
334
+ }
335
+ if (style === "matrix") {
336
+ url = url.replace(
337
+ match,
338
+ `;${serializePrimitiveParam({
339
+ name,
340
+ value
341
+ })}`
342
+ );
343
+ continue;
344
+ }
345
+ const replaceValue = encodeURIComponent(
346
+ style === "label" ? `.${value}` : value
347
+ );
348
+ url = url.replace(match, replaceValue);
349
+ }
350
+ }
351
+ return url;
352
+ };
353
+ var getUrl = ({
354
+ baseUrl,
355
+ path,
356
+ query,
357
+ querySerializer,
358
+ url: _url
359
+ }) => {
360
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
361
+ let url = (baseUrl ?? "") + pathUrl;
362
+ if (path) {
363
+ url = defaultPathSerializer({ path, url });
364
+ }
365
+ let search = query ? querySerializer(query) : "";
366
+ if (search.startsWith("?")) {
367
+ search = search.substring(1);
368
+ }
369
+ if (search) {
370
+ url += `?${search}`;
371
+ }
372
+ return url;
373
+ };
374
+ function getValidRequestBody(options) {
375
+ const hasBody = options.body !== void 0;
376
+ const isSerializedBody = hasBody && options.bodySerializer;
377
+ if (isSerializedBody) {
378
+ if ("serializedBody" in options) {
379
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
380
+ return hasSerializedBody ? options.serializedBody : null;
381
+ }
382
+ return options.body !== "" ? options.body : null;
383
+ }
384
+ if (hasBody) {
385
+ return options.body;
386
+ }
387
+ return void 0;
388
+ }
389
+
390
+ // src/client/core/auth.gen.ts
391
+ var getAuthToken = async (auth, callback) => {
392
+ const token = typeof callback === "function" ? await callback(auth) : callback;
393
+ if (!token) {
394
+ return;
395
+ }
396
+ if (auth.scheme === "bearer") {
397
+ return `Bearer ${token}`;
398
+ }
399
+ if (auth.scheme === "basic") {
400
+ return `Basic ${btoa(token)}`;
401
+ }
402
+ return token;
403
+ };
404
+
405
+ // src/client/client/utils.gen.ts
406
+ var createQuerySerializer = ({
407
+ parameters = {},
408
+ ...args
409
+ } = {}) => {
410
+ const querySerializer = (queryParams) => {
411
+ const search = [];
412
+ if (queryParams && typeof queryParams === "object") {
413
+ for (const name in queryParams) {
414
+ const value = queryParams[name];
415
+ if (value === void 0 || value === null) {
416
+ continue;
417
+ }
418
+ const options = parameters[name] || args;
419
+ if (Array.isArray(value)) {
420
+ const serializedArray = serializeArrayParam({
421
+ allowReserved: options.allowReserved,
422
+ explode: true,
423
+ name,
424
+ style: "form",
425
+ value,
426
+ ...options.array
427
+ });
428
+ if (serializedArray) search.push(serializedArray);
429
+ } else if (typeof value === "object") {
430
+ const serializedObject = serializeObjectParam({
431
+ allowReserved: options.allowReserved,
432
+ explode: true,
433
+ name,
434
+ style: "deepObject",
435
+ value,
436
+ ...options.object
437
+ });
438
+ if (serializedObject) search.push(serializedObject);
439
+ } else {
440
+ const serializedPrimitive = serializePrimitiveParam({
441
+ allowReserved: options.allowReserved,
442
+ name,
443
+ value
444
+ });
445
+ if (serializedPrimitive) search.push(serializedPrimitive);
446
+ }
447
+ }
448
+ }
449
+ return search.join("&");
450
+ };
451
+ return querySerializer;
452
+ };
453
+ var getParseAs = (contentType) => {
454
+ if (!contentType) {
455
+ return "stream";
456
+ }
457
+ const cleanContent = contentType.split(";")[0]?.trim();
458
+ if (!cleanContent) {
459
+ return;
460
+ }
461
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
462
+ return "json";
463
+ }
464
+ if (cleanContent === "multipart/form-data") {
465
+ return "formData";
466
+ }
467
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
468
+ return "blob";
469
+ }
470
+ if (cleanContent.startsWith("text/")) {
471
+ return "text";
472
+ }
473
+ return;
474
+ };
475
+ var checkForExistence = (options, name) => {
476
+ if (!name) {
477
+ return false;
478
+ }
479
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
480
+ return true;
481
+ }
482
+ return false;
483
+ };
484
+ async function setAuthParams(options) {
485
+ for (const auth of options.security ?? []) {
486
+ if (checkForExistence(options, auth.name)) {
487
+ continue;
488
+ }
489
+ const token = await getAuthToken(auth, options.auth);
490
+ if (!token) {
491
+ continue;
492
+ }
493
+ const name = auth.name ?? "Authorization";
494
+ switch (auth.in) {
495
+ case "query":
496
+ if (!options.query) {
497
+ options.query = {};
498
+ }
499
+ options.query[name] = token;
500
+ break;
501
+ case "cookie":
502
+ options.headers.append("Cookie", `${name}=${token}`);
503
+ break;
504
+ case "header":
505
+ default:
506
+ options.headers.set(name, token);
507
+ break;
508
+ }
509
+ }
510
+ }
511
+ var buildUrl = (options) => getUrl({
512
+ baseUrl: options.baseUrl,
513
+ path: options.path,
514
+ query: options.query,
515
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
516
+ url: options.url
517
+ });
518
+ var mergeConfigs = (a, b) => {
519
+ const config = { ...a, ...b };
520
+ if (config.baseUrl?.endsWith("/")) {
521
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
522
+ }
523
+ config.headers = mergeHeaders(a.headers, b.headers);
524
+ return config;
525
+ };
526
+ var headersEntries = (headers) => {
527
+ const entries = [];
528
+ headers.forEach((value, key) => {
529
+ entries.push([key, value]);
530
+ });
531
+ return entries;
532
+ };
533
+ var mergeHeaders = (...headers) => {
534
+ const mergedHeaders = new Headers();
535
+ for (const header of headers) {
536
+ if (!header) {
537
+ continue;
538
+ }
539
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
540
+ for (const [key, value] of iterator) {
541
+ if (value === null) {
542
+ mergedHeaders.delete(key);
543
+ } else if (Array.isArray(value)) {
544
+ for (const v of value) {
545
+ mergedHeaders.append(key, v);
546
+ }
547
+ } else if (value !== void 0) {
548
+ mergedHeaders.set(
549
+ key,
550
+ typeof value === "object" ? JSON.stringify(value) : value
551
+ );
552
+ }
553
+ }
554
+ }
555
+ return mergedHeaders;
556
+ };
557
+ var Interceptors = class {
558
+ fns = [];
559
+ clear() {
560
+ this.fns = [];
561
+ }
562
+ eject(id) {
563
+ const index = this.getInterceptorIndex(id);
564
+ if (this.fns[index]) {
565
+ this.fns[index] = null;
566
+ }
567
+ }
568
+ exists(id) {
569
+ const index = this.getInterceptorIndex(id);
570
+ return Boolean(this.fns[index]);
571
+ }
572
+ getInterceptorIndex(id) {
573
+ if (typeof id === "number") {
574
+ return this.fns[id] ? id : -1;
575
+ }
576
+ return this.fns.indexOf(id);
577
+ }
578
+ update(id, fn) {
579
+ const index = this.getInterceptorIndex(id);
580
+ if (this.fns[index]) {
581
+ this.fns[index] = fn;
582
+ return id;
583
+ }
584
+ return false;
585
+ }
586
+ use(fn) {
587
+ this.fns.push(fn);
588
+ return this.fns.length - 1;
589
+ }
590
+ };
591
+ var createInterceptors = () => ({
592
+ error: new Interceptors(),
593
+ request: new Interceptors(),
594
+ response: new Interceptors()
595
+ });
596
+ var defaultQuerySerializer = createQuerySerializer({
597
+ allowReserved: false,
598
+ array: {
599
+ explode: true,
600
+ style: "form"
601
+ },
602
+ object: {
603
+ explode: true,
604
+ style: "deepObject"
605
+ }
606
+ });
607
+ var defaultHeaders = {
608
+ "Content-Type": "application/json"
609
+ };
610
+ var createConfig = (override = {}) => ({
611
+ ...jsonBodySerializer,
612
+ headers: defaultHeaders,
613
+ parseAs: "auto",
614
+ querySerializer: defaultQuerySerializer,
615
+ ...override
616
+ });
617
+
618
+ // src/client/client/client.gen.ts
619
+ var createClient = (config = {}) => {
620
+ let _config = mergeConfigs(createConfig(), config);
621
+ const getConfig = () => ({ ..._config });
622
+ const setConfig = (config2) => {
623
+ _config = mergeConfigs(_config, config2);
624
+ return getConfig();
625
+ };
626
+ const interceptors = createInterceptors();
627
+ const beforeRequest = async (options) => {
628
+ const opts = {
629
+ ..._config,
630
+ ...options,
631
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
632
+ headers: mergeHeaders(_config.headers, options.headers),
633
+ serializedBody: void 0
634
+ };
635
+ if (opts.security) {
636
+ await setAuthParams(opts);
637
+ }
638
+ if (opts.requestValidator) {
639
+ await opts.requestValidator(opts);
640
+ }
641
+ if (opts.body !== void 0 && opts.bodySerializer) {
642
+ opts.serializedBody = opts.bodySerializer(opts.body);
643
+ }
644
+ if (opts.body === void 0 || opts.serializedBody === "") {
645
+ opts.headers.delete("Content-Type");
646
+ }
647
+ const resolvedOpts = opts;
648
+ const url = buildUrl(resolvedOpts);
649
+ return { opts: resolvedOpts, url };
650
+ };
651
+ const request = async (options) => {
652
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
653
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
654
+ let request2;
655
+ let response;
656
+ try {
657
+ const { opts, url } = await beforeRequest(options);
658
+ const requestInit = {
659
+ redirect: "follow",
660
+ ...opts,
661
+ body: getValidRequestBody(opts)
662
+ };
663
+ request2 = new Request(url, requestInit);
664
+ for (const fn of interceptors.request.fns) {
665
+ if (fn) {
666
+ request2 = await fn(request2, opts);
667
+ }
668
+ }
669
+ const _fetch = opts.fetch;
670
+ response = await _fetch(request2);
671
+ for (const fn of interceptors.response.fns) {
672
+ if (fn) {
673
+ response = await fn(response, request2, opts);
674
+ }
675
+ }
676
+ const result = {
677
+ request: request2,
678
+ response
679
+ };
680
+ if (response.ok) {
681
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
682
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
683
+ let emptyData;
684
+ switch (parseAs) {
685
+ case "arrayBuffer":
686
+ case "blob":
687
+ case "text":
688
+ emptyData = await response[parseAs]();
689
+ break;
690
+ case "formData":
691
+ emptyData = new FormData();
692
+ break;
693
+ case "stream":
694
+ emptyData = response.body;
695
+ break;
696
+ case "json":
697
+ default:
698
+ emptyData = {};
699
+ break;
700
+ }
701
+ return opts.responseStyle === "data" ? emptyData : {
702
+ data: emptyData,
703
+ ...result
704
+ };
705
+ }
706
+ let data;
707
+ switch (parseAs) {
708
+ case "arrayBuffer":
709
+ case "blob":
710
+ case "formData":
711
+ case "text":
712
+ data = await response[parseAs]();
713
+ break;
714
+ case "json": {
715
+ const text = await response.text();
716
+ data = text ? JSON.parse(text) : {};
717
+ break;
718
+ }
719
+ case "stream":
720
+ return opts.responseStyle === "data" ? response.body : {
721
+ data: response.body,
722
+ ...result
723
+ };
724
+ }
725
+ if (parseAs === "json") {
726
+ if (opts.responseValidator) {
727
+ await opts.responseValidator(data);
728
+ }
729
+ if (opts.responseTransformer) {
730
+ data = await opts.responseTransformer(data);
731
+ }
732
+ }
733
+ return opts.responseStyle === "data" ? data : {
734
+ data,
735
+ ...result
736
+ };
737
+ }
738
+ const textError = await response.text();
739
+ let jsonError;
740
+ try {
741
+ jsonError = JSON.parse(textError);
742
+ } catch {
743
+ }
744
+ throw jsonError ?? textError;
745
+ } catch (error) {
746
+ let finalError = error;
747
+ for (const fn of interceptors.error.fns) {
748
+ if (fn) {
749
+ finalError = await fn(finalError, response, request2, options);
750
+ }
751
+ }
752
+ finalError = finalError || {};
753
+ if (throwOnError) {
754
+ throw finalError;
755
+ }
756
+ return responseStyle === "data" ? void 0 : {
757
+ error: finalError,
758
+ request: request2,
759
+ response
760
+ };
761
+ }
762
+ };
763
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
764
+ const makeSseFn = (method) => async (options) => {
765
+ const { opts, url } = await beforeRequest(options);
766
+ return createSseClient({
767
+ ...opts,
768
+ body: opts.body,
769
+ method,
770
+ onRequest: async (url2, init) => {
771
+ let request2 = new Request(url2, init);
772
+ for (const fn of interceptors.request.fns) {
773
+ if (fn) {
774
+ request2 = await fn(request2, opts);
775
+ }
776
+ }
777
+ return request2;
778
+ },
779
+ serializedBody: getValidRequestBody(opts),
780
+ url
781
+ });
782
+ };
783
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
784
+ return {
785
+ buildUrl: _buildUrl,
786
+ connect: makeMethodFn("CONNECT"),
787
+ delete: makeMethodFn("DELETE"),
788
+ get: makeMethodFn("GET"),
789
+ getConfig,
790
+ head: makeMethodFn("HEAD"),
791
+ interceptors,
792
+ options: makeMethodFn("OPTIONS"),
793
+ patch: makeMethodFn("PATCH"),
794
+ post: makeMethodFn("POST"),
795
+ put: makeMethodFn("PUT"),
796
+ request,
797
+ setConfig,
798
+ sse: {
799
+ connect: makeSseFn("CONNECT"),
800
+ delete: makeSseFn("DELETE"),
801
+ get: makeSseFn("GET"),
802
+ head: makeSseFn("HEAD"),
803
+ options: makeSseFn("OPTIONS"),
804
+ patch: makeSseFn("PATCH"),
805
+ post: makeSseFn("POST"),
806
+ put: makeSseFn("PUT"),
807
+ trace: makeSseFn("TRACE")
808
+ },
809
+ trace: makeMethodFn("TRACE")
810
+ };
811
+ };
812
+
813
+ // src/client.ts
814
+ var DEFAULT_BASE_URL = "https://api.postrun.ai/v1";
815
+ function appendScalar(parts, key, value) {
816
+ parts.push(
817
+ `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
818
+ );
819
+ }
820
+ function serializeQuery(query) {
821
+ const parts = [];
822
+ for (const [key, value] of Object.entries(query)) {
823
+ if (value === void 0 || value === null) {
824
+ continue;
825
+ }
826
+ if (Array.isArray(value)) {
827
+ for (const item of value) {
828
+ if (item !== void 0 && item !== null) {
829
+ appendScalar(parts, key, item);
830
+ }
831
+ }
832
+ } else if (typeof value === "object") {
833
+ appendScalar(parts, key, JSON.stringify(value));
834
+ } else {
835
+ appendScalar(parts, key, value);
836
+ }
837
+ }
838
+ return parts.join("&");
839
+ }
840
+ function createPostrunClient(options) {
841
+ const client2 = createClient(
842
+ createConfig({
843
+ baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
844
+ auth: () => options.getToken(),
845
+ querySerializer: serializeQuery,
846
+ throwOnError: true
847
+ })
848
+ );
849
+ client2.interceptors.error.use(
850
+ (error, response) => error instanceof PostrunError ? error : new PostrunError(response?.status ?? 0, error)
851
+ );
852
+ return client2;
853
+ }
854
+
855
+ // src/client/client.gen.ts
856
+ var client = createClient(createConfig({ baseUrl: "https://api.postrun.ai/v1", throwOnError: true }));
857
+
858
+ // src/client/sdk.gen.ts
859
+ var profilesList = (options) => (options?.client ?? client).get({
860
+ security: [{
861
+ key: "secretKey",
862
+ scheme: "bearer",
863
+ type: "http"
864
+ }, {
865
+ key: "frontendToken",
866
+ scheme: "bearer",
867
+ type: "http"
868
+ }],
869
+ url: "/profiles",
870
+ ...options
871
+ });
872
+ var profilesCreate = (options) => (options.client ?? client).post({
873
+ security: [{
874
+ key: "secretKey",
875
+ scheme: "bearer",
876
+ type: "http"
877
+ }, {
878
+ key: "frontendToken",
879
+ scheme: "bearer",
880
+ type: "http"
881
+ }],
882
+ url: "/profiles",
883
+ ...options,
884
+ headers: {
885
+ "Content-Type": "application/json",
886
+ ...options.headers
887
+ }
888
+ });
889
+ var profilesDelete = (options) => (options.client ?? client).delete({
890
+ security: [{
891
+ key: "secretKey",
892
+ scheme: "bearer",
893
+ type: "http"
894
+ }, {
895
+ key: "frontendToken",
896
+ scheme: "bearer",
897
+ type: "http"
898
+ }],
899
+ url: "/profiles/{id}",
900
+ ...options
901
+ });
902
+ var profilesGet = (options) => (options.client ?? client).get({
903
+ security: [{
904
+ key: "secretKey",
905
+ scheme: "bearer",
906
+ type: "http"
907
+ }, {
908
+ key: "frontendToken",
909
+ scheme: "bearer",
910
+ type: "http"
911
+ }],
912
+ url: "/profiles/{id}",
913
+ ...options
914
+ });
915
+ var profilesUpdate = (options) => (options.client ?? client).patch({
916
+ security: [{
917
+ key: "secretKey",
918
+ scheme: "bearer",
919
+ type: "http"
920
+ }, {
921
+ key: "frontendToken",
922
+ scheme: "bearer",
923
+ type: "http"
924
+ }],
925
+ url: "/profiles/{id}",
926
+ ...options,
927
+ headers: {
928
+ "Content-Type": "application/json",
929
+ ...options.headers
930
+ }
931
+ });
932
+ var connectionsListByProfile = (options) => (options.client ?? client).get({
933
+ security: [{
934
+ key: "secretKey",
935
+ scheme: "bearer",
936
+ type: "http"
937
+ }, {
938
+ key: "frontendToken",
939
+ scheme: "bearer",
940
+ type: "http"
941
+ }],
942
+ url: "/profiles/{id}/connections",
943
+ ...options
944
+ });
945
+ var connectionsDelete = (options) => (options.client ?? client).delete({
946
+ security: [{
947
+ key: "secretKey",
948
+ scheme: "bearer",
949
+ type: "http"
950
+ }, {
951
+ key: "frontendToken",
952
+ scheme: "bearer",
953
+ type: "http"
954
+ }],
955
+ url: "/connections/{id}",
956
+ ...options
957
+ });
958
+ var connectionsGet = (options) => (options.client ?? client).get({
959
+ security: [{
960
+ key: "secretKey",
961
+ scheme: "bearer",
962
+ type: "http"
963
+ }, {
964
+ key: "frontendToken",
965
+ scheme: "bearer",
966
+ type: "http"
967
+ }],
968
+ url: "/connections/{id}",
969
+ ...options
970
+ });
971
+ var connectionsSelect = (options) => (options.client ?? client).patch({
972
+ security: [{
973
+ key: "secretKey",
974
+ scheme: "bearer",
975
+ type: "http"
976
+ }, {
977
+ key: "frontendToken",
978
+ scheme: "bearer",
979
+ type: "http"
980
+ }],
981
+ url: "/connections/{id}",
982
+ ...options,
983
+ headers: {
984
+ "Content-Type": "application/json",
985
+ ...options.headers
986
+ }
987
+ });
988
+ var connectionsListAccounts = (options) => (options.client ?? client).get({
989
+ security: [{
990
+ key: "secretKey",
991
+ scheme: "bearer",
992
+ type: "http"
993
+ }, {
994
+ key: "frontendToken",
995
+ scheme: "bearer",
996
+ type: "http"
997
+ }],
998
+ url: "/connections/{id}/accounts",
999
+ ...options
1000
+ });
1001
+ var connectionsConnect = (options) => (options.client ?? client).post({
1002
+ security: [{
1003
+ key: "secretKey",
1004
+ scheme: "bearer",
1005
+ type: "http"
1006
+ }, {
1007
+ key: "frontendToken",
1008
+ scheme: "bearer",
1009
+ type: "http"
1010
+ }],
1011
+ url: "/profiles/{id}/connect",
1012
+ ...options,
1013
+ headers: {
1014
+ "Content-Type": "application/json",
1015
+ ...options.headers
1016
+ }
1017
+ });
1018
+ var mediaCreate = (options) => (options.client ?? client).post({
1019
+ security: [{
1020
+ key: "secretKey",
1021
+ scheme: "bearer",
1022
+ type: "http"
1023
+ }, {
1024
+ key: "frontendToken",
1025
+ scheme: "bearer",
1026
+ type: "http"
1027
+ }],
1028
+ url: "/media",
1029
+ ...options,
1030
+ headers: {
1031
+ "Content-Type": "application/json",
1032
+ ...options.headers
1033
+ }
1034
+ });
1035
+ var mediaDelete = (options) => (options.client ?? client).delete({
1036
+ security: [{
1037
+ key: "secretKey",
1038
+ scheme: "bearer",
1039
+ type: "http"
1040
+ }, {
1041
+ key: "frontendToken",
1042
+ scheme: "bearer",
1043
+ type: "http"
1044
+ }],
1045
+ url: "/media/{id}",
1046
+ ...options
1047
+ });
1048
+ var mediaGet = (options) => (options.client ?? client).get({
1049
+ security: [{
1050
+ key: "secretKey",
1051
+ scheme: "bearer",
1052
+ type: "http"
1053
+ }, {
1054
+ key: "frontendToken",
1055
+ scheme: "bearer",
1056
+ type: "http"
1057
+ }],
1058
+ url: "/media/{id}",
1059
+ ...options
1060
+ });
1061
+ var mediaUpdate = (options) => (options.client ?? client).patch({
1062
+ security: [{
1063
+ key: "secretKey",
1064
+ scheme: "bearer",
1065
+ type: "http"
1066
+ }, {
1067
+ key: "frontendToken",
1068
+ scheme: "bearer",
1069
+ type: "http"
1070
+ }],
1071
+ url: "/media/{id}",
1072
+ ...options,
1073
+ headers: {
1074
+ "Content-Type": "application/json",
1075
+ ...options.headers
1076
+ }
1077
+ });
1078
+ var postsList = (options) => (options?.client ?? client).get({
1079
+ security: [{
1080
+ key: "secretKey",
1081
+ scheme: "bearer",
1082
+ type: "http"
1083
+ }, {
1084
+ key: "frontendToken",
1085
+ scheme: "bearer",
1086
+ type: "http"
1087
+ }],
1088
+ url: "/posts",
1089
+ ...options
1090
+ });
1091
+ var postsCreate = (options) => (options.client ?? client).post({
1092
+ security: [{
1093
+ key: "secretKey",
1094
+ scheme: "bearer",
1095
+ type: "http"
1096
+ }, {
1097
+ key: "frontendToken",
1098
+ scheme: "bearer",
1099
+ type: "http"
1100
+ }],
1101
+ url: "/posts",
1102
+ ...options,
1103
+ headers: {
1104
+ "Content-Type": "application/json",
1105
+ ...options.headers
1106
+ }
1107
+ });
1108
+ var postsDelete = (options) => (options.client ?? client).delete({
1109
+ security: [{
1110
+ key: "secretKey",
1111
+ scheme: "bearer",
1112
+ type: "http"
1113
+ }, {
1114
+ key: "frontendToken",
1115
+ scheme: "bearer",
1116
+ type: "http"
1117
+ }],
1118
+ url: "/posts/{id}",
1119
+ ...options
1120
+ });
1121
+ var postsGet = (options) => (options.client ?? client).get({
1122
+ security: [{
1123
+ key: "secretKey",
1124
+ scheme: "bearer",
1125
+ type: "http"
1126
+ }, {
1127
+ key: "frontendToken",
1128
+ scheme: "bearer",
1129
+ type: "http"
1130
+ }],
1131
+ url: "/posts/{id}",
1132
+ ...options
1133
+ });
1134
+ var postsUpdate = (options) => (options.client ?? client).patch({
1135
+ security: [{
1136
+ key: "secretKey",
1137
+ scheme: "bearer",
1138
+ type: "http"
1139
+ }, {
1140
+ key: "frontendToken",
1141
+ scheme: "bearer",
1142
+ type: "http"
1143
+ }],
1144
+ url: "/posts/{id}",
1145
+ ...options,
1146
+ headers: {
1147
+ "Content-Type": "application/json",
1148
+ ...options.headers
1149
+ }
1150
+ });
1151
+ var metaAccount = (options) => (options.client ?? client).get({
1152
+ security: [{
1153
+ key: "secretKey",
1154
+ scheme: "bearer",
1155
+ type: "http"
1156
+ }, {
1157
+ key: "frontendToken",
1158
+ scheme: "bearer",
1159
+ type: "http"
1160
+ }],
1161
+ url: "/meta/{connection_id}/account",
1162
+ ...options
1163
+ });
1164
+ var metaInsights = (options) => (options.client ?? client).get({
1165
+ security: [{
1166
+ key: "secretKey",
1167
+ scheme: "bearer",
1168
+ type: "http"
1169
+ }, {
1170
+ key: "frontendToken",
1171
+ scheme: "bearer",
1172
+ type: "http"
1173
+ }],
1174
+ url: "/meta/{connection_id}/insights",
1175
+ ...options
1176
+ });
1177
+ var metaCampaigns = (options) => (options.client ?? client).get({
1178
+ security: [{
1179
+ key: "secretKey",
1180
+ scheme: "bearer",
1181
+ type: "http"
1182
+ }, {
1183
+ key: "frontendToken",
1184
+ scheme: "bearer",
1185
+ type: "http"
1186
+ }],
1187
+ url: "/meta/{connection_id}/campaigns",
1188
+ ...options
1189
+ });
1190
+ var metaCampaign = (options) => (options.client ?? client).get({
1191
+ security: [{
1192
+ key: "secretKey",
1193
+ scheme: "bearer",
1194
+ type: "http"
1195
+ }, {
1196
+ key: "frontendToken",
1197
+ scheme: "bearer",
1198
+ type: "http"
1199
+ }],
1200
+ url: "/meta/{connection_id}/campaigns/{campaign_id}",
1201
+ ...options
1202
+ });
1203
+ var metaAdsets = (options) => (options.client ?? client).get({
1204
+ security: [{
1205
+ key: "secretKey",
1206
+ scheme: "bearer",
1207
+ type: "http"
1208
+ }, {
1209
+ key: "frontendToken",
1210
+ scheme: "bearer",
1211
+ type: "http"
1212
+ }],
1213
+ url: "/meta/{connection_id}/adsets",
1214
+ ...options
1215
+ });
1216
+ var metaAdset = (options) => (options.client ?? client).get({
1217
+ security: [{
1218
+ key: "secretKey",
1219
+ scheme: "bearer",
1220
+ type: "http"
1221
+ }, {
1222
+ key: "frontendToken",
1223
+ scheme: "bearer",
1224
+ type: "http"
1225
+ }],
1226
+ url: "/meta/{connection_id}/adsets/{adset_id}",
1227
+ ...options
1228
+ });
1229
+ var metaAds = (options) => (options.client ?? client).get({
1230
+ security: [{
1231
+ key: "secretKey",
1232
+ scheme: "bearer",
1233
+ type: "http"
1234
+ }, {
1235
+ key: "frontendToken",
1236
+ scheme: "bearer",
1237
+ type: "http"
1238
+ }],
1239
+ url: "/meta/{connection_id}/ads",
1240
+ ...options
1241
+ });
1242
+ var metaAd = (options) => (options.client ?? client).get({
1243
+ security: [{
1244
+ key: "secretKey",
1245
+ scheme: "bearer",
1246
+ type: "http"
1247
+ }, {
1248
+ key: "frontendToken",
1249
+ scheme: "bearer",
1250
+ type: "http"
1251
+ }],
1252
+ url: "/meta/{connection_id}/ads/{ad_id}",
1253
+ ...options
1254
+ });
1255
+ var googleGetAccount = (options) => (options.client ?? client).get({
1256
+ security: [{
1257
+ key: "secretKey",
1258
+ scheme: "bearer",
1259
+ type: "http"
1260
+ }, {
1261
+ key: "frontendToken",
1262
+ scheme: "bearer",
1263
+ type: "http"
1264
+ }],
1265
+ url: "/google/{connection_id}/account",
1266
+ ...options
1267
+ });
1268
+ var googleGetInsights = (options) => (options.client ?? client).post({
1269
+ security: [{
1270
+ key: "secretKey",
1271
+ scheme: "bearer",
1272
+ type: "http"
1273
+ }, {
1274
+ key: "frontendToken",
1275
+ scheme: "bearer",
1276
+ type: "http"
1277
+ }],
1278
+ url: "/google/{connection_id}/insights",
1279
+ ...options,
1280
+ headers: {
1281
+ "Content-Type": "application/json",
1282
+ ...options.headers
1283
+ }
1284
+ });
1285
+ var googleRunGaql = (options) => (options.client ?? client).post({
1286
+ security: [{
1287
+ key: "secretKey",
1288
+ scheme: "bearer",
1289
+ type: "http"
1290
+ }, {
1291
+ key: "frontendToken",
1292
+ scheme: "bearer",
1293
+ type: "http"
1294
+ }],
1295
+ url: "/google/{connection_id}/gaql",
1296
+ ...options,
1297
+ headers: {
1298
+ "Content-Type": "application/json",
1299
+ ...options.headers
1300
+ }
1301
+ });
1302
+ var googleCreateBudget = (options) => (options.client ?? client).post({
1303
+ security: [{
1304
+ key: "secretKey",
1305
+ scheme: "bearer",
1306
+ type: "http"
1307
+ }],
1308
+ url: "/google/{connection_id}/budgets",
1309
+ ...options,
1310
+ headers: {
1311
+ "Content-Type": "application/json",
1312
+ ...options.headers
1313
+ }
1314
+ });
1315
+ var googleDeleteBudget = (options) => (options.client ?? client).delete({
1316
+ security: [{
1317
+ key: "secretKey",
1318
+ scheme: "bearer",
1319
+ type: "http"
1320
+ }, {
1321
+ key: "frontendToken",
1322
+ scheme: "bearer",
1323
+ type: "http"
1324
+ }],
1325
+ url: "/google/{connection_id}/budgets/{id}",
1326
+ ...options,
1327
+ headers: {
1328
+ "Content-Type": "application/json",
1329
+ ...options.headers
1330
+ }
1331
+ });
1332
+ var googleEditBudget = (options) => (options.client ?? client).patch({
1333
+ security: [{
1334
+ key: "secretKey",
1335
+ scheme: "bearer",
1336
+ type: "http"
1337
+ }],
1338
+ url: "/google/{connection_id}/budgets/{id}",
1339
+ ...options,
1340
+ headers: {
1341
+ "Content-Type": "application/json",
1342
+ ...options.headers
1343
+ }
1344
+ });
1345
+ var googleListCampaigns = (options) => (options.client ?? client).get({
1346
+ security: [{
1347
+ key: "secretKey",
1348
+ scheme: "bearer",
1349
+ type: "http"
1350
+ }, {
1351
+ key: "frontendToken",
1352
+ scheme: "bearer",
1353
+ type: "http"
1354
+ }],
1355
+ url: "/google/{connection_id}/campaigns",
1356
+ ...options
1357
+ });
1358
+ var googleCreateCampaign = (options) => (options.client ?? client).post({
1359
+ security: [{
1360
+ key: "secretKey",
1361
+ scheme: "bearer",
1362
+ type: "http"
1363
+ }, {
1364
+ key: "frontendToken",
1365
+ scheme: "bearer",
1366
+ type: "http"
1367
+ }],
1368
+ url: "/google/{connection_id}/campaigns",
1369
+ ...options,
1370
+ headers: {
1371
+ "Content-Type": "application/json",
1372
+ ...options.headers
1373
+ }
1374
+ });
1375
+ var googleDeleteCampaign = (options) => (options.client ?? client).delete({
1376
+ security: [{
1377
+ key: "secretKey",
1378
+ scheme: "bearer",
1379
+ type: "http"
1380
+ }, {
1381
+ key: "frontendToken",
1382
+ scheme: "bearer",
1383
+ type: "http"
1384
+ }],
1385
+ url: "/google/{connection_id}/campaigns/{id}",
1386
+ ...options,
1387
+ headers: {
1388
+ "Content-Type": "application/json",
1389
+ ...options.headers
1390
+ }
1391
+ });
1392
+ var googleGetCampaign = (options) => (options.client ?? client).get({
1393
+ security: [{
1394
+ key: "secretKey",
1395
+ scheme: "bearer",
1396
+ type: "http"
1397
+ }, {
1398
+ key: "frontendToken",
1399
+ scheme: "bearer",
1400
+ type: "http"
1401
+ }],
1402
+ url: "/google/{connection_id}/campaigns/{id}",
1403
+ ...options
1404
+ });
1405
+ var googleEditCampaign = (options) => (options.client ?? client).patch({
1406
+ security: [{
1407
+ key: "secretKey",
1408
+ scheme: "bearer",
1409
+ type: "http"
1410
+ }, {
1411
+ key: "frontendToken",
1412
+ scheme: "bearer",
1413
+ type: "http"
1414
+ }],
1415
+ url: "/google/{connection_id}/campaigns/{id}",
1416
+ ...options,
1417
+ headers: {
1418
+ "Content-Type": "application/json",
1419
+ ...options.headers
1420
+ }
1421
+ });
1422
+ var googlePauseCampaign = (options) => (options.client ?? client).post({
1423
+ security: [{
1424
+ key: "secretKey",
1425
+ scheme: "bearer",
1426
+ type: "http"
1427
+ }, {
1428
+ key: "frontendToken",
1429
+ scheme: "bearer",
1430
+ type: "http"
1431
+ }],
1432
+ url: "/google/{connection_id}/campaigns/{id}/pause",
1433
+ ...options,
1434
+ headers: {
1435
+ "Content-Type": "application/json",
1436
+ ...options.headers
1437
+ }
1438
+ });
1439
+ var googleEnableCampaign = (options) => (options.client ?? client).post({
1440
+ security: [{
1441
+ key: "secretKey",
1442
+ scheme: "bearer",
1443
+ type: "http"
1444
+ }, {
1445
+ key: "frontendToken",
1446
+ scheme: "bearer",
1447
+ type: "http"
1448
+ }],
1449
+ url: "/google/{connection_id}/campaigns/{id}/enable",
1450
+ ...options,
1451
+ headers: {
1452
+ "Content-Type": "application/json",
1453
+ ...options.headers
1454
+ }
1455
+ });
1456
+ var googleListAdGroups = (options) => (options.client ?? client).get({
1457
+ security: [{
1458
+ key: "secretKey",
1459
+ scheme: "bearer",
1460
+ type: "http"
1461
+ }, {
1462
+ key: "frontendToken",
1463
+ scheme: "bearer",
1464
+ type: "http"
1465
+ }],
1466
+ url: "/google/{connection_id}/ad-groups",
1467
+ ...options
1468
+ });
1469
+ var googleCreateAdGroup = (options) => (options.client ?? client).post({
1470
+ security: [{
1471
+ key: "secretKey",
1472
+ scheme: "bearer",
1473
+ type: "http"
1474
+ }, {
1475
+ key: "frontendToken",
1476
+ scheme: "bearer",
1477
+ type: "http"
1478
+ }],
1479
+ url: "/google/{connection_id}/ad-groups",
1480
+ ...options,
1481
+ headers: {
1482
+ "Content-Type": "application/json",
1483
+ ...options.headers
1484
+ }
1485
+ });
1486
+ var googleDeleteAdGroup = (options) => (options.client ?? client).delete({
1487
+ security: [{
1488
+ key: "secretKey",
1489
+ scheme: "bearer",
1490
+ type: "http"
1491
+ }, {
1492
+ key: "frontendToken",
1493
+ scheme: "bearer",
1494
+ type: "http"
1495
+ }],
1496
+ url: "/google/{connection_id}/ad-groups/{id}",
1497
+ ...options,
1498
+ headers: {
1499
+ "Content-Type": "application/json",
1500
+ ...options.headers
1501
+ }
1502
+ });
1503
+ var googleGetAdGroup = (options) => (options.client ?? client).get({
1504
+ security: [{
1505
+ key: "secretKey",
1506
+ scheme: "bearer",
1507
+ type: "http"
1508
+ }, {
1509
+ key: "frontendToken",
1510
+ scheme: "bearer",
1511
+ type: "http"
1512
+ }],
1513
+ url: "/google/{connection_id}/ad-groups/{id}",
1514
+ ...options
1515
+ });
1516
+ var googleEditAdGroup = (options) => (options.client ?? client).patch({
1517
+ security: [{
1518
+ key: "secretKey",
1519
+ scheme: "bearer",
1520
+ type: "http"
1521
+ }, {
1522
+ key: "frontendToken",
1523
+ scheme: "bearer",
1524
+ type: "http"
1525
+ }],
1526
+ url: "/google/{connection_id}/ad-groups/{id}",
1527
+ ...options,
1528
+ headers: {
1529
+ "Content-Type": "application/json",
1530
+ ...options.headers
1531
+ }
1532
+ });
1533
+ var googleSetAdGroupBids = (options) => (options.client ?? client).patch({
1534
+ security: [{
1535
+ key: "secretKey",
1536
+ scheme: "bearer",
1537
+ type: "http"
1538
+ }],
1539
+ url: "/google/{connection_id}/ad-groups/{id}/bids",
1540
+ ...options,
1541
+ headers: {
1542
+ "Content-Type": "application/json",
1543
+ ...options.headers
1544
+ }
1545
+ });
1546
+ var googlePauseAdGroup = (options) => (options.client ?? client).post({
1547
+ security: [{
1548
+ key: "secretKey",
1549
+ scheme: "bearer",
1550
+ type: "http"
1551
+ }, {
1552
+ key: "frontendToken",
1553
+ scheme: "bearer",
1554
+ type: "http"
1555
+ }],
1556
+ url: "/google/{connection_id}/ad-groups/{id}/pause",
1557
+ ...options,
1558
+ headers: {
1559
+ "Content-Type": "application/json",
1560
+ ...options.headers
1561
+ }
1562
+ });
1563
+ var googleEnableAdGroup = (options) => (options.client ?? client).post({
1564
+ security: [{
1565
+ key: "secretKey",
1566
+ scheme: "bearer",
1567
+ type: "http"
1568
+ }, {
1569
+ key: "frontendToken",
1570
+ scheme: "bearer",
1571
+ type: "http"
1572
+ }],
1573
+ url: "/google/{connection_id}/ad-groups/{id}/enable",
1574
+ ...options,
1575
+ headers: {
1576
+ "Content-Type": "application/json",
1577
+ ...options.headers
1578
+ }
1579
+ });
1580
+ var googleListAds = (options) => (options.client ?? client).get({
1581
+ security: [{
1582
+ key: "secretKey",
1583
+ scheme: "bearer",
1584
+ type: "http"
1585
+ }, {
1586
+ key: "frontendToken",
1587
+ scheme: "bearer",
1588
+ type: "http"
1589
+ }],
1590
+ url: "/google/{connection_id}/ads",
1591
+ ...options
1592
+ });
1593
+ var googleCreateAd = (options) => (options.client ?? client).post({
1594
+ security: [{
1595
+ key: "secretKey",
1596
+ scheme: "bearer",
1597
+ type: "http"
1598
+ }, {
1599
+ key: "frontendToken",
1600
+ scheme: "bearer",
1601
+ type: "http"
1602
+ }],
1603
+ url: "/google/{connection_id}/ads",
1604
+ ...options,
1605
+ headers: {
1606
+ "Content-Type": "application/json",
1607
+ ...options.headers
1608
+ }
1609
+ });
1610
+ var googleDeleteAd = (options) => (options.client ?? client).delete({
1611
+ security: [{
1612
+ key: "secretKey",
1613
+ scheme: "bearer",
1614
+ type: "http"
1615
+ }, {
1616
+ key: "frontendToken",
1617
+ scheme: "bearer",
1618
+ type: "http"
1619
+ }],
1620
+ url: "/google/{connection_id}/ads/{id}",
1621
+ ...options,
1622
+ headers: {
1623
+ "Content-Type": "application/json",
1624
+ ...options.headers
1625
+ }
1626
+ });
1627
+ var googleGetAd = (options) => (options.client ?? client).get({
1628
+ security: [{
1629
+ key: "secretKey",
1630
+ scheme: "bearer",
1631
+ type: "http"
1632
+ }, {
1633
+ key: "frontendToken",
1634
+ scheme: "bearer",
1635
+ type: "http"
1636
+ }],
1637
+ url: "/google/{connection_id}/ads/{id}",
1638
+ ...options
1639
+ });
1640
+ var googleCreateDisplayAd = (options) => (options.client ?? client).post({
1641
+ security: [{
1642
+ key: "secretKey",
1643
+ scheme: "bearer",
1644
+ type: "http"
1645
+ }, {
1646
+ key: "frontendToken",
1647
+ scheme: "bearer",
1648
+ type: "http"
1649
+ }],
1650
+ url: "/google/{connection_id}/display-ads",
1651
+ ...options,
1652
+ headers: {
1653
+ "Content-Type": "application/json",
1654
+ ...options.headers
1655
+ }
1656
+ });
1657
+ var googlePauseAd = (options) => (options.client ?? client).post({
1658
+ security: [{
1659
+ key: "secretKey",
1660
+ scheme: "bearer",
1661
+ type: "http"
1662
+ }, {
1663
+ key: "frontendToken",
1664
+ scheme: "bearer",
1665
+ type: "http"
1666
+ }],
1667
+ url: "/google/{connection_id}/ads/{id}/pause",
1668
+ ...options,
1669
+ headers: {
1670
+ "Content-Type": "application/json",
1671
+ ...options.headers
1672
+ }
1673
+ });
1674
+ var googleEnableAd = (options) => (options.client ?? client).post({
1675
+ security: [{
1676
+ key: "secretKey",
1677
+ scheme: "bearer",
1678
+ type: "http"
1679
+ }, {
1680
+ key: "frontendToken",
1681
+ scheme: "bearer",
1682
+ type: "http"
1683
+ }],
1684
+ url: "/google/{connection_id}/ads/{id}/enable",
1685
+ ...options,
1686
+ headers: {
1687
+ "Content-Type": "application/json",
1688
+ ...options.headers
1689
+ }
1690
+ });
1691
+ var googleListKeywords = (options) => (options.client ?? client).get({
1692
+ security: [{
1693
+ key: "secretKey",
1694
+ scheme: "bearer",
1695
+ type: "http"
1696
+ }, {
1697
+ key: "frontendToken",
1698
+ scheme: "bearer",
1699
+ type: "http"
1700
+ }],
1701
+ url: "/google/{connection_id}/keywords",
1702
+ ...options
1703
+ });
1704
+ var googleCreateKeyword = (options) => (options.client ?? client).post({
1705
+ security: [{
1706
+ key: "secretKey",
1707
+ scheme: "bearer",
1708
+ type: "http"
1709
+ }, {
1710
+ key: "frontendToken",
1711
+ scheme: "bearer",
1712
+ type: "http"
1713
+ }],
1714
+ url: "/google/{connection_id}/keywords",
1715
+ ...options,
1716
+ headers: {
1717
+ "Content-Type": "application/json",
1718
+ ...options.headers
1719
+ }
1720
+ });
1721
+ var googleDeleteKeyword = (options) => (options.client ?? client).delete({
1722
+ security: [{
1723
+ key: "secretKey",
1724
+ scheme: "bearer",
1725
+ type: "http"
1726
+ }, {
1727
+ key: "frontendToken",
1728
+ scheme: "bearer",
1729
+ type: "http"
1730
+ }],
1731
+ url: "/google/{connection_id}/keywords/{id}",
1732
+ ...options,
1733
+ headers: {
1734
+ "Content-Type": "application/json",
1735
+ ...options.headers
1736
+ }
1737
+ });
1738
+ var googleGetKeyword = (options) => (options.client ?? client).get({
1739
+ security: [{
1740
+ key: "secretKey",
1741
+ scheme: "bearer",
1742
+ type: "http"
1743
+ }, {
1744
+ key: "frontendToken",
1745
+ scheme: "bearer",
1746
+ type: "http"
1747
+ }],
1748
+ url: "/google/{connection_id}/keywords/{id}",
1749
+ ...options
1750
+ });
1751
+ var googleSetKeywordBid = (options) => (options.client ?? client).patch({
1752
+ security: [{
1753
+ key: "secretKey",
1754
+ scheme: "bearer",
1755
+ type: "http"
1756
+ }],
1757
+ url: "/google/{connection_id}/keywords/{id}/bid",
1758
+ ...options,
1759
+ headers: {
1760
+ "Content-Type": "application/json",
1761
+ ...options.headers
1762
+ }
1763
+ });
1764
+ var googlePauseKeyword = (options) => (options.client ?? client).post({
1765
+ security: [{
1766
+ key: "secretKey",
1767
+ scheme: "bearer",
1768
+ type: "http"
1769
+ }, {
1770
+ key: "frontendToken",
1771
+ scheme: "bearer",
1772
+ type: "http"
1773
+ }],
1774
+ url: "/google/{connection_id}/keywords/{id}/pause",
1775
+ ...options,
1776
+ headers: {
1777
+ "Content-Type": "application/json",
1778
+ ...options.headers
1779
+ }
1780
+ });
1781
+ var googleEnableKeyword = (options) => (options.client ?? client).post({
1782
+ security: [{
1783
+ key: "secretKey",
1784
+ scheme: "bearer",
1785
+ type: "http"
1786
+ }, {
1787
+ key: "frontendToken",
1788
+ scheme: "bearer",
1789
+ type: "http"
1790
+ }],
1791
+ url: "/google/{connection_id}/keywords/{id}/enable",
1792
+ ...options,
1793
+ headers: {
1794
+ "Content-Type": "application/json",
1795
+ ...options.headers
1796
+ }
1797
+ });
1798
+ var googleListConversionActions = (options) => (options.client ?? client).get({
1799
+ security: [{
1800
+ key: "secretKey",
1801
+ scheme: "bearer",
1802
+ type: "http"
1803
+ }, {
1804
+ key: "frontendToken",
1805
+ scheme: "bearer",
1806
+ type: "http"
1807
+ }],
1808
+ url: "/google/{connection_id}/conversion-actions",
1809
+ ...options
1810
+ });
1811
+ var googleCreateConversionAction = (options) => (options.client ?? client).post({
1812
+ security: [{
1813
+ key: "secretKey",
1814
+ scheme: "bearer",
1815
+ type: "http"
1816
+ }, {
1817
+ key: "frontendToken",
1818
+ scheme: "bearer",
1819
+ type: "http"
1820
+ }],
1821
+ url: "/google/{connection_id}/conversion-actions",
1822
+ ...options,
1823
+ headers: {
1824
+ "Content-Type": "application/json",
1825
+ ...options.headers
1826
+ }
1827
+ });
1828
+ var googleGetConversionAction = (options) => (options.client ?? client).get({
1829
+ security: [{
1830
+ key: "secretKey",
1831
+ scheme: "bearer",
1832
+ type: "http"
1833
+ }, {
1834
+ key: "frontendToken",
1835
+ scheme: "bearer",
1836
+ type: "http"
1837
+ }],
1838
+ url: "/google/{connection_id}/conversion-actions/{id}",
1839
+ ...options
1840
+ });
1841
+ var googleListConversionGoals = (options) => (options.client ?? client).get({
1842
+ security: [{
1843
+ key: "secretKey",
1844
+ scheme: "bearer",
1845
+ type: "http"
1846
+ }, {
1847
+ key: "frontendToken",
1848
+ scheme: "bearer",
1849
+ type: "http"
1850
+ }],
1851
+ url: "/google/{connection_id}/conversion-goals",
1852
+ ...options
1853
+ });
1854
+ var googleSetConversionGoal = (options) => (options.client ?? client).post({
1855
+ security: [{
1856
+ key: "secretKey",
1857
+ scheme: "bearer",
1858
+ type: "http"
1859
+ }, {
1860
+ key: "frontendToken",
1861
+ scheme: "bearer",
1862
+ type: "http"
1863
+ }],
1864
+ url: "/google/{connection_id}/conversion-goals",
1865
+ ...options,
1866
+ headers: {
1867
+ "Content-Type": "application/json",
1868
+ ...options.headers
1869
+ }
1870
+ });
1871
+ var googleUploadConversions = (options) => (options.client ?? client).post({
1872
+ security: [{
1873
+ key: "secretKey",
1874
+ scheme: "bearer",
1875
+ type: "http"
1876
+ }, {
1877
+ key: "frontendToken",
1878
+ scheme: "bearer",
1879
+ type: "http"
1880
+ }],
1881
+ url: "/google/{connection_id}/conversion-uploads",
1882
+ ...options,
1883
+ headers: {
1884
+ "Content-Type": "application/json",
1885
+ ...options.headers
1886
+ }
1887
+ });
1888
+ var googleUploadImageAsset = (options) => (options.client ?? client).post({
1889
+ security: [{
1890
+ key: "secretKey",
1891
+ scheme: "bearer",
1892
+ type: "http"
1893
+ }, {
1894
+ key: "frontendToken",
1895
+ scheme: "bearer",
1896
+ type: "http"
1897
+ }],
1898
+ url: "/google/{connection_id}/assets/images",
1899
+ ...options,
1900
+ headers: {
1901
+ "Content-Type": "application/json",
1902
+ ...options.headers
1903
+ }
1904
+ });
1905
+ var logsList = (options) => (options?.client ?? client).get({
1906
+ security: [{
1907
+ key: "secretKey",
1908
+ scheme: "bearer",
1909
+ type: "http"
1910
+ }],
1911
+ url: "/logs",
1912
+ ...options
1913
+ });
1914
+ var logsGet = (options) => (options.client ?? client).get({
1915
+ security: [{
1916
+ key: "secretKey",
1917
+ scheme: "bearer",
1918
+ type: "http"
1919
+ }],
1920
+ url: "/logs/{id}",
1921
+ ...options
1922
+ });
1923
+ var webhooksListEndpoints = (options) => (options?.client ?? client).get({
1924
+ security: [{
1925
+ key: "secretKey",
1926
+ scheme: "bearer",
1927
+ type: "http"
1928
+ }],
1929
+ url: "/webhooks/endpoints",
1930
+ ...options
1931
+ });
1932
+ var webhooksCreateEndpoint = (options) => (options.client ?? client).post({
1933
+ security: [{
1934
+ key: "secretKey",
1935
+ scheme: "bearer",
1936
+ type: "http"
1937
+ }],
1938
+ url: "/webhooks/endpoints",
1939
+ ...options,
1940
+ headers: {
1941
+ "Content-Type": "application/json",
1942
+ ...options.headers
1943
+ }
1944
+ });
1945
+ var webhooksDeleteEndpoint = (options) => (options.client ?? client).delete({
1946
+ security: [{
1947
+ key: "secretKey",
1948
+ scheme: "bearer",
1949
+ type: "http"
1950
+ }],
1951
+ url: "/webhooks/endpoints/{id}",
1952
+ ...options
1953
+ });
1954
+ var webhooksGetEndpoint = (options) => (options.client ?? client).get({
1955
+ security: [{
1956
+ key: "secretKey",
1957
+ scheme: "bearer",
1958
+ type: "http"
1959
+ }],
1960
+ url: "/webhooks/endpoints/{id}",
1961
+ ...options
1962
+ });
1963
+ var webhooksUpdateEndpoint = (options) => (options.client ?? client).patch({
1964
+ security: [{
1965
+ key: "secretKey",
1966
+ scheme: "bearer",
1967
+ type: "http"
1968
+ }],
1969
+ url: "/webhooks/endpoints/{id}",
1970
+ ...options,
1971
+ headers: {
1972
+ "Content-Type": "application/json",
1973
+ ...options.headers
1974
+ }
1975
+ });
1976
+ var webhooksCreatePortal = (options) => (options?.client ?? client).post({
1977
+ security: [{
1978
+ key: "secretKey",
1979
+ scheme: "bearer",
1980
+ type: "http"
1981
+ }],
1982
+ url: "/webhooks/portal",
1983
+ ...options
1984
+ });
1985
+ var webhooksListEventTypes = (options) => (options?.client ?? client).get({
1986
+ security: [{
1987
+ key: "secretKey",
1988
+ scheme: "bearer",
1989
+ type: "http"
1990
+ }],
1991
+ url: "/webhooks/event-types",
1992
+ ...options
1993
+ });
1994
+ var webhooksPing = (options) => (options.client ?? client).post({
1995
+ security: [{
1996
+ key: "secretKey",
1997
+ scheme: "bearer",
1998
+ type: "http"
1999
+ }],
2000
+ url: "/webhooks/ping",
2001
+ ...options,
2002
+ headers: {
2003
+ "Content-Type": "application/json",
2004
+ ...options.headers
2005
+ }
2006
+ });
2007
+ var tokensMint = (options) => (options.client ?? client).post({
2008
+ security: [{
2009
+ key: "secretKey",
2010
+ scheme: "bearer",
2011
+ type: "http"
2012
+ }],
2013
+ url: "/tokens",
2014
+ ...options,
2015
+ headers: {
2016
+ "Content-Type": "application/json",
2017
+ ...options.headers
2018
+ }
2019
+ });
2020
+
2021
+ export { PostrunError, connectionsConnect, connectionsDelete, connectionsGet, connectionsListAccounts, connectionsListByProfile, connectionsSelect, createPostrunClient, googleCreateAd, googleCreateAdGroup, googleCreateBudget, googleCreateCampaign, googleCreateConversionAction, googleCreateDisplayAd, googleCreateKeyword, googleDeleteAd, googleDeleteAdGroup, googleDeleteBudget, googleDeleteCampaign, googleDeleteKeyword, googleEditAdGroup, googleEditBudget, googleEditCampaign, googleEnableAd, googleEnableAdGroup, googleEnableCampaign, googleEnableKeyword, googleGetAccount, googleGetAd, googleGetAdGroup, googleGetCampaign, googleGetConversionAction, googleGetInsights, googleGetKeyword, googleListAdGroups, googleListAds, googleListCampaigns, googleListConversionActions, googleListConversionGoals, googleListKeywords, googlePauseAd, googlePauseAdGroup, googlePauseCampaign, googlePauseKeyword, googleRunGaql, googleSetAdGroupBids, googleSetConversionGoal, googleSetKeywordBid, googleUploadConversions, googleUploadImageAsset, logsGet, logsList, mediaCreate, mediaDelete, mediaGet, mediaUpdate, metaAccount, metaAd, metaAds, metaAdset, metaAdsets, metaCampaign, metaCampaigns, metaInsights, postsCreate, postsDelete, postsGet, postsList, postsUpdate, profilesCreate, profilesDelete, profilesGet, profilesList, profilesUpdate, tokensMint, webhooksCreateEndpoint, webhooksCreatePortal, webhooksDeleteEndpoint, webhooksGetEndpoint, webhooksListEndpoints, webhooksListEventTypes, webhooksPing, webhooksUpdateEndpoint };
2022
+ //# sourceMappingURL=chunk-A545VJ5X.js.map
2023
+ //# sourceMappingURL=chunk-A545VJ5X.js.map