@ideal-postcodes/sdk 0.1.0 → 0.2.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.
Files changed (43) hide show
  1. package/LICENSE +1 -23
  2. package/README.md +16 -18
  3. package/dist/autocomplete.cjs +1 -146
  4. package/dist/autocomplete.d.cts +26 -14
  5. package/dist/autocomplete.d.ts +26 -14
  6. package/dist/autocomplete.mjs +1 -146
  7. package/dist/chunk-BNT2VR2B.mjs +6 -0
  8. package/dist/chunk-HQKXKJXR.cjs +6 -0
  9. package/dist/chunk-OHO6PZYM.mjs +1 -0
  10. package/dist/chunk-UO7BIPJH.cjs +1 -0
  11. package/dist/index.cjs +1 -76
  12. package/dist/index.d-BuZcXRMe.d.cts +45 -0
  13. package/dist/index.d-BuZcXRMe.d.ts +45 -0
  14. package/dist/index.d.cts +6 -12
  15. package/dist/index.d.ts +6 -12
  16. package/dist/index.mjs +1 -76
  17. package/dist/preact-query.cjs +1 -497
  18. package/dist/preact-query.d.cts +379 -123
  19. package/dist/preact-query.d.ts +379 -123
  20. package/dist/preact-query.mjs +1 -497
  21. package/dist/react-query.cjs +1 -497
  22. package/dist/react-query.d.cts +378 -122
  23. package/dist/react-query.d.ts +378 -122
  24. package/dist/react-query.mjs +1 -497
  25. package/dist/sdk.gen-C6G6f1JU.d.ts +420 -0
  26. package/dist/sdk.gen-CMX5dsNg.d.cts +420 -0
  27. package/dist/{types.gen-l7tYP1ZJ.d.cts → types.gen-Dmx_l_fj.d.cts} +4612 -2685
  28. package/dist/{types.gen-l7tYP1ZJ.d.ts → types.gen-Dmx_l_fj.d.ts} +4612 -2685
  29. package/package.json +71 -38
  30. package/dist/autocomplete.cjs.map +0 -1
  31. package/dist/autocomplete.mjs.map +0 -1
  32. package/dist/chunk-AVMJGCHZ.mjs +0 -913
  33. package/dist/chunk-AVMJGCHZ.mjs.map +0 -1
  34. package/dist/chunk-ZZUZHG5D.cjs +0 -913
  35. package/dist/chunk-ZZUZHG5D.cjs.map +0 -1
  36. package/dist/index.cjs.map +0 -1
  37. package/dist/index.mjs.map +0 -1
  38. package/dist/preact-query.cjs.map +0 -1
  39. package/dist/preact-query.mjs.map +0 -1
  40. package/dist/react-query.cjs.map +0 -1
  41. package/dist/react-query.mjs.map +0 -1
  42. package/dist/sdk.gen-C45EbTVQ.d.cts +0 -302
  43. package/dist/sdk.gen-_z1PNdoT.d.ts +0 -302
@@ -1,913 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/generated/core/bodySerializer.gen.ts
2
- var jsonBodySerializer = {
3
- bodySerializer: (body) => JSON.stringify(
4
- body,
5
- (_key, value) => typeof value === "bigint" ? value.toString() : value
6
- )
7
- };
8
-
9
- // src/generated/core/serverSentEvents.gen.ts
10
- function createSseClient({
11
- onRequest,
12
- onSseError,
13
- onSseEvent,
14
- responseTransformer,
15
- responseValidator,
16
- sseDefaultRetryDelay,
17
- sseMaxRetryAttempts,
18
- sseMaxRetryDelay,
19
- sseSleepFn,
20
- url,
21
- ...options
22
- }) {
23
- let lastEventId;
24
- const sleep = _nullishCoalesce(sseSleepFn, () => ( ((ms) => new Promise((resolve) => setTimeout(resolve, ms)))));
25
- const createStream = async function* () {
26
- let retryDelay = _nullishCoalesce(sseDefaultRetryDelay, () => ( 3e3));
27
- let attempt = 0;
28
- const signal = _nullishCoalesce(options.signal, () => ( new AbortController().signal));
29
- while (true) {
30
- if (signal.aborted) break;
31
- attempt++;
32
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
33
- if (lastEventId !== void 0) {
34
- headers.set("Last-Event-ID", lastEventId);
35
- }
36
- try {
37
- const requestInit = {
38
- redirect: "follow",
39
- ...options,
40
- body: options.serializedBody,
41
- headers,
42
- signal
43
- };
44
- let request = new Request(url, requestInit);
45
- if (onRequest) {
46
- request = await onRequest(url, requestInit);
47
- }
48
- const _fetch = _nullishCoalesce(options.fetch, () => ( globalThis.fetch));
49
- const response = await _fetch(request);
50
- if (!response.ok)
51
- throw new Error(
52
- `SSE failed: ${response.status} ${response.statusText}`
53
- );
54
- if (!response.body) throw new Error("No body in SSE response");
55
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
56
- let buffer = "";
57
- const abortHandler = () => {
58
- try {
59
- reader.cancel();
60
- } catch (e) {
61
- }
62
- };
63
- signal.addEventListener("abort", abortHandler);
64
- try {
65
- while (true) {
66
- const { done, value } = await reader.read();
67
- if (done) break;
68
- buffer += value;
69
- buffer = buffer.replace(/\r\n?/g, "\n");
70
- const chunks = buffer.split("\n\n");
71
- buffer = _nullishCoalesce(chunks.pop(), () => ( ""));
72
- for (const chunk of chunks) {
73
- const lines = chunk.split("\n");
74
- const dataLines = [];
75
- let eventName;
76
- for (const line of lines) {
77
- if (line.startsWith("data:")) {
78
- dataLines.push(line.replace(/^data:\s*/, ""));
79
- } else if (line.startsWith("event:")) {
80
- eventName = line.replace(/^event:\s*/, "");
81
- } else if (line.startsWith("id:")) {
82
- lastEventId = line.replace(/^id:\s*/, "");
83
- } else if (line.startsWith("retry:")) {
84
- const parsed = Number.parseInt(
85
- line.replace(/^retry:\s*/, ""),
86
- 10
87
- );
88
- if (!Number.isNaN(parsed)) {
89
- retryDelay = parsed;
90
- }
91
- }
92
- }
93
- let data;
94
- let parsedJson = false;
95
- if (dataLines.length) {
96
- const rawData = dataLines.join("\n");
97
- try {
98
- data = JSON.parse(rawData);
99
- parsedJson = true;
100
- } catch (e2) {
101
- data = rawData;
102
- }
103
- }
104
- if (parsedJson) {
105
- if (responseValidator) {
106
- await responseValidator(data);
107
- }
108
- if (responseTransformer) {
109
- data = await responseTransformer(data);
110
- }
111
- }
112
- _optionalChain([onSseEvent, 'optionalCall', _ => _({
113
- data,
114
- event: eventName,
115
- id: lastEventId,
116
- retry: retryDelay
117
- })]);
118
- if (dataLines.length) {
119
- yield data;
120
- }
121
- }
122
- }
123
- } finally {
124
- signal.removeEventListener("abort", abortHandler);
125
- reader.releaseLock();
126
- }
127
- break;
128
- } catch (error) {
129
- _optionalChain([onSseError, 'optionalCall', _2 => _2(error)]);
130
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
131
- break;
132
- }
133
- const backoff = Math.min(
134
- retryDelay * 2 ** (attempt - 1),
135
- _nullishCoalesce(sseMaxRetryDelay, () => ( 3e4))
136
- );
137
- await sleep(backoff);
138
- }
139
- }
140
- };
141
- const stream = createStream();
142
- return { stream };
143
- }
144
-
145
- // src/generated/core/pathSerializer.gen.ts
146
- var separatorArrayExplode = (style) => {
147
- switch (style) {
148
- case "label":
149
- return ".";
150
- case "matrix":
151
- return ";";
152
- case "simple":
153
- return ",";
154
- default:
155
- return "&";
156
- }
157
- };
158
- var separatorArrayNoExplode = (style) => {
159
- switch (style) {
160
- case "form":
161
- return ",";
162
- case "pipeDelimited":
163
- return "|";
164
- case "spaceDelimited":
165
- return "%20";
166
- default:
167
- return ",";
168
- }
169
- };
170
- var separatorObjectExplode = (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 serializeArrayParam = ({
183
- allowReserved,
184
- explode,
185
- name,
186
- style,
187
- value
188
- }) => {
189
- if (!explode) {
190
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
191
- switch (style) {
192
- case "label":
193
- return `.${joinedValues2}`;
194
- case "matrix":
195
- return `;${name}=${joinedValues2}`;
196
- case "simple":
197
- return joinedValues2;
198
- default:
199
- return `${name}=${joinedValues2}`;
200
- }
201
- }
202
- const separator = separatorArrayExplode(style);
203
- const joinedValues = value.map((v) => {
204
- if (style === "label" || style === "simple") {
205
- return allowReserved ? v : encodeURIComponent(v);
206
- }
207
- return serializePrimitiveParam({
208
- allowReserved,
209
- name,
210
- value: v
211
- });
212
- }).join(separator);
213
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
214
- };
215
- var serializePrimitiveParam = ({
216
- allowReserved,
217
- name,
218
- value
219
- }) => {
220
- if (value === void 0 || value === null) {
221
- return "";
222
- }
223
- if (typeof value === "object") {
224
- throw new Error(
225
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
226
- );
227
- }
228
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
229
- };
230
- var serializeObjectParam = ({
231
- allowReserved,
232
- explode,
233
- name,
234
- style,
235
- value,
236
- valueOnly
237
- }) => {
238
- if (value instanceof Date) {
239
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
240
- }
241
- if (style !== "deepObject" && !explode) {
242
- let values = [];
243
- Object.entries(value).forEach(([key, v]) => {
244
- values = [
245
- ...values,
246
- key,
247
- allowReserved ? v : encodeURIComponent(v)
248
- ];
249
- });
250
- const joinedValues2 = values.join(",");
251
- switch (style) {
252
- case "form":
253
- return `${name}=${joinedValues2}`;
254
- case "label":
255
- return `.${joinedValues2}`;
256
- case "matrix":
257
- return `;${name}=${joinedValues2}`;
258
- default:
259
- return joinedValues2;
260
- }
261
- }
262
- const separator = separatorObjectExplode(style);
263
- const joinedValues = Object.entries(value).map(
264
- ([key, v]) => serializePrimitiveParam({
265
- allowReserved,
266
- name: style === "deepObject" ? `${name}[${key}]` : key,
267
- value: v
268
- })
269
- ).join(separator);
270
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
271
- };
272
-
273
- // src/generated/core/utils.gen.ts
274
- var PATH_PARAM_RE = /\{[^{}]+\}/g;
275
- var defaultPathSerializer = ({ path, url: _url }) => {
276
- let url = _url;
277
- const matches = _url.match(PATH_PARAM_RE);
278
- if (matches) {
279
- for (const match of matches) {
280
- let explode = false;
281
- let name = match.substring(1, match.length - 1);
282
- let style = "simple";
283
- if (name.endsWith("*")) {
284
- explode = true;
285
- name = name.substring(0, name.length - 1);
286
- }
287
- if (name.startsWith(".")) {
288
- name = name.substring(1);
289
- style = "label";
290
- } else if (name.startsWith(";")) {
291
- name = name.substring(1);
292
- style = "matrix";
293
- }
294
- const value = path[name];
295
- if (value === void 0 || value === null) {
296
- continue;
297
- }
298
- if (Array.isArray(value)) {
299
- url = url.replace(
300
- match,
301
- serializeArrayParam({ explode, name, style, value })
302
- );
303
- continue;
304
- }
305
- if (typeof value === "object") {
306
- url = url.replace(
307
- match,
308
- serializeObjectParam({
309
- explode,
310
- name,
311
- style,
312
- value,
313
- valueOnly: true
314
- })
315
- );
316
- continue;
317
- }
318
- if (style === "matrix") {
319
- url = url.replace(
320
- match,
321
- `;${serializePrimitiveParam({
322
- name,
323
- value
324
- })}`
325
- );
326
- continue;
327
- }
328
- const replaceValue = encodeURIComponent(
329
- style === "label" ? `.${value}` : value
330
- );
331
- url = url.replace(match, replaceValue);
332
- }
333
- }
334
- return url;
335
- };
336
- var getUrl = ({
337
- baseUrl,
338
- path,
339
- query,
340
- querySerializer,
341
- url: _url
342
- }) => {
343
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
344
- let url = (_nullishCoalesce(baseUrl, () => ( ""))) + pathUrl;
345
- if (path) {
346
- url = defaultPathSerializer({ path, url });
347
- }
348
- let search = query ? querySerializer(query) : "";
349
- if (search.startsWith("?")) {
350
- search = search.substring(1);
351
- }
352
- if (search) {
353
- url += `?${search}`;
354
- }
355
- return url;
356
- };
357
- function getValidRequestBody(options) {
358
- const hasBody = options.body !== void 0;
359
- const isSerializedBody = hasBody && options.bodySerializer;
360
- if (isSerializedBody) {
361
- if ("serializedBody" in options) {
362
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
363
- return hasSerializedBody ? options.serializedBody : null;
364
- }
365
- return options.body !== "" ? options.body : null;
366
- }
367
- if (hasBody) {
368
- return options.body;
369
- }
370
- return void 0;
371
- }
372
-
373
- // src/generated/core/auth.gen.ts
374
- var getAuthToken = async (auth, callback) => {
375
- const token = typeof callback === "function" ? await callback(auth) : callback;
376
- if (!token) {
377
- return;
378
- }
379
- if (auth.scheme === "bearer") {
380
- return `Bearer ${token}`;
381
- }
382
- if (auth.scheme === "basic") {
383
- return `Basic ${btoa(token)}`;
384
- }
385
- return token;
386
- };
387
-
388
- // src/generated/client/utils.gen.ts
389
- var createQuerySerializer = ({
390
- parameters = {},
391
- ...args
392
- } = {}) => {
393
- const querySerializer = (queryParams) => {
394
- const search = [];
395
- if (queryParams && typeof queryParams === "object") {
396
- for (const name in queryParams) {
397
- const value = queryParams[name];
398
- if (value === void 0 || value === null) {
399
- continue;
400
- }
401
- const options = parameters[name] || args;
402
- if (Array.isArray(value)) {
403
- const serializedArray = serializeArrayParam({
404
- allowReserved: options.allowReserved,
405
- explode: true,
406
- name,
407
- style: "form",
408
- value,
409
- ...options.array
410
- });
411
- if (serializedArray) search.push(serializedArray);
412
- } else if (typeof value === "object") {
413
- const serializedObject = serializeObjectParam({
414
- allowReserved: options.allowReserved,
415
- explode: true,
416
- name,
417
- style: "deepObject",
418
- value,
419
- ...options.object
420
- });
421
- if (serializedObject) search.push(serializedObject);
422
- } else {
423
- const serializedPrimitive = serializePrimitiveParam({
424
- allowReserved: options.allowReserved,
425
- name,
426
- value
427
- });
428
- if (serializedPrimitive) search.push(serializedPrimitive);
429
- }
430
- }
431
- }
432
- return search.join("&");
433
- };
434
- return querySerializer;
435
- };
436
- var getParseAs = (contentType) => {
437
- if (!contentType) {
438
- return "stream";
439
- }
440
- const cleanContent = _optionalChain([contentType, 'access', _3 => _3.split, 'call', _4 => _4(";"), 'access', _5 => _5[0], 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]);
441
- if (!cleanContent) {
442
- return;
443
- }
444
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
445
- return "json";
446
- }
447
- if (cleanContent === "multipart/form-data") {
448
- return "formData";
449
- }
450
- if (["application/", "audio/", "image/", "video/"].some(
451
- (type) => cleanContent.startsWith(type)
452
- )) {
453
- return "blob";
454
- }
455
- if (cleanContent.startsWith("text/")) {
456
- return "text";
457
- }
458
- return;
459
- };
460
- var checkForExistence = (options, name) => {
461
- if (!name) {
462
- return false;
463
- }
464
- if (options.headers.has(name) || _optionalChain([options, 'access', _8 => _8.query, 'optionalAccess', _9 => _9[name]]) || _optionalChain([options, 'access', _10 => _10.headers, 'access', _11 => _11.get, 'call', _12 => _12("Cookie"), 'optionalAccess', _13 => _13.includes, 'call', _14 => _14(`${name}=`)])) {
465
- return true;
466
- }
467
- return false;
468
- };
469
- async function setAuthParams(options) {
470
- for (const auth of _nullishCoalesce(options.security, () => ( []))) {
471
- if (checkForExistence(options, auth.name)) {
472
- continue;
473
- }
474
- const token = await getAuthToken(auth, options.auth);
475
- if (!token) {
476
- continue;
477
- }
478
- const name = _nullishCoalesce(auth.name, () => ( "Authorization"));
479
- switch (auth.in) {
480
- case "query":
481
- if (!options.query) {
482
- options.query = {};
483
- }
484
- options.query[name] = token;
485
- break;
486
- case "cookie":
487
- options.headers.append("Cookie", `${name}=${token}`);
488
- break;
489
- case "header":
490
- default:
491
- options.headers.set(name, token);
492
- break;
493
- }
494
- }
495
- }
496
- var buildUrl = (options) => getUrl({
497
- baseUrl: options.baseUrl,
498
- path: options.path,
499
- query: options.query,
500
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
501
- url: options.url
502
- });
503
- var mergeConfigs = (a, b) => {
504
- const config = { ...a, ...b };
505
- if (_optionalChain([config, 'access', _15 => _15.baseUrl, 'optionalAccess', _16 => _16.endsWith, 'call', _17 => _17("/")])) {
506
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
507
- }
508
- config.headers = mergeHeaders(a.headers, b.headers);
509
- return config;
510
- };
511
- var headersEntries = (headers) => {
512
- const entries = [];
513
- headers.forEach((value, key) => {
514
- entries.push([key, value]);
515
- });
516
- return entries;
517
- };
518
- var mergeHeaders = (...headers) => {
519
- const mergedHeaders = new Headers();
520
- for (const header of headers) {
521
- if (!header) {
522
- continue;
523
- }
524
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
525
- for (const [key, value] of iterator) {
526
- if (value === null) {
527
- mergedHeaders.delete(key);
528
- } else if (Array.isArray(value)) {
529
- for (const v of value) {
530
- mergedHeaders.append(key, v);
531
- }
532
- } else if (value !== void 0) {
533
- mergedHeaders.set(
534
- key,
535
- typeof value === "object" ? JSON.stringify(value) : value
536
- );
537
- }
538
- }
539
- }
540
- return mergedHeaders;
541
- };
542
- var Interceptors = class {
543
- constructor() {
544
- this.fns = [];
545
- }
546
- clear() {
547
- this.fns = [];
548
- }
549
- eject(id) {
550
- const index = this.getInterceptorIndex(id);
551
- if (this.fns[index]) {
552
- this.fns[index] = null;
553
- }
554
- }
555
- exists(id) {
556
- const index = this.getInterceptorIndex(id);
557
- return Boolean(this.fns[index]);
558
- }
559
- getInterceptorIndex(id) {
560
- if (typeof id === "number") {
561
- return this.fns[id] ? id : -1;
562
- }
563
- return this.fns.indexOf(id);
564
- }
565
- update(id, fn) {
566
- const index = this.getInterceptorIndex(id);
567
- if (this.fns[index]) {
568
- this.fns[index] = fn;
569
- return id;
570
- }
571
- return false;
572
- }
573
- use(fn) {
574
- this.fns.push(fn);
575
- return this.fns.length - 1;
576
- }
577
- };
578
- var createInterceptors = () => ({
579
- error: new Interceptors(),
580
- request: new Interceptors(),
581
- response: new Interceptors()
582
- });
583
- var defaultQuerySerializer = createQuerySerializer({
584
- allowReserved: false,
585
- array: {
586
- explode: true,
587
- style: "form"
588
- },
589
- object: {
590
- explode: true,
591
- style: "deepObject"
592
- }
593
- });
594
- var defaultHeaders = {
595
- "Content-Type": "application/json"
596
- };
597
- var createConfig = (override = {}) => ({
598
- ...jsonBodySerializer,
599
- headers: defaultHeaders,
600
- parseAs: "auto",
601
- querySerializer: defaultQuerySerializer,
602
- ...override
603
- });
604
-
605
- // src/generated/client/client.gen.ts
606
- var createClient = (config = {}) => {
607
- let _config = mergeConfigs(createConfig(), config);
608
- const getConfig = () => ({ ..._config });
609
- const setConfig = (config2) => {
610
- _config = mergeConfigs(_config, config2);
611
- return getConfig();
612
- };
613
- const interceptors = createInterceptors();
614
- const beforeRequest = async (options) => {
615
- const opts = {
616
- ..._config,
617
- ...options,
618
- fetch: _nullishCoalesce(_nullishCoalesce(options.fetch, () => ( _config.fetch)), () => ( globalThis.fetch)),
619
- headers: mergeHeaders(_config.headers, options.headers),
620
- serializedBody: void 0
621
- };
622
- if (opts.security) {
623
- await setAuthParams(opts);
624
- }
625
- if (opts.requestValidator) {
626
- await opts.requestValidator(opts);
627
- }
628
- if (opts.body !== void 0 && opts.bodySerializer) {
629
- opts.serializedBody = opts.bodySerializer(opts.body);
630
- }
631
- if (opts.body === void 0 || opts.serializedBody === "") {
632
- opts.headers.delete("Content-Type");
633
- }
634
- const resolvedOpts = opts;
635
- const url = buildUrl(resolvedOpts);
636
- return { opts: resolvedOpts, url };
637
- };
638
- const request = async (options) => {
639
- const throwOnError = _nullishCoalesce(options.throwOnError, () => ( _config.throwOnError));
640
- const responseStyle = _nullishCoalesce(options.responseStyle, () => ( _config.responseStyle));
641
- let request2;
642
- let response;
643
- try {
644
- const { opts, url } = await beforeRequest(options);
645
- const requestInit = {
646
- redirect: "follow",
647
- ...opts,
648
- body: getValidRequestBody(opts)
649
- };
650
- request2 = new Request(url, requestInit);
651
- for (const fn of interceptors.request.fns) {
652
- if (fn) {
653
- request2 = await fn(request2, opts);
654
- }
655
- }
656
- const _fetch = opts.fetch;
657
- response = await _fetch(request2);
658
- for (const fn of interceptors.response.fns) {
659
- if (fn) {
660
- response = await fn(response, request2, opts);
661
- }
662
- }
663
- const result = {
664
- request: request2,
665
- response
666
- };
667
- if (response.ok) {
668
- const parseAs = _nullishCoalesce((opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs), () => ( "json"));
669
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
670
- let emptyData;
671
- switch (parseAs) {
672
- case "arrayBuffer":
673
- case "blob":
674
- case "text":
675
- emptyData = await response[parseAs]();
676
- break;
677
- case "formData":
678
- emptyData = new FormData();
679
- break;
680
- case "stream":
681
- emptyData = response.body;
682
- break;
683
- case "json":
684
- default:
685
- emptyData = {};
686
- break;
687
- }
688
- return opts.responseStyle === "data" ? emptyData : {
689
- data: emptyData,
690
- ...result
691
- };
692
- }
693
- let data;
694
- switch (parseAs) {
695
- case "arrayBuffer":
696
- case "blob":
697
- case "formData":
698
- case "text":
699
- data = await response[parseAs]();
700
- break;
701
- case "json": {
702
- const text = await response.text();
703
- data = text ? JSON.parse(text) : {};
704
- break;
705
- }
706
- case "stream":
707
- return opts.responseStyle === "data" ? response.body : {
708
- data: response.body,
709
- ...result
710
- };
711
- }
712
- if (parseAs === "json") {
713
- if (opts.responseValidator) {
714
- await opts.responseValidator(data);
715
- }
716
- if (opts.responseTransformer) {
717
- data = await opts.responseTransformer(data);
718
- }
719
- }
720
- return opts.responseStyle === "data" ? data : {
721
- data,
722
- ...result
723
- };
724
- }
725
- const textError = await response.text();
726
- let jsonError;
727
- try {
728
- jsonError = JSON.parse(textError);
729
- } catch (e3) {
730
- }
731
- throw _nullishCoalesce(jsonError, () => ( textError));
732
- } catch (error) {
733
- let finalError = error;
734
- for (const fn of interceptors.error.fns) {
735
- if (fn) {
736
- finalError = await fn(
737
- finalError,
738
- response,
739
- request2,
740
- options
741
- );
742
- }
743
- }
744
- finalError = finalError || {};
745
- if (throwOnError) {
746
- throw finalError;
747
- }
748
- return responseStyle === "data" ? void 0 : {
749
- error: finalError,
750
- request: request2,
751
- response
752
- };
753
- }
754
- };
755
- const makeMethodFn = (method) => (options) => request({ ...options, method });
756
- const makeSseFn = (method) => async (options) => {
757
- const { opts, url } = await beforeRequest(options);
758
- return createSseClient({
759
- ...opts,
760
- body: opts.body,
761
- method,
762
- onRequest: async (url2, init) => {
763
- let request2 = new Request(url2, init);
764
- for (const fn of interceptors.request.fns) {
765
- if (fn) {
766
- request2 = await fn(request2, opts);
767
- }
768
- }
769
- return request2;
770
- },
771
- serializedBody: getValidRequestBody(opts),
772
- url
773
- });
774
- };
775
- const _buildUrl = (options) => buildUrl({ ..._config, ...options });
776
- return {
777
- buildUrl: _buildUrl,
778
- connect: makeMethodFn("CONNECT"),
779
- delete: makeMethodFn("DELETE"),
780
- get: makeMethodFn("GET"),
781
- getConfig,
782
- head: makeMethodFn("HEAD"),
783
- interceptors,
784
- options: makeMethodFn("OPTIONS"),
785
- patch: makeMethodFn("PATCH"),
786
- post: makeMethodFn("POST"),
787
- put: makeMethodFn("PUT"),
788
- request,
789
- setConfig,
790
- sse: {
791
- connect: makeSseFn("CONNECT"),
792
- delete: makeSseFn("DELETE"),
793
- get: makeSseFn("GET"),
794
- head: makeSseFn("HEAD"),
795
- options: makeSseFn("OPTIONS"),
796
- patch: makeSseFn("PATCH"),
797
- post: makeSseFn("POST"),
798
- put: makeSseFn("PUT"),
799
- trace: makeSseFn("TRACE")
800
- },
801
- trace: makeMethodFn("TRACE")
802
- };
803
- };
804
-
805
- // src/generated/client.gen.ts
806
- var client = createClient(
807
- createConfig({
808
- baseUrl: "https://api.ideal-postcodes.co.uk/v1"
809
- })
810
- );
811
-
812
- // src/generated/sdk.gen.ts
813
- var postcodes = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/postcodes/{postcode}", ...options });
814
- var keyAvailability = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}", ...options });
815
- var keyDetails = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}/details", ...options });
816
- var updateKeyDetails = (options) => (_nullishCoalesce(options.client, () => ( client))).put({
817
- url: "/keys/{key}/details",
818
- ...options,
819
- headers: {
820
- "Content-Type": "application/json",
821
- ...options.headers
822
- }
823
- });
824
- var keyUsage = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}/usage", ...options });
825
- var keyLogs = (options) => (_nullishCoalesce(options.client, () => ( client))).get(
826
- { url: "/keys/{key}/lookups", ...options }
827
- );
828
- var addressCleanse = (options) => (_nullishCoalesce(options.client, () => ( client))).post({
829
- url: "/cleanse/addresses",
830
- ...options,
831
- headers: {
832
- "Content-Type": "application/json",
833
- ...options.headers
834
- }
835
- });
836
- var findAddress = (options) => (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.client]), () => ( client))).get({
837
- querySerializer: { parameters: { dataset: { array: { explode: false } } } },
838
- url: "/autocomplete/addresses",
839
- ...options
840
- });
841
- var resolveAddress = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/autocomplete/addresses/{address}/gbr", ...options });
842
- var findPlace = (options) => (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _19 => _19.client]), () => ( client))).get({ url: "/places", ...options });
843
- var resolvePlace = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/places/{place}", ...options });
844
- var listLicensees = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}/licensees", ...options });
845
- var createLicensee = (options) => (_nullishCoalesce(options.client, () => ( client))).post({
846
- url: "/keys/{key}/licensees",
847
- ...options,
848
- headers: {
849
- "Content-Type": "application/json",
850
- ...options.headers
851
- }
852
- });
853
- var deleteLicensee = (options) => (_nullishCoalesce(options.client, () => ( client))).delete({ url: "/keys/{key}/licensees/{licensee}", ...options });
854
- var retrieveLicensee = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}/licensees/{licensee}", ...options });
855
- var updateLicensee = (options) => (_nullishCoalesce(options.client, () => ( client))).put({
856
- url: "/keys/{key}/licensees/{licensee}",
857
- ...options,
858
- headers: {
859
- "Content-Type": "application/json",
860
- ...options.headers
861
- }
862
- });
863
- var listConfigs = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}/configs", ...options });
864
- var createConfig2 = (options) => (_nullishCoalesce(options.client, () => ( client))).post({
865
- url: "/keys/{key}/configs",
866
- ...options,
867
- headers: {
868
- "Content-Type": "application/json",
869
- ...options.headers
870
- }
871
- });
872
- var deleteConfig = (options) => (_nullishCoalesce(options.client, () => ( client))).delete({ url: "/keys/{key}/configs/{config}", ...options });
873
- var retrieveConfig = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/keys/{key}/configs/{config}", ...options });
874
- var updateConfig = (options) => (_nullishCoalesce(options.client, () => ( client))).post({
875
- url: "/keys/{key}/configs/{config}",
876
- ...options,
877
- headers: {
878
- "Content-Type": "application/json",
879
- ...options.headers
880
- }
881
- });
882
- var emailValidation = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/emails", ...options });
883
- var phoneNumberValidation = (options) => (_nullishCoalesce(options.client, () => ( client))).get({ url: "/phone_numbers", ...options });
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
-
904
-
905
-
906
-
907
-
908
-
909
-
910
-
911
-
912
- exports.createConfig = createConfig; exports.createClient = createClient; exports.client = client; exports.postcodes = postcodes; exports.keyAvailability = keyAvailability; exports.keyDetails = keyDetails; exports.updateKeyDetails = updateKeyDetails; exports.keyUsage = keyUsage; exports.keyLogs = keyLogs; exports.addressCleanse = addressCleanse; exports.findAddress = findAddress; exports.resolveAddress = resolveAddress; exports.findPlace = findPlace; exports.resolvePlace = resolvePlace; exports.listLicensees = listLicensees; exports.createLicensee = createLicensee; exports.deleteLicensee = deleteLicensee; exports.retrieveLicensee = retrieveLicensee; exports.updateLicensee = updateLicensee; exports.listConfigs = listConfigs; exports.createConfig2 = createConfig2; exports.deleteConfig = deleteConfig; exports.retrieveConfig = retrieveConfig; exports.updateConfig = updateConfig; exports.emailValidation = emailValidation; exports.phoneNumberValidation = phoneNumberValidation;
913
- //# sourceMappingURL=chunk-ZZUZHG5D.cjs.map